Changeset 210 for trunk


Ignore:
Timestamp:
Feb 22, 2006 5:57:00 PM (18 years ago)
Author:
mmc
Message:

Last few fixes for file upload/download. Changed the "Download..."
button to an icon, and added a "Download..." option on the drop-down
list for the Results area. Fixed the "Upload..." to pop up a message,
in case the web form doesn't appear.

Fixed the "grab" function, so it won't fail with a Tk error box.
If it can't get the grab, it tries a few more times and then gives
up. Also, fixed <Esc><Esc><Esc> desperation binding to release
any busy windows.

Location:
trunk/gui/scripts
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/analyzer.tcl

    r193 r210  
    5454    public method load {file}
    5555    public method clear {}
    56     public method download {option}
     56    public method download {option args}
    5757
    5858    protected method _plot {args}
     
    7070    private variable _pages 0          ;# number of pages for result sets
    7171    private variable _label2page       ;# maps output label => result set
     72    private variable _lastlabel ""     ;# label of last example loaded
    7273    private variable _plotlist ""      ;# items currently being plotted
    7374
    7475    private common job                 ;# array var used for blt::bgexec jobs
     76
     77    private common icons
     78    set icons(download) [image create photo -data {
     79R0lGODlhFAAUAMYBAAAAAP///+js9vL1+4yhxrbD21h6sFp8slx+tV6Bt2CFumSIvmOHvWaLwGyS
     80yG6UynCRwWiOw2yUyXCZzm+XzG+Wy3Oc0XKaz3We1Hqk23mj2Xqk2nmi2ICex/T3+3Od0nqm3Hag
     811Xun3Iat3ZK56JK03t7n8uzy+PX4+/f5+/T4+/L3+vn7/Pj7/Pf7/Pb6+/n9/fz///r9/fn8/Pz+
     82/vv9/fr8/Pz9/UGMfluegZzRp6XYqwWXC67frwCZAAKaAgOaAgOaAwWbBQabBQicCA6fDg6eDw+f
     83Dw+fEA+eDxCfEF6/Xl+/X6TbpKbbpqzerK7frq3era/fr/z+/P3+/bXjsXjSbKrjotbw02bSVKvj
     84olnSQYPfcJbjh5/jk1TSOV7XQm3bVIvidprmiKjqmXTgV4DjZrPuo7TupNb1zo/qc5nsf8L0s8Hz
     85sar0j7L1mdD5wdH5wur+4eL91f///////////////////////////////////////////////yH5
     86BAEAAH8ALAIAAgAQABAAAAfYgAUlIiAbHCEYHxcTFRIdBX8jJJOUlZQQfyKam5ycDX8ZAaKjpKMM
     87fxoBLC0pHis7Rz5GOiYBCn8cATI2LC8oSFhVWEkCAQl/IQE3NTIzLj5aVlc+JwEIfxgBNDXLMD5e
     88WV4+AwEHfxbaNNs1Pl1bXT4qAQZ/FAExPUo++1xfXPs+eEh5IIpJGjJjxIQBE0bMGDJpljgQFQUI
     89GjNlMmY0c0bIEwIRGizAEYTNGjUo17QhkoPKn5cvnwSJ88bNGzhEmkyByfPJDzlz5AxxspMnTyix
     90ijxx+TIQADs=
     91}]
    7592}
    7693                                                                               
     
    194211    pack $itk_component(resultselector) -side left -expand yes -fill x
    195212    bind $itk_component(resultselector) <<Value>> [itcl::code $this _fixResult]
     213    bind $itk_component(resultselector) <Enter> \
     214        [itcl::code $this download coming]
    196215
    197216    if {[Rappture::filexfer::enabled]} {
    198217        itk_component add download {
    199             button $w.top.dl -text "Download..." -anchor w \
    200                 -command [itcl::code $this download now]
     218            button $w.top.dl -image $icons(download) -anchor e \
     219                -borderwidth 1 -relief flat -overrelief raised \
     220                -command [itcl::code $this download now $w.top.dl]
    201221        }
    202222        pack $itk_component(download) -side right -padx {4 0}
     
    461481                    pack $page.rviewer -expand yes -fill both -pady 4
    462482
    463                     $itk_component(resultselector) choices insert end \
     483                    set end [$itk_component(resultselector) \
     484                        choices index -value ---]
     485                    if {$end < 0} {
     486                        set end "end"
     487                    }
     488                    $itk_component(resultselector) choices insert $end \
    464489                        $name $label
    465490                }
     
    478503
    479504    # show the first page by default
    480     set first [$itk_component(resultselector) choices get -label 0]
    481     if {$first != ""} {
    482         set page [$itk_component(resultselector) choices get -value 0]
    483         $itk_component(resultpages) current $page
    484         $itk_component(resultselector) value $first
     505    set max [$itk_component(resultselector) choices size]
     506    for {set i 0} {$i < $max} {incr i} {
     507        set first [$itk_component(resultselector) choices get -label $i]
     508        if {$first != ""} {
     509            set page [$itk_component(resultselector) choices get -value $i]
     510            set char [string index $page 0]
     511            if {$char != "@" && $char != "-"} {
     512                $itk_component(resultpages) current $page
     513                $itk_component(resultselector) value $first
     514                break
     515            }
     516        }
    485517    }
    486518}
     
    508540    catch {unset _label2page}
    509541    set _plotlist ""
     542
     543    if {[Rappture::filexfer::enabled]} {
     544        $itk_component(resultselector) choices insert end \
     545            --- "---"
     546        $itk_component(resultselector) choices insert end \
     547            @download "Download..."
     548    }
    510549
    511550    #
     
    525564# ----------------------------------------------------------------------
    526565# USAGE: download coming
    527 # USAGE: download now
     566# USAGE: download now ?widget?
    528567#
    529568# Spools the current result so the user can download it.
    530569# ----------------------------------------------------------------------
    531 itcl::body Rappture::Analyzer::download {option} {
     570itcl::body Rappture::Analyzer::download {option args} {
    532571    if {[Rappture::filexfer::enabled]} {
    533572        set title [$itk_component(resultselector) value]
     
    540579                # it needs to take a screen snap.
    541580                #
    542                 if {$page != ""} {
     581                if {![regexp {^(|@download|---)$} $page]} {
    543582                    set f [$itk_component(resultpages) page $page]
    544583                    $f.rviewer download coming
     
    546585            }
    547586            now {
     587                set widget $itk_component(download)
     588                if {[llength $args] > 0} {
     589                    set widget [lindex $args 0]
     590                    if {[catch {winfo class $widget}]} {
     591                        set widget $itk_component(download)
     592                    }
     593                }
    548594                #
    549595                # Perform the actual download.
     
    554600                    foreach {ext data} [$f.rviewer download now] break
    555601                    if {"" == $ext} {
    556                         Rappture::Tooltip::cue $itk_component(download) \
    557                             "Can't download this result."
     602                        if {"" != $widget} {
     603                            Rappture::Tooltip::cue $widget \
     604                                "Can't download this result."
     605                        }
    558606                        return
    559607                    }
     
    568616                if {[catch {Rappture::filexfer::spool $data $file} result]} {
    569617                    if {"no clients" == $result} {
    570                         Rappture::Tooltip::cue $itk_component(download) \
    571                             "Can't download this result.  Looks like you might be having trouble with the version of Java installed for your browser."
     618                        if {"" != $widget} {
     619                            Rappture::Tooltip::cue $widget "Can't download this result.  Looks like you might be having trouble with the version of Java installed for your browser."
     620                        }
    572621                    } else {
    573622                        error $result "    (while spooling result \"$title\")"
     
    672721# ----------------------------------------------------------------------
    673722itcl::body Rappture::Analyzer::_fixResult {} {
    674     set page [$itk_component(resultselector) value]
    675     set page [$itk_component(resultselector) translate $page]
    676     if {$page != ""} {
    677         blt::busy hold [winfo toplevel $itk_component(hull)]; update idletasks
     723    set name [$itk_component(resultselector) value]
     724    set page ""
     725    if {"" != $name} {
     726        set page [$itk_component(resultselector) translate $name]
     727    }
     728    if {$page == "@download"} {
     729        # put the combobox back to its last value
     730        $itk_component(resultselector) component entry configure -state normal
     731        $itk_component(resultselector) component entry delete 0 end
     732        $itk_component(resultselector) component entry insert end $_lastlabel
     733        $itk_component(resultselector) component entry configure -state disabled
     734        # perform the actual download
     735        download now $itk_component(resultselector)
     736    } elseif {$page == "---"} {
     737        # put the combobox back to its last value
     738        $itk_component(resultselector) component entry configure -state normal
     739        $itk_component(resultselector) component entry delete 0 end
     740        $itk_component(resultselector) component entry insert end $_lastlabel
     741        $itk_component(resultselector) component entry configure -state disabled
     742    } else {
     743        set _lastlabel $name
     744        set win [winfo toplevel $itk_component(hull)]
     745        blt::busy hold $win; update idletasks
    678746        $itk_component(resultpages) current $page
    679747
  • trunk/gui/scripts/filexfer.tcl

    r195 r210  
    708708  <script language="JavaScript">
    709709    function setup() {
    710         setTimeout("window.close()",100);
     710        window.close()
    711711    }
    712712    window.onload = setup;
  • trunk/gui/scripts/grab.tcl

    r115 r210  
    1313#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1414# ======================================================================
     15package require BLT
    1516
    1617namespace eval Rappture { # forward declaration }
     
    6869            [linsert $::Rappture::grab::stack 0 $window]
    6970
    70         return [eval _tk_grab set $window]
     71        return [eval _grabset $window]
    7172
    7273    } elseif {$op == "release"} {
     
    8990                set ::Rappture::grab::state ""
    9091            }
    91             eval _tk_grab $window
     92            eval _grabset $window
    9293        }
    9394        return ""
     
    9697    # perform any other grab operation as usual...
    9798    return [eval _tk_grab $args]
     99}
     100
     101proc _grabset {args} {
     102    # give it 3 tries, if necessary
     103    for {set i 0} {$i < 3} {incr i} {
     104        set status [catch {eval _tk_grab set $args} result]
     105        if {$status == 0} {
     106            return $result
     107        }
     108        after 100; update
     109    }
     110    # oh well, we tried...
     111    return ""
    98112}
    99113
     
    111125    set Rappture::grab::stack ""
    112126    set Rappture::grab::state ""
     127
     128    foreach win [blt::busy windows] {
     129        blt::busy release $win
     130    }
    113131}
  • trunk/gui/scripts/loader.tcl

    r201 r210  
    284284            set status [catch {Rappture::filexfer::upload \
    285285                $_updesc [itcl::code $this _uploadValue]} result]
    286             if {$status != 0} {
     286            if {$status == 0} {
     287                Rappture::Tooltip::cue $itk_component(combo) \
     288                    "Upload starting...\nA web browser page should pop up on your desktop.  Use that form to handle the upload operation."
     289            } else {
    287290                if {$result == "no clients"} {
    288291                    Rappture::Tooltip::cue $itk_component(combo) \
     
    384387# ----------------------------------------------------------------------
    385388itcl::body Rappture::Loader::_uploadValue {string} {
     389    Rappture::Tooltip::cue hide  ;# take down the note about the popup window
    386390    #
    387391    # BE CAREFUL:  This string may have binary characters that
     
    391395    #
    392396    regsub -all {[\000-\010\013\014\016-\037\177-\377]} $string {} string
     397    regsub -all "\r" $string "\n" string
    393398    $itk_option(-tool) valuefor $_uppath $string
    394399
Note: See TracChangeset for help on using the changeset viewer.