home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
opendiagra.tcl
< prev
next >
Wrap
Text File
|
1996-11-13
|
11KB
|
395 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)opendiagra.tcl /main/hindenburg/8
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)opendiagra.tcl /main/hindenburg/8 13 Nov 1996 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require "opdatatype.tcl"
require "openaction.tcl"
# End user added include file section
Class OpenDiagram : {TemplateDialog} {
constructor
method destructor
method popUp
method handleOk
method handleCancel
method handleSelectionChanged
method addSearch
method addCreate
method addCreateAct
method addUserDef
method makeDecompIn
method createSystem
method selectedProp
method evalMacsIn
attribute selectedItem
attribute selDataType
attribute diagramItem
attribute diagramType
attribute editor
}
constructor OpenDiagram {class this name} {
set this [TemplateDialog::constructor $class $this $name]
# Start constructor user section
interface BrowsView $this.bv {
rowCount 10
mode DETAIL
columnCount 80
selectionPolicy BROWSE
BrowsHeader operation {
label Operation
width 24
}
BrowsHeader diagram {
label Diagram
width 24
}
BrowsHeader type {
label Type
width 7
}
BrowsHeader system {
label System
width 24
}
}
$this config \
-modal yes \
-title "Select Operation" \
-okPressed "$this handleOk" \
-cancelPressed "$this handleCancel" \
-helpPressed {.main helpOnName openDiagram}
$this.bv selectionChanged "$this handleSelectionChanged"
# End constructor user section
return $this
}
method OpenDiagram::destructor {this} {
# Start destructor user section
# End destructor user section
}
method OpenDiagram::popUp {this} {
set ed [$this editor]
busy {
# check if objtypes handler is already created
if {![isCommand [$ed objHdlr]]} {
$ed objHdlr [CustObjHandler new]
[$ed objHdlr] setCurrentContext
}
set file [[$ed fileVersion] file]
set fileType [$file type]
set selItemRec [$ed selectedItem]
set selItem [lindex $selItemRec 0]
$this selectedItem [$selItem item]
$this selDataType [[$this selectedProp data_type] name]
$this diagramItem [$file item]
$this diagramType $fileType
OpenLocation new .openLocation \
-itemType "[$selItem type]" \
-phaseType "[[[lindex [$ed context] 3] phase] type]" \
-diagramType "$fileType" \
-componentType "[lindex $selItemRec 1]" \
-labelType "[lindex $selItemRec 2]" \
-condition "[lindex $selItemRec 3]"
set openKnowlDB [$ed openKnowledgeDB]
foreach stg [$openKnowlDB definitions .openLocation] {
if [$stg isA SearchStrategy] {
$this addSearch $stg
} elseif [$stg isA CrFileStrategy] {
$this addCreate $stg
} else {
$this addUserDef $stg
}
}
set objSet [$this.bv objectSet]
set objSetSize [llength $objSet]
if {$objSetSize == 0} {
wmtkerror "No Open operations available for selected item"
$this delete
return
}
if {$objSetSize == 1} {
eval [[lindex $objSet 0] script]
$this delete
return
}
$this handleSelectionChanged
$this TemplateDialog::popUp
}
}
method OpenDiagram::handleOk {this} {
foreach action [$this.bv selectedSet] {
eval [$action script]
}
$this delete
}
method OpenDiagram::handleCancel {this} {
$this delete
}
method OpenDiagram::handleSelectionChanged {this} {
set selected [llength [$this.bv selectedSet]]
$this okSensitive $selected
$this okDefault $selected
$this cancelDefault [expr 1 - $selected]
}
method OpenDiagram::addSearch {this stg} {
set ed [$this editor]
set configV [$ed configVersion]
set systemV [$ed systemVersion]
set system [$systemV system]
set selItem [$this selectedItem]
$systemV getDecompositions $selItem $configV \
[$stg decompFlags] [$stg fileTypes] decompSystems decompFiles
foreach decFileV $decompFiles {
if {$decFileV == [$ed fileVersion]} continue
set decSys [$decFileV system]
set dfl [$decFileV file]
set decType [$dfl type]
set opId ${decType}File[$dfl qualifiedName :]InSys[$decSys name]
regsub -all "\\." "$opId" "DOT" opId
set opAct $this.bv.$opId
if [isCommand $opAct] continue
set objSpec [getObjectSpec [$ed objHdlr] Graph $decType]
if {"$objSpec" == ""} continue
if {$decSys == $system && $decType == [$this diagramType]} {
set action "load diagram"
set script "$ed push $decFileV"
} else {
set action "start editor"
set phaseV [[ClientContext::global] currentPhase]
set decSysV [$phaseV findSystemVersion \
-bySystem $decSys]
set script "$ed newEditor $decSysV $decFileV"
}
set details [list [$dfl qualifiedName :]]
lappend details $decType
lappend details "[$decSys name]"
OpenAction new $opAct \
-activated "$this popDown; $this handleOk" \
-smallIcon [$objSpec smallIcon] \
-label "$action" \
-details "$details" \
-script "$script"
lappend [$this.bv objectSet] $opAct
}
}
method OpenDiagram::addCreate {this stg} {
set ed [$this editor]
set configV [$ed configVersion]
set systemV [$ed systemVersion]
set decQual [$this evalMacsIn [$stg qualItemSpec]]
if {"$decQual" != "" && [$decQual isNil]} return
set decName [$this evalMacsIn [$stg fileNameSpec]]
set decType [$this evalMacsIn [$stg fileTypeSpec]]
set itemType [file2itemtype $decType]
if {"$decQual" == ""} {
set wItm [$systemV findDefinition $decName $itemType $configV]
} elseif {"$decName" == ""} {
set wItm [$systemV findDefinition $decQual $configV]
} else {
set wItm [$systemV findDefinition \
$decQual $decName $itemType $configV]
}
set decSysV [ORB::nil]
if {![$wItm isNil]} {
set decSysV [$wItm owner]
}
if [$decSysV isNil] {
if [$stg isA CrSysStrategy] {
set phaseV [lindex [$ed context] 3]
set decSysName [$this evalMacsIn [$stg sysNameSpec]]
set decSysV [$phaseV findSystemVersion \
$decSysName system]
} else {
set decSysV $systemV
set decSysName [[$decSysV system] name]
}
} else {
set decSysName [[$decSysV system] name]
}
$this addCreateAct $stg $decSysName $decSysV [ORB::nil]
if {"$decName" == ""} {
if {![$wItm isNil]} {
foreach qItm [$wItm qualifiedDeclarations] {
set decFileV [$decSysV findFileVersion \
-byItemAndType [$qItm item] $decType]
if {![$decFileV isNil]} {
$this addCreateAct $stg $decSysName \
$decSysV $decFileV
}
}
}
}
}
method OpenDiagram::addCreateAct {this stg decSysName decSysV decFileV} {
set ed [$this editor]
set systemV [$ed systemVersion]
set fileType [$this diagramType]
set decQual [$this evalMacsIn [$stg qualItemSpec]]
set decName [$this evalMacsIn [$stg fileNameSpec]]
set decType [$this evalMacsIn [$stg fileTypeSpec]]
set itemType [file2itemtype $decType]
if {"$decQual" == ""} {
set decQualName $decName
} elseif {"$decName" == ""} {
set decQualName [$decQual name]
if {![$decFileV isNil]} {
set decQualName [[$decFileV file] qualifiedName :]
}
} else {
set decQualName "[$decQual name]:$decName"
}
set opId ${decType}File${decQualName}InSys$decSysName
regsub -all "\\." "$opId" "DOT" opId
set opAct $this.bv.$opId
if [isCommand $opAct] return
set objSpec [getObjectSpec [$ed objHdlr] Graph $decType]
if {"$objSpec" == ""} return
if [$decSysV isNil] {
set action "create system"
set script "$this createSystem $decSysName"
append script " \"$decQual\" \"$decName\" $decType"
} else {
if {"$decQual" == ""} {
set decFileV [$decSysV findFileVersion \
$decName $decType]
} elseif [$decFileV isNil] {
set fItm [ORB::nil]
if {$decName != ""} {
set fItm [$decQual findItem $decName $itemType]
}
if {![$fItm isNil]} {
set decFileV [$decSysV findFileVersion \
-byItemAndType $fItm $decType]
}
}
if [$decFileV isNil] {
if {$decType == $fileType} {
set action "make decomposition"
} else {
set action "create diagram"
}
set script "$this makeDecompIn $decSysV"
append script " \"$decQual\" \"$decName\" $decType"
} elseif {$decFileV == [$ed fileVersion]} {
return
} elseif {$decSysV == $systemV} {
if {$decType == $fileType} {
set action "load diagram"
set script "$ed push $decFileV"
} else {
set action "start editor"
set script "$ed newEditor $decSysV $decFileV"
}
} else {
set action "start editor"
set script "$ed newEditor $decSysV $decFileV"
}
}
set details [list "$decQualName"]
lappend details $decType
lappend details $decSysName
OpenAction new $opAct \
-activated "$this popDown; $this handleOk" \
-smallIcon [$objSpec smallIcon] \
-label "$action" \
-details "$details" \
-script "$script"
lappend [$this.bv objectSet] $opAct
}
method OpenDiagram::addUserDef {this stg} {
[$stg procedure] $this
}
method OpenDiagram::makeDecompIn {this sv qualItem fileName fileType} {
set ed [$this editor]
if {"$fileName" == ""} {
$ed askDecName $sv $qualItem $fileType
return
}
$ed decompose $sv $qualItem $fileName $fileType
}
method OpenDiagram::createSystem {this sysName qualItem fileName fileType} {
set ed [$this editor]
set configV [$ed configVersion]
set phaseV [lindex [$ed context] 3]
wmtkmessage "Creating system '$sysName'"
busy {
if [catch {
set decSysV [$phaseV createSystemVersion \
$sysName cl system $configV]
} msg] {
wmtkerror $msg
return
}
}
$this makeDecompIn $decSysV $qualItem $fileName $fileType
}
method OpenDiagram::selectedProp {this prop} {
set ed [$this editor]
set configV [$ed configVersion]
set selItem [lindex [$ed selectedItem] 0]
set selWorkProps [[$selItem workItem $configV] properties]
if {![$selWorkProps isNil]} {
set propSpec [$selWorkProps findProperty $prop]
if {![$propSpec isNil]} {
set propItemRef [lindex [$propSpec itemRefs] 0]
if {![$propItemRef isNil]} {
set propItem [$propItemRef item]
if {![$propItem isNil]} {
return $propItem
}
}
}
}
return [$this selectedItem]
}
method OpenDiagram::evalMacsIn {this spec} {
set item [$this selectedItem]
set itemName [$item name]
set itemQual [$item qualifier]
if [$itemQual isNil] {
set itemQualName ""
} else {
set itemQualName [$itemQual name]
}
set dataType [$this selDataType]
set diagItem [$this diagramItem]
set diagName [$diagItem name]
set diagQual [$diagItem qualifier]
if [$diagQual isNil] {
set diagQualName ""
} else {
set diagQualName [$diagQual name]
}
set diagType [$this diagramType]
return [expr \"$spec\"]
}
# Do not delete this line -- regeneration end marker