home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cadre Technologies Inc. 1996
- #
- # File: @(#)namechange.tcl /main/hindenburg/3
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)namechange.tcl /main/hindenburg/3 25 Feb 1997 Copyright 1996 Cadre Technologies Inc.
-
- # Start user added include file section
-
- global illegalCharacters
-
- set illegalCharacters(cl) {[/$:=,(){}]}
- set illegalCharacters(de) {[]/$*:=,(){}[]}
- set illegalCharacters(pe) {[]/$:=,(){}[]}
- set illegalCharacters(et) {[/:,]}
- set illegalCharacters(st) {[/,]}
- set illegalCharacters(rs) {}
- set illegalCharacters(doc) {}
- set illegalCharacters(section) {,}
- set illegalCharacters(name) {}
-
- require nameconfli.tcl
-
- # End user added include file section
-
-
- Class NameChangeDialog : {TemplateDialog} {
- constructor
- method destructor
- method popUp
- method text
- method handleTextModified
- method handleOk
- method popUpConflict
- attribute configV
- attribute keeper
- attribute item
- attribute prevText
- attribute illegalCharacters
- attribute tool
- }
-
- constructor NameChangeDialog {class this name tool} {
- set this [TemplateDialog::constructor $class $this $name]
- $this tool $tool
- # Start constructor user section
-
- interface DlgColumn $this.c {
- Label message {
- text "New Name:"
- }
- SingleLineText name {
- columnCount 30
- }
- }
- $this.c.name textModified "$this handleTextModified"
- $this config -okPressed "$this handleOk" \
- -helpPressed {.main helpOnName changeName} \
- -cancelPressed "$this delete" \
- -title "Change Name" \
- -autoPopDown 0 \
- -modal 1
-
- # End constructor user section
- return $this
- }
-
- method NameChangeDialog::destructor {this} {
- # Start destructor user section
- $this popDown
- # End destructor user section
- }
-
- method NameChangeDialog::popUp {this} {
- global illegalCharacters
- if { "[$this item]" != "" } {
- $this illegalCharacters $illegalCharacters([[$this item] type])
- } else {
- $this illegalCharacters $illegalCharacters(name)
- }
- $this TemplateDialog::popUp
- }
-
- method NameChangeDialog::text {this {newText ,}} {
- if {$newText == ","} {
- return [$this.c.name text]
- }
- $this.c.name text $newText
- $this prevText $newText
- }
-
- method NameChangeDialog::handleTextModified {this} {
- if { ("[$this illegalCharacters]" != "") && \
- [regexp [$this illegalCharacters] [$this.c.name text]] } {
- set cursorIndex [$this.c.name cursorIndex]
- $this.c.name text [$this prevText]
- $this.c.name cursorIndex [expr $cursorIndex - 1]
- } else {
- $this prevText [$this.c.name text]
- }
- }
-
- method NameChangeDialog::handleOk {this} {
- set newName [$this.c.name text]
- set configV [$this configV]
- set keeper [$this keeper]
- set oldItem [$this item]
-
- # name change for objects without item
- if { "$oldItem" == "" } {
- $this changeObjectName
- return
- }
-
- set itemType [$oldItem type]
- set itemQual [$oldItem qualifier]
- if [$itemQual isNil] {
- set newItem [$keeper findDeclaration \
- $newName $itemType $configV]
- } else {
- set newItem [$keeper findDeclaration $itemQual \
- $newName $itemType $configV]
- }
- if [$newItem isNil] {
- $this changeName 1
- return
- }
- if {[$newItem item] != $oldItem} {
- $this popUpConflict
- return
- }
- wmtkerror "Name not changed: Specified name equals original name"
- }
-
- method NameChangeDialog::popUpConflict {this} {
- set conflict [$this tool].nameConflict
- if {![isCommand $conflict]} {
- NameConflictDialog new $conflict $this
- }
- $conflict popUp
- }
-
- # Do not delete this line -- regeneration end marker
-
-