home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
vsobjnamec.tcl
< prev
next >
Wrap
Text File
|
1997-06-06
|
11KB
|
394 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)vsobjnamec.tcl /main/hindenburg/7
# Author: <generated>
# Description: VCM integration file
#---------------------------------------------------------------------------
# SccsId = @(#)vsobjnamec.tcl /main/hindenburg/7 6 Jun 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
require "objnamecha.tcl"
# Redefinition of ObjNameChangeDialog
# to add rename functionality in VCM
# system.
Class VSObjNameChangeDialog : {ObjNameChangeDialog} {
constructor
method destructor
method changeName
method changeObjectName
method isPathError
method getParent
method updateObjectPath
method updateVSFilePath
method updateFileSystemPath
method getOldPath
method readPathCustomization
method renameDirectoryWithConfirm
method initialize
# Set by subclass: CCSystem, RazorSystem or
# ContSystem. Used to access static methods
# of these classes.
#
attribute vsSystem
}
constructor VSObjNameChangeDialog {class this name tool} {
set this [ObjNameChangeDialog::constructor $class $this $name $tool]
# Start constructor user section
# End constructor user section
return $this
}
method VSObjNameChangeDialog::destructor {this} {
# Start destructor user section
# End destructor user section
$this ObjNameChangeDialog::destructor
}
method VSObjNameChangeDialog::initialize {this newObj} {
# sport7: check integration type of object and promote if necessary
# call upper level if no VCM integration is installed here
set project $newObj
if { ![$newObj isA Project] } {
set project [[ClientContext::global] currentProject]
}
set vcmIntegration [$project getPropertyValue vcmIntegration]
if { ($vcmIntegration == "") || ($vcmIntegration == "razor") } {
return 0
}
set cc [ClientContext::global]
set level [$cc currentLevel]
if { ($level == "System") || ($level == "Phase") } {
set phase [[[$cc currentPhase] phase] type]
if { $phase != "Implementation" } {
return 0
}
}
case $vcmIntegration in {
{cc} {
CCObjNameChangeDialog promote $this
}
{cont} {
ContObjNameChangeDialog promote $this
}
}
return 1
}
# Redefinition that catches path name errors
# in the repository.
#
method VSObjNameChangeDialog::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 { ![$this initialize $selectedObj] } {
$this ObjNameChangeDialog::changeName $useOld
return
}
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
if [ catch { $keeper renameRefs [$this item] $newName $useOld $configV } message] {
if { ![$this isPathError $message] } {
error $message
}
}
# 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
}
# Redefinition that catches path name errors
# in the repository.
#
method VSObjNameChangeDialog::changeObjectName {this} {
set newName [$this text]
set selectedObj [lindex [[$this tool] selectedObjSet] 0]
set oldName [$selectedObj name]
if { ![$this initialize $selectedObj] } {
$this ObjNameChangeDialog::changeObjectName
return
}
# do the rename
set renameObject $selectedObj
# for configversions the config must be renamed
if [$renameObject isA ConfigVersion] {
set renameObject [$selectedObj ConfigVersion::config]
}
if [catch { $renameObject name $newName } message] {
if { ![$this isPathError $message] } {
error $message
}
}
$this updateObjectPath $oldName $selectedObj
[$this tool] updateView
wmtkmessage ""
$this delete
}
# Return whether given error message is a
# path error or not. Path error: some error
# that occurred during change name because
# a directory could not be moved.
#
method VSObjNameChangeDialog::isPathError {this message} {
return [regexp {able to rename directory} $message]
}
# Return parent object of object in which object is
# a SystemVersion, ConfigVersion or Project.
#
method VSObjNameChangeDialog::getParent {this object} {
set cc [ClientContext::global]
if [$object isA SystemVersion] {
return [$cc currentPhase]
}
if [$object isA ConfigVersion] {
return [$cc currentProject]
}
return [$cc currentCorporate]
}
# Update the path of newObj in the VCM system
# if there is a correspondance. For VSFiles there
# always is, for Project, ConfigVersion and SystemVersion
# check presence of name in path through vsObject
# UserPath and rename if so.
#
method VSObjNameChangeDialog::updateObjectPath {this oldName newObj} {
# if this dialog is not VCM specific initialization failed;
# delegate to super class in this case
# another sport7 hack
if { [$this objType] == "VSObjNameChangeDialog" } {
$this ObjNameChangeDialog::updateObjectPath $oldName $newObj
return
}
if [$newObj isNil] {
return
}
# This action may be called at a level above system level in which
# case the VCM vars must still be initialized.
if { ![$this initializeVCMVars] } {
return
}
# real external links: do nothing
if [$newObj isA ExternalLink] {
return
}
if [$newObj isA VSFile] {
$this updateVSFilePath $oldName $newObj
return
}
# make sure that path redefinitions are available
$this readPathCustomization $newObj
set oldPath [[$this vsSystem]::vsObjectUserPath $newObj]
$this updateFileSystemPath $oldName $newObj
set newPath [[$this vsSystem]::vsObjectUserPath $newObj]
# if path did not change because of change in the fileSystemPath property
# retrieve old path
if { "$newPath" == "$oldPath" } {
set oldPath [$this getOldPath $oldName $newObj]
}
# if path changed: action
if { "$newPath" != "$oldPath" } {
# find changed part
set newPathParts [file_split $newPath]
set oldPathParts [file_split $oldPath]
set index 0
while { $index < [llength $newPathParts] } {
if { [lindex $newPathParts $index] != [lindex $oldPathParts $index] } {
set oldPath [file_join [lrange $oldPathParts 0 $index]]
set newPath [file_join [lrange $newPathParts 0 $index]]
$this renameDirectoryWithConfirm $oldPath $newPath
}
incr index 1
}
}
}
# Update fileSystemPath property of newObj
# and move file in the VCM system.
#
method VSObjNameChangeDialog::updateVSFilePath {this oldName newObj} {
$newObj updatePath
# if name change in VCM fails reset name
if { ![$newObj renameInVS $oldName] } {
$newObj name $oldName
} else {
# force update by deleting object; updateView will take care
# of the rest
$newObj delete
}
}
# Update file System Path property if
# oldName occurred in it.
#
method VSObjNameChangeDialog::updateFileSystemPath {this oldName newObj} {
set filePathProperty [$newObj findProperty fileSystemPath]
if { ![$filePathProperty isNil] } {
set newName [$newObj name]
set oldValue [$filePathProperty value]
if [regsub $oldName $oldValue $newName newValue] {
$filePathProperty change "$newValue"
}
}
}
# Get old path of object: find relative part and replace
# newName with oldName in this part.
#
method VSObjNameChangeDialog::getOldPath {this oldName newObj} {
set newPath [[$this vsSystem]::vsObjectUserPath $newObj]
set newName [$newObj name]
set parentObj [$this getParent $newObj]
set parentPath [[$this vsSystem]::vsObjectUserPath $parentObj]
# if parent path occurs in new path we can determine the relative path
if { [string first $parentPath $newPath] == 0 } {
set relativePathIndex [expr [string length $parentPath]+1]
set relativePath [string range $newPath $relativePathIndex end]
regsub -all $newName $relativePath $oldName oldRelativePath
return [path_name concat $parentPath $oldRelativePath]
}
return $newPath
}
# Read u_vcm.tcl at the correct level.
#
method VSObjNameChangeDialog::readPathCustomization {this {levelID ""}} {
set cc [ClientContext::global]
set levelChanged 0
# if level does not occur in level string we are one level too high
# go down in this case.
if { $levelID != "" } {
if { ![regexp [$levelID identity] [$cc currentLevelIdString]] } {
$cc downLevelId $levelID
set levelChanged 1
}
}
# source the customization file
eval [$cc getCustomFileContents u_vcm tcl etc]
# reset level if needed
if $levelChanged {
$cc upLevel
}
}
# Issue warning that a directory is about te be renamed
# and ask confirmation.
#
method VSObjNameChangeDialog::renameDirectoryWithConfirm {this oldPath newPath} {
if { ![[$this vsSystem]::directoryExists $oldPath] } {
return
}
set message "Directory $oldPath will be renamed to $newPath"
WarningDialog new .main.renameWarning \
-title "Change Name Warning" \
-message $message
.main.renameWarning okPressed \
".main busy 1;\
[$this vsSystem]::renameVSDirectory [list $oldPath] [list $newPath];\
.main busy 0;\
.main.renameWarning delete"
.main.renameWarning delHelpButton
.main.renameWarning popUp
}
# Do not delete this line -- regeneration end marker