home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-03-07 | 28.0 KB | 1,043 lines |
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)diagramedi.tcl /main/hindenburg/15
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)diagramedi.tcl /main/hindenburg/15 7 Mar 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
-
- # 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 "wmttool.tcl"
-
- Class DiagramEditor : {WmtTool MainWindow} {
- method destructor
- constructor
- method createEdAreaPopUpMenu
- method startEdit
- method context
- method fileVersion
- method changeFileVersion
- method addFileHistory
- method historyActivated
- method renumberFileHistory
- method setFileHistory
- method saveFileHistory
- 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 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 addPropContainer
- method removePropContainer
- attribute _fileVersion
- attribute systemVersion
- attribute configVersion
- attribute fileStack
- attribute selectedItem
- attribute historyCount
- attribute selPopDlg
- attribute permanentReadOnly
- attribute m4VarDes
- attribute options
- attribute openByNameDlg
- attribute printOptions
- attribute openKnowledgeDB
- attribute propKnowledgeDB
- attribute panel
- attribute _editorArea
- attribute moduleHdlr
- attribute genericMenuHdlr
- attribute specificMenuHdlr
- attribute objHdlr
- attribute propContainerSet
- attribute readDiagram
- attribute closeExit
- attribute notSaved
- attribute fileHistorySet
- attribute wmtArea
- }
-
- method DiagramEditor::destructor {this} {
- # Start destructor user section
-
- $this saveToolBarPresence ude
- $this saveContextAreaPresence ude
- $this saveMessageAreaPresence ude
-
- [$this options] delete
- [$this propKnowledgeDB] delete
- [$this openKnowledgeDB] delete
- [$this genericMenuHdlr] delete
- if [isCommand [$this objHdlr]] {
- [$this objHdlr] delete
- }
-
- # End destructor user section
- $this WmtTool::destructor
- }
-
- constructor DiagramEditor {class this name} {
- set this [MainWindow::constructor $class $this $name]
- WmtTool::constructor $class $this $name
-
- $this m4VarDes [M4VarDescription new $this.m4VarDes]
- $this options [EditorOptions new $this.options]
-
- MenuBar new $this.bar
- $this genericMenuHdlr [CustEdMenuHandler new diagram]
- $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] \
- -fileHistorySet [List new] \
- -historyCount 0 \
- -permanentReadOnly 0 \
- -closed {%this exit} \
- -exitButton [$this menuBar].file.menu.exit \
- -propKnowledgeDB [PropKnowledgeDB new $this.propKnowledgeDB] \
- -openKnowledgeDB [OpenKnowledgeDB new $this.openKnowledgeDB]
-
- # Use some trickery to set the right icon
- $this icon [$this diagramType]e
- $this iconTitle [string toupper [$this icon]]
-
- global classCount
- set classCount 1
- # take care of the generic entries
- [$this genericMenuHdlr] setCurrentContext
-
- ClassMaker::extend CustMenuPushButton HistMenuButton file
-
- return $this
- }
-
- method DiagramEditor::createEdAreaPopUpMenu {this} {
- EdAreaPopUpMenu new [$this editorArea].pop -poppedUp {
- [.main editorArea].pop entrySet [concat \
- [[.main genericMenuHdlr] getValidPopUpEntrySet] \
- [[.main specificMenuHdlr] getValidPopUpEntrySet]]
- }
- }
-
- method DiagramEditor::startEdit {this fv} {
- $this setFileHistory [[$fv file] type]
- $this edit $fv
- }
-
- method DiagramEditor::context {this} {
- set corp [[ClientContext::global] currentCorporate]
- set configV [$this configVersion]
- set systemV [$this systemVersion]
- set fileV [$this fileVersion]
- set proj [$configV project]
- set phaseV [$configV findPhaseVersion -byPhase [$systemV phase]]
- return "$corp $proj $configV $phaseV $systemV $fileV"
- }
-
- method DiagramEditor::fileVersion {this {fv -}} {
- if {$fv == "-"} {
- return [$this _fileVersion]
- }
- $this changeFileVersion $fv
-
- set context [$this context]
- set cc [ClientContext::global]
- set cntStr /[[lvarpop context] identity]
- append cntStr /[[lvarpop context] identity]
- append cntStr /[[lvarpop context] identity]
- append cntStr /[[lvarpop context] identity]
- append cntStr /[[lvarpop context] identity]
- if {![$fv isNil]} {
- append cntStr /[$fv identity]
- $this addFileHistory [$fv file]
- }
- $cc setLevelIds $cntStr
- }
-
- method DiagramEditor::changeFileVersion {this fv} {
- if [$fv isNil] {
- set name ""
- } else {
- set name [[$fv file] qualifiedName :]
- }
- $this _fileVersion $fv
- $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"
- $this title $title
- }
-
- method DiagramEditor::addFileHistory {this file} {
- set index [expr [[$this exitButton] index] - 1 - \
- [[$this fileHistorySet] length]]
- [$this fileHistorySet] foreach entry {
- if {$file != [$entry file]} {
- continue
- }
- [$this fileHistorySet] removeValue $entry
- [$this fileHistorySet] insert $entry
- $this renumberFileHistory
- $entry index $index
- return
- }
-
- set latest [expr [$this historyCount] + 1]
- HistMenuButton new [$this menuBar].file.menu.his$latest \
- -label "1 [$file qualifiedName :]" -mnemonic 1 -file $file \
- -operations edit -activated "$this historyActivated %this" \
- -index $index -hintText "Opens [$file qualifiedName :]."
- [$this fileHistorySet] insert [$this menuBar].file.menu.his$latest
- $this historyCount $latest
- $this renumberFileHistory
-
- if {[[$this fileHistorySet] length] > 5} {
- [[$this fileHistorySet] index end] delete
- [$this fileHistorySet] remove end
- }
- }
-
- method DiagramEditor::historyActivated {this entry} {
- set fv [[$this systemVersion] findFileVersion -byFile [$entry file]]
- if [$fv isNil] {
- wmtkerror "No version of [[$entry file] qualifiedName :] found"
- [$this fileHistorySet] removeValue $entry
- $this renumberFileHistory
- $entry delete
- } else {
- $this edit $fv
- }
- }
-
- method DiagramEditor::renumberFileHistory {this} {
- set m 1
- set sv [$this systemVersion]
- [$this fileHistorySet] foreach entry {
- if [[$sv findFileVersion -byFile [$entry file]] isNil] {
- $entry delete
- [$this fileHistorySet] removeValue $entry
- $this renumberFileHistory
- return
- }
- $entry config -mnemonic $m \
- -label "$m [[$entry file] qualifiedName :]"
- incr m
- }
- }
-
- method DiagramEditor::setFileHistory {this context} {
- set history [m4_var get M4_file_history -context $context]
- if {"$history" == ""} {
- return
- }
- if {[[[$this systemVersion] system] identity] != [lindex $history 0]} {
- return
- }
- set history [lrange $history 1 [expr [llength $history] - 1]]
- foreach fileId $history {
- catch {$this addFileHistory [File new $fileId]}
- }
- }
-
- method DiagramEditor::saveFileHistory {this context} {
- set history [[[$this systemVersion] system] identity]
- [$this fileHistorySet] foreach entry {
- set history [linsert $history 1 [[$entry file] identity]]
- }
- if {$history != [m4_var get M4_file_history -context $context]} {
- m4_var set M4_file_history $history -context $context
- }
- }
-
- method DiagramEditor::addContextArea {this} {
- $this wmtArea [EdWmtArea new $this.c.wmtArea]
- }
-
- method DiagramEditor::updateToolBar {this} {
- [$this genericMenuHdlr] setCurrentContext
- [$this specificMenuHdlr] setCurrentContext
- }
-
- method DiagramEditor::updateWmtArea {this} {
- if {[$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}
- $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}
- $this.editProperties popUp
- }
- }
-
- method DiagramEditor::createPropContainers {this selComps edit} {
- set propStructList [List new]
- set configV [$this configVersion]
- set phaseV [[ClientContext::global] currentPhase]
- set fileV [$this fileVersion]
- 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 phase [[[ClientContext::global] currentPhase] phase]
- set file [[$this fileVersion] 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 fv} {
- if [[$this editorArea] isChanged] {
- $this popupNotSaved "$this doEdit $fv"
- } else {
- $this doEdit $fv
- }
- }
-
- method DiagramEditor::push {this fv} {
- set stack [$this fileStack]
- lappend stack [[$this fileVersion] file]
- $this fileStack $stack
- $this doEdit $fv
- }
-
- method DiagramEditor::doEdit {this fv} {
- busy {
- if {[$this fileVersion] == ""} {
- wmtkmessage "Loading ..."
- } elseif {[$this fileVersion] == $fv ||
- [[$this fileVersion] file] == [$fv file]} {
- wmtkmessage "Reloading ..."
- # dummy call updating cache used for getting status
- $fv initialScope
- if {[$fv status] == "noStatus" ||
- [$fv status] == "backGround"} {
- set file [$fv file]
- set sv [$this systemVersion]
- set fv [$sv findFileVersion -byFile $file]
- if [$fv isNil] {
- set name [$file qualifiedName :]
- wmtkerror "No version of $name found"
- return
- }
- }
- } else {
- wmtkmessage "Loading ..."
- }
- if [$this permanentReadOnly] {
- if [catch {[$this editorArea] load $fv} msg] {
- wmtkerror $msg
- set fv [ORB::nil]
- wmtkmessage "Not done"
- } else {
- wmtkmessage "Loaded read-only"
- }
- if {[$this fileVersion] != $fv} {
- $this fileVersion $fv
- }
- return
- }
- if [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"
- set fv [ORB::nil]
- } else {
- wmtkmessage "Loaded read-only"
- wmtkwarning $msg
- }
- } else {
- wmtkmessage Done
- }
- if {[$this fileVersion] != $fv} {
- $this fileVersion $fv
- }
- }
- }
-
- 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 fv [$this fileVersion]
- set optionsBox [$this printOptions]
- if {$optionsBox != ""} {
- set args [$optionsBox printOptions]
- }
- lappend args -configVersion [$this configVersion]
- lappend args -systemVersion [$this systemVersion]
- 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] {
- 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]]
- set sv [$this systemVersion]
- set fv [$sv findFileVersion -byFile $file]
- if [$fv isNil] {
- wmtkerror "No version of [$file qualifiedName :] found"
- } else {
- $this doEdit $fv
- }
- }
-
- 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 sv fv} {
- set dfl [$fv file]
- set fId [$fv identity]
- set sId [$sv identity]
- set cId [[$this configVersion] identity]
- set presName "[$dfl name].[$dfl type]"
- set dflQual [[$dfl item] qualifier]
- if {![$dflQual isNil]} {
- set presName "[$dflQual name]:$presName"
- }
- set msg "Starting ude for '$presName'"
- set script "SystemUtilities::fork otk \
- ude -c [list [get_comm_name]] $fId $sId $cId"
- $this startCommand tcl "$script" "" "$msg" {0 0} 1
- }
-
- method DiagramEditor::askDecName {this sv qualItem fileType} {
- if {![isCommand $this.askDecName]} {
- ClassMaker::extend EntryDialog DecNameDialog {
- editor sysVers qualItem fileType}
- DecNameDialog new $this.askDecName \
- -modal yes \
- -editor $this \
- -message Name: \
- -helpPressed {.main helpOnName askDecName} \
- -okPressed {
- [%this editor] decompose [%this sysVers] \
- [%this qualItem] [%this entry] [%this fileType]
- }
- }
- $this.askDecName config \
- -title "Create [string toupper $fileType] for [$qualItem name]" \
- -sysVers $sv -qualItem $qualItem -fileType $fileType -entry ""
- $this.askDecName popUp
- }
-
- method DiagramEditor::decompose {this sv qualItem fileName fileType} {
- set configV [$this configVersion]
- 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 == [$this systemVersion] &&
- $fileType == [[[$this fileVersion] file] type]} {
- $this push $decFileV
- } else {
- $this newEditor $sv $decFileV
- }
- }
-
- method DiagramEditor::zoom {this factor} {
- busy {
- set area [$this editorArea]
- set scale [expr {[$area scale] * $factor}]
- if {$scale < 0.1} {
- wmtkmessage "Minimum zoom factor reached"
- return
- }
- if {$scale > 3} {
- 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]
- if {$printOptions == ""} {
- uplevel #0 require printoptio.tcl
- set printOptions [PrintOptionsDialog new $this.printOptions]
- $this printOptions $printOptions
- }
- $printOptions config -diagram [$this fileVersion] \
- -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
- ItemNameChangeDialog new $this.changeName $this \
- -configV [$this configVersion] \
- -keeper [$this fileVersion]
- $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
- ScopeChangeDialog new $this.changeScope \
- -configV [$this configVersion] \
- -systemV [$this systemVersion] \
- -diagram [$this fileVersion] \
- -editor $this
- $this selPopDlg $this.changeScope
- $this.items popUp
- }
-
- method DiagramEditor::enDisableMenuEntries {this} {
- [$this genericMenuHdlr] areaChanged
- [$this specificMenuHdlr] 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 localKey [[[$this fileVersion] 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 file [[$this fileVersion] file]
- set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] \
- -c [$file qualifiedName].[$file type]"
- $this startCommand mtool $script "" "Starting 'Check'" {0 0} 0
- }
-
- method DiagramEditor::checkLocalModel {this} {
- set file [[$this fileVersion] file]
- set args "-f check.tcl -S [$file qualifiedName].[$file type]"
- set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] $args"
- $this startCommand mtool $script "" "Starting 'Check'" {0 0} 0
- }
-
- method DiagramEditor::removeUnreferencedItems {this} {
- set fv [$this fileVersion]
- 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]
- }
- }
-
- # 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
- }
-
-