]> git.entuzijast.net Git - imunes.git/commitdiff
Improvement of the custom configuration window.
authorana <ana>
Fri, 10 Aug 2007 18:31:52 +0000 (18:31 +0000)
committerana <ana>
Fri, 10 Aug 2007 18:31:52 +0000 (18:31 +0000)
Bug found by:
Submitted by:
Reviewed by:
Approved by:
Obtained from:

editor.tcl
install.sh
nodecfg.tcl

index f81a128c167980e70739d3370d34c579c18887c6..e8a8f54ade0c8fb70dc0cce806eac66960493a13 100755 (executable)
@@ -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
index 1d99441efdf6be7979608164da380d1d7fb413a5..b4d68ad8df525a975f7a47a2a9aba18cee23b17b 100755 (executable)
@@ -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 \
index bf76b7ba65cb9427d30a4959adc145b96d51a5f0..b37c7dd04b92043b9be08e6aa08d833bba08081e 100755 (executable)
@@ -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
 }