home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cadre Technologies Inc. 1996
- #
- # File: @(#)propertydi.tcl /main/3
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)propertydi.tcl /main/3 26 Jun 1996 Copyright 1996 Cadre Technologies Inc.
-
- # Start user added include file section
-
- require propcontif.tcl
-
- # End user added include file section
-
-
- Class PropertyDialog : {TemplateDialog} {
- constructor
- method destructor
- method popUp
- method handleOk
- method handleDefine
- method handleCancel
- method selectionChanged
- method fillInterface
- method addContainer
- method removeContainer
- method holderDialog
- method getEditStatus
- method setEditStatus
- method removeEditStatus
- attribute editable
- attribute tool
- attribute currentContainer
- attribute containerSet
- attribute _holderDialog
- attribute editStatus
- }
-
- constructor PropertyDialog {class this name tool} {
- set this [TemplateDialog::constructor $class $this $name]
- $this editable 1
- $this tool $tool
- $this containerSet [List new]
- $this editStatus [Dictionary new]
- # Start constructor user section
-
- $this config \
- -modal yes \
- -title Properties \
- -okPressed {%this handleOk} \
- -cancelPressed {%this handleCancel}
- DlgRow new $this.r
- TextList new $this.r.list \
- -selectionChanged "$this selectionChanged" \
- -selectionPolicy BROWSE \
- -font "courier-normal-12" \
- -rowCount 10
- OneOf new $this.r.oneOf -horShrinkFactor 10 -horStretchFactor 10
- Label new $this.r.oneOf.startPage -text Properties
- PushButton new $this.define -label "Define Item" \
- -activated "$this handleDefine" -sensitive 0
-
- # End constructor user section
- return $this
- }
-
- method PropertyDialog::destructor {this} {
- set ref [$this _holderDialog]
- if {$ref != ""} {
- $ref _dialog ""
- }
- # Start destructor user section
- [$this tool] releasePropContainers
- PropContIf::clearInterfaces
- # End destructor user section
- }
-
- method PropertyDialog::popUp {this} {
- set contents ""
- set cntSet [[$this tool] propContainerSet]
- [$this containerSet] contents [$cntSet contents]
- $cntSet foreach cnt {
- PropContIf::createInterface $this.r.oneOf $cnt
- lappend contents [$cnt propertyPresentation]
- }
- $this.r.list entrySet $contents
- $this.r.oneOf currentOne 0
- $this config -currentContainer "" -editStatus [Dictionary new]
- $this TemplateDialog::popUp
- }
-
- method PropertyDialog::handleOk {this} {
- set cnt [$this currentContainer]
- if {$cnt != "" && [$this editable]} {
- [$cnt propInterface] setProperties $cnt
- }
- [$this containerSet] foreach cnt {
- if {[$this getEditStatus $cnt] == "editProperties"} {
- $cnt saveProperties
- }
- $cnt quitProperties
- }
- $this delete
- }
-
- method PropertyDialog::handleDefine {this} {
- set cnt [$this currentContainer]
- $this setEditStatus $cnt ""
- $cnt createPropertyHolder
- $this selectionChanged
- }
-
- method PropertyDialog::handleCancel {this} {
- [$this containerSet] foreach cnt {
- $cnt quitProperties
- }
- $this delete
- }
-
- method PropertyDialog::selectionChanged {this} {
- set cnt [$this currentContainer]
- if {$cnt != "" && [$this editable]} {
- [$cnt propInterface] setProperties $cnt
- }
- set index [lindex [$this.r.list selectedIndexSet] 0]
- set cnt [[$this containerSet] index $index]
- $this currentContainer $cnt
- $this.define sensitive \
- [expr ![$cnt existPropertyHolder] && [$this editable]]
- if [$this editable] {
- set method editProperties
- } else {
- set method loadProperties
- }
- $this fillInterface $cnt $method
- }
-
- method PropertyDialog::fillInterface {this cnt method} {
- set status [$this getEditStatus $cnt]
- if {$status == ""} {
- if [catch {$cnt $method} msg] {
- wmtkerror $msg
- if {$method == "loadProperties"} {
- $this.r.oneOf currentOne 0
- return
- }
- # Edit failed, try load.
- if [catch {$cnt loadProperties} msg] {
- wmtkerror $msg
- $this.r.oneOf currentOne 0
- return
- }
- wmtkmessage "Showing properties"
- set method loadProperties
- $cnt editable 0
- }
- $this setEditStatus $cnt $method
- set status $method
- }
- if {$status == "editProperties"} {
- $this title "Edit Properties"
- } else {
- $this title "Show Properties"
- }
- set if [$cnt propInterface]
- $if getProperties $cnt
- $this.r.oneOf currentOne [$if index]
- }
-
- # Do not delete this line -- regeneration end marker
-
- method PropertyDialog::addContainer {this newContainer} {
- [$this containerSet] append $newContainer
-
- }
-
- method PropertyDialog::removeContainer {this oldContainer} {
- [$this containerSet] removeValue $oldContainer
- }
-
- method PropertyDialog::holderDialog {this args} {
- if {$args == ""} {
- return [$this _holderDialog]
- }
- set ref [$this _holderDialog]
- if {$ref != ""} {
- $ref _dialog ""
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- $obj _dialog $this
- }
- $this _holderDialog $obj
- }
-
- method PropertyDialog::getEditStatus {this container} {
- return [[$this editStatus] set $container]
- }
-
- method PropertyDialog::setEditStatus {this container newEditStatus} {
- [$this editStatus] set $container $newEditStatus
- }
-
- method PropertyDialog::removeEditStatus {this container} {
- [$this editStatus] unset $container
- }
-
-