home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
commandpag.tcl
< prev
next >
Wrap
Text File
|
1996-11-22
|
14KB
|
479 lines
#---------------------------------------------------------------------------
#
# (c) Westmount Technology 1994
#
# File: @(#)commandpag.tcl /main/hindenburg/6
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)commandpag.tcl /main/hindenburg/6 22 Nov 1996 Copyright 1994 Westmount Technology
# Start user added include file section
# End user added include file section
Class CommandPage : {NoteBkPage} {
constructor
method destructor
method createInterface
method clearInterface
method fromInterface
method toInterface
method setMethods
method setProcs
method preDefinedChanged
method commandTypeChanged
attribute cPage
attribute isMethod
attribute preDefinedProcs
}
constructor CommandPage {class this name} {
set this [NoteBkPage::constructor $class $this $name]
# Start constructor user section
# read type preDefinedProcs file
if {[[.main editorArea] toolType] == "browser"} {
set procfile browserprocs
} else {
set procfile editorprocs
}
if [file exists [m4_path_name etc $procfile]] {
set fid [open [m4_path_name etc $procfile] r]
$this preDefinedProcs [read -nonewline $fid]
close $fid
} else {
$this preDefinedProcs {}
}
$this createInterface
$this label Command
$this isMethod 0
# End constructor user section
return $this
}
method CommandPage::destructor {this} {
# Start destructor user section
# End destructor user section
}
proc CommandPage::checkBraces {cmd} {
set checkCmd $cmd
set openBraces 0
for {set brace [string last "\{" $checkCmd]} \
{$brace >= 0} \
{set brace [string last "\{" $checkCmd]} {
incr openBraces
set checkCmd [string range $checkCmd 0 [expr $brace - 1]]
}
set checkCmd $cmd
set closeBraces 0
for {set brace [string last "\}" $checkCmd]} \
{$brace >= 0} \
{set brace [string last "\}" $checkCmd]} {
incr closeBraces
set checkCmd [string range $checkCmd 0 [expr $brace - 1]]
}
if {$closeBraces != $openBraces} {
return 0
}
return 1
}
method CommandPage::createInterface {this} {
interface DlgRow $this.NG {
DlgColumn DC {
NamedGroup NG {
label Command
DlgColumn DC {
DlgRow DRpredefs {
verStretchFactor 0
DlgColumn DC {
Label L {
text "Predefined Procedure"
}
DropDwnList preDefinedProcDLL {
rowCount 5
}
}
}
Label L {
text "Command"
}
MultiLineText commandMLT {
columnCount 50
rowCount 3
}
DlgRow DR {
DlgColumn DC {
Label L {text "Command kind"}
VerRadioGroup externCmdVRG {
entrySet {Internal
"External Output Only"
"External Input/Output"
"External Own Interface"}
}
}
DlgColumn DC {
CheckButton askForOptionsCB {
label "Ask for options"
}
}
}
}
}
NamedGroup NG {
verStretchFactor 0
label Interface
DlgColumn DC {
CheckButton writeMessageCB {
label "Write message to message area"
}
Label L {
text Message
}
SingleLineText messageSLT {
}
CheckButton busyCursorCB {
label "Busy cursor while executing"
}
CheckButton updateViewCB {
label "Update view after execution"
}
CheckButton updateWmtAreaCB {
label "Update context area after execution"
}
}
}
}
}
$this cPage $this.NG.DC.NG.DC
if {[[.main editorArea] toolType] != "browser"} {
$this.NG.DC.NG.DC.updateViewCB delete
$this.NG.DC.NG.DC.updateWmtAreaCB delete
[$this cPage].commandMLT textModified \
"[$this cPage].DRpredefs.DC.preDefinedProcDLL selected {} "
} else {
interface DlgColumn $this.NG.DC.NG.DC.DRpredefs.objectOpsDC {
Label L {
text "Object Operation"
}
DropDwnList objectOpsDDL {
rowCount 5
}
}
[$this cPage].DRpredefs.objectOpsDC.objectOpsDDL selectionChanged \
"$this preDefinedChanged methods"
[$this cPage].commandMLT textModified \
"[$this cPage].DRpredefs.objectOpsDC.objectOpsDDL selected {}
[$this cPage].DRpredefs.DC.preDefinedProcDLL selected {} "
}
set names {}
foreach i [$this preDefinedProcs] {
lappend names [lvarpop i]
}
[$this cPage].DRpredefs.DC.preDefinedProcDLL entrySet $names
[$this cPage].DRpredefs.DC.preDefinedProcDLL selectionChanged \
"$this preDefinedChanged procs"
[$this cPage].DR.DC.externCmdVRG selectionChanged \
"$this commandTypeChanged"
}
method CommandPage::clearInterface {this} {
# clean page
[$this cPage].DRpredefs.DC.preDefinedProcDLL selected {}
[$this cPage].commandMLT text ""
[$this cPage].DR.DC.externCmdVRG selected "Internal"
$this commandTypeChanged
[$this cPage].writeMessageCB state 0
[$this cPage].messageSLT text ""
[$this cPage].busyCursorCB state 0
if {[[.main editorArea] toolType] == "browser"} {
[$this cPage].updateViewCB state 0
[$this cPage].updateWmtAreaCB state 0
[$this cPage].DRpredefs.objectOpsDC.objectOpsDDL selected {}
}
}
method CommandPage::fromInterface {this} {
# save page "Command"
set script [[$this cPage].commandMLT text]
if ![CommandPage::checkBraces $script] {
wmtkerror "Brace mismatch in command."
return ""
}
set kind [[$this cPage].DR.DC.externCmdVRG selected]
if {$kind == "Internal" } {
set cmdSpec ""
set message ""
set busyCursor 0
if [[$this cPage].writeMessageCB state] {
set message [[$this cPage].messageSLT text]
set cmdSpec "$cmdSpec {#CTGENMessage\n}"
set msgCmd wmtkmessage
set msgCmd [concat $msgCmd \{$message\}]
set cmdSpec "$cmdSpec \{$msgCmd\}"
}
if [[$this cPage].busyCursorCB state] {
set busyCursor 1
set cmdSpec "$cmdSpec {#CTGENBusyCursorOn\n}"
set cmdSpec "$cmdSpec {.main busy TRUE}"
}
set cmdSpec "$cmdSpec {#CTGENCommandScript\n}"
regsub -all "\n" $script "\n\t" script
set cmdSpec "$cmdSpec \{$script \}"
set cmdSpec "$cmdSpec {#CTGENEndCommandScript} {}"
if { $message != ""} {
set cmdSpec "$cmdSpec {#CTGENRemoveMessage\n}"
set msgCmd wmtkmessage
set msgCmd [concat $msgCmd \"\"]
set cmdSpec "$cmdSpec \{$msgCmd\}"
}
if $busyCursor {
set cmdSpec "$cmdSpec {#CTGENBusyCursorOff\n}"
set cmdSpec "$cmdSpec {.main busy FALSE}"
}
if {[[.main editorArea] toolType] == "browser"} {
if [[$this cPage].updateViewCB state] {
set cmdSpec "$cmdSpec {#CTGENUpdateView\n}"
set cmdSpec "$cmdSpec {.main updateView}"
}
if [[$this cPage].updateWmtAreaCB state] {
set cmdSpec "$cmdSpec {#CTGENUpdateWmtArea\n}"
set cmdSpec "$cmdSpec {.main updateWmtArea}"
}
}
set cmdSpec [CustEdArea::indentList $cmdSpec 0 0]
regsub -all "\n" $cmdSpec "\n\t\t" cmdSpec
return $cmdSpec
} else {
if {[[$this cPage].DR.DC.askForOptionsCB state] == 1} {
set cmdSpec {.main startCommandWithOptions}
} else {
set cmdSpec {.main startCommand}
}
if {$kind == "External Input/Output" } {
set cmdSpec [concat $cmdSpec xtool]
} elseif {$kind == "External Output Only"} {
set cmdSpec [concat $cmdSpec mtool]
} else {
set cmdSpec [concat $cmdSpec extern]
}
set script [[$this cPage].commandMLT text]
set cmdSpec [concat $cmdSpec \{$script\} \"\"]
if [[$this cPage].writeMessageCB state] {
set message [[$this cPage].messageSLT text]
set cmdSpec [concat $cmdSpec \"$message\"]
} else {
set cmdSpec [concat $cmdSpec \"\"]
}
if {[[.main editorArea] toolType] == "browser"} {
set upd [[$this cPage].updateViewCB state]
set upd [concat $upd \
[[$this cPage].updateWmtAreaCB state]]
set cmdSpec [concat $cmdSpec \{$upd\}]
} else {
# for editor commands update{view wmtarea} always 0
set cmdSpec [concat $cmdSpec \{0 0\}]
}
set cmdSpec [concat $cmdSpec \
[[$this cPage].busyCursorCB state]]
set cmdSpec "#CTGENCommandExtern \"\" \{$cmdSpec\}"
set cmdSpec [CustEdArea::indentList $cmdSpec 2 0]
return $cmdSpec
}
}
method CommandPage::toInterface {this value} {
# first protect the command
regsub "#CTGENCommandScript" $value "#CTGENCommandScript \{" value
regsub "#CTGENEndCommandScript" $value "\} #CTGENEndCommandScript" value
#strip the extra tabs
regsub -all "\n\t\t\t" $value "\n" value
set value [string trim $value]
# to be sure that a self made commands are not lost
if {[lsearch $value "#CTGENCommandScript"] == -1 &&
[lsearch $value "#CTGENCommandExtern"] == -1} {
[$this cPage].commandMLT text $value
return
}
while {![lempty $value]} {
set check [lvarpop value]
if {$check == "#CTGENMessage"} {
lvarpop value
[$this cPage].messageSLT text [lvarpop value]
[$this cPage].writeMessageCB state 1
} elseif {$check == "#CTGENBusyCursorOn"} {
[$this cPage].busyCursorCB state 1
} elseif {$check == "#CTGENUpdateWmtArea"} {
[$this cPage].updateWmtAreaCB state 1
} elseif {$check == "#CTGENUpdateView"} {
[$this cPage].updateViewCB state 1
} elseif {$check == "#CTGENCommandScript"} {
set command [lvarpop value]
lvarpop value
#strip the extra tabs
regsub -all "\n\t\t\t" $command "\n" command
set command [string trim $command]
[$this cPage].commandMLT text $command
[$this cPage].DR.DC.externCmdVRG selected "Internal"
} elseif {$check == "#CTGENCommandExtern"} {
#.main
lvarpop value
#startCommand
set cmd [lvarpop value]
if {$cmd == "startCommand"} {
[$this cPage].DR.DC.askForOptionsCB state 0
} else {
[$this cPage].DR.DC.askForOptionsCB state 1
}
set exeType [lvarpop value]
if {$exeType == "mtool"} {
[$this cPage].DR.DC.externCmdVRG selected \
"External Output Only"
} elseif {$exeType == "xtool"} {
[$this cPage].DR.DC.externCmdVRG selected \
"External Input/Output"
} else {
[$this cPage].DR.DC.externCmdVRG selected \
"External Own Interface"
}
set command [lvarpop value]
[$this cPage].commandMLT text $command
# skip the finish script
lvarpop value
set message [lvarpop value]
[$this cPage].messageSLT text $message
if { $message != ""} {
[$this cPage].writeMessageCB state 1
}
set updateState [lvarpop value]
if [lindex $updateState 0] {
[$this cPage].updateViewCB state 1
}
if [lindex $updateState 1] {
[$this cPage].updateWmtAreaCB state 1
}
set busy [lvarpop value]
if $busy {
[$this cPage].busyCursorCB state 1
}
}
}
$this commandTypeChanged
}
method CommandPage::setMethods {this classList} {
if [lempty $classList] {
[$this cPage].DRpredefs.objectOpsDC.objectOpsDDL entrySet ""
return
}
# fill the list with the first entry of classList
# transfrom from 'uiNames' to real classes
set className [.main getBrowsObj [lindex $classList 0]]
if {$className == ""} {
return
}
set methodList [$className info methods]
foreach className $classList {
set className [.main getBrowsObj $className]
if {$className == ""} {
continue
}
set classMethods [$className info methods]
foreach i $methodList {
set idx [lsearch $classMethods $i]
# if this method is not in the current class, skip it
if {$idx == -1} {
set methodList [lreplace $methodList $idx $idx]
}
}
}
[$this cPage].DRpredefs.objectOpsDC.objectOpsDDL entrySet $methodList
}
method CommandPage::setProcs {this} {
# !! Implement this function !!
}
method CommandPage::preDefinedChanged {this type} {
if {$type == "procs"} {
# find the corresponding command
set sel [[$this cPage].DRpredefs.DC.preDefinedProcDLL selected]
if {$sel == ""} {
# bug in combo (callback activated when set in code)
return
}
set cmd ""
foreach i [$this preDefinedProcs] {
if {[lindex $i 0] == $sel} {
set cmd [lindex $i 1]
}
}
[$this cPage].DRpredefs.DC.preDefinedProcDLL selected ""
} else {
set sel [[$this cPage].DRpredefs.objectOpsDC.objectOpsDDL selected]
if {$sel == ""} {
# bug in combo (callback activated when set in code)
return
}
if [$this isMethod] {
set cmd {[%this browsUiObj]}
lappend cmd $sel
} else {
set cmd { foreach i [.main selectedSet] }
set cmd "$cmd \{\n\t \[\$i browsUiObj\] $sel \n\}"
}
[$this cPage].DRpredefs.objectOpsDC.objectOpsDDL selected ""
}
[$this cPage].commandMLT text $cmd
[$this cPage].DR.DC.externCmdVRG selected "Internal"
$this commandTypeChanged
}
method CommandPage::commandTypeChanged {this} {
if {[[$this cPage].DR.DC.externCmdVRG selected] == "Internal" } {
[$this cPage].DR.DC.askForOptionsCB state 0
[$this cPage].DR.DC.askForOptionsCB sensitive 0
} else {
[$this cPage].DR.DC.askForOptionsCB sensitive 1
}
}
# Do not delete this line -- regeneration end marker