home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
clmtool.tcl
< prev
next >
Wrap
Text File
|
1997-10-16
|
15KB
|
526 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)clmtool.tcl /main/titanic/13
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)clmtool.tcl /main/titanic/13 16 Oct 1997 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require "asciiprint.tcl"
require "classmaker.tcl"
require "m4vardescr.tcl"
require "showversio.tcl"
# End user added include file section
require "exetool.tcl"
# Definition of the Mtool class.
# The mtool is an output-only exetool. Output from
# host commands is shown in a multi-line text widget.
Class ClMtool : {Exetool MainWindow} {
method destructor
constructor
method messageAreaPresent
method toolBarPresent
method addToolBar
method setToolBarPresence
method saveToolBarPresence
method addMessageArea
method setMessageAreaPresence
method saveMessageAreaPresence
method cmdStarted
method cmdFinished
method updateTitle
method execute
method stop
method handleReusableChanged
method toolName
attribute reusable
attribute m4VarDes
attribute winFont
attribute aPrinter
attribute saveFile
attribute suspendButton
attribute reuseButton
attribute win
attribute top
}
method ClMtool::destructor {this} {
# Start destructor user section
$this saveMessageAreaPresence
$this saveToolBarPresence
set geom [$this geometry]
if {$geom != [m4_var get M4_geometry -context mtool]} {
m4_var set M4_geometry $geom -context mtool
}
m4_var save
# End destructor user section
$this Exetool::destructor
}
constructor ClMtool {class this name dispatcher cmd {dir ""}} {
set this [MainWindow::constructor $class $this $name]
set this [Exetool::constructor $class $this $name $dispatcher]
$this config \
-closed {%this stop} \
-title "ObjectTeam Monitoring Window" \
-icon mtool_64 \
-iconTitle "ObjectTeam Monitoring Window" \
-reusable [m4_var get M4_reuse_tool -context mtool] \
-geometry [m4_var get M4_geometry -context mtool]
# create work-area
MenuBar new $this.menubar
$this top [DlgColumn new $this.top]
$this win [OutTermWindow new [$this top].win \
-horStretchFactor 10 \
-verStretchFactor 10 \
-horShrinkFactor 10 \
-verShrinkFactor 10 \
-font "[m4_var get M4_font -context mtool]" \
-clearScreen [m4_var get M4_clear_screen] \
-rowCount 24 \
-columnCount 80 \
-started {
.main cmdStarted "Executing '[%this command]' ..."
} \
-finished {
set exitStatusList [.main exitStatusList]
lappend exitStatusList [%this exitStatus]
.main exitStatusList $exitStatusList
} \
-stopped {
.main cmdFinished "Executing '[%this command]' failed"
} \
-ready {
.main cmdFinished "Command Ready"
} \
-selectionChanged {
[.main menuBar].edit.menu.copy sensitive \
[expr {[string length [%this selectedText]] > 0}]
}]
# create menus
set fileMenuButton [MenuBarButton new [$this menuBar].file \
-label File -mnemonic F]
set fileMenu [Menu new $fileMenuButton.menu \
-pinnable yes]
MenuPushButton new $fileMenu.save \
-label "Save As..." -mnemonic A -accelerator "Ctrl+s" \
-toolBarPixmap save \
-activated {[.main saveFile] popUp} \
-hintText "Saves mtool contents to a file."
MenuPushButton new $fileMenu.print \
-label "Print" \
-mnemonic P \
-accelerator "Ctrl+p" \
-toolBarPixmap print_16 \
-activated {
set printer [[[.main aPrinter] cmdField] text]
set printfile [args_file {}]
set msg "Sending output to $printer ..."
[.main win] saveOutput $printfile
wmtkmessage $msg
if [system "$printer $printfile"] {
wmtkmessage "Executing '$printer' failed"
} else {
wmtkmessage "Done"
}
unlink $printfile
} \
-hintText "Prints mtool contents."
MenuSeparator new $fileMenu.sep
MenuPushButton new $fileMenu.exit \
-label "Exit" -mnemonic x \
-activated {.main stop} \
-toolBarPixmap exit_16 \
-hintText "Quits the mtool."
# Edit Menu.
MenuBarButton new [$this menuBar].edit -label Edit -mnemonic E
Menu new [$this menuBar].edit.menu -pinnable yes
MenuPushButton new [$this menuBar].edit.menu.copy \
-label Copy -mnemonic C -accelerator Ctrl+C -toolBarPixmap copy \
-sensitive 0 -activated {[.main win] setClipboardValue}
if $win95 {
set mnemonic A
set accelerator Ctrl+A
} else {
set mnemonic S
set accelerator Ctrl+/
}
MenuPushButton new [$this menuBar].edit.menu.selectall \
-label "Select All" -mnemonic $mnemonic -accelerator $accelerator \
-activated {
[.main win] setSelectedText 0 -1
}
# View menu.
set viewMenuButton [MenuBarButton new [$this menuBar].view \
-label View -mnemonic V]
set viewMenu [Menu new $viewMenuButton.menu -pinnable yes]
MenuCheckButton new $viewMenu.toolbar \
-label "ToolBar" -mnemonic T -state 1 \
-stateChanged {
.main toolBarPresent [[.main menuBar].view.menu.toolbar state]
} \
-hintText "Shows or hides the toolbar."
MenuCheckButton new $viewMenu.messagearea \
-label "Message Area" -mnemonic M -state 1 \
-stateChanged {
.main messageAreaPresent [[.main menuBar].view.menu.messagearea state]
} \
-hintText "Shows or hides the message area."
set optionsMenuButton [MenuBarButton new [$this menuBar].options \
-label Options -mnemonic O]
set optionsMenu [Menu new $optionsMenuButton.menu \
-pinnable yes]
MenuPushButton new $optionsMenu.font \
-label "Font..." -mnemonic F \
-activated {
busy {
[.main winFont] value "[m4_var get M4_font -context mtool]"
[.main winFont] popUp
}
} \
-hintText "Changes the mtool font (M4_font__mtool)."
MenuPushButton new $optionsMenu.printer \
-label "Printer Setup..." -mnemonic P \
-activated {
[.main aPrinter] popUp
} \
-hintText "Changes settings for the printer."
MenuCheckButton new $optionsMenu.clearscreen \
-label "Clear Screen" \
-mnemonic C \
-toolBarPixmap cls_16 \
-state [m4_var get M4_clear_screen] \
-stateChanged {
[.main win] clearScreen [%this state]
m4_var set M4_clear_screen [%this state]
}
$this reuseButton [MenuCheckButton new $optionsMenu.reuse \
-label "Reuse" \
-mnemonic R \
-toolBarPixmap recycl_16 \
-state [m4_var get M4_reuse_tool -context mtool] \
-stateChanged {.main handleReusableChanged}]
$this suspendButton [MenuCheckButton new $optionsMenu.suspendoutput \
-label "Suspend Output" \
-mnemonic S \
-toolBarPixmap stop_16 \
-stateChanged {[.main win] suspend [%this state]}]
if {! $win95} {
set processMenuButton [MenuBarButton new [$this menuBar].process \
-label Process -mnemonic P]
set processMenu [Menu new $processMenuButton.menu \
-pinnable yes]
MenuPushButton new $processMenu.terminate \
-label "Terminate" -mnemonic T -sensitive no \
-activated {[.main win] abort 15} \
-hintText "Terminates the running process."
MenuPushButton new $processMenu.abort \
-label "Abort" -mnemonic A -sensitive no \
-activated {[.main win] abort 6}
MenuPushButton new $processMenu.kill \
-label "Kill" -mnemonic K -sensitive no \
-activated {[.main win] abort 9}
}
# Help menu
[$this menuBar] helpEntry [MenuBarButton new [$this menuBar].help \
-label Help -mnemonic H]
interface Menu [$this menuBar].help.menu {
pinnable 1
MenuPushButton whatsthis {
label "What's This?"
mnemonic W
activated {showHelp MTO/tl_mto.html}
hintText "Shows context sensitive help."
}
}
if {!$win95} {
MenuPushButton new [$this menuBar].help.menu.onhelp \
-label "On Help" \
-mnemonic H \
-activated {showHelp GEN/tl_hlp.html}
}
MenuPushButton new [$this menuBar].help.menu.helptopics \
-label "Help Topics" \
-mnemonic T \
-activated {showHelpTopics} \
-hintText "Shows help topics."
MenuPushButton new [$this menuBar].help.menu.abouthelptool \
-label "About Monitoring Window" \
-mnemonic A \
-activated {showVersionDialog [%this label]} \
-hintText "Shows version information."
$this setMessageAreaPresence
$this setToolBarPresence
# create save-output file-chooser using full pathnames
set M4_repdir [m4_var get M4_repdir]
set directory $M4_repdir
for {set root [path_name directory $directory]} 1 {set directory $root} {
if {"$root" == "$directory" ||
"[path_name base $directory]" == "$directory"} break
}
case "$root" in {
"." {
if {"$directory" == "."} {
set M4_repdir [string range $M4_repdir 2 end]
}
set M4_repdir [path_name concat [pwd] $M4_repdir]
}
".." {
set M4_repdir [path_name concat [pwd] $M4_repdir]
}
}
if $win95 {
set filter "Text Files (*.txt)|*.txt|All Files (*.*)|*|"
set fileNm mtool[pid].txt
} else {
set filter "*"
set fileNm mtool_log.[pid]
}
$this saveFile [FileChooser new $this.saveOutput \
-saveDialog 1 \
-title "Save As" \
-selectionPolicy BROWSE \
-filter $filter \
-directory "$M4_repdir" \
-selectedSet "[list [path_name concat $M4_repdir $fileNm]]" \
-helpPressed {showHelp MTO/db_saveoutput.html} \
-okPressed {
set logFile [lindex [%this selectedSet] 0]
set logDir [path_name directory $logFile]
if {"$logDir" != "[m4_var get M4_repdir]"} {
catch {m4_var set M4_repdir $logDir}
}
if [file exists $logFile] {
set box .main.saveOutputQuestion
QuestionDialog new $box \
-title "Confirm File Save" \
-message "Overwrite existing file '$logFile'?" \
-cancelPressed {$box delete} \
-okPressed {
if {[[.main win] saveOutput $logFile] == -1} {
# show error message
open $logFile w
}
$box delete
}
$box delHelpButton
$box popUp
} elseif {[[.main win] saveOutput $logFile] == -1} {
# show error message
open $logFile w
}
}]
# create font-chooser
$this winFont [FontChooser new $this.winFont \
-title "Monitoring Window Font" \
-okPressed {
[.main win] font [%this value]
if {"[m4_var get M4_font -context mtool]" != "[%this value]"} {
catch {m4_var set M4_font "[%this value]" -context mtool}
}
}]
[$this winFont] delHelpButton
# create ascii-printer entry-dialog
ClassMaker::extend AsciiPrinterDlg MtoolAsciiPrinterDlg \
{M4_a_printer M4_a_printer_llen M4_a_printer_plen}
$this aPrinter [MtoolAsciiPrinterDlg new $this.aPrinter \
-M4_a_printer [m4_var get M4_a_printer] \
-M4_a_printer_llen [m4_var get M4_a_printer_llen] \
-M4_a_printer_plen [m4_var get M4_a_printer_plen] \
-cancelPressed {
[%this cmdField] text [%this M4_a_printer]
[%this llenField] intValue [%this M4_a_printer_llen]
[%this plenField] intValue [%this M4_a_printer_plen]
} \
-okPressed {
set dim ""
if {[%this length l] <= 0} {
set dim l
} elseif {[%this length p] <= 0} {
set dim p
}
if {"$dim" != ""} {
set fieldName [%this.top.printer.prView.${dim}lenLabel text]
wmtkerror "$fieldName must be a positive value"
return
}
set index 0
foreach triple {
{M4_a_printer cmdField text}
{M4_a_printer_llen llenField intValue}
{M4_a_printer_plen plenField intValue}
} {
set m4var [lindex $triple 0]
set field [%this [lindex $triple 1]]
set entry [lindex $triple 2]
if {"[%this $m4var]" != "[$field $entry]"} {
%this $m4var [$field $entry]
catch {m4_var set $m4var [%this $m4var]}
}
incr index 1
}
%this popDown
}]
$this m4VarDes [M4VarDescription new $this.m4VarDes]
send -async [$this dispatcher] \
ClDispatcher::mtoolStarted [list [get_comm_name]] $cmd [list $dir]
return $this
}
method ClMtool::messageAreaPresent {this show} {
if {$show} {
$this addMessageArea
} else {
[$this messageArea] delete
}
}
method ClMtool::toolBarPresent {this show} {
if {$show} {
$this addToolBar
} else {
[$this toolBar] delete
}
}
method ClMtool::addToolBar {this} {
ToolBar new .main.bar -entrySet {
.main.menubar.file.menu.save
.main.menubar.file.menu.print
.main.menubar.file.menu.exit
SEPARATOR
.main.menubar.edit.menu.copy
SEPARATOR
.main.menubar.options.menu.clearscreen
.main.menubar.options.menu.reuse
.main.menubar.options.menu.suspendoutput
}
}
method ClMtool::setToolBarPresence {this} {
if [m4_var get M4_toolbar -context mtool] {
$this addToolBar
} else {
[$this menuBar].view.menu.toolbar state 0
}
}
method ClMtool::saveToolBarPresence {this} {
set toolBarPresent [expr {[$this toolBar] != ""}]
if {$toolBarPresent != [m4_var get M4_toolbar -context mtool]} {
m4_var set M4_toolbar $toolBarPresent -context mtool
}
}
method ClMtool::addMessageArea {this} {
MessageArea new $this.msg
}
method ClMtool::setMessageAreaPresence {this} {
if [m4_var get M4_messagearea -context mtool] {
$this addMessageArea
} else {
[$this menuBar].view.menu.messagearea state 0
}
}
method ClMtool::saveMessageAreaPresence {this} {
set areaPresent [expr {[$this messageArea] != ""}]
if {$areaPresent != [m4_var get M4_messagearea -context mtool]} {
m4_var set M4_messagearea $areaPresent -context mtool
}
}
# Callback for when a command is started.
#
method ClMtool::cmdStarted {this msg} {
[$this menuBar].file.menu.exit sensitive no
if {! $win95} {
[$this menuBar].process.menu.terminate sensitive yes
[$this menuBar].process.menu.abort sensitive yes
[$this menuBar].process.menu.kill sensitive yes
}
wmtkmessage $msg
}
# Callback for when a command is finished.
#
method ClMtool::cmdFinished {this msg} {
wmtkmessage $msg
if {"[$this clientId]" == ""} {
return
}
[$this menuBar].file.menu.exit sensitive yes
if {! $win95} {
[$this menuBar].process.menu.terminate sensitive no
[$this menuBar].process.menu.abort sensitive no
[$this menuBar].process.menu.kill sensitive no
}
$this notifyFinished
}
# Update the title of the OutTermWindow.
#
method ClMtool::updateTitle {this} {
$this Exetool::updateTitle
$this popUp
}
# Start the execution of command(s) and show the output
# in the OutTermWindow.
#
method ClMtool::execute {this} {
[$this suspendButton] state no
[$this win] suspend no
[$this win] commandLine [$this cmdLine]
[$this win] execute
}
# Stop the Mtool if it is not busy.
#
method ClMtool::stop {this} {
if {![[$this win] busy]} {
$this busy TRUE
wmtkmessage "Exiting..."
$this Exetool::stop
}
}
method ClMtool::handleReusableChanged {this} {
$this reusable [[$this reuseButton] state]
m4_var set M4_reuse_tool [$this reusable] -context mtool
if {![[$this win] busy]} {
$this Exetool::handleReusableChanged
}
}
method ClMtool::toolName {this} {
return mtool
}
# Do not delete this line -- regeneration end marker