home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1996
- #
- # File: @(#)ctrlpnldia.tcl /main/hindenburg/4
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)ctrlpnldia.tcl /main/hindenburg/4 8 Nov 1996 Copyright 1996 Cayenne Software Inc.
-
- # Start user added include file section
- require "ctrlpnlvie.tcl"
- require "custfileut.tcl"
- # End user added include file section
-
-
- Class CtrlPnlDialog : {TemplateDialog} {
- constructor
- method destructor
- method newableObjectList
- method newObjects
- method addObjects
- method removeObjects
- method showResult
- method popUp
- method quit
- method save
- method registerObject
- method getSpec
- method checkButtons
- attribute cadEntries
- attribute stdEntries
- attribute dfdEntries
- attribute etdEntries
- attribute mgdEntries
- attribute ccdEntries
- attribute ucdEntries
- attribute lvlObj
- attribute fileName
- attribute fileType
- attribute editable
- attribute number
- attribute _view
- }
-
- constructor CtrlPnlDialog {class this name} {
- set this [TemplateDialog::constructor $class $this $name]
- # Start constructor user section
-
- $this cadEntries {cad_class link_attr_box cad_container nary_assoc
- Vertex more_classes association aggregation
- qualif_assoc qualif_aggr nary_assoc_conn constraint
- generalization_conn overlap_gen_conn loop propagation
- Select}
-
- $this stdEntries {state super_state start_state final_state std_class
- Vertex transition event_msg Select}
-
- $this dfdEntries {data_proc data_store dfd_actor dfd_anchor Vertex
- data_flow result_flow ctrl_flow update_flow Select}
-
- $this etdEntries {etd_initiator etd_object Vertex etd_event Select}
-
- $this mgdEntries {message_def Vertex message_gen_conn Select}
-
- $this ccdEntries {ccd_class ccd_class_ref ccd_container ccd_actor
- subject Vertex com_message Select}
-
- $this ucdEntries {use_case ucd_actor Vertex
- und_com_assoc dir_com_assoc use_case_gen Select}
-
- ClassMaker::extend BrowsObject CtrlPnlObj {index id}
-
- global classCount
- incr classCount
- $this number $classCount
-
- $this config \
- -cancelPressed { %this quit } \
- -okPressed { %this save } \
- -helpPressed {.main helpOnName ctrlPnlDialog }
-
- interface DlgColumn $this.top {
- DlgRow menu {
- verStretchFactor 0
- verShrinkFactor 0
- horStretchFactor 0
- verStretchFactor 0
- PushButton new {
- label New...
- }
- PushButton test {
- label Test...
- }
- PushButton delete {
- label Delete
- }
- }
- Label contentsLab {
- text "Contents:"
- alignment CENTER
- }
- CtrlPnlView view {
- rowCount 10
- mode DETAIL
- BrowsHeader header0 {
- label Name
- width 20
- }
- }
- HorRadioGroup colCountHRG {
- entrySet {"one column" "two columns" "three columns"}
- justification CENTER
- }
- }
-
- $this.top.menu.new activated [list $this newObjects]
- $this.top.menu.test activated [list $this showResult]
- $this.top.menu.delete activated [list $this removeObjects]
-
- $this _view $this.top.view
- $this modal Yes
-
- $this.top.view selectionChanged "$this checkButtons"
-
- # End constructor user section
- return $this
- }
-
- method CtrlPnlDialog::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method CtrlPnlDialog::newableObjectList {this} {
-
- set allEntries [$this [$this fileName]Entries]
- set newEntries $allEntries
-
- foreach obj [[$this _view] objectSet] {
- set name [$obj label]
- set idx [lsearch -exact $newEntries $name]
- if {$idx != -1} {
- # does already exist so it can not be newed
- set newEntries [lreplace $newEntries $idx $idx]
- }
- }
- return $newEntries
- }
-
- method CtrlPnlDialog::newObjects {this} {
-
- set newEntries [$this newableObjectList]
-
- set box .main.panelListDialog[$this number]
- if {! [isCommand $box]} {
- ListDialog new $box \
- -modal Yes \
- -title "New Panel Entry" \
- -selectionPolicy EXTENDED \
- -rowCount 12 \
- -okPressed "$this addObjects \[%this selectedSet\]"
- }
- $box entrySet $newEntries
- $box popUp
- }
-
- method CtrlPnlDialog::addObjects {this names} {
-
- foreach name $names {
- set object [$this _view].object$name
- CtrlPnlObj new $object \
- -smallIcon $name \
- -largeIcon $name \
- -label $name \
- -selectState 0 \
- -id $object
- if [$this editable] {
- $object conversionSet "CONTROLPANELENTRY id"
- }
- }
- [$this _view] reIndex
- $this checkButtons
- }
-
- method CtrlPnlDialog::removeObjects {this} {
-
- foreach obj [[$this _view] selectedSet] {
- $obj delete
- }
- [$this _view] reIndex
- $this checkButtons
- }
-
- method CtrlPnlDialog::showResult {this} {
-
- if [isCommand .main.showPanel[$this number]] {
- .main.showPanel[$this number] popDown
- .main.showPanel[$this number] delete
- }
-
- interface TemplateDialog .main.showPanel[$this number] {
- modal Yes
- DlgColumn DC {
- VerControlPanel VCP {
- }
- }
- }
- .main.showPanel[$this number] delHelpButton
- .main.showPanel[$this number] delCancelButton
-
- set spec [$this getSpec]
- .main.showPanel[$this number].DC.VCP config \
- -entrySet [lindex $spec 0] \
- -columnCount [lindex $spec 1]
- .main.showPanel[$this number] config \
- -title [$this title] \
- -okPressed {%this delete}
- .main.showPanel[$this number] popUp
- }
-
- method CtrlPnlDialog::popUp {this} {
- eval "proc registerObject {spec} {$this registerObject \$spec}"
- CustFileUtilities::read [$this lvlObj] [$this fileName] [$this fileType]
-
- $this title "'[string toupper [$this fileName]]' Control Panel"
- $this TemplateDialog::popUp
-
- $this.top.menu.new sensitive [$this editable]
- $this.top.menu.delete sensitive [$this editable]
- $this.top.colCountHRG sensitive [$this editable]
-
- if {"[$this lvlObj]" == ""} return
- if [[$this lvlObj] isA Corporate] return
-
- set custFV [[$this lvlObj] findCustomFileVersion \
- [$this fileName] [$this fileType]]
- if [$custFV isNil] return
-
- if [$this editable] {
- if [catch {$custFV edit} msg] {
- wmtkerror $msg
- $this.top.menu.new sensitive 0
- $this.top.menu.delete sensitive 0
- $this.top.colCountHRG sensitive 0
- }
- }
-
- $this checkButtons
- }
-
- method CtrlPnlDialog::quit {this} {
-
- if {"[$this lvlObj]" == ""} return
- if [[$this lvlObj] isA Corporate] return
-
- set custFV [[$this lvlObj] findCustomFileVersion \
- [$this fileName] [$this fileType]]
- if [$custFV isNil] return
-
- if [$this editable] {
- $custFV quit
- }
- }
-
- method CtrlPnlDialog::save {this} {
-
- if {![$this editable]} {
- return
- }
-
- set tmpFile [args_file {}]
- set fid [open $tmpFile w]
-
- set spec [$this getSpec]
- set objSpec "entrySet \"[lindex $spec 0]\""
- set objSpec "$objSpec columnCount \"[lindex $spec 1]\""
- puts $fid "registerObject \{$objSpec\}"
- close $fid
- CustFileUtilities::save $tmpFile \
- [$this lvlObj] [$this fileName] [$this fileType]
- unlink $tmpFile
-
- $this quit
- }
-
- method CtrlPnlDialog::registerObject {this objSpec} {
-
- while {![lempty $objSpec]} {
- set key [lvarpop objSpec]
- set value [lvarpop objSpec]
-
- if {$key == "entrySet"} {
- $this addObjects $value
- }
-
- if {$key == "columnCount"} {
- if {$value == 1} {
- $this.top.colCountHRG selected "one column"
- } elseif {$value == 2} {
- $this.top.colCountHRG selected "two columns"
- } elseif {$value == 3} {
- $this.top.colCountHRG selected "three columns"
- }
- }
- }
- }
-
- method CtrlPnlDialog::getSpec {this} {
-
- set entrySet {}
- set columnCount 1
-
- foreach obj [[$this _view] objectSet] {
- set entrySet "$entrySet [$obj label]"
- }
-
-
- set selected [$this.top.colCountHRG selected]
- if {$selected == "two columns"} {
- set columnCount 2
- } elseif {$selected == "three columns"} {
- set columnCount 3
- }
-
- return [list $entrySet $columnCount]
- }
-
- method CtrlPnlDialog::checkButtons {this} {
-
- if ![$this editable] {
- # disabled stays disabled
- return
- }
-
- if [lempty [[$this _view] selectedSet]] {
- $this.top.menu.delete sensitive 0
- } else {
- $this.top.menu.delete sensitive 1
- }
-
-
- if [lempty [$this newableObjectList]] {
- $this.top.menu.new sensitive 0
- } else {
- $this.top.menu.new sensitive 1
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
-