Changeset 2252 for trunk


Ignore:
Timestamp:
May 20, 2011 12:38:51 PM (13 years ago)
Author:
mmc
Message:

Fixed the builder to check for errors before handling the "save as..."
operation. It used to be that if you didn't preview, you wouldn't get
any report of errors. Now, you see the errors when you preview or when
you save. When you save, you can choose to ignore them.

File:
1 edited

Legend:

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

    r2160 r2252  
    323323
    324324# ----------------------------------------------------------------------
    325 # USAGE: main_errors
     325# USAGE: main_errors ?-strict?
    326326#
    327327# Checks the values of all objects in the tree to look for errors
    328 # before previewing and saving.  If any errors are found, the user
    329 # is prompted to look at them, and they can be popped up in a viewer
    330 # above the object tree.
    331 # ----------------------------------------------------------------------
    332 proc main_errors {} {
     328# before previewing and saving.  If any errors are found and the
     329# -strict flag is set, the user is forced to look at them before
     330# continuing on.  Otherwise, the user may choose to look at warnings
     331# and errors before continuing.  Usually called before previewing
     332# and saving the tool definition.  Returns 1 if there are errors that
     333# should be viewed/fixed, and 0 otherwise.
     334# ----------------------------------------------------------------------
     335proc main_errors {args} {
    333336    global ErrList ErrListPos
     337
     338    set strict no
     339    while {[llength $args] > 0} {
     340        set flag [lindex $args 0]
     341        set args [lrange $args 1 end]
     342        if {$flag eq "-strict"} {
     343            set strict yes
     344        } else {
     345            error "bad option \"$flag\": should be -strict"
     346        }
     347    }
    334348
    335349    set ErrList ""
     
    443457                set errors "these errors"
    444458            } else {
    445                 set errors "at least the $nerrs errors"
     459                set errors "at least the $nerrs error"
     460                if {$nerrs > 1} {lappend errors "s"}
    446461            }
    447462        }
     
    449464        # if there are errors, we can't continue on
    450465        if {$nerrs > 0} {
    451             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."
    452             return 1
     466            if {$strict} {
     467                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."
     468                return 1
     469            } else {
     470                set resp [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?"]
     471                return $resp
     472            }
    453473        }
    454474
     
    649669            $win.scrl.skel select none
    650670
    651             # generate now to catch any errors
    652             main_generate_xml
     671            # freshen up the ToolXml
     672            if {![main_generate_xml]} {
     673                # something went wrong while saving the xml
     674                # pull up the build tab, so we can see the error
     675                .func select [.func index -name "Build"]
     676                return
     677            }
     678
     679            if {[main_errors]} {
     680                .func select [.func index -name "Build"]
     681                pack .func.build.options.errs \
     682                    -before .func.build.options.panes \
     683                    -pady {10 0} -fill x
     684                main_errors_nav 0
     685                return
     686            }
    653687
    654688            # get the language choice and update the skeleton program option
     
    965999    }
    9661000
    967     if {[main_errors]} {
     1001    if {[main_errors -strict]} {
    9681002        .func select [.func index -name "Build"]
    9691003        pack .func.build.options.errs -before .func.build.options.panes \
Note: See TracChangeset for help on using the changeset viewer.