home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)objnamecha.tcl /main/hindenburg/4
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)objnamecha.tcl /main/hindenburg/4 25 Feb 1997 Copyright 1997 Cayenne Software Inc.
-
- # Start user added include file section
- # End user added include file section
-
- require "namechange.tcl"
-
- Class ObjNameChangeDialog : {NameChangeDialog} {
- constructor
- method destructor
- method popUp
- method changeName
- method changeObjectName
- method updateObjectPath
- }
-
- constructor ObjNameChangeDialog {class this name tool} {
- set this [NameChangeDialog::constructor $class $this $name $tool]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method ObjNameChangeDialog::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this NameChangeDialog::destructor
- }
-
- method ObjNameChangeDialog::popUp {this} {
- set selectedObj [lindex [[$this tool] selectedObjSet] 0]
- if { "[$this item]" == "" } {
- $this text [$selectedObj name]
- } else {
- $this text [[$this item] name]
- }
- $this NameChangeDialog::popUp
- }
-
-
- # Item name change.
- #
- method ObjNameChangeDialog::changeName {this useOld} {
- set keeper [$this keeper]
- set configV [$this configV]
- set newName [$this text]
- set oldName [[$this item] name]
-
- # Store info about the selected object
- # which will possibly be deselected by the ItemKeeper
- set selectedObj [lindex [[$this tool] selectedObjSet] 0]
- if [$selectedObj isA SystemVersion] {
- set parentObj [$selectedObj getParent PhaseVersion]
- set objType [[$selectedObj system] type]
- set level system
- } elseif [$selectedObj isA FileVersion] {
- set phaseObj [$selectedObj getParent PhaseVersion]
- set parentObj [$selectedObj getParent SystemVersion]
- set objType [[$selectedObj file] type]
- set sysType [[$parentObj system] type]
- set level file
- } else {
- set level other
- }
-
- # Do the actual name change
- $keeper renameRefs [$this item] $newName $useOld $configV
-
- # Retrieve the name-changed object
- # which is possibly just created by the ItemKeeper
- set closeFlag 0
- case $level in {
- {system} {
- set newObj [$parentObj findSystemVersion "$newName" "$objType"]
- }
- {file} {
- if [catch {set newObj \
- [$parentObj findFileVersion "$newName" "$objType"]}] {
- set parentObj \
- [$phaseObj findSystemVersion "$newName" "$sysType"]
- set newObj \
- [$parentObj findFileVersion "$newName" "$objType"]
- set closeFlag 1
- global errorInfo
- set errorInfo ""
- global errorCode
- set errorCode ""
- }
- }
- {default} {
- set newObj [ORB::nil]
- }
- }
-
- $this updateObjectPath $oldName $newObj
-
- # Close the current view if the parent is deselected
- if $closeFlag {
- wmtkmessage "Deselected [$parentObj browserType] '$oldName':\
- Closing View ..."
- [[[$this tool] currentObj] parent] open
- wmtkmessage "Done"
- }
-
- [$this tool] updateView
- $this delete
- }
-
-
- # Rename an object.
- #
- method ObjNameChangeDialog::changeObjectName {this} {
- set newName [$this text]
- set selectedObj [lindex [[$this tool] selectedObjSet] 0]
- set oldName [$selectedObj name]
-
- # do the rename
- set renameObject $selectedObj
- # for configversions the config must be renamed
- if [$renameObject isA ConfigVersion] {
- set renameObject [$selectedObj ConfigVersion::config]
- }
- $renameObject name $newName
-
- $this updateObjectPath $oldName $selectedObj
- [$this tool] updateView
- wmtkmessage ""
- $this delete
- }
-
-
- # Update the user environment path for this object
- # if it is not an ExternalLink.
- #
- method ObjNameChangeDialog::updateObjectPath {this oldName newObj} {
- # If the fileSystemPath property of the name-changed object
- # contains the old name then replace it by the new name
- if {! [$newObj isNil]} {
- if [$newObj isA ExternalLink] {
- return
- }
- set newName [$newObj name]
- set property [$newObj findProperty fileSystemPath]
- if {! [$property isNil]} {
- set oldValue [$property value]
- set id [string first "$oldName" "$oldValue"]
- if {$id >= 0} {
- set newValue "$newName[string range \
- $oldValue [expr $id + [string length $oldName]] end]"
- set oldPath [$newObj path]
- $property change "$newValue"
- set newPath [$newObj path]
- if [file exists $oldPath] {
- if [file isdirectory $oldPath] {
- BasicFS::renameDir $oldPath $newPath
- } else {
- BasicFS::renameFile $oldPath $newPath
- }
- }
- }
- }
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
-