home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
diagramedi.tcl
< prev
next >
Wrap
Text File
|
1997-11-27
|
31KB
|
1,113 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)diagramedi.tcl /main/titanic/43
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)diagramedi.tcl /main/titanic/43 27 Nov 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
require edwmtarea.tcl
require edpropcont.tcl
require propstruct.tcl
require labelpartn.tcl
require showversio.tcl
require systemutil.tcl
require editoropti.tcl
require m4vardescr.tcl
require otherude.tcl
# Hidden component types.
#
global hiddenCompTypes
set hiddenCompTypes(link_attrib) 1
set hiddenCompTypes(attribute) 1
set hiddenCompTypes(method) 1
set hiddenCompTypes(parameter) 1
set hiddenCompTypes(activity) 1
set hiddenCompTypes(state_action) 1
global compIndent
set compIndent [Dictionary new -contents {
parameter " "
attribute " "
method " "
link_attrib " "
activity " "
state_action " "
}]
# End user added include file section
require "histwmttoo.tcl"
Class DiagramEditor : {HistWmtTool MainWindow} {
method destructor
constructor
method createEdAreaPopUpMenu
method startEdit
method updateTitle
method mkHistEntry
method historyActivated
method addContextArea
method updateToolBar
method updateWmtArea
method editProperties
method removeProperties
method showProperties
method createPropContainers
method editDiagramProperties
method removeDiagramProperties
method showDiagramProperties
method createDiagPropContainer
method indent
method releasePropContainers
method startReport
method save
method edit
method push
method doEdit
method doEditExt
method read
method doRead
method print
method doPrint
method openByName
method open
method close
method doClose
method exit
method doExit
method newEditor
method askDecName
method decompose
method zoom
method popupNotSaved
method popupCloseExit
method popUpPrintOptions
method popUpNameDialog
method popUpScopeDialog
method enDisableMenuEntries
method helpOnContext
method helpOnName
method checkContents
method checkLocalModel
method removeUnreferencedItems
method createOpenByName
method editorArea
method reinit
method createShellLink
method switchLook
method addPropContainer
method removePropContainer
attribute fileStack
attribute selectedItem
attribute historyCount
attribute selPopDlg
attribute permanentReadOnly
attribute firstInit
attribute diagramType
attribute m4VarDes
attribute options
attribute openByNameDlg
attribute printOptions
attribute openKnowledgeDB
attribute propKnowledgeDB
attribute panel
attribute _editorArea
attribute moduleHdlr
attribute menuHdlr
attribute objHdlr
attribute propContainerSet
attribute readDiagram
attribute closeExit
attribute notSaved
attribute wmtArea
}
method DiagramEditor::destructor {this} {
# Start destructor user section
$this saveToolBarPresence ude
$this saveContextAreaPresence ude
$this saveMessageAreaPresence ude
$this saveHist [$this diagramType]
$this saveWindowGeometry [$this diagramType]
[$this menuHdlr] delete
[$this options] delete
[$this propKnowledgeDB] delete
[$this openKnowledgeDB] delete
[$this moduleHdlr] delete
if [isCommand [$this objHdlr]] {
[$this objHdlr] delete
}
# End destructor user section
$this HistWmtTool::destructor
}
constructor DiagramEditor {class this name} {
set this [MainWindow::constructor $class $this $name]
HistWmtTool::constructor $class $this $name
$this m4VarDes [M4VarDescription new $this.m4VarDes]
$this options [EditorOptions new $this.options]
$this moduleHdlr [ModuleHandler new -moduleSpecSetChanged {
set d_modules [%this deselectedModuleSpecSet]
foreach file [%this getFiles tcl d_ude.tcl $d_modules] {
source $file
}
set s_modules [%this selectedModuleSpecSet]
foreach file [%this getFiles tcl s_ude.tcl $s_modules] {
source $file
}
# clear dictionary, used in the proc module_promoter in proc.tcl
global modulePromoterSet
$modulePromoterSet contents ""
}]
global globalModuleHandler
set globalModuleHandler [$this moduleHdlr]
MenuBar new $this.bar
$this setToolBarPresence ude
DlgColumn new $this.c
$this setContextAreaPresence ude
HorSeparator new $this.c.sep
DlgRow new $this.c.r -spaceType NONE
$this setMessageAreaPresence ude
$this config \
-propContainerSet [List new] \
-historyCount 0 \
-permanentReadOnly 0 \
-closed {%this exit} \
-exitButton [$this menuBar].file.menu.exit \
-propKnowledgeDB [PropKnowledgeDB new \
$this.propKnowledgeDB [$this moduleHdlr]] \
-openKnowledgeDB [OpenKnowledgeDB new \
$this.openKnowledgeDB [$this moduleHdlr]]
global classCount
set classCount 1
ClassMaker::extend CustMenuPushButton HistMenuButton {levelPath abbrev}
$this firstInit 1
eval [[$this moduleHdlr] moduleSpecSetChanged]
return $this
}
method DiagramEditor::createEdAreaPopUpMenu {this} {
DrAreaPopUpMenu new [$this editorArea].pop -poppedUp {
[.main editorArea].pop entrySet [[.main menuHdlr] validPopUpEntrySet]
}
}
method DiagramEditor::startEdit {this levelPath} {
set levelPathObj [LevelPath new $levelPath]
$this loadHist [$this diagramType]
$this edit $levelPathObj
}
method DiagramEditor::updateTitle {this} {
set fv [[ClientContext::global] currentFile]
if [$fv isNil] {
set name ""
} else {
set name [[$fv file] qualifiedName :]
}
$this iconTitle $name
set title [$this title]
set hyphen [string last "-" $title]
if {$hyphen < 0} {
set title "- $title"
} else {
set title [string range $title $hyphen end]
}
set title "$name $title"
if [$this permanentReadOnly] {
regsub Editor$ $title Viewer title
} else {
regsub Viewer$ $title Editor title
}
$this title $title
}
method DiagramEditor::mkHistEntry {this levelPath mnem} {
set latest [$this historyCount]
incr latest
set abbrev [HistWmtTool::abbrevLevelPath $levelPath]
set button [$this menuBar].file.menu.his$latest
HistMenuButton new $button \
-label "$mnem $abbrev" -abbrev $abbrev \
-levelPath $levelPath \
-activated "$this historyActivated %this" \
-mnemonic $mnem -hintText "Opens $levelPath."
$this historyCount $latest
return $button
}
method DiagramEditor::historyActivated {this entry} {
$this edit [LevelPath new [$entry levelPath]]
}
method DiagramEditor::addContextArea {this} {
if {![isCommand [$this wmtArea]]} {
$this wmtArea [EdWmtArea new $this.c.wmtArea]
[$this wmtArea] index 0
}
if [isCommand [$this menuBar].view.menu.contextarea] {
[$this menuBar].view.menu.contextarea state 1
}
}
method DiagramEditor::updateToolBar {this} {
[$this menuHdlr] setCurrentContext
}
method DiagramEditor::updateWmtArea {this} {
if [isCommand [$this wmtArea]] {
[$this wmtArea] notify
}
}
method DiagramEditor::editProperties {this} {
busy {
set editorArea [$this editorArea]
if [catch {
set selComps [$editorArea editSelectedComponents]
} msg] {
wmtkerror $msg
return
}
$this createPropContainers $selComps 1
if {[[$this propContainerSet] contents] == ""} {
wmtkerror "There are no properties defined for the selected object(s)"
return
}
# Don't reuse a PropertyDialog:
# The initial size does not change to fit new contents.
uplevel #0 require propertydi.tcl
PropertyDialog new $this.editProperties $this \
-editable 1 \
-title "Edit Properties" \
-helpPressed {.main helpOnName editProperties}
set script [$this.editProperties okPressed]\;
append script "[$this editorArea] updateEditorComponents true"
$this.editProperties okPressed $script
$this.editProperties popUp
}
}
method DiagramEditor::removeProperties {this} {
busy {
set editorArea [$this editorArea]
if [catch {
set selComps [$editorArea editSelectedComponents]
} msg] {
wmtkerror $msg
return
}
$this createPropContainers $selComps 1
# Don't reuse a RmPropDialog:
# The initial size does not change to fit new contents.
uplevel #0 require rmpropdial.tcl
RmPropDialog new $this.removeProperties $this \
-title "Delete Properties" \
-helpPressed {.main helpOnName selectMany}
$this.removeProperties popUp
}
}
method DiagramEditor::showProperties {this} {
busy {
set editorArea [$this editorArea]
if [catch {
set selComps [$editorArea getSelectedComponents]
} msg] {
wmtkerror $msg
return
}
$this createPropContainers $selComps 0
if {[[$this propContainerSet] contents] == ""} {
wmtkerror "There are no properties defined for the selected object(s)"
return
}
# Don't reuse a PropertyDialog:
# The initial size does not change to fit new contents.
uplevel #0 require propertydi.tcl
PropertyDialog new $this.editProperties $this \
-editable 0 \
-title "Show Properties" \
-helpPressed {.main helpOnName editProperties}
set script [$this.editProperties okPressed]\;
append script "[$this editorArea] updateEditorComponents true"
$this.editProperties okPressed $script
$this.editProperties popUp
}
}
method DiagramEditor::createPropContainers {this selComps edit} {
set propStructList [List new]
set cc [ClientContext::global]
set configV [$cc currentConfig]
set phaseV [$cc currentPhase]
set fileV [$cc currentFile]
set propKnowledgeDB [$this propKnowledgeDB]
PropLocation new .propLocation \
-phaseType [[$phaseV phase] type] \
-diagramType [[$fileV file] type]
set maxNameLength 0
foreach obj $selComps {
set count 0
set labs [llength [$obj labelSet]]
.propLocation componentType [$obj type]
if {[$obj getProperty initiator] == 1} {
.propLocation condition "INITIATOR"
} elseif {[$obj getProperty key] == 1} {
.propLocation condition "KEY"
} else {
.propLocation condition "NOKEY"
}
set indent [$this indent [$obj type]]
foreach lab [$obj labelSet] {
.propLocation labelType [$lab type]
foreach itm [$lab itemRefSet] {
.propLocation containerKind Component
.propLocation containerType [$obj type]
set compPropDefs [$propKnowledgeDB \
definitions .propLocation]
.propLocation containerKind Item
.propLocation containerType [$itm type]
set itemPropDefs [$propKnowledgeDB \
definitions .propLocation]
if {"$compPropDefs$itemPropDefs" == ""} {
continue
}
set objName $indent[$itm itemName]
set objNameLength [string length $objName]
if {$objNameLength > $maxNameLength} {
set maxNameLength $objNameLength
}
set labIdx [$obj type],[$lab type],[$itm type]
if [info exists labelPartName($labIdx)] {
set objType $labelPartName($labIdx)
} else {
set objType [$obj longName]
if {$labs > 1} {
set labType [$lab longName]
set objType "$objType $labType"
}
}
$propStructList append [PropStruct new \
-name $objName \
-type $objType \
-compPropDefs $compPropDefs \
-containerKey [.propLocation asString] \
-component $obj \
-itemRef $itm \
-itemPropDefs $itemPropDefs]
incr count
}
}
if {$count == 0} {
.propLocation containerKind Component
.propLocation containerType [$obj type]
.propLocation labelType ""
set compPropDefs [$propKnowledgeDB \
definitions .propLocation]
if {[llength $compPropDefs] > 0} {
$propStructList append [PropStruct new \
-type [$obj longName] \
-compPropDefs $compPropDefs \
-containerKey [.propLocation asString] \
-component $obj]
}
}
}
.propLocation delete
set formatString "%-*.*s %s"
set cntList [List new]
$propStructList foreach propStruct {
set pres [format $formatString $maxNameLength $maxNameLength \
[$propStruct name] [$propStruct type]]
set cnt [EdPropContainer new -editable $edit \
-propertyKey [$propStruct containerKey] \
-propertyPresentation $pres \
-holderComp [$propStruct component] \
-itemRef [$propStruct itemRef]]
if {[$cnt getPropInfoMethods]} {
foreach propDef [$propStruct compPropDefs] {
$cnt addPropDefinition $propDef
}
foreach propDef [$propStruct itemPropDefs] {
$cnt addPropDefinition $propDef
}
$cnt storePropInfoMethods
} else {
foreach propDef [$propStruct compPropDefs] {
$cnt addSpecificPropDef $propDef holderComp
}
foreach propDef [$propStruct itemPropDefs] {
$cnt addSpecificPropDef $propDef itemPropInfo
}
$cnt storePropInfoMethods
}
$cntList append $cnt
}
$this propContainerSet $cntList
}
method DiagramEditor::editDiagramProperties {this} {
$this createDiagPropContainer 1
# Don't reuse a PropertyDialog:
# The initial size does not change to fit new contents.
uplevel #0 require propertydi.tcl
PropertyDialog new $this.editProperties $this \
-editable 1 \
-title "Edit Diagram Properties" \
-helpPressed {.main helpOnName editDiagramProperties}
$this.editProperties popUp
}
method DiagramEditor::removeDiagramProperties {this} {
$this createDiagPropContainer 1
# Don't reuse a RmPropDialog:
# The initial size does not change to fit new contents.
uplevel #0 require rmpropdial.tcl
RmPropDialog new $this.removeProperties $this \
-title "Delete Diagram Properties" \
-helpPressed {.main helpOnName selectMany}
$this.removeProperties popUp
}
method DiagramEditor::showDiagramProperties {this} {
$this createDiagPropContainer 0
# Don't reuse a PropertyDialog:
# The initial size does not change to fit new contents.
uplevel #0 require propertydi.tcl
PropertyDialog new $this.editProperties $this \
-editable 0 \
-title "Show Diagram Properties" \
-helpPressed {.main helpOnName editDiagramProperties}
$this.editProperties popUp
}
method DiagramEditor::createDiagPropContainer {this edit} {
set cc [ClientContext::global]
set phase [[$cc currentPhase] phase]
set file [[$cc currentFile] file]
PropLocation new .propLocation \
-containerKind Graph \
-containerType [$file type] \
-phaseType [$phase type]
$this propContainerSet [List new]
set propDefs [[$this propKnowledgeDB] definitions .propLocation]
if {[llength $propDefs] == 0} {
.propLocation delete
return
}
set cnt [EdPropContainer new -editable $edit \
-propertyKey [.propLocation asString] \
-propertyPresentation "[$file name] [$file type]" \
-diagPropInfo [[$this editorArea] propInfo]]
foreach propDef $propDefs {
$cnt addSpecificPropDef $propDef diagPropInfo
}
.propLocation delete
[$this propContainerSet] append $cnt
}
method DiagramEditor::indent {this compType} {
return [$compIndent set $compType]
}
method DiagramEditor::releasePropContainers {this} {
[$this editorArea] releaseSelectedComponents
}
method DiagramEditor::startReport {this file comment} {
if [[$this editorArea] isChanged] {
$this popupNotSaved "startReportInMtool \"$file\" \"$comment\""
} else {
startReportInMtool $file $comment
}
}
method DiagramEditor::save {this} {
busy {
wmtkmessage "Saving..."
[$this editorArea] save
wmtkmessage "Done"
}
}
method DiagramEditor::edit {this levelPathObj} {
if [[$this editorArea] isChanged] {
$this popupNotSaved "$this doEdit $levelPathObj"
} else {
$this doEdit $levelPathObj
}
}
method DiagramEditor::push {this levelPathObj} {
set stack [$this fileStack]
lappend stack [[ClientContext::global] createPath]
$this fileStack $stack
$this doEdit $levelPathObj
}
method DiagramEditor::doEdit {this levelPathObj} {
if [$this firstInit] {
$this doEditExt $levelPathObj
} else {
openOtherUde $levelPathObj "" "" "$this doEditExt $levelPathObj"
}
}
method DiagramEditor::doEditExt {this levelPathObj} {
if {[$levelPathObj depth] != "File"} {
wmtkerror "Invalid argument specified: [$levelPathObj asString]"
return
}
set newLevelPathObj $levelPathObj
busy { blockOutput {
set cc [ClientContext::global]
set oldLevelPath [$cc currentLevelString]
set newLevelPath [$newLevelPathObj asString]
set oldLevelPathObj [$cc createPath]
set corp [$newLevelPathObj nameAt Corporate]
if [isObjectId $corp Corporate:] {
# levelpath ids specified, convert to strings
if [catch {$cc setLevelIds $newLevelPath}] {
wmtkerror ""
return
}
set newLevelPathObj [$cc createPath]
set newLevelPath [$newLevelPathObj asString]
}
# newLevelPath contains strings
if [catch {$cc setLevelPath $newLevelPath}] {
wmtkerror ""
$this removeHistEntry $newLevelPath
return
}
$oldLevelPathObj removeTail
$newLevelPathObj removeTail
set systemSwitch 0
if {[$this firstInit] ||
[$oldLevelPathObj compare $newLevelPathObj]} {
set systemSwitch 1
$this reinit
}
if {[$this firstInit] || $oldLevelPath != $newLevelPath} {
wmtkmessage "Loading ..."
} else {
wmtkmessage "Reloading ..."
}
set fv [$cc currentFile]
if [$this permanentReadOnly] {
if [catch {[$this editorArea] load $fv} msg] {
wmtkerror $msg
wmtkmessage "Not done"
} else {
wmtkmessage "Loaded read-only"
}
} elseif [catch {[$this editorArea] edit $fv} msg] {
# Edit failed, try load
if [catch {[$this editorArea] load $fv} loadMsg] {
wmtkerror \
"Edit failed:\n${msg}\nLoad failed:\n$loadMsg"
wmtkmessage "Not done"
} else {
wmtkmessage "Loaded read-only"
wmtkwarning $msg
}
} else {
wmtkmessage Done
}
set entry [$this mkHistEntry $newLevelPath 1]
$this insertHistEntry $entry
$this updateTitle
$this firstInit 0
} }
}
method DiagramEditor::read {this} {
set dlg [$this readDiagram]
if {$dlg == ""} {
uplevel #0 require readdiagra.tcl
set dlg [ReadDiagram new $this.read -editor $this]
$this readDiagram $dlg
}
$dlg popUp
}
method DiagramEditor::doRead {this fv} {
busy {
wmtkmessage "Reading..."
if [catch {[$this editorArea] read $fv} msg] {
wmtkerror $msg
wmtkmessage "Not done"
} else {
wmtkmessage Done
}
}
}
method DiagramEditor::print {this} {
if [[$this editorArea] isChanged] {
$this popupNotSaved "$this doPrint"
} else {
$this doPrint
}
}
method DiagramEditor::doPrint {this} {
busy {
uplevel #0 require print.tcl
set cc [ClientContext::global]
set fv [$cc currentFile]
set optionsBox [$this printOptions]
if {$optionsBox != ""} {
set args [$optionsBox printOptions]
}
lappend args -configVersion [$cc currentConfig]
lappend args -systemVersion [$cc currentSystem]
lappend args $fv
eval Print::printDiagrams $args
}
}
method DiagramEditor::openByName {this} {
uplevel #0 require openbyname.tcl
set obn [$this openByNameDlg]
if {$obn == ""} {
set obn [$this createOpenByName]
$this openByNameDlg $obn
}
if [[$this editorArea] isChanged] {
$this popupNotSaved "$obn popUp"
} else {
$obn popUp
}
}
method DiagramEditor::open {this} {
if [[$this editorArea] isChanged] {
set dlg [WarningDialog new $this.warnopen \
-title "Navigation" \
-message "Navigation needs saved diagram.\nSave diagram ?" \
-okPressed "$this save; $this open"]
$dlg delHelpButton
$dlg popUp
return
}
busy {
uplevel #0 require selectitem.tcl
SelectItem new $this.items -editor $this
uplevel #0 require opendiagra.tcl
OpenDiagram new $this.open -editor $this
$this selPopDlg $this.open
$this.items popUp
}
}
method DiagramEditor::close {this} {
if {[llength [$this fileStack]] == 0} {
$this popupCloseExit "$this exit"
} elseif [[$this editorArea] isChanged] {
$this popupNotSaved "$this doClose"
} else {
$this doClose
}
}
method DiagramEditor::doClose {this} {
set stack [$this fileStack]
set last [llength $stack]
set file [lindex $stack [incr last -1]]
$this fileStack [lrange $stack 0 [incr last -1]]
$this doEdit $file
}
method DiagramEditor::exit {this} {
if [[$this editorArea] isChanged] {
$this popupNotSaved "$this doExit"
} else {
$this doExit
}
}
method DiagramEditor::doExit {this} {
$this busy TRUE
wmtkmessage "Exiting ..."
[$this editorArea] quit
$this stop
}
method DiagramEditor::newEditor {this levelPathObj} {
set presName [$levelPathObj nameAt File]
set msg "Starting diagram editor for '$presName'"
set script "SystemUtilities::fork otk \
ude -c [list [get_comm_name]] [$levelPathObj asString]"
$this startCommand tcl "$script" "" "$msg" {0 0} 1
}
method DiagramEditor::askDecName {this sv qualItem fileType} {
uplevel #0 require decnamedia.tcl
if {![isCommand $this.askDecName]} {
DecNameDialog new $this.askDecName -editor $this
}
set name [ShortLongName::longName $fileType]
$this.askDecName config \
-title "Create $name for '[$qualItem name]'" \
-sysVers $sv -qualItem $qualItem -fileType $fileType
$this.askDecName popUp
}
method DiagramEditor::decompose {this sv qualItem fileName fileType} {
set cc [ClientContext::global]
set configV [$cc currentConfig]
set scopePhase [fileHasScopePhase $fileType]
set itemType [file2itemtype $fileType]
set presName "$fileName.$fileType"
if {$qualItem != ""} {
set presName "[$qualItem name]:$presName"
}
wmtkmessage "Creating '$presName'"
busy {
if [catch {
if {"$qualItem" == ""} {
set decFileV [$sv createFileVersion $fileName \
$itemType $scopePhase $fileType graph $configV]
} else {
set fItm [$qualItem findCreateItem \
$fileName $itemType]
set decFileV [$sv createFileVersion $fItm \
$scopePhase $fileType graph $configV]
}
} msg] {
wmtkerror $msg
return
}
}
if {$sv == [$cc currentSystem] &&
$fileType == [[[$cc currentFile] file] type]} {
$this push [$cc createPath $decFileV]
} else {
$this newEditor [$cc createPath $sv $decFileV]
}
}
method DiagramEditor::zoom {this factor} {
busy {
set area [$this editorArea]
set orgScale [$area scale]
set scale [expr {$orgScale * $factor}]
if {$scale < 0.1} {
if {$orgScale < 0.1} {
wmtkmessage "Scale factor too small, reset to 1.00"
$area scale 1.00
return
}
wmtkmessage "Minimum zoom factor reached"
return
}
if {$scale > 3} {
if {$orgScale > 3} {
wmtkmessage "Scale factor too large, reset to 1.00"
$area scale 1.00
return
}
wmtkmessage "Maximum zoom factor reached"
return
}
wmtkmessage "Scale factor is now [format %.2f $scale]"
$area scale $scale
}
}
method DiagramEditor::popupNotSaved {this action} {
set notSaved [$this notSaved]
if {$notSaved == ""} {
uplevel #0 require notsaveddi.tcl
set notSaved [NotSavedDialog new $this.notSaved -editor $this]
$this notSaved $notSaved
}
$notSaved action $action
$notSaved popUp
}
method DiagramEditor::popupCloseExit {this action} {
set closeExit [$this closeExit]
if {$closeExit == ""} {
uplevel #0 require closeexitd.tcl
set closeExit [CloseExitDialog new $this.close]
$this closeExit $closeExit
}
$closeExit action $action
$closeExit popUp
}
method DiagramEditor::popUpPrintOptions {this} {
set printOptions [$this printOptions]
set cc [ClientContext::global]
if {$printOptions == ""} {
uplevel #0 require printoptio.tcl
set printOptions [PrintOptionsDialog new $this.printOptions]
$this printOptions $printOptions
}
$printOptions config -diagram [$cc currentFile] \
-readOnly [[$this editorArea] readOnly] \
-props [[$this editorArea] propInfo]
$printOptions popUp
}
method DiagramEditor::popUpNameDialog {this} {
if {[isCommand $this.items] || [isCommand $this.changeName]} {
wmtkerror "Another dialog is busy"
return
}
uplevel #0 require selectitem.tcl
SelectItem new $this.items \
-editor $this \
-cancelPressed "$this.changeName delete; %this delete"
uplevel #0 require itemnamech.tcl
set cc [ClientContext::global]
ItemNameChangeDialog new $this.changeName $this \
-configV [$cc currentConfig] \
-keeper [$cc currentFile]
$this selPopDlg $this.changeName
$this.items popUp
}
method DiagramEditor::popUpScopeDialog {this} {
if {[isCommand $this.items] || [isCommand $this.changeScope]} {
wmtkerror "Another dialog is busy"
return
}
uplevel #0 require selectitem.tcl
SelectItem new $this.items \
-editor $this \
-cancelPressed "$this.changeScope delete; %this delete"
uplevel #0 require scopechang.tcl
set cc [ClientContext::global]
ScopeChangeDialog new $this.changeScope \
-configV [$cc currentConfig] \
-systemV [$cc currentSystem] \
-diagram [$cc currentFile] \
-editor $this
$this selPopDlg $this.changeScope
$this.items popUp
}
method DiagramEditor::enDisableMenuEntries {this} {
[$this menuHdlr] areaChanged
}
method DiagramEditor::helpOnContext {this} {
set area [$this editorArea]
# Get selected components. Throw away "hidden" components.
set comps ""
global hiddenCompTypes
foreach comp [$area getSelectedComponents] {
if {![info exists hiddenCompTypes([$comp type])]} {
lappend comps $comp
}
}
if {[llength $comps] == 1} {
# Show help based on type of selected component.
set localKey [$comps type]
} else {
# Show generic help, based on type of diagram.
set cc [ClientContext::global]
set localKey [[[$cc currentFile] file] type]
}
$area releaseSelectedComponents
$this helpOnName $localKey
}
method DiagramEditor::helpOnName {this name} {
uplevel #0 require edsymb2url.tcl
global short2url
if [catch {set url $short2url($name)}] {
wmtkerror "Sorry, no help available for '$name'"
} else {
showHelp $url
}
}
method DiagramEditor::checkContents {this} {
set cc [ClientContext::global]
set file [[$cc currentFile] file]
set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] \
-c [$file qualifiedName].[$file type]"
set cmd [list $this startCommand mtool \
$script "" {Starting 'Check'} {0 0} 0]
if [[$this editorArea] isChanged] {
$this popupNotSaved $cmd
} else {
eval $cmd
}
}
method DiagramEditor::checkLocalModel {this} {
set cc [ClientContext::global]
set file [[$cc currentFile] file]
set args "-f check.tcl -S [$file qualifiedName].[$file type]"
set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] $args"
set cmd [list $this startCommand mtool \
$script "" {Starting 'Check'} {0 0} 0]
if [[$this editorArea] isChanged] {
$this popupNotSaved $cmd
} else {
eval $cmd
}
}
method DiagramEditor::removeUnreferencedItems {this} {
set cc [ClientContext::global]
set fv [$cc currentFile]
set script "busy \{ $fv removeUnusedDeclarations \}"
if [[$this editorArea] isChanged] {
$this popupNotSaved $script
} else {
eval $script
}
}
method DiagramEditor::createOpenByName {this} {
return [OpenByName new $this.obn -editor $this]
}
method DiagramEditor::editorArea {this {newArea -}} {
if {$newArea == "-"} {
return [$this _editorArea]
}
$this _editorArea $newArea
set focusButton "[$this menuBar].options.menu.pointerfocus"
if [isCommand $focusButton] {
$focusButton state [$newArea pointerFocus]
}
}
method DiagramEditor::reinit {this} {
# Use some trickery to set the right icon
$this icon [$this diagramType]e
$this iconTitle [string toupper [$this icon]]
#
$this updateTitle
#
[$this moduleHdlr] setCurrentContext
#
global EdPropContainer::propInfoMethodDicts
set EdPropContainer::propInfoMethodDicts [Dictionary new]
#
set connSelButton [$this menuBar].options.menu.selectconnectorstoo
if [isCommand $connSelButton] {
$connSelButton state [m4_var get M4_select_conns \
-context [$this diagramType]]
}
#
set foldButton "[$this menuBar].options.menu.initialfold"
if [isCommand $foldButton] {
$foldButton state [m4_var get M4_initial_fold \
-context [$this diagramType]]
}
#
set focusButton "[$this menuBar].options.menu.pointerfocus"
if [isCommand $focusButton] {
$focusButton state [[$this _editorArea] pointerFocus]
}
[$this panel] initialize [$this diagramType]
set area [.main editorArea]
if {[m4_var get M4_font -context ude] != [$area normalFontSpec]} {
$area normalFontSpec [m4_var get M4_font -context ude]
}
if {[m4_var get M4_font_annotation -context ude] != \
[$area annotationFontSpec]} {
$area annotationFontSpec [m4_var get M4_font_annotation \
-context ude]
}
if {[m4_var get M4_fg -context ude] != [$area areaForeground]} {
$area areaForeground [m4_var get M4_fg -context ude]
}
if {[m4_var get M4_bg -context ude] != [$area areaBackground]} {
$area areaBackground [m4_var get M4_bg -context ude]
}
if {[m4_var get M4_sel_color -context ude] != \
[$area areaSelectionColor]} {
$area areaSelectionColor [m4_var get M4_sel_color -context ude]
}
$this setToolBarPresence ude
$this updateToolBar
$this setMessageAreaPresence ude
$this setContextAreaPresence ude
$this updateWmtArea
}
method DiagramEditor::createShellLink {this} {
set cc [ClientContext::global]
set file [[$cc currentFile] file]
set lvl [$cc currentLevelString]
if [catch {set shl [ShellLink new]} msg] {
# NT 3.51? ignore
wmtkerror $msg
return
}
$shl path [m4_path_name bin otk.exe]
$shl arguments "[quoteIf [m4_path_name tcl ude.tcl]] -- $lvl"
set guiName \
"[$file qualifiedName " "] [ShortLongName::longName [$file type]].lnk"
set dir [registry get HKEY_CURRENT_USER \
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" Desktop]
$shl createIt $dir\\$guiName
}
method DiagramEditor::switchLook {this newLook} {
set oldLook [m4_var get M4_diagram_look status]
if {[string index $status 1] == "O"} {
wmtkmessage "Unable to change Diagram Look (M4 variable M4_diagram_look is read only)"
return
}
if {$oldLook == $newLook} {
return
}
set code "catch {m4_var set M4_diagram_look $newLook}; \
[$this panel] initialize [.main diagramType]; \
$this doEdit [LevelPath new \
[[ClientContext::global] currentLevelIdString]];\
[$this options] initLook"
if [[$this editorArea] isChanged] {
$this popupNotSaved $code
} else {
eval $code
}
}
# Do not delete this line -- regeneration end marker
method DiagramEditor::addPropContainer {this newPropContainer} {
[$this propContainerSet] append $newPropContainer
}
method DiagramEditor::removePropContainer {this oldPropContainer} {
[$this propContainerSet] removeValue $oldPropContainer
}