From: ana Date: Fri, 10 Aug 2007 18:31:52 +0000 (+0000) Subject: Improvement of the custom configuration window. X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=28ba700f1e36b7fdefcc42eaa707dd13948f41ac;p=imunes.git Improvement of the custom configuration window. Bug found by: Submitted by: Reviewed by: Approved by: Obtained from: --- diff --git a/editor.tcl b/editor.tcl index f81a128..e8a8f54 100755 --- a/editor.tcl +++ b/editor.tcl @@ -1,4 +1,4 @@ -# $Id: editor.tcl,v 1.72 2007/07/20 22:52:32 marko Exp $ +# $Id: editor.tcl,v 1.73 2007/08/10 18:31:52 ana Exp $ # # Copyright 2004, 2005 University of Zagreb, Croatia. All rights reserved. # @@ -2223,7 +2223,7 @@ proc popupConfigDialog { c } { button $wi.custom.cfg.edit -text "Edit" \ -command "editStartupCfg $target 0" button $wi.custom.cfg.clear -text "Clear" \ - -command "setCustomConfig $target {} {} {} 0" + -command "setCustomConfig $target {} {} {} 0 0" pack $wi.custom.cfg.generate $wi.custom.cfg.edit \ $wi.custom.cfg.clear -side left @@ -2426,7 +2426,7 @@ proc cfgGenerate { node } { set id "generic" set cmd [[typemodel $node].bootcmd $node] set cfg [[typemodel $node].cfggen $node] - setCustomConfig $node $id $cmd $cfg 0 + setCustomConfig $node $id $cmd $cfg 0 0 } @@ -2526,12 +2526,15 @@ proc editStartupCfg { node deleted } { frame $w.buttons pack $w.buttons -side bottom + button $w.buttons.addccfg -text "Add new" \ + -command "customConfigApply $w $node 1" button $w.buttons.apply -text "Apply" \ - -command "customConfigApply $w $node" - button $w.buttons.close -text Close -command "destroy $w" + -command "customConfigApply $w $node 0" button $w.buttons.delete -text Delete -command \ "deleteCustomConfig $w $node $viewcustomid {} {} 1" - pack $w.buttons.apply $w.buttons.close $w.buttons.delete -side left + button $w.buttons.close -text Close -command "destroy $w" + pack $w.buttons.addccfg $w.buttons.apply $w.buttons.delete \ + $w.buttons.close -side left pack $w.scroll -side right -fill y pack $w.text -expand yes -fill both @@ -2562,7 +2565,7 @@ proc editStartupCfg { node deleted } { # * w -- widget # * node_id -- node id #**** -proc customConfigApply { w node } { +proc customConfigApply { w node addccfg } { global changed set newcmd [$w.ftop.cmd get] @@ -2575,9 +2578,8 @@ proc customConfigApply { w node } { [getCustomConfig $node] != $newconf } { set changed 1 } - setCustomConfig $node $newid $newcmd $newconf 0 + setCustomConfig $node $newid $newcmd $newconf 0 $addccfg destroy $w - editStartupCfg $node 0 } #****f* editor.tcl/popupConfigApply diff --git a/install.sh b/install.sh index 1d99441..b4d68ad 100755 --- a/install.sh +++ b/install.sh @@ -26,7 +26,7 @@ lib_files="nodecfg.tcl linkcfg.tcl cfgparse.tcl ipv4.tcl ipv6.tcl exec.tcl \ canvas.tcl editor.tcl filemgmt.tcl help.tcl initgui.tcl \ quagga.tcl xorp.tcl static.tcl pc.tcl host.tcl \ lanswitch.tcl rj45.tcl hub.tcl ns2imunes.tcl ipsec.tcl \ - topogen.tcl annotations.tcl" + topogen.tcl annotations.tcl gpgui.tcl graph_partitioning.tcl" tiny_icons="oval.gif delete.gif frswitch.gif host.gif hub.gif \ lanswitch.gif link.gif pc.gif rectangle.gif rj45.gif \ diff --git a/nodecfg.tcl b/nodecfg.tcl index bf76b7b..b37c7dd 100755 --- a/nodecfg.tcl +++ b/nodecfg.tcl @@ -1,4 +1,4 @@ -# $Id: nodecfg.tcl,v 1.19 2007/07/19 03:14:13 marko Exp $ +# $Id: nodecfg.tcl,v 1.20 2007/08/10 18:31:52 ana Exp $ # # Copyright 2004, 2005 University of Zagreb, Croatia. All rights reserved. # @@ -406,7 +406,7 @@ proc getCustomConfig { node } { # * #**** -proc setCustomConfig { node id cmd cfg delete } { +proc setCustomConfig { node id cmd cfg delete addccfg } { global viewcustomid global $node @@ -417,14 +417,30 @@ proc setCustomConfig { node id cmd cfg delete } { set $node [lreplace [set $node] $j $j] } + set cnt 0 set indices [lsearch -all [set $node] "custom-config *"] foreach i $indices { + set i [expr $i-$cnt] + set cnt [expr $cnt+1] set tmp [lindex [set $node] $i] set customCfg [lindex $tmp 1] set cid [lindex [lsearch -inline $customCfg "custom-config-id *"] 1] - if { $cid == $id } { + + if { $addccfg == 0 && $delete == 0 } { set $node [lreplace [set $node] $i $i] - } + } elseif { $addccfg == 0 && $delete == 1 } { + if { $cid == $id } { + set $node [lreplace [set $node] $i $i] + } + } else { + if { $cid == $id } { + set warning "Choose another custom config id!" + tk_messageBox -message $warning -type ok -icon warning \ + -title "Custom configuration id warning" + set $node [lreplace [set $node] $i $i] + } + } + } if { $delete == 0 } { @@ -454,7 +470,7 @@ proc setCustomConfig { node id cmd cfg delete } { proc deleteCustomConfig { w node id cmd cfg delete } { global viewcustomid - setCustomConfig $node $viewcustomid {} {} 1 + setCustomConfig $node $viewcustomid {} {} 1 0 destroy $w editStartupCfg $node 1 }