home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
vssysvdbob.tcl
< prev
next >
Wrap
Text File
|
1997-11-25
|
19KB
|
709 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)vssysvdbob.tcl /main/titanic/13
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)vssysvdbob.tcl /main/titanic/13 25 Nov 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
require_module_file "selectvers.tcl" vcm
# End user added include file section
require "psysvdbobj.tcl"
Class VSSysVDbObj : {PSysVDbObj} {
constructor
method destructor
method browserType
method promoter
method copy
method changeSourceClass
method moveVersion
method selectVersion
method deselectVersion
method importObject
method importObjects
method initializeCustomization
method makeDirectoryList
method updateFileInfo
method updateUserEnv
method printObjects
method getObjHandler
method importFromPrevPhase
method removeObjects
method showPreviousVersion
method showOtherVersion
method diffPreviousVersion
method diffOtherVersion
method listVersions
method addDirectory
method removeDirectory
# Indicates whether the customization files for this system have been read.
#
attribute initializedCustomization
attribute directorySet
}
constructor VSSysVDbObj {class this name} {
set this [PSysVDbObj::constructor $class $this $name]
$this initializedCustomization 0
$this directorySet [List new]
# Start constructor user section
# End constructor user section
return $this
}
method VSSysVDbObj::destructor {this} {
# Start destructor user section
# End destructor user section
$this PSysVDbObj::destructor
}
proc VSSysVDbObj::associations {} {
return {externalLinks vsFiles customFileVersionSet}
}
proc VSSysVDbObj::childTypes {assoc} {
if {[lsearch -exact "[VSSysVDbObj::associations]" "$assoc"] == -1} {
return ""
}
set childTypes [BrowserProcs::childTypes $assoc]
case "$childTypes" in {
{VsFile} {
return "${BrowserProcs::programmerFileTypes}"
}
{default} {
return [SysVDbObj::childTypes "$assoc"]
}
}
}
proc VSSysVDbObj::controlledLists {} {
return [PSysVDbObj::controlledLists]
}
proc VSSysVDbObj::infoProperties {} {
return [PSysVDbObj::infoProperties]
}
# Returns special VS system type.
#
method VSSysVDbObj::browserType {this} {
return "VCMSystemVersion"
}
method VSSysVDbObj::promoter {this} {
VSTypeMapper new $this
$this directorySet [List new]
$this initializedCustomization 0
}
# Extension of copy with support for Edit etc.
# Only do it if file is a VSFile, otherwise pass to superclass.
#
method VSSysVDbObj::copy {this args} {
set argc [llength $args]
# it's not a VSFile: don't touch it
if { [lindex $args 0] != "\-vsFile" } {
eval $this PSysVDbObj::copy $args
return
}
# make sure this system is initialized
$this initializeVCMVars
if { ![$this initializedCustomization] } {
$this initializeCustomization
}
set vsFile [lindex $args 1]
if { $argc <= 2 } {
eval $this VSSystem::copy $vsFile
return
}
set editPasteCmdBusy [lindex $args [expr $argc -1]]
set newVSFile [$this VSSystem::copy $vsFile]
if {$editPasteCmdBusy && ( $newVSFile != "" )} {
[.main undoCommand] sourceObj [$vsFile systemVersion]
[.main undoCommand] addObject $newVSFile
}
}
# Pops up a singeline text dialog for
# changing the source class of the file.
#
method VSSysVDbObj::changeSourceClass {this} {
.main busy 1
if { ![isCommand .main.changesource] } {
EntryDialog new .main.changesource -title "Change Source Class"
}
set vsFile [lindex [.main selectedObjSet] 0]
.main.changesource config \
-message "Source class for file [$vsFile name]:" \
-entry [$vsFile getClass] \
-okPressed "[list $vsFile] setClass \[.main.changesource entry\]; [list $vsFile] setInfo \"Generated From Class\" \[.main.changesource entry\]"
.main busy 0
.main.changesource delHelpButton
.main.changesource popUp
}
# Move specified version to this system.
#
method VSSysVDbObj::moveVersion {this args} {
# make sure this system is initialized
$this initializeVCMVars
if { ![$this initializedCustomization] } {
$this initializeCustomization
}
set vsFile [lindex $args 0]
set sourceSys [lindex $args 1]
set editPasteCmdBusy [lindex $args 2]
if { ![$this move $vsFile] } {
return
}
# make new object
set type [$vsFile type]
set objectName [$this getObjectName [$vsFile name] $type]
set newVSFile [VSFile new $objectName $type $this]
# check if copy succeeded
if { $newVSFile == "" } {
return ""
}
$this promoteFile $newVSFile
# check out if necessary
set userPath [$newVSFile path]
if { ![$newVSFile isCheckedOut] } {
set comment "Moved from [$vsFile vsPath]"
if { ![$newVSFile checkOut $comment] } {
return ""
}
}
if {$editPasteCmdBusy && ( $newVSFile != "" )} {
[.main undoCommand] sourceObj $sourceSys
[.main undoCommand] addObject $newVSFile
}
}
method VSSysVDbObj::selectVersion {this version {confV ""}} {
# check if it's a VS file
if { ![$version isA VSFile] } {
$this PSysVDbObj::selectVersion $version
return
}
if {"[[.main undoCommand] operation]" == "cut"} {
wmtkmessage "Moving [$version getInfo Text]"
if [$this move $version] {
[.main undoCommand] removeObject $version
[.main undoCommand] addObject \
[$this getObjectName [$version name] [$version type]]
}
wmtkmessage ""
} else {
set sourceSys [[.main undoCommand] sourceObj]
set sourceFile [$sourceSys getObjectName [$version name] [$version type]]
wmtkmessage "Copying [$sourceFile getInfo Text]"
$this VSSystem::copy $sourceFile
wmtkmessage ""
}
}
method VSSysVDbObj::deselectVersion {this version} {
if { ![$version isA VSFile] } {
$this PSysVDbObj::deselectVersion $version
return
}
if {"[[.main undoCommand] operation]" == "cut"} {
wmtkmessage "Moving [$version getInfo Text]"
set sys [[.main undoCommand] sourceObj]
# make sure sys is initialized
$sys initializeVCMVars
if { ![$sys initializedCustomization] } {
$sys initializeCustomization
}
if [$sys move $version] {
[.main undoCommand] removeObject $version
[.main undoCommand] addObject \
[$sys getObjectName [$version name] [$version type]]
}
wmtkmessage ""
} else {
$version removeFromVS
}
}
method VSSysVDbObj::importObject {this context node} {
# context is: project, configversion, phaseversion
# systemversion, file, type, uiClass
set isAVSFile 0
set len [llength $context]
if { $len == 7 } {
set fileId [lindex $context 4]
if [regexp VSFile $fileId] {
set isAVSFile 1
}
}
# if it's not a vs file leave it
if !$isAVSFile {
$this PSysVDbObj::importObject $context $node
return 0
}
if {$this == [[.main currentObj] browsUiObj]} {
set update 1
} else {
set update 0
}
# sanity check: systems must be different
set sysVId [lindex $context 3]
if {$sysVId == [$this getInfo Identity]} {
wmtkmessage "Can not import object into its own parent"
if [isCommand [.main undoCommand]] {
[.main undoCommand] delete
}
return 0
}
# retrieve source info
set sysV [BrowserProcs::id2obj $sysVId SystemVersion $node]
regsub -all {\.} $sysVId "_" sysId
set vsFile "${sysId}_$fileId"
# Make sure vsFile exists
if [catch {$vsFile name}] {
wmtkinfo "Can not import [lindex $context 5] because it is removed"
if [isCommand [.main undoCommand]] {
[.main undoCommand] delete
}
return 0
}
# Move imported object in case of a cut operation
set editPasteCmdBusy [.main undoCommandBusy EditPasteCmd]
if {$editPasteCmdBusy && \
"[[.main undoCommand] operation]" == "cut"} {
set script "$this moveVersion [list $vsFile] $sysV $editPasteCmdBusy"
set action "Moving"
} else {
set script "$this copy -vsFile [list $vsFile] $editPasteCmdBusy"
set action "Copying"
}
$wmttoolObj startCommand tcl "$script" "" \
"$action [$vsFile getInfo Text]" [list $update 0] 1
return 1
}
method VSSysVDbObj::importObjects {this contextList node} {
foreach context $contextList {
if { ![$this importObject $context $node] } {
return 0
}
}
return 1
}
# Read type mapping and u_vcm.tcl and set
# initializedCustomization.
#
method VSSysVDbObj::initializeCustomization {this} {
[$this typeMapper] initialize
$this initializedCustomization 1
}
# Determines the directories used by this
# system, compares this with the repository links and
# updates if necessary, and sets the directory
# association.
#
method VSSysVDbObj::makeDirectoryList {this} {
set directoryLinkList {}
set fileList {}
set pathToFile [Dictionary new]
set pathList {}
# use externalLinks directly for better performance.
foreach file [$this SystemVersion::externalLinks] {
if { ![$file isA VSFile] } {
continue
}
# determine path relative to system
regsub "[$this path]." [$file path] "" relativePath
if { "$relativePath" == "" } {
set relativePath "\."
}
if [$file isDirectory] {
lappend directoryLinkList $relativePath
} else {
set dirPath [path_name directory $relativePath]
if { [lsearch $pathList $dirPath] == - 1 } {
lappend pathList $dirPath
}
}
$pathToFile set $relativePath $file
lappend fileList $relativePath
}
# make new links if necessary
foreach dir $pathList {
if { [lsearch $directoryLinkList $dir] == -1 } {
# puts "Must create $dir"
# $directoryLinkList set
# lappend directo
}
}
# remove obsolete links
foreach dir $directoryLinkList {
if { [lsearch $pathList $dir] == -1 } {
# puts "Must remove $dir"
}
}
# add files and directories to associations and adjust indentation
foreach filePath $fileList {
set parentPath [path_name directory $filePath]
set file [$pathToFile set $filePath]
$file setIndentation [expr [llength [file split $parentPath]] -1]
# if parent is a . add to system association
# else add to file association of directory
if { ("$parentPath" == "\.") && ([$file isDirectory]) } {
$this addDirectory $file
} else {
[$pathToFile set $parentPath] addFile $file
}
}
}
# Updates the cached information for these files.
#
method VSSysVDbObj::updateFileInfo {this files} {
foreach file $files {
# invalidate cached info
$file updatePath
$file initializedAllInfo 0
}
}
# Updates the user environment files.
#
method VSSysVDbObj::updateUserEnv {this} {
# VCM systems will redefine this if it make sense
# menu entry disabling should prevent this from being called
wmtkinfo "You should not be able to use this function"
}
# Send objects to printer.
#
method VSSysVDbObj::printObjects {this} {
# this variable will hold script to delete file references after
# printing
set vsFileDeleteRefs ""
# this variable holds the path list of files to print
set pathList ""
foreach obj [.main selectedObjSet] {
if [$obj isA VSFile] {
# get a reference: a path to the required version
set path [$obj getReference]
if { $vsFileDeleteRefs != "" } {
append vsFileDeleteRefs "; "
}
append vsFileDeleteRefs "[list $obj] deleteReference [list $path]"
} else {
set path [$obj path]
}
if $win95 {
append pathList " [list $path]"
} else {
append pathList " [quoteIf $path]"
}
}
# make print command
set printCommand [m4_var get M4_a_printer]
if !$win95 {
set message "Sending files to $printCommand..."
set printFiles "$printCommand $pathList"
.main startCommand extern "$printFiles" "$vsFileDeleteRefs" \
"$message" {0 0} 0
return
}
# one by one for Windows
foreach path $pathList {
set printFile "$printCommand $path"
if { ![regexp {([^;]*);(.*)} $vsFileDeleteRefs \
dummy deleteRef vsFileDeleteRefs] } {
set deleteRef $vsFileDeleteRefs
}
set message "Sending $path to $printCommand..."
.main startCommand extern "$printFile" "$deleteRef" \
"$message" {0 0} 0
}
}
# Returns the CustObjHandler of .main
#
method VSSysVDbObj::getObjHandler {this} {
return [.main objectHdlr]
}
method VSSysVDbObj::importFromPrevPhase {this mode} {
if {"$mode" == "selected"} {
set tmpFile [args_file {}]
set fid [open $tmpFile w]
foreach obj [.main selectedObjSet] {
if [$obj isA SystemFileReference] {
set confV [$obj getParent ConfigVersion]
set fileV [$obj referredFileVersion]
if [$fileV isA ExternalFileVersion] {
puts $fid "[$fileV identity]"
}
} elseif [$obj isA ExternalFileVersion] {
puts $fid "[$obj identity]"
} elseif [$obj isA VSFile] {
set name [$obj name]
set type [$obj type]
if { $type != "" } {
set fileSpec "$name.$type"
} else {
set fileSpec "$name"
}
puts $fid "$fileSpec"
}
}
close $fid
set options "-S oopl -t $tmpFile -f import.tcl"
set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] $options"
.main startCommand mtool \
"$script" "" \
"Starting 'Import From Previous Phase'..." \
{1 0} 0
} else {
set box .main.importNew
if {! [isCommand $box]} {
interface TemplateDialog $box {
title "Import New"
modal yes
DlgColumn DC {
Label L {
text "Import new"
alignment CENTER
}
CheckButton SQLCB {
label SQL
}
CheckButton OOPLCB {
label OOPL
}
}
}
$box config \
-helpPressed {.main helpOnName importNew} \
-okPressed {
if [%this.DC.SQLCB state] {
set options "-S sql "
} else {
set options ""
}
if [%this.DC.OOPLCB state] {
append options "-S oopl "
}
append options "-f import.tcl"
set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] $options"
.main startCommand mtool \
"$script" "" \
"Starting 'Import From Previous Phase'..." \
{1 0} 0
}
}
$box popUp
}
}
method VSSysVDbObj::removeObjects {this} {
set box $wmttoolObj.removeWarning
ClassMaker::extend YesNoWarningDialog RemoveObjectsWarningDialog dbObj
RemoveObjectsWarningDialog new $box \
-title "Confirm Object Delete" \
-message [BrowserProcs::removeMessage] \
-dbObj $this \
-noPressed {%this delete} \
-yesPressed {
set dbObj [%this dbObj]
set script ""
set update 0
busy {
vsCommandHandler suspendOutput
foreach obj [$wmttoolObj selectedObjSet] {
if {"$script" != ""} {
append script " ;"
}
if [$obj isA VSFile] {
# remove from VS if it still exists there.
set system [[.main currentObj] browsUiObj]
if [$system fileExists [$obj name] [$obj type]] {
if { ![$obj removeFromVS] } {
break
}
set update 1
}
} else {
append script " $dbObj removeObject $obj"
}
}
}
%this delete
if { $script != "" } {
$wmttoolObj startCommand tcl "$script" "vsCommandHandler showOutput" "" {1 0} 1
} else {
if $update {
.main updateView
wmtkmessage ""
vsCommandHandler showOutput
}
}
}
$box delCancelButton
$box popUp
}
# Shows the prvious version of this file.
#
method VSSysVDbObj::showPreviousVersion {this} {
set selectedFile [lindex [.main selectedObjSet] 0]
set previousVersion [$selectedFile previousVersion]
if { $previousVersion == "" } {
wmtkinfo "There is no previous version"
return
}
$selectedFile showFileVersion $previousVersion
}
# Show another version of this file.
#
method VSSysVDbObj::showOtherVersion {this} {
set selectedFile [lindex [.main selectedObjSet] 0]
set versions [$selectedFile otherVersions]
if { $versions == "" } {
wmtkinfo "There are no other versions"
return
}
SelectVersionDialog new .main.selectversion \
-title "Show Other Version" \
-file $selectedFile \
-entrySet $versions \
-options "" \
-command "showFileVersion"
.main.selectversion popUp
}
# Shows diff of selected file with previous version.
#
method VSSysVDbObj::diffPreviousVersion {this {options ""}} {
set selectedFile [lindex [.main selectedObjSet] 0]
set previousVersion [$selectedFile previousVersion]
if { $previousVersion == "" } {
wmtkinfo "There is no previous version"
return
}
$selectedFile showDiff $previousVersion $options
}
# Pops up version selection dialog and shows diff
# with selected version.
#
method VSSysVDbObj::diffOtherVersion {this {options ""}} {
set selectedFile [lindex [.main selectedObjSet] 0]
set versions [$selectedFile otherVersions]
if { $versions == "" } {
wmtkinfo "There are no other versions"
return
}
SelectVersionDialog new .main.selectversion \
-title "Show Diff with Other Version" \
-file $selectedFile \
-entrySet $versions \
-options $options \
-command "showDiff"
.main.selectversion popUp
}
# List the version of this file in an info dialog.
#
method VSSysVDbObj::listVersions {this} {
set selectedFile [lindex [.main selectedObjSet] 0]
set versions [$selectedFile otherVersions]
if { $versions == "" } {
wmtkinfo "There are no other versions of [file tail [$selectedFile path]]"
return
}
set versionOutput [join $versions "\n"]
set message "Other versions of [$selectedFile path]:\n\n$versionOutput"
wmtkinfo "$message"
}
# Do not delete this line -- regeneration end marker
method VSSysVDbObj::addDirectory {this newDirectory} {
[$this directorySet] append $newDirectory
}
method VSSysVDbObj::removeDirectory {this oldDirectory} {
[$this directorySet] removeValue $oldDirectory
}