home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)custeditor.tcl /main/hindenburg/6
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)custeditor.tcl /main/hindenburg/6 11 Mar 1997 Copyright 1997 Cayenne Software Inc.
-
- # Start user added include file section
-
- require "browserpro.tcl"
- require "custedopti.tcl"
- require "custedwmta.tcl"
- require "showversio.tcl"
- require "ucsymb2url.tcl"
-
- # End user added include file section
-
- require "wmttool.tcl"
-
- Class CustEditor : {WmtTool MainWindow} {
- method destructor
- constructor
- method save
- method edit
- method doEdit
- method exit
- method doExit
- method popupNotSaved
- method selectionChanged
- method showObjectInfo
- method showRepObjInfo
- method setContext
- method getSelectedSet
- method selectedObjSet
- method helpOnContext
- method helpOnName
- method addContextArea
- method updateToolBar
- method updateWmtArea
- method initObjTypeInformation
- method getBrowsObj
- method setBrowsObj
- method removeBrowsObj
- attribute permanentReadOnly
- attribute currentlyReadOnly
- attribute object
- attribute m4VarDes
- attribute options
- attribute notSaved
- attribute editorArea
- attribute menuHdlr
- attribute wmtArea
- attribute BrowsObj
- }
-
- global CustEditor::extFileVTypes
- set CustEditor::extFileVTypes ""
-
- global CustEditor::graphTypes
- set CustEditor::graphTypes ""
-
- global CustEditor::itemTypes
- set CustEditor::itemTypes "cl de doc et pe st"
-
- global CustEditor::matrixTypes
- set CustEditor::matrixTypes ""
-
- global CustEditor::extFileTypes
- set CustEditor::extFileTypes ""
-
-
- method CustEditor::destructor {this} {
- # Start destructor user section
- [$this options] delete
- # End destructor user section
- $this WmtTool::destructor
- }
-
- constructor CustEditor {class this name} {
- set this [MainWindow::constructor $class $this $name]
- WmtTool::constructor $class $this $name
-
- $this permanentReadOnly 0
- $this currentlyReadOnly 0
- $this BrowsObj [Dictionary new]
-
- $this config -closed {%this exit}
- $this options [CustEdOptions new $this.options]
-
- MenuBar new $this.menuBar
- # creation of the 'editor area' is done in the derived classes
- $this editorArea [DlgColumn new $this.editorArea]
-
- # read phases file
- getPhases
-
- return $this
- }
-
- proc CustEditor::subTypes {repType} {
- case "$repType" in {
- {AccessRule} {
- set subTypes [CListObj::childTypes rules]
- }
- {SystemFileReference} {
- set subTypes [SysVDbObj::childTypes fileVersionReferences]
- }
- {CustomFileVersion} {
- set subTypes [CustFVUiObj::childTypes customFileVersions]
- }
- {ExternalFile} {
- set subTypes [HCustFUiObj::childTypes externalFiles]
- }
- {ExternalFileVersion} {
- set subTypes "${CustEditor::extFileVTypes}"
- }
- {ExternalLink} {
- set subTypes [SysVDbObj::childTypes externalLinks]
- }
- {Graph} {
- set subTypes "${CustEditor::graphTypes}"
- }
- {Matrix} {
- set subTypes "${CustEditor::matrixTypes}"
- }
- {PhaseVersion} {
- set subTypes [ConfVDbObj::childTypes phaseVersions]
- }
- {SystemVersion} {
- set subTypes [PhaseVDbObj::childTypes systemVersions]
- }
- {UserRoleLink} {
- set subTypes [concat \
- [RoleDbObj::childTypes userLinks] \
- [UsrDbObj::childTypes roleLinks] \
- ]
- }
- {WorkItem} {
- set subTypes "${CustEditor::itemTypes}"
- }
- {default} {
- set subTypes ""
- }
- }
- return $subTypes
- }
-
- method CustEditor::save {this} {
-
- $this busy TRUE
- wmtkmessage "Saving..."
- if [catch {
- [$this editorArea] save
- wmtkmessage "Done"
- } msg ] {
- wmtkerror $msg
- wmtkmessage "Not done"
- }
- $this busy FALSE
- }
-
- method CustEditor::edit {this obj} {
-
- if [[$this editorArea] isChanged] {
- $this popupNotSaved "$this doEdit $obj"
- } else {
- $this doEdit $obj
- }
- }
-
- method CustEditor::doEdit {this obj} {
-
- $this busy TRUE
- [$this editorArea] clearArea
- if {[[$this editorArea] _repObj] == $obj} {
- wmtkmessage "Reloading ..."
- } else {
- wmtkmessage "Loading ..."
- }
- if [$this permanentReadOnly] {
- if [catch {[$this editorArea] load $obj} msg] {
- wmtkerror $msg
- wmtkmessage "Not done"
- } else {
- wmtkmessage "Loaded read-only"
- $this object $obj
- $this showRepObjInfo
- }
- $this busy FALSE
- $this currentlyReadOnly 1
- # force an update of the menu entry enable status
- [$this menuHdlr] levelChanged
- [$this menuHdlr] selectionChanged
- return
- }
- if [catch {[$this editorArea] edit $obj} msg] {
- # Edit failed, try load
- if [catch {[$this editorArea] load $obj} loadMsg] {
- wmtkerror "Edit failed:\n${msg}\nLoad failed:\n$loadMsg"
- wmtkmessage "Not done"
- $this busy FALSE
- return
- } else {
- wmtkmessage "Loaded read-only"
- wmtkwarning $msg
- }
- $this currentlyReadOnly 1
- # force an update of the menu's (enable/disable)
- [$this menuHdlr] levelChanged
- [$this menuHdlr] selectionChanged
- } else {
- wmtkmessage Done
- $this currentlyReadOnly 0
- # force an update of the menu's (enable/disable)
- [$this menuHdlr] levelChanged
- [$this menuHdlr] selectionChanged
- }
- $this object $obj
- $this showRepObjInfo
- $this busy FALSE
- }
-
- method CustEditor::exit {this} {
-
- if [[$this editorArea] isChanged] {
- $this popupNotSaved "$this doExit"
- } else {
- $this doExit
- }
- }
-
- method CustEditor::doExit {this} {
-
- $this busy TRUE
- wmtkmessage "Exiting ..."
- catch {[$this editorArea] quit}
- $this delete
- GCControl collect
- exit
- }
-
- method CustEditor::popupNotSaved {this action} {
-
- set notSaved [$this notSaved]
- if {$notSaved == ""} {
- require "notsaveddi.tcl"
- set notSaved [NotSavedDialog new $this.notSaved -editor $this]
- $notSaved infoKind "Customization File"
- $this notSaved $notSaved
- }
- $notSaved action $action
- $notSaved popUp
- }
-
- method CustEditor::selectionChanged {this} {
-
- [$this menuHdlr] selectionChanged
- wmtkmessage ""
- }
-
- method CustEditor::showObjectInfo {this obj} {
-
- global classCount
- set box .main.showObjectInfo$classCount
- incr classCount
- interface TemplateDialog $box {
- title "Info"
- DlgColumn col {}
- okPressed {%this delete}
- }
- $box modal $win95
- $box delCancelButton
- $box delHelpButton
-
- set infoList [$obj infoList]
- set len [llength $infoList]
- for {set i 0} {$i < $len} {incr i 2} {
- DlgRow new $box.col.row$i \
- -spaceType NONE \
- -justification RIGHT
- Label new $box.col.row$i.header \
- -text "[lindex $infoList $i]:" \
- -alignment RIGHT \
- -horStretchFactor 10 \
- -justification TOP \
- -font "courier-bold-12"
- DlgColumn new $box.col.row$i.col
- set breakUpCnt 0
- foreach part [lineBreak [lindex $infoList [expr $i+1]] 31 " "] {
- set text [format "%-31s" $part]
- Label new $box.col.row$i.col.label$breakUpCnt \
- -text $text \
- -font "courier-normal-12"
- incr breakUpCnt
- }
- }
-
- $box popUp
- }
-
- method CustEditor::showRepObjInfo {this} {
-
- if {"[$this wmtArea]" == ""} {
- return
- }
-
- # the object is possible a user file
- if [isCommand [$this object]] {
- set name [[[$this object] customFile] name]
- set version [[$this object] versionNumber]
- [$this wmtArea] file "$name (V$version)"
- } else {
- [$this wmtArea] file "[$this object] (-)"
- }
- }
-
- method CustEditor::setContext {this} {
-
- [$this editorArea] setContext
-
- if {"[$this wmtArea]" == ""} {
- return
- }
-
- set clientContext [ClientContext::global]
-
- set project [$clientContext currentProject]
- if [$project isNil] return
- [$this wmtArea] project [$project name]
- set configV [$clientContext currentConfig]
- if [$configV isNil] return
- [$this wmtArea] configuration \
- "[[$configV ConfigVersion::config] name] (V[$configV versionName])"
- set phaseV [$clientContext currentPhase]
- if [$phaseV isNil] return
- [$this wmtArea] phase [[$phaseV phase] name]
- set systemV [$clientContext currentSystem]
- if [$systemV isNil] return
- [$this wmtArea] system [[$systemV system] name]
- }
-
- method CustEditor::getSelectedSet {this} {
-
- if {![[$this editorArea] isA BrowsView]} {
- return ""
- }
-
- return [[$this editorArea] selectedSet]
- }
-
- method CustEditor::selectedObjSet {this} {
-
- return [$this getSelectedSet]
- }
-
- method CustEditor::helpOnContext {this} {
-
- showHelp {CMZ/tl_cmz.html}
- }
-
- method CustEditor::helpOnName {this name} {
-
- global short2url
- if [catch {set url $short2url($name)}] {
- wmtkerror "Sorry, no help available for '$name'"
- } else {
- showHelp $url
- }
- }
-
- method CustEditor::addContextArea {this} {
- $this wmtArea [CustEdWmtArea new $this.editorArea.wmtarea]
- }
-
- method CustEditor::updateToolBar {this} {
- [$this menuHdlr] setCurrentContext
- }
-
- method CustEditor::updateWmtArea {this} {
- $this setContext
- $this showRepObjInfo
- }
-
- method CustEditor::initObjTypeInformation {this} {
-
- require "browserobj.tcl"
-
- # Initialize table for conversion from RepositoryObject to BrowsUiObj
- initRepObj2UiObjTable BrowsObj
-
- # retrieve the possible file-types from objectHdlr
- global CustEditor::extFileVTypes
- global CustEditor::graphTypes
- global CustEditor::matrixTypes
- global CustEditor::extFileTypes
- set objectHdlr [CustObjHandler new]
- $objectHdlr setCurrentContext
- foreach objectSpec [$objectHdlr getCurrentObjectSpecSet] {
- set browserType [$objectSpec browserType]
- if {"$browserType" == ""} continue
- case [$objectSpec repositoryType] in {
- {ExternalFileVersion} {
- lappend CustEditor::extFileVTypes $browserType
- }
- {Graph} {
- lappend CustEditor::graphTypes $browserType
- }
- {Matrix} {
- lappend CustEditor::matrixTypes $browserType
- }
- {ExternalLink} {
- lappend CustEditor::extFileTypes $browserType
- }
- }
- }
- global BrowserProcs::externalFileTypes
- set BrowserProcs::externalFileTypes ${CustEditor::extFileTypes}
- global BrowserProcs::diagramFileTypes
- set BrowserProcs::diagramFileTypes [concat \
- ${CustEditor::graphTypes} \
- ${CustEditor::matrixTypes} \
- ]
- global BrowserProcs::programmerFileTypes
- set BrowserProcs::programmerFileTypes ${CustEditor::extFileVTypes}
- global BrowserProcs::itemTypes
- set BrowserProcs::itemTypes ${CustEditor::itemTypes}
- $objectHdlr delete
- }
-
- # Do not delete this line -- regeneration end marker
-
- method CustEditor::getBrowsObj {this name} {
- return [[$this BrowsObj] set $name]
- }
-
- method CustEditor::setBrowsObj {this name newBrowsObj} {
- [$this BrowsObj] set $name $newBrowsObj
- }
-
- method CustEditor::removeBrowsObj {this name} {
- [$this BrowsObj] unset $name
- }
-
-