From 2aa34adc3b02fc1e4443dc313f1d2f73d93adc8b Mon Sep 17 00:00:00 2001 From: Michael Wiebusch Date: Wed, 3 Jul 2013 11:54:09 +0200 Subject: [PATCH] show ancestry as nested table --- layout/jtageditor.css | 16 +++--- xml_spielwiese/cgitest.pl | 111 ++++++++++++++++++++++++-------------- 2 files changed, 79 insertions(+), 48 deletions(-) diff --git a/layout/jtageditor.css b/layout/jtageditor.css index e329f53..b19854f 100644 --- a/layout/jtageditor.css +++ b/layout/jtageditor.css @@ -99,43 +99,43 @@ table.registers>tbody>tr>td:nth-child(2) { } -tr.fileLevel +.fileLevel { background:#CCFFCC; //background:#dea; } -tr.fileLevel1 +.fileLevel1 { background:#CCFFFF; } -tr.fileLevel2 +.fileLevel2 { background:#CCCCFF; } -tr.fileLevel3 +.fileLevel3 { background:#FFCCFF; } -tr.fileLevel4 +.fileLevel4 { background:#FFCCCC; } -tr.fileLevel5 +.fileLevel5 { background:#FFFFCC; } -tr.fileLevel6 +.fileLevel6 { background:#FFFFFF; } -table.fields td.button_move, table.registers td.button_move { +table.fields td.button_move, table.registers td.button_move, .button_move { background:orange; cursor:pointer; text-align:center; diff --git a/xml_spielwiese/cgitest.pl b/xml_spielwiese/cgitest.pl index 7318326..2cb4eea 100755 --- a/xml_spielwiese/cgitest.pl +++ b/xml_spielwiese/cgitest.pl @@ -81,7 +81,6 @@ if ( $cgiHash{'print'} eq 'spectree' ) { parseSetAndSpec( $cgiHash{'configFile'} ); "
specifications loaded from $specfileName
"; - print_registers($specfile); } @@ -97,10 +96,10 @@ if ( $cgiHash{'print'} eq 'settree' ) { print ""; print_ancestorInfo(); print ""; - print "
"; + print "
"; print ""; - - print "
you are editing
$setfileName
"; + print +"
you are editing
$setfileName
"; print ""; print ""; @@ -128,53 +127,70 @@ if ( defined $cgiHash{'action'} ) { copyDefaultRegister( $cgiHash{'register'} ); } if ( $cgiHash{'action'} eq 'createFile' ) { - createFile($cgiHash{'configFile'},$cgiHash{'specFile'}); + createFile( $cgiHash{'configFile'}, $cgiHash{'specFile'} ); } + if ( $cgiHash{'action'} eq 'changeAncestor' ) { + parseSet( $cgiHash{'configFile'} ); + changeAncestor( $cgiHash{'newAncestor'} ); + } + } #################### SUBLAND ###################### - sub createFile { - my $configFileName=$_[0]; - - my $specFileName=$_[1]; #config file is based on this specification! - my $configFile= $confDir."/".$configFileName; - my $specFile=$specDir."/".$specFileName; - + my $configFileName = $_[0]; + + my $specFileName = $_[1]; #config file is based on this specification! + my $configFile = $confDir . "/" . $configFileName; + my $specFile = $specDir . "/" . $specFileName; + my $configTree = XML::LibXML->createDocument; - my $specTree = $parser->parse_file($specFile); - + my $specTree = $parser->parse_file($specFile); + my $configMaps = $configTree->createElementNS( "", "MAPS" ); - $configTree->setDocumentElement( $configMaps ); + $configTree->setDocumentElement($configMaps); my $specMaps = $specTree->findnodes("/MAPS")->shift(); - + my $mapsType = $specMaps->findvalue("./\@type"); - - $configMaps->setAttribute("type",$mapsType); - $configMaps->setAttribute("specDbFile",$specFileName); - - + + $configMaps->setAttribute( "type", $mapsType ); + $configMaps->setAttribute( "specDbFile", $specFileName ); + open( SCHREIBEN, "> $configFile" ) or print "could not open file $configFile for writing: $!\n"; print SCHREIBEN $configTree->toString(); close SCHREIBEN; - + } sub print_ancestorInfo { print "
"; - if (@ancestryList) { - print "inherit settings from:
"; - print ""; + + print "inherit settings from:
"; + if (@ancestryList) + { # if ancestry is not empty, print current ancestry as a nested table + # and also a button that can unlink the heritage + + print "
"; + + my $tableNestingDepth = @ancestryList; + for my $ancestor ( reverse(@ancestryList) ) { + print ""; + print ""; + + print "$ancestor
"; + } for my $ancestor (@ancestryList) { - print "
$ancestor
"; } - print "
"; + + print ""; + print < X  +EOF + print ""; } print "
"; } @@ -337,9 +353,9 @@ sub del { close SCHREIBEN; } -sub print_fileSelector{ - - my $configFile = $_[0]; +sub print_fileSelector { + + my $configFile = $_[0]; opendir( DIR, $confDir ) or die $!; print ''; } -sub print_specSelector{ - - my $configFile = $_[0]; +sub print_specSelector { + + my $configFile = $_[0]; opendir( DIR, $specDir ) or die $!; print ''; } + sub print_fileSelection { my $configFile = $_[0]; @@ -422,9 +439,9 @@ sub print_fileSelection { print ""; print ""; - - print "
"; - + + print "
"; + print ""; print ""; print ""; - + print ""; + print "
"; @@ -438,8 +455,8 @@ sub print_fileSelection { print ""; print ""; - print "
"; print ""; print ""; @@ -448,10 +465,17 @@ sub print_fileSelection { sub changeAncestor { my $ancestorFileName = $_[0]; my $xmltree = $settree; + my $xmlfile = $setfile; my $maps = $xmltree->findnodes("/MAPS")->shift(); $maps->setAttribute( "inheritSettingsFrom", $ancestorFileName ); + open( SCHREIBEN, "> $xmlfile" ) + or print "could not open file $xmlfile for writing: $!\n"; + + print SCHREIBEN $xmltree->toString(); + close SCHREIBEN; + } sub getAncestor { @@ -745,6 +769,13 @@ sub printJavaScripts {