home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)groupdefin.tcl /main/titanic/3
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)groupdefin.tcl /main/titanic/3 14 Nov 1997 Copyright 1997 Cayenne Software Inc.
-
- # Start user added include file section
- require "gdrfilesel.tcl"
- require "gdritemsel.tcl"
- require "gdrfile.tcl"
- # End user added include file section
-
- require "groupdialo.tcl"
-
- Class GroupDefinitionFileDialog : {GroupDialog} {
- method destructor
- constructor
- method handleDelete
- method handleApplyNow
- method modeChanged
- method showFileSelectors
- method showItemSelectors
- method popUp
- attribute fileName
- }
-
- method GroupDefinitionFileDialog::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this GroupDialog::destructor
- }
-
- constructor GroupDefinitionFileDialog {class this name file} {
- set this [GroupDialog::constructor $class $this $name]
-
- $this groupV [GDRFile new $file]
-
- # adjust group structure interface for gdr files
- $this.top.menu.delete label Delete
- $this.top.menu.show delete
-
- # add description part
- Label new $this.top.descLabel -text "Description:"
- SingleLineText new $this.top.description
-
- set view $this.top.view
- $view columnCount 80
-
- # delete action
- $this.top.menu.delete sensitive 0
- $view selectionChanged {
- if { ([llength [%this selectedSet]] > 0) \
- && [[[%this parent] parent] editable] } {
- [%this parent].menu.delete sensitive 1
- } else {
- [%this parent].menu.delete sensitive 0
- }
- }
- $this.top.menu.delete activated "$this handleDelete"
-
- # extra customization buttons
- PushButton new $this.applynow \
- -label "Apply Now" \
- -activated "$this handleApplyNow"
-
- PushButton new $this.cancel \
- -label "Cancel" \
- -activated "$this popDown; $this delete"
-
- $this okPressed {
- if [%this editable] {
- [%this groupV] description [%this.top.description text]
- [%this groupV] write
- }
- %this delete
- }
-
- return $this
- }
-
- method GroupDefinitionFileDialog::handleDelete {this} {
- set selectedSet [$this.top.view selectedSet]
- foreach object $selectedSet {
- # find related selector object
- regsub {.*\.} $object "" selector
- $selector file ""
- }
-
- $this modeChanged
- }
-
- method GroupDefinitionFileDialog::handleApplyNow {this} {
- if { ![$this editable] } {
- return
- }
-
- set gdrFile [$this groupV]
- $gdrFile description [$this.top.description text]
- $gdrFile write
- }
-
- method GroupDefinitionFileDialog::modeChanged {this {forceFlag 1}} {
- set currentMode [$this.top.mode.optmenu selected]
- $this currentMode $currentMode
-
- set contentsLabel $this.top.contentsLab
- case $currentMode in {
- {"item selector"} {
- $contentsLabel text "Item Selectors:"
- $this showItemSelectors
- }
- {"file selector"} {
- $contentsLabel text "File Selectors:"
- $this showFileSelectors
- }
- }
- }
-
- method GroupDefinitionFileDialog::showFileSelectors {this} {
- set view $this.top.view
- foreach header [$view headerSet] {
- $header delete
- }
- foreach object [$view objectSet] {
- $object delete
- }
-
- BrowsHeader new $view.h1 -label "Item Type" -width 12
- BrowsHeader new $view.h2 -label "Decomposition Flags" -width 31
- BrowsHeader new $view.h3 -label "File Types" -width 37
-
- [[$this groupV] fileSelectorSet] foreach fileSelector {
- set details [list [$fileSelector decompFlags]]
- lappend details [$fileSelector fileTypes]
- BrowsObject new $view.$fileSelector \
- -label [$fileSelector itemType] \
- -details $details
-
- }
-
- # Sort the view
- set sortSpec "\
- -column {$this.top.view.h1 ascii increasing} \
- -column {$this.top.view.h2 ascii increasing} \
- -column {$this.top.view.h3 ascii increasing}"
- eval $view sort $sortSpec
- }
-
- method GroupDefinitionFileDialog::showItemSelectors {this} {
- set view $this.top.view
- foreach header [$view headerSet] {
- $header delete
- }
- foreach object [$view objectSet] {
- $object delete
- }
-
- BrowsHeader new $view.h1 -label "File Type" -width 12
- BrowsHeader new $view.h2 -label "Item Type" -width 12
- BrowsHeader new $view.h3 -label "Qualified" -width 12
-
- [[$this groupV] itemSelectorSet] foreach itemSelector {
- set details [list [$itemSelector itemType]]
- lappend details [$itemSelector qualified]
- BrowsObject new $view.$itemSelector \
- -label [$itemSelector fileType] \
- -details $details
-
- }
-
- # Sort the view
- set sortSpec "\
- -column {$this.top.view.h1 ascii increasing} \
- -column {$this.top.view.h2 ascii increasing} \
- -column {$this.top.view.h3 ascii increasing}"
- eval $view sort $sortSpec
- }
-
- method GroupDefinitionFileDialog::popUp {this} {
- if {[$this editable] && [catch {[$this groupV] edit} errorMsg]} {
- if [info exists errorInfo] {
- set errorTrace $errorInfo
- set errorCodeCopy $errorCode
- } else {
- set errorTrace ""
- set errorCodeCopy ""
- }
- $this editable 0
- } else {
- set errorMsg ""
- }
-
- $this.top.mode.optmenu entrySet \
- { "file selector" "item selector"}
-
- $this title "Edit [$this fileName]"
-
- # disable buttons if not editable
- if { ![$this editable] } {
- $this.top.menu.delete sensitive 0
- $this.top.menu.new sensitive 0
- $this.applynow sensitive 0
- $this.top.description sensitive 0
- }
-
- # read file and show contents
- [$this groupV] read
- $this modeChanged
- $this.top.description text [[$this groupV] description]
-
- $this TemplateDialog::popUp
-
- if {"$errorMsg" != ""} {
- global errorInfo errorCode
- set errorInfo $errorTrace
- set errorCode $errorCodeCopy
- wmtkerror $errorMsg
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
-