Changeset 2155 for trunk


Ignore:
Timestamp:
Mar 27, 2011, 11:34:36 AM (14 years ago)
Author:
mmc
Message:

Added some fixes to the error/warning system. You cannot preview any
object that gives errors. This helps guard against unexpected errors
later due to missing default values, etc. Also, fixed the error
navigation code to highlight the attribute that needs attention.

Location:
trunk/builder/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/builder/scripts/main.tcl

    r2153 r2155  
    4040option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-18-*
    4141option add *Filmstrip.background #aaaaaa
     42option add *Hierlist.selectBackground #9999ff
     43option add *errorHighlightColor #9999ff
    4244option add *previewButtonBackground #4a758c
    4345option add *previewButtonActiveBackground #a3c3cc
     
    5254option add *build*cntls*Button.padX 2
    5355option add *build*cntls*Editor.background white
     56option add *build*editelem*background #cccccc
     57option add *build*editelem*font {helvetica -12}
     58option add *build*editelem*title.font {helvetica -12 italic}
     59option add *build*editelem*vopt.font {helvetica -12 italic}
    5460option add *options*Entry.background white
     61option add *options*Listbox.background white
    5562option add *options*Text.background white
    5663option add *options*Text.font {Helvetica -12}
     
    153160    set vname "value[incr ValueId]"
    154161    set type [string totitle $type]
    155     return [list node: id $vname type $type terminal $term attributes ""]
     162    return [list node: id $vname type $type terminal $term \
     163        attributes [list label $type]]
    156164}
    157165
     
    175183
    176184    if {[string length $LastToolXmlLoaded] > 0 && [$ToolXml xml] ne $LastToolXmlLoaded} {
    177 puts ">>>>"
    178 puts $LastToolXmlLoaded
    179 puts "----"
    180 puts [$ToolXml xml]
    181 puts "<<<<"
    182185        set choice [tk_messageBox -icon warning -type yesno -title "Rappture: Save Changes?" -message "Changes to the current tool haven't been saved.\n\nSave changes?"]
    183186        if {$choice == "yes" && ![main_saveas]} {
     
    289292    set alist ""
    290293    set type [$xmlobj element -as type $path]
     294    set side [lindex [split $path .] 0]
    291295
    292296    if {[catch {Rappture::objects::get $type -attributes} attr] == 0} {
     
    296300            catch {unset info}
    297301            array set info [lrange $rec 1 end]
     302
     303            # see if this attribute is excluded based on the -only option
     304            if {$info(-only) ne "" && [lsearch $info(-only) $side] < 0} {
     305                continue  ;# skip it!
     306            }
    298307
    299308            set atype [lindex [split $info(-type) :] 0]
     
    342351        set type [string tolower [$hlist tree get $node type]]
    343352
     353        # make sure this object has a viewer
     354        if {[catch {Rappture::objects::get $type -palettes} pals]} {
     355            # must not have an object definition
     356            continue
     357        }
     358        set debug [list -node $node -counter [incr counter]]
     359
     360        set path [$hlist tree path $node "%lc:type(%id)"]
     361        regsub -all {\(%id\)} $path "" path
     362        # convert input.foo to palette name "Inputs"
     363        set side [lindex [split $path .] 0]
     364        set pname "[string totitle $side]s"
     365
     366        if {$side ne "tool" && [lsearch $pals $pname] < 0} {
     367            lappend ErrList [list error "This object doesn't yet have a visualizer that lets it be used as an $side to the program.  Support for this probably will be added in a future version of Rappture, but for now, it must be removed from the $side section." $debug]
     368            continue
     369        }
     370
     371        # query attributes for this type and check their values
    344372        if {[catch {Rappture::objects::get $type -attributes} attrdef]
    345373             || [catch {$hlist tree get $node attributes} attrlist]} {
     
    355383            }
    356384        }
    357         set debug [list -node $node -counter [incr counter]]
    358385
    359386        # perform all checks for this attribute type and append to ErrList
    360387        eval lappend ErrList [Rappture::objects::check $type \
    361             [array get ainfo] $debug]
     388            $side [array get ainfo] $debug]
    362389    }
    363390
     
    406433            set thereis "There is"
    407434            set problem "this problem"
     435            set errors "this error"
    408436        } else {
    409437            set thereis "There are"
    410438            set problem "these problems"
    411         }
    412 
     439            if {$nwarn+$nother == 0} {
     440                set errors "these errors"
     441            } else {
     442                set errors "at least the $nerrs errors"
     443            }
     444        }
     445
     446        # if there are errors, we can't continue on
     447        if {$nerrs > 0} {
     448            tk_messageBox -icon error -type ok -title "Rappture: Problems with your tool definition" -message "$thereis $phrases for your current tool definition.  You must resolve $errors before you continue with the preview."
     449            return 1
     450        }
     451
     452        # let the user decide whether to proceed
    413453        set choice [tk_messageBox -icon error -type yesno -title "Rappture: Problems with your tool definition" -message "$thereis $phrases for your current tool definition.  Examine and resolve $problem?"]
    414454        if {$choice == "yes"} {
     
    464504
    465505    set win [.func.build.options.panes pane 0]
    466     set ErrFocusAttr $debug(-attribute)
     506    if {[info exists debug(-attribute)]} {
     507        set ErrFocusAttr $debug(-attribute)
     508    } else {
     509        set ErrFocusAttr ""
     510    }
    467511    $win.scrl.skel select none -silent  ;# force a reload of options
    468512    $win.scrl.skel select $debug(-node) ;# so we can highlight ErrFocusAttr
    469513
     514    # fix the navigation buttons for next/prev error
    470515    .func.build.options.errs.nav.prev configure \
    471516        -state [expr {($ErrListPos == 0) ? "disabled" : "normal"}]
     
    551596        regsub -all {\(%id\)} $path "" path
    552597        set type [string tolower [$hlist tree get $node type]]
     598        set side [lindex [split $path .] 0]
    553599
    554600        if {[catch {Rappture::objects::get $type -attributes} attrdef]
     
    565611            }
    566612            array set info [lrange $rec 1 end]
     613
     614            # see if this attribute is excluded based on the -only option
     615            if {$info(-only) ne "" && [lsearch $info(-only) $side] < 0} {
     616                continue  ;# skip it!
     617            }
     618
    567619            set atype [lindex [split $info(-type) :] 0]
    568620            set proc "Attr[string totitle $atype]::export"
     
    11361188    set path [$hlist curselection -path "%lc:type(%id)"]
    11371189    regsub -all {\(%id\)} $path "" path
     1190    set side [lindex [split $path .] 0]
    11381191
    11391192    # set the value column to expand
     
    11761229            array set info [lrange $rec 1 end]
    11771230
     1231            # see if this attribute is excluded based on the -only option
     1232            if {$info(-only) ne "" && [lsearch $info(-only) $side] < 0} {
     1233                continue  ;# skip it!
     1234            }
     1235
     1236            # create the widget to edit this attribute
    11781237            set atype [split $info(-type) :]
    11791238            set atname [lindex $atype 0]
     
    12121271            if {$name eq $ErrFocusAttr} {
    12131272                $obj edit
     1273                set errbg [option get $frame errorHighlightColor Background]
     1274                $frame.l$wnum configure -background $errbg
    12141275                set ErrFocusAttr ""
    12151276            }
  • trunk/builder/scripts/tool.rp

    r2153 r2155  
    2121        set cmd [string trim $attr(command)]
    2222        if {[string length $cmd] == 0} {
    23             return [list error "Must set the command associated with the underlying tool that will be invoked to handle the simulation."]
     23            return [list warning "You should set the program type or enter a custom command that will be used to invoke the simulation program.  This is necessary in order for the tool to compute any results.  If you select a programming language, the builder will let you save a skeleton program that you can use as a starting point."]
    2424        }
    25         if {![regexp @tool $cmd]} {
    26             return [list warning "The command string usually contains @tool, which represents the directory containing the tool.xml file.  The program is usually located relative to this directory.  Avoid hard-coded directory paths."]
    27         }
    28         if {![regexp @driver $cmd]} {
    29             return [list warning "The command should contain the argument @driver, which represents the driver input file generated by Rappture."]
     25        if {[string index $cmd 0] ne "!"} {
     26            if {![regexp @tool $cmd]} {
     27                return [list warning "The command string usually contains @tool, which represents the directory containing the tool.xml file.  The program is usually located relative to this directory.  Avoid hard-coded directory paths."]
     28            }
     29            if {![regexp @driver $cmd]} {
     30                return [list warning "The command should contain the argument @driver, which represents the driver input file generated by Rappture."]
     31            }
    3032        }
    3133    }
Note: See TracChangeset for help on using the changeset viewer.