home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
classbrows.tcl
< prev
next >
Wrap
Text File
|
1997-11-26
|
24KB
|
936 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)classbrows.tcl /main/titanic/11
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)classbrows.tcl /main/titanic/11 26 Nov 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
require "cbwmtarea.tcl"
require "cbsupercla.tcl"
require "cbsubclass.tcl"
require "cbclasstex.tcl"
require "cbfeaturet.tcl"
require "cbassoctex.tcl"
require "cbcadphase.tcl"
require "cbcadsyste.tcl"
require "cbclasssta.tcl"
require "classselha.tcl"
require "diagramsel.tcl"
require "workitemse.tcl"
require "cbpropview.tcl"
require "cbfindclas.tcl"
require "cbfindfeat.tcl"
require "cbattrfilt.tcl"
require "cboperfilt.tcl"
require "cbfilterfe.tcl"
require "cbfontchoo.tcl"
require "tooloption.tcl"
require "cb2url.tcl"
require "showversio.tcl"
require "closeexitd.tcl"
# End user added include file section
require "wmttool.tcl"
Class ClassBrowser : {WmtTool MainWindow} {
method destructor
constructor
method fileReloadClasses
method fileOpen
method fileClose
method fileFindClass
method fileFindFeature
method filePrintView
method fileExit
method itemShowProperties
method itemShowScope
method viewFlat
method viewFilterFeatures
method optionsSortCaseSensitive
method optionsFont
method optionsPrinterSetup
method utilEditCAD
method helpOnContext
method popUp
method initView
method selTextListChanged
method getSelTextListEntry
method getSelectedSet
method getCBClass
method getCurrentOpenedClassIndex
method updateClientContext
method addFileHistory
method renumberFileHistory
method updateFileHistory
method setFileHistory
method saveFileHistory
method addContextArea
method updateToolBar
method updateWmtArea
method updateTitle
method updateWmtAreaClass
method popupCloseExit
method doClose
method setFont
method helpOnName
method classTL
method superClassTL
method subClassTL
method featureTL
method assocTL
method startEditCADHandler
attribute projectName
attribute configurationName
attribute phaseName
attribute systemName
attribute className
attribute historyCount
attribute isInFlatViewMode
attribute showVisibility
attribute umlLook
attribute phaseLevelPathIds
attribute _classTL
attribute _superClassTL
attribute _subClassTL
attribute _featureTL
attribute _assocTL
attribute propertyViewer
attribute propKnowledgeDB
attribute filterFeaturesDialog
attribute options
attribute moduleHdlr
attribute fileHistorySet
attribute showScopeHandler
attribute closeExit
attribute menuHandler
attribute _startEditCADHandler
attribute editCADHandler
attribute openHandler
attribute selTextList
attribute currentOpenedClass
attribute openHistory
attribute ccontext
attribute model
attribute wmtArea
}
global ClassBrowser::attrFilter
set ClassBrowser::attrFilter ""
global ClassBrowser::operFilter
set ClassBrowser::operFilter ""
method ClassBrowser::destructor {this} {
set ref [$this _classTL]
if {$ref != ""} {
$ref _browser ""
}
set ref [$this _superClassTL]
if {$ref != ""} {
$ref _browser ""
}
set ref [$this _subClassTL]
if {$ref != ""} {
$ref _browser ""
}
set ref [$this _featureTL]
if {$ref != ""} {
$ref _browser ""
}
set ref [$this _assocTL]
if {$ref != ""} {
$ref _browser ""
}
set ref [$this _startEditCADHandler]
if {$ref != ""} {
$ref _browser ""
}
# Start destructor user section
$this saveFileHistory
$this saveToolBarPresence classbrowser
$this saveContextAreaPresence classbrowser
$this saveMessageAreaPresence classbrowser
$this saveWindowGeometry classbrowser
[$this moduleHdlr] delete
if {[$this model] != ""} {
[$this model] delete
}
GCControl collect
# End destructor user section
$this WmtTool::destructor
}
constructor ClassBrowser {class this name ccontext} {
set this [MainWindow::constructor $class $this $name]
set this [WmtTool::constructor $class $this $name]
$this ccontext $ccontext
# Initialize some attributes
#
$this model ""
global globalModuleHandler
set globalModuleHandler [ModuleHandler new \
-moduleSpecSetChanged {
set d_modules [%this deselectedModuleSpecSet]
foreach file [%this getFiles tcl d_clbrowser.tcl $d_modules] {
source $file
}
set s_modules [%this selectedModuleSpecSet]
foreach file [%this getFiles tcl s_clbrowser.tcl $s_modules] {
source $file
}
# clear dictionary, used in proc module_promoter in proc.tcl
global modulePromoterSet
$modulePromoterSet contents ""
}]
$this moduleHdlr $globalModuleHandler
$this isInFlatViewMode \
[expr {([m4_var get M4_flat_view] == "1") ? 1 : 0}]
set phaseType [[[$ccontext currentPhase] phase] type]
$this showVisibility [expr {([m4_var get \
M4_show_visibility -context $phaseType] == "1") ? 1 : 0}]
$this umlLook [expr {([m4_var get M4_diagram_look ] == "UML") ? 1 : 0}]
# Initialize graphical stuff
#
$this config \
-title "ObjectTeam Class Browser" \
-fileHistorySet [List new] \
-historyCount 0 \
-closed {%this fileExit} \
-exitButton $this.bar.file.menu.exit \
-icon clbrowser \
-iconTitle "ObjectTeam Class Browser"
global classCount
set classCount 1
MenuBar new $this.bar
$this menuHandler [CustCBMenuHandler new class [$this moduleHdlr]]
$this setToolBarPresence classbrowser
[$this menuHandler] setCurrentContext
# Initialize the two menucheckbuttons if they exist
if {[isCommand $this.bar.view.menu.flat]} {
$this.bar.view.menu.flat state \
[expr {([m4_var get M4_flat_view] == "1") ? 1 : 0}]
}
if {[isCommand $this.bar.options.menu.sortcasesensitive]} {
$this.bar.options.menu.sortcasesensitive state [expr \
{([m4_var get M4_sort_case_sensitive] == "1") ? 1 : 0}]
}
DlgColumn new $this.c
$this setContextAreaPresence classbrowser
HorSeparator new $this.c.sep
interface VerSplitter $this.c.vs {
DlgRow r1 {
HorSplitter hs1 {
DlgColumn c1 {
Label superClassesLab {
text "Superclasses"
}
CBSuperClassTextList superClasses {
selectionPolicy BROWSE
rowCount 3
}
}
DlgColumn c2 {
Label classesLab {
text "Classes"
}
CBClassTextList classes {
selectionPolicy BROWSE
rowCount 7
justification FILLED
}
}
DlgColumn c3 {
Label subClassesLab {
text "Subclasses"
}
CBSubClassTextList subClasses {
selectionPolicy BROWSE
rowCount 3
}
}
}
}
DlgRow r2 {
HorSplitter hs2 {
DlgColumn c1 {
Label featuresLab {
text "Features"
}
CBFeatureTextlist features {
selectionPolicy BROWSE
rowCount 12
justification FILLED
}
}
DlgColumn c2 {
Label associationsLab {
text "Associations"
}
CBAssocTextList associations {
selectionPolicy BROWSE
rowCount 3
}
}
}
}
}
# hack start
# give label SuperClassesLab extra spaces
# so that it determines the width of the column
# which is to small default
# real solution: add columnWidth to TextList
set hackLbl $this.c.vs.r1.hs1.c1.superClassesLab
$hackLbl text "Superclasses "
# hack end
$this projectName [[[$this ccontext] currentProject] name]
set confName [[[[$this ccontext] currentConfig] config] name]
set confVersion [[[$this ccontext] currentConfig] versionNumber]
$this configurationName "$confName (V$confVersion)"
$this phaseName [[[[$this ccontext] currentPhase] phase] name]
$this updateWmtArea
$this superClassTL $this.c.vs.r1.hs1.c1.superClasses
$this classTL $this.c.vs.r1.hs1.c2.classes
$this subClassTL $this.c.vs.r1.hs1.c3.subClasses
$this featureTL $this.c.vs.r2.hs2.c1.features
$this assocTL $this.c.vs.r2.hs2.c2.associations
$this setMessageAreaPresence classbrowser
$this setFont [m4_var get M4_font -context classbrowser]
$this options [ToolOptions new $this.options]
# Set phaseLevelPathIds attribute with LevelIds upto Phase level.
# would like to use LevelPath::parentAt ... (not available in TCL!!)
set levelPathObj [LevelPath new [$ccontext currentLevelIdString]]
while {[$levelPathObj depth] != "Phase"} {
$levelPathObj removeTail
}
$this phaseLevelPathIds $levelPathObj
# Create PropKnowledgeDB and PropertyViewer.
#
$this propKnowledgeDB [PropKnowledgeDB new \
$this.propKnowledgeDB [$this moduleHdlr]]
$this propertyViewer [CBPropViewer new $this.propViewer \
[$this propKnowledgeDB]]
# Create global attribute and operation filters
#
global ClassBrowser::attrFilter
set ClassBrowser::attrFilter [CBAttrFilter new \
.attrFilter [$this propKnowledgeDB]]
global ClassBrowser::operFilter
set ClassBrowser::operFilter [CBOperFilter new \
.operFilter [$this propKnowledgeDB]]
# Initialize handlers/dialogs
#
$this openHandler [ClassSelHandler new $this.openHandler \
-title "Open Class" \
-message "Select Class:" \
-command open]
$this showScopeHandler [WorkItemSelHandler new $this.showScopeHandler \
-title "Show Scope" \
-message "Select Item:" \
-command showScope]
$this editCADHandler [ClassSelHandler new $this.editCADHandler \
-title "Edit Class" \
-message "Select Class:" \
-command editCAD]
$this startEditCADHandler [DiagramSelHandler new \
$this.startEditCADHandler \
-title "Edit [ShortLongName::longName $CAD_TYPE]" \
-message "Select [ShortLongName::longName $CAD_TYPE]:" \
-command editCAD]
$this filterFeaturesDialog ""
$this setWindowGeometry classbrowser
ClassMaker::extend CustMenuPushButton HistMenuButton {cbClass nameItem}
return $this
}
method ClassBrowser::fileReloadClasses {this} {
$this initView 1
}
method ClassBrowser::fileOpen {this} {
busy {
set textListEntry [$this getSelTextListEntry]
if {$textListEntry != ""} {
$textListEntry open
}
}
}
method ClassBrowser::fileClose {this} {
if {[[$this openHistory] size] == 0} {
$this popupCloseExit "$this fileExit"
} else {
$this doClose
}
}
method ClassBrowser::fileFindClass {this} {
if {![isCommand $this.findClassDialog]} {
CBFindClassDialog new $this.findClassDialog
}
$this.findClassDialog popUp
}
method ClassBrowser::fileFindFeature {this} {
if {![isCommand $this.findFeatureDialog]} {
CBFindFeatureDialog new $this.findFeatureDialog
}
$this.findFeatureDialog popUp
}
method ClassBrowser::filePrintView {this} {
set printer [m4_var get M4_a_printer]
set tmpFile [args_file {}]
set fid [open $tmpFile w]
puts $fid "View of:"
puts $fid " Project: [$this projectName]"
puts $fid " Configuration Version: [$this configurationName]"
puts $fid " Phase Version: [$this phaseName]"
puts $fid " System Version: [$this systemName]"
puts $fid " Class: [$this className]"
puts $fid "\n-- Superclasses --"
foreach entry [[$this superClassTL] entrySet] {
puts $fid " $entry"
}
puts $fid "\n-- Subclasses --"
foreach entry [[$this subClassTL] entrySet] {
puts $fid " $entry"
}
puts $fid "\n-- Features --"
foreach entry [[$this featureTL] entrySet] {
puts $fid " $entry"
}
puts $fid "\n-- Associations --"
foreach entry [[$this assocTL] entrySet] {
puts $fid " $entry"
}
close $fid
$this startCommand extern \
"$printer $tmpFile" "[list BasicFS::removeFile $tmpFile]" \
"Sending output to $printer..." \
{0 0} 0
}
method ClassBrowser::fileExit {this} {
$this delete
exit
}
method ClassBrowser::itemShowProperties {this} {
busy {
set textListEntry [$this getSelTextListEntry]
if {$textListEntry != ""} {
[$this propertyViewer] showProperties $textListEntry
}
}
}
method ClassBrowser::itemShowScope {this} {
busy {
set textListEntry [$this getSelTextListEntry]
if {$textListEntry != ""} {
$textListEntry showScope
}
}
}
method ClassBrowser::viewFlat {this checkButton} {
if {[catch {m4_var set M4_flat_view [$checkButton state]}]} {
wmtkerror "Unable to set Display Flat View"
$checkButton state [expr ![$checkButton state]]
return
}
$this isInFlatViewMode [$checkButton state]
set currentClass [$this currentOpenedClass]
if {$currentClass == ""} {
return
}
busy {
[$this superClassTL] updateView $currentClass
[$this featureTL] updateView $currentClass
[$this assocTL] updateView $currentClass
}
}
method ClassBrowser::viewFilterFeatures {this} {
if {[$this filterFeaturesDialog] == ""} {
$this filterFeaturesDialog [CBFilterFeaturesDialog \
new $this.filterFeaturesDialog]
}
$this.filterFeaturesDialog popUp
}
method ClassBrowser::optionsSortCaseSensitive {this checkButton} {
if {[catch {m4_var set M4_sort_case_sensitive [$checkButton state]}]} {
wmtkerror "Unable to set Sort Case Sensitive"
$checkButton state [expr ![$checkButton state]]
return
}
busy {
[$this superClassTL] sort
[$this classTL] sort
[$this subClassTL] sort
}
}
method ClassBrowser::optionsFont {this} {
busy {
if {![isCommand $this.fontChooser]} {
CBFontChooser new $this.fontChooser
}
}
$this.fontChooser popUp
}
method ClassBrowser::optionsPrinterSetup {this} {
[$this options] aPrinterSetup
}
method ClassBrowser::utilEditCAD {this} {
busy {
set textListEntry [$this getSelTextListEntry]
if {$textListEntry != ""} {
$textListEntry editCAD
}
}
}
method ClassBrowser::helpOnContext {this} {
set selTextList [$this selTextList]
if {$selTextList == ""} {
$this helpOnName context
return
}
set idx [expr {[string last "." $selTextList] + 1}]
set name [string range $selTextList $idx end]TL
$this helpOnName $name
}
method ClassBrowser::popUp {this} {
$this MainWindow::popUp
$this ready
}
method ClassBrowser::initView {this {reload 0}} {
busy {
# (Re)Initialize attributes
#
$this openHistory [CBClassStack new]
$this currentOpenedClass ""
$this updateWmtAreaClass ""
if {[$this model] != ""} {
[$this model] delete
}
if {[[$this ccontext] currentLevel] == "Phase"} {
$this model [CBCADPhaseModel new \
[[$this ccontext] currentConfig] \
[[$this ccontext] currentPhase]]
} else {
$this model [CBCADSystemModel new \
[[$this ccontext] currentConfig] \
[[$this ccontext] currentSystem]]
}
# Reinitialise findClassDialog and findFeatureDialog
#
if {[isCommand $this.findClassDialog]} {
$this.findClassDialog initialisedView
}
if {[isCommand $this.findFeatureDialog]} {
$this.findFeatureDialog initialisedView
}
# Do GC
#
GCControl collect
#puts "GCControl lastNrOfColl: [GCControl lastNrOfCollected]"
# (Re)Load
#
if {!$reload} {
wmtkmessage "Loading Classes ..."
} else {
wmtkmessage "Reloading Classes ..."
}
[$this model] load
[$this superClassTL] initView
[$this subClassTL] initView
[$this classTL] initView
[$this featureTL] initView
[$this assocTL] initView
$this selTextList ""
wmtkmessage ""
if {!$reload} {
$this setFileHistory
} else {
$this updateFileHistory
}
# notify the menuhandler of the selectionChange
[$this menuHandler] selectionChanged
}
}
method ClassBrowser::selTextListChanged {this newSelTextList} {
set selTextList [$this selTextList]
if {$selTextList == $newSelTextList} {
[$this menuHandler] selectionChanged
return
}
if {$selTextList != ""} {
$selTextList deselectEntries
}
$this selTextList $newSelTextList
[$this menuHandler] selectionChanged
}
method ClassBrowser::getSelTextListEntry {this} {
set selTextList [$this selTextList]
if {$selTextList == ""} {
return ""
}
return [$selTextList getSelTextListEntry]
}
# Used by Menu Customization Mechanism
#
method ClassBrowser::getSelectedSet {this} {
return [$this getSelTextListEntry]
}
method ClassBrowser::getCBClass {this nameItem} {
[[$this classTL] textListEntrySet] foreach class {
if {[$nameItem isSame [$class getNameItem]]} {
return $class
}
}
return ""
}
method ClassBrowser::getCurrentOpenedClassIndex {this} {
set currentClass [$this currentOpenedClass]
if {$currentClass == ""} {
return 0
}
set classList [[[$this classTL] textListEntrySet] contents]
set idx [lsearch -exact $classList $currentClass]
if {$idx == -1} {
return 0
}
return $idx
}
method ClassBrowser::updateClientContext {this cbClass} {
set newLevelPathIds [LevelPath new [[$this phaseLevelPathIds] asString]]
if {$cbClass != ""} {
set sysV [$cbClass getDefiningSystemVersion]
if ![$sysV isNil] {
$newLevelPathIds append [$sysV identity]
}
}
set cc [ClientContext::global]
set currentLevelPathIds [LevelPath new [$cc currentLevelIdString]]
if {[$currentLevelPathIds compare $newLevelPathIds] != 0} {
$cc setLevelIds [$newLevelPathIds asString]
[$this moduleHdlr] setCurrentContext
}
}
method ClassBrowser::addFileHistory {this cbClass} {
set index [expr [[$this exitButton] index] - 1 - \
[[$this fileHistorySet] length]]
[$this fileHistorySet] foreach entry {
if {$cbClass != [$entry cbClass]} {
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 [$cbClass name]" -mnemonic 1 -index $index \
-cbClass $cbClass -nameItem [$cbClass getNameItem] \
-hintText "Opens class [$cbClass name]." \
-activated "$cbClass open"
[$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
} elseif {[[$this fileHistorySet] length] == 1} {
CustMenuSeparator new [$this menuBar].file.menu.histsep \
-index $index
}
}
method ClassBrowser::renumberFileHistory {this} {
set m 1
[$this fileHistorySet] foreach entry {
$entry config -mnemonic $m -label "$m [[$entry cbClass] name]"
incr m
}
}
method ClassBrowser::updateFileHistory {this} {
[$this fileHistorySet] foreach entry {
set cbClass [$this getCBClass [$entry nameItem]]
if {$cbClass != ""} {
$entry config -cbClass $cbClass \
-activated "$cbClass open"
} else {
$entry delete
[$this fileHistorySet] removeValue $entry
if {[[$this fileHistorySet] length] == 0} {
[$this menuBar].file.menu.histsep delete
} else {
$this updateFileHistory
}
return
}
}
$this renumberFileHistory
}
method ClassBrowser::setFileHistory {this} {
set history [m4_var get M4_file_history -context classbrowser]
if {"$history" == ""} {
return
}
foreach itemId $history {
set cbClass [$this getCBClass [Item new $itemId]]
if {$cbClass != ""} {
$this addFileHistory $cbClass
}
}
}
method ClassBrowser::saveFileHistory {this} {
set history ""
[$this fileHistorySet] foreach entry {
set history [linsert $history 0 [[$entry nameItem] identity]]
}
if {$history != [m4_var get M4_file_history -context classbrowser]} {
m4_var set M4_file_history $history -context classbrowser
}
}
method ClassBrowser::addContextArea {this} {
$this wmtArea [CBWmtArea new $this.c.wmtArea]
}
method ClassBrowser::updateToolBar {this} {
[$this menuHandler] setCurrentContext
}
method ClassBrowser::updateWmtArea {this} {
if [isCommand [$this wmtArea]] {
[$this wmtArea] projectNm [$this projectName]
[$this wmtArea] configurationNm [$this configurationName]
[$this wmtArea] phaseNm [$this phaseName]
if {[$this systemName] != ""} {
[$this wmtArea] systemNm [$this systemName]
} else {
# Reserve some space for the 'System Version'
# and 'Class' fields
[$this wmtArea] systemNm " "
}
[$this wmtArea] classNm [$this className]
}
}
method ClassBrowser::updateTitle {this currentClass} {
set title [$this title]
set hyphen [string first "-" $title]
if {$hyphen < 0} {
append title " -"
} else {
set title [string range $title 0 $hyphen]
}
set iconTitle [$currentClass name]
append title " $iconTitle"
$this config \
-title $title \
-iconTitle $iconTitle
}
method ClassBrowser::updateWmtAreaClass {this currentClass} {
if {$currentClass == ""} {
$this systemName ""
$this className ""
} else {
set systemV [$currentClass getDefiningSystemVersion]
if {[$systemV isNil]} {
$this systemName ""
} else {
$this systemName [[$systemV system] name]
}
$this className [$currentClass name]
}
$this updateWmtArea
}
method ClassBrowser::popupCloseExit {this action} {
set closeExit [$this closeExit]
if {$closeExit == ""} {
set closeExit [CloseExitDialog new $this.closeExit]
$this closeExit $closeExit
}
$closeExit action $action
$closeExit popUp
}
method ClassBrowser::doClose {this} {
busy {
set previousClass [[$this openHistory] pop]
if {$previousClass != ""} {
$previousClass doOpen
}
}
}
method ClassBrowser::setFont {this newFont} {
[$this superClassTL] font $newFont
[$this subClassTL] font $newFont
[$this classTL] font $newFont
[$this featureTL] font $newFont
[$this assocTL] font $newFont
}
method ClassBrowser::helpOnName {this name} {
global short2url
if [catch {set url $short2url($name)}] {
wmtkerror "Sorry, no help available for '$name'"
} else {
showHelp $url
}
}
# Do not delete this line -- regeneration end marker
method ClassBrowser::classTL {this args} {
if {$args == ""} {
return [$this _classTL]
}
set ref [$this _classTL]
if {$ref != ""} {
$ref _browser ""
}
set obj [lindex $args 0]
if {$obj != ""} {
$obj _browser $this
}
$this _classTL $obj
}
method ClassBrowser::superClassTL {this args} {
if {$args == ""} {
return [$this _superClassTL]
}
set ref [$this _superClassTL]
if {$ref != ""} {
$ref _browser ""
}
set obj [lindex $args 0]
if {$obj != ""} {
$obj _browser $this
}
$this _superClassTL $obj
}
method ClassBrowser::subClassTL {this args} {
if {$args == ""} {
return [$this _subClassTL]
}
set ref [$this _subClassTL]
if {$ref != ""} {
$ref _browser ""
}
set obj [lindex $args 0]
if {$obj != ""} {
$obj _browser $this
}
$this _subClassTL $obj
}
method ClassBrowser::featureTL {this args} {
if {$args == ""} {
return [$this _featureTL]
}
set ref [$this _featureTL]
if {$ref != ""} {
$ref _browser ""
}
set obj [lindex $args 0]
if {$obj != ""} {
$obj _browser $this
}
$this _featureTL $obj
}
method ClassBrowser::assocTL {this args} {
if {$args == ""} {
return [$this _assocTL]
}
set ref [$this _assocTL]
if {$ref != ""} {
$ref _browser ""
}
set obj [lindex $args 0]
if {$obj != ""} {
$obj _browser $this
}
$this _assocTL $obj
}
method ClassBrowser::startEditCADHandler {this args} {
if {$args == ""} {
return [$this _startEditCADHandler]
}
set ref [$this _startEditCADHandler]
if {$ref != ""} {
$ref _browser ""
}
set obj [lindex $args 0]
if {$obj != ""} {
$obj _browser $this
}
$this _startEditCADHandler $obj
}