]> git.entuzijast.net Git - imunes.git/commitdiff
Added configRemoteHosts - for configuration of remote hosts IP addresses,
authormiljenko <miljenko>
Mon, 5 Dec 2005 09:33:33 +0000 (09:33 +0000)
committermiljenko <miljenko>
Mon, 5 Dec 2005 09:33:33 +0000 (09:33 +0000)
and selection "local execution / remote exec / editor only".

Bug found by:
Submitted by:
Requested by:
Reviewed by:
Approved by:
Obtained from:

editor.tcl

index 906b4ad0c14c3837d800f0e6e35fcc71c8d0d68c..2db99a07c2e8f0faa1b81476b4f769073cb5affa 100755 (executable)
@@ -2137,3 +2137,147 @@ proc animate {} {
 }
 
 
+proc toolOptions {} {
+    return
+}
+
+
+proc configRemoteHosts {} {
+    global exec_hosts
+    global exec_host exec_port monitor_port remote_exec
+    global old_remote_exec
+    global editor_only
+    set old_remote_exec $remote_exec
+
+    if { $remote_exec } {
+        set state normal
+    } else {
+        set state disabled
+    }
+
+    set wi .popup
+    catch {destroy $wi}
+    toplevel $wi
+
+    wm transient $wi .
+    wm resizable $wi 0 0
+    wm title $wi "Remote host(s) configuration"
+
+    labelframe $wi.select -pady 2 -text "Experiment running:" \
+        -padx 2 -borderwidth 2
+
+    radiobutton $wi.select.remote -text "remotely" \
+        -command "enable_disable $wi"\
+        -variable remote_exec -value true
+    radiobutton $wi.select.local -text "locally" \
+        -command "enable_disable $wi"\
+        -variable remote_exec -value false
+    checkbutton $wi.select.editor -text "edit mode only" \
+        -command "enable_disable $wi"\
+        -variable editor_only -onvalue true -offvalue false
+    pack $wi.select.local $wi.select.remote $wi.select.editor -side left
+
+    labelframe $wi.hosts -pady 2 -text "Remote hosts:" -padx 2
+
+    frame $wi.hosts.labels -borderwidth 2
+    label $wi.hosts.labels.label -text "Id" -anchor w
+    frame $wi.hosts.address -borderwidth 2
+    label $wi.hosts.address.label -text "IP address" -anchor w
+    frame $wi.hosts.ports -borderwidth 2
+    label $wi.hosts.ports.label -text "Port" -anchor w
+    frame $wi.hosts.monitors -borderwidth 2
+    label $wi.hosts.monitors.label -text "Monitor port" -anchor w
+
+    set i 0
+    foreach host_elem $exec_hosts {
+
+        eval label $wi.hosts.labels.v$i -text "$i. " -anchor e
+
+        eval entry $wi.hosts.address.v$i -bg white -width 15 \
+           -validate focus -invcmd "focusAndFlash"
+        $wi.hosts.address.v$i insert 0 [lindex $host_elem 0]
+
+        eval entry $wi.hosts.ports.v$i -bg white -width 5 \
+            -validate focus -invcmd "focusAndFlash"
+        $wi.hosts.ports.v$i insert 0 [lindex $host_elem 1]
+
+        eval entry $wi.hosts.monitors.v$i -bg white -width 5 \
+           -validate focus -invcmd "focusAndFlash"
+        $wi.hosts.monitors.v$i insert 0 [lindex $host_elem 2]
+
+        incr i
+    }
+
+    foreach j [list labels address ports monitors] {
+        eval pack $wi.hosts.$j.label -side top -padx 4 -pady 2 -fill x
+        set n [llength $exec_hosts]
+        for {set i 0} {$i < $n} {incr i} {
+            eval pack $wi.hosts.$j.v$i -side top -padx 4 -pady 2 -fill x
+        }
+    }
+    pack $wi.hosts.labels $wi.hosts.address $wi.hosts.ports \
+         $wi.hosts.monitors -side left -fill x
+    pack $wi.select $wi.hosts -side top -fill x -padx 4
+
+    frame $wi.butt -borderwidth 4
+    button $wi.butt.apply -text "Apply" -command \
+          "configRemoteHostsApply $wi; destroy $wi"
+    focus $wi.butt.apply
+    button $wi.butt.cancel -text "Cancel" -command \
+       "set remote_exec $old_remote_exec; destroy $wi"
+    pack $wi.butt.cancel $wi.butt.apply -side right
+    pack $wi.butt -side bottom
+
+    enable_disable $wi
+
+    after 100 {
+       grab .popup
+    }
+    ;# Apply and Cancel explicitly destroy $wi
+    vwait forever
+    ;# return
+}
+
+
+proc configRemoteHostsApply { wi } {
+    global exec_hosts
+
+    set n [llength $exec_hosts]
+    set exec_hosts []
+    for {set i 0} {$i < $n} {incr i} {
+        set ent [list [$wi.hosts.address.v$i get] \
+                      [$wi.hosts.ports.v$i get]   \
+                      [$wi.hosts.monitors.v$i get]\
+                ]
+        lappend exec_hosts $ent
+    }
+    destroy $wi
+}
+
+
+proc enable_disable { wi } {
+    global exec_hosts
+    global remote_exec editor_only
+
+    set i 0
+
+    if { ! $remote_exec || $editor_only } {
+        set state disabled
+    } else {
+        set state normal
+    }
+
+    if { $editor_only } {
+       .menubar.experiment entryconfigure "Execute" -state disabled
+    } else {
+        .menubar.experiment entryconfigure "Execute" -state normal
+    }
+
+    foreach host_elem $exec_hosts {
+        eval $wi.hosts.address.v$i configure -state $state
+        eval $wi.hosts.ports.v$i configure -state $state
+        eval $wi.hosts.monitors.v$i configure -state $state
+        set i [expr $i + 1]
+    }
+}
+