
set LFrame $DLabels.lframe

UploadLabels

destroy $DLabels
toplevel $DLabels
wm title $DLabels "GOBLIN Node Attributes"
wm resizable $DLabels 0 0
DownloadNodeLabels $currentNode

frame $LFrame
     
    label $LFrame.indexText -text "Node Index" -anchor w
    grid $LFrame.indexText -in $LFrame \
        -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m -pady 2m
    label $LFrame.index -textvariable ThisNode -anchor w
    grid $LFrame.index -in $LFrame \
        -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m -pady 2m

    label $LFrame.demandText -text "Demand" -anchor w
    grid $LFrame.demandText -in $LFrame \
        -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry $LFrame.demand -textvariable ThisDemand -bg white -width 10
    grid $LFrame.demand -in $LFrame \
        -row 1 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m

    label $LFrame.distanceText -text "Distance Label" -anchor w
    grid $LFrame.distanceText -in $LFrame \
        -row 2 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry $LFrame.distance -textvariable ThisDistance -bg white -width 10
    grid $LFrame.distance -in $LFrame \
        -row 2 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m

    label $LFrame.colourText -text "Colour" -anchor w
    grid $LFrame.colourText -in $LFrame \
        -row 3 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry $LFrame.colour -textvariable ThisColour -bg white -width 10
    grid $LFrame.colour -in $LFrame \
        -row 3 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m

    label $LFrame.potentialText -text "Potential" -anchor w
    grid $LFrame.potentialText -in $LFrame \
        -row 4 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry $LFrame.potential -textvariable ThisPotential -bg white -width 10
    grid $LFrame.potential -in $LFrame \
        -row 4 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m

    label $LFrame.predecessorText -text "Predecessor" -anchor w
    grid $LFrame.predecessorText -in $LFrame \
        -row 5 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry $LFrame.predecessor -textvariable ThisPredecessor -bg white -width 10
    grid $LFrame.predecessor -in $LFrame \
        -row 5 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m

    grid rowconfig    $LFrame 0 -weight 1 -minsize 0
    grid columnconfig $LFrame 0 -weight 1 -minsize 0

pack $LFrame -side top -padx 10m -pady 5m
    
proc QualifiedNodeAttrib {} {
    global ThisDemand ThisDistance ThisColour ThisPotential ThisPredecessor
    if {$ThisDemand==""} {return 0}
    if {$ThisDistance==""} {return 0}
    if {$ThisColour!="*" && ![QualifiedNode $ThisColour]} {return 0}
    if {$ThisPotential==""} {return 0}
    
    return 1
}

frame $DLabels.buttons
    button $DLabels.buttons.prev -text "Previous" -command {
        if {[QualifiedNodeAttrib]} {
            UploadLabels
            global ThisNode ThisGraph
            incr ThisNode -1
            if {$ThisNode==-1} {
                set ThisNode [expr {[$ThisGraph #nodes]-1}]
            }
            DownloadNodeLabels $ThisNode
        }
    }
    
    button $DLabels.buttons.next -text "Next" -command {
        if {[QualifiedNodeAttrib]} {
            UploadLabels
            global ThisNode ThisGraph
            incr ThisNode
            if {$ThisNode==[$ThisGraph #nodes]} {
                set ThisNode 0
            }
            DownloadNodeLabels $ThisNode
        }
    }
    
    button $DLabels.buttons.done -text "Done" -command {
        if {[QualifiedNodeAttrib]} {
            UploadLabels
            destroy $DLabels
            InitBrowser
        }
    }
    
    pack $DLabels.buttons.prev $DLabels.buttons.next $DLabels.buttons.done \
        -side left -fill x -padx 3m
     
pack $DLabels.buttons -padx 3m -pady 3m -side bottom
