home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
opendiagra.tcl
< prev
next >
Wrap
Text File
|
1997-11-27
|
13KB
|
472 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)opendiagra.tcl /main/titanic/12
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)opendiagra.tcl /main/titanic/12 27 Nov 1997 Copyright 1997 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 selItemSys
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 def {
label ""
width 2
}
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]
set cc [ClientContext::global]
busy {
# check if objtypes handler is already created
if {![isCommand [$ed objHdlr]]} {
$ed objHdlr [CustObjHandler new [$ed moduleHdlr]]
[$ed objHdlr] setCurrentContext
}
set confV [$cc currentConfig]
set fileV [$cc currentFile]
set file [$fileV 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
$this selItemSys [ORB::nil]
set selWorkItem [$fileV findDefinition [$selItem item] $confV]
if {![$selWorkItem isNil]} {
set selItemOwner [$selWorkItem owner]
if [$selItemOwner isA SystemVersion] {
$this selItemSys [$selItemOwner system]
}
}
OpenLocation new .openLocation \
-itemType "[$selItem type]" \
-phaseType "[[[$cc currentPhase] 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} {
# no automatic navigation
# just select the one and only
[lindex $objSet 0] selectState true
}
$this.bv sort -command OpenDiagram::cmpOpenAct
$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 cc [ClientContext::global]
set configV [$cc currentConfig]
set systemV [$cc currentSystem]
set system [$systemV system]
set selItem [$this selectedItem]
$systemV getDecompositions $selItem $configV \
[$stg decompFlags] [$stg fileTypes] decompSystems decompFiles
foreach decFileV $decompFiles {
if {$decFileV == [$cc currentFile]} 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 actionId 1
set script "$ed push [$cc createPath $decFileV]"
} else {
set action "start editor"
set actionId 2
set phaseV [$cc currentPhase]
set decSysV [$phaseV findSystemVersion \
-bySystem $decSys]
set script \
"$ed newEditor [$cc createPath $decSysV $decFileV]"
}
set details [list [$dfl qualifiedName :]]
lappend details $decType
if {$decSys == [$this selItemSys]} {
lappend details *
} else {
lappend details ""
}
lappend details [$decSys name]
OpenAction new $opAct \
-activated "$this popDown; $this handleOk" \
-smallIcon [$objSpec smallIcon] \
-label "$action" \
-details "$details" \
-operationId $actionId \
-script "$script"
lappend [$this.bv objectSet] $opAct
}
}
method OpenDiagram::addCreate {this stg} {
set cc [ClientContext::global]
set configV [$cc currentConfig]
set systemV [$cc currentSystem]
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]
} else {
set wItm [$systemV findDefinition $decQual $configV]
}
set decSysV [ORB::nil]
if {![$wItm isNil]} {
set decSysV [$wItm owner]
}
if [$decSysV isNil] {
if [$stg isA CrSysStrategy] {
set phaseV [$cc currentPhase]
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 cc [ClientContext::global]
set ed [$this editor]
set systemV [$cc currentSystem]
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 actionId 5
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"
set actionId 3
} else {
set action "create diagram"
set actionId 4
}
set script "$this makeDecompIn $decSysV"
append script " \"$decQual\" \"$decName\" $decType"
} elseif {$decFileV == [$cc currentFile]} {
return
} elseif {$decSysV == $systemV} {
if {$decType == $fileType} {
set action "load diagram"
set actionId 1
set script "$ed push [$cc createPath $decFileV]"
} else {
set action "start editor"
set actionId 2
set script "$ed newEditor [$cc createPath $decSysV $decFileV]"
}
} else {
set action "start editor"
set actionId 2
set script \
"$ed newEditor [$cc createPath $decSysV $decFileV]"
}
}
set details [list "$decQualName"]
lappend details $decType
if {[$decSysV system] == [$this selItemSys]} {
lappend details *
} else {
lappend details ""
}
lappend details $decSysName
OpenAction new $opAct \
-activated "$this popDown; $this handleOk" \
-smallIcon [$objSpec smallIcon] \
-label "$action" \
-details "$details" \
-operationId $actionId \
-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 cc [ClientContext::global]
set configV [$cc currentConfig]
set phaseV [$cc currentPhase]
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 cc [ClientContext::global]
set ed [$this editor]
set configV [$cc currentConfig]
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\"]
}
proc OpenDiagram::cmpOpenAct {actA actB} {
set oIdA [$actA operationId]
set oIdB [$actB operationId]
if {$oIdA > $oIdB} {
return 1
}
if {$oIdB > $oIdA} {
return -1
}
set detA [$actA details]
set detB [$actB details]
set sysA [lindex $detA 3]
set sysB [lindex $detB 3]
if {$sysA > $sysB} {
return 1
}
if {$sysB > $sysA} {
return -1
}
set typA [lindex $detA 1]
set typB [lindex $detB 1]
if {$typA > $typB} {
return 1
}
if {$typB > $typA} {
return -1
}
set namA [lindex $detA 0]
set namB [lindex $detB 0]
if {$namA > $namB} {
return 1
}
if {$namB > $namA} {
return -1
}
return 0
}
# Do not delete this line -- regeneration end marker