home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)browservsc.tcl /main/hindenburg/5
- # Author: <generated>
- # Description: VCM integration file
- #---------------------------------------------------------------------------
- # SccsId = @(#)browservsc.tcl /main/hindenburg/5 30 May 1997 Copyright 1997 Cayenne Software Inc.
-
- # Start user added include file section
- require platform.tcl
- # End user added include file section
-
- require_module_file "vscmdhandl.tcl" vcm
-
- # Command handler for commands executed in the browser.
-
- Class BrowserVSCmdHandler : {VSCmdHandler} {
- constructor
- method destructor
- method suspendAll
- method suspendOutput
- method execute
- method executeSilent
- method executeExternal
- method showOutput
- method error
-
- # Indicates whether browser output must be suspended.
- #
- attribute outputSuspended
-
- # Indicates whether error output must be suspended.
- #
- attribute errorsSuspended
-
- # Commands with unprocessed output.
- #
- attribute commands
- }
-
- constructor BrowserVSCmdHandler {class this name} {
- set this [VSCmdHandler::constructor $class $this $name]
- $this outputSuspended 0
- $this errorsSuspended 0
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method BrowserVSCmdHandler::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this VSCmdHandler::destructor
- }
-
-
- # Suspend all output from command execution.
- #
- method BrowserVSCmdHandler::suspendAll {this} {
- $this outputSuspended 1
- $this errorsSuspended 1
- }
-
-
- # Suspend command output except: one line output that can be put in the message area,
- # error output.
- #
- method BrowserVSCmdHandler::suspendOutput {this} {
- $this outputSuspended 1
- }
-
-
- # Execute the command and classify the output.
- # Show output depending on the outputSuspended and errorSuspended variables.
- # If they are not set:
- # If there is an error: show all output in error dialog.
- # If not: Show last line of normal output in message area.
- # Show warnings and additional info in warning dialog.
- # Show other info in info dialog.
- # If there is any suspended output add command to list.
- #
- method BrowserVSCmdHandler::execute {this command} {
- $command execute 1
-
- if { [$command errors] != "" } {
- if [$this errorsSuspended] {
- set commandList [$this commands]
- lappend commandList $command
- $this commands $commandList
- return 0
- }
- $this error "[$command description]: [$command errors]"
- return 0
- }
-
- if { [$command output] != "" } {
- set outputLines [split [$command output] "\n"]
- set lastLineIndex [expr [llength $outputLines] - 1]
- set lastLine [lindex $outputLines $lastLineIndex]
- set remainingLines [lrange $outputLines 0 [expr $lastLineIndex -1]]
- set remainingOutput [join $remainingLines "\n"]
- wmtkmessage "$lastLine"
- } else {
- set remainingLines ""
- set remainingOutput ""
- }
-
- if [$this outputSuspended] {
- if { ([$command warnings] != "") || ( $remainingLines != "" ) } {
- $command output $remainingOutput
- set commandList [$this commands]
- lappend commandList $command
- $this commands $commandList
- }
- return 1
- }
-
- wmtkmessage ""
-
- if { [$command warnings] != "" } {
- wmtkwarning "[$command warnings]\n$remainingOutput"
- return 1
- }
-
- if { $remainingLines != "" } {
- # if there already is an info box add to it
- if [isCommand .main.wmtkinfo] {
- set remainingOutput "[.main.wmtkinfo message]\n$remainingOutput"
- .main.wmtkinfo popDown
- .main.wmtkinfo delete
- }
- wmtkinfo "$remainingOutput"
- }
- return 1
- }
-
-
- # Execute the command, only handles errors if they occur.
- #
- method BrowserVSCmdHandler::executeSilent {this command} {
- $command execute 0
- if { [$command errors] != "" } {
- $this error "[$command description]: [$command errors]"
- return 0
- }
- return 1
- }
-
-
- # Eexcute command in given tool:
- # mtool, xtool or external.
- #
- method BrowserVSCmdHandler::executeExternal {this command tool {endCommand ""} {dir ""}} {
- if { $tool == "external" } {
- system "[$command command] &"
- return
- }
-
- if { $win95 && ($dir != "") } {
- .main startCommand $tool "cmd.exe /c cd $dir && [$command command]" "$endCommand" "" {0 0} 0
- } else {
- .main startCommand $tool "[$command command]" "$endCommand" "" {0 0} 0 "[quoteIf $dir]"
- }
- }
-
-
- # Process all supended command output and remove commands from list.
- #
- method BrowserVSCmdHandler::showOutput {this} {
- $this outputSuspended 0
- set warningsFound 0
- set outputList {}
-
- foreach command [$this commands] {
- lappend outputList [$command output]
- if { [$command warnings] != "" } {
- lappend outputList [$command warnings]
- set warningsFound 1
- }
- }
-
- $this commands ""
-
- set outputLines [join $outputList "\n"]
- if $warningsFound {
- wmtkwarning "$outputLines"
- return
- }
-
- # no output: show nothing
- if { [string trim $outputLines] == "" } {
- return
- }
- wmtkinfo "$outputLines"
- }
-
- method BrowserVSCmdHandler::error {this message} {
- wmtkerror "$message"
- if { !$win95 } {
- .main.error delHelpButton
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
-