home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
vsinstallm.tcl
< prev
next >
Wrap
Text File
|
1997-05-29
|
12KB
|
437 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)vsinstallm.tcl /main/hindenburg/7
# Author: <generated>
# Description: VCM integration file
#---------------------------------------------------------------------------
# SccsId = @(#)vsinstallm.tcl /main/hindenburg/7 29 May 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
require installabl.tcl
require methodextr.tcl
require procs.tcl
# End user added include file section
require "installman.tcl"
Class VSInstallManager : {InstallManager} {
constructor
method destructor
method createInterface
method handleInstall
method handleUninstall
method doInstall
method doUninstall
method handleShowCurrent
method showSuccess
method getProjects
method getOldInstallation
method addTclFile
method addEtcFile
method addAllFiles
method configureProject
method addToCorporate
method removeFromCorporate
method getCurrentIntegration
method install
method unInstall
# Source directory for Tcl customization files.
#
attribute tclSrcDir
# Source directory for etc customization files.
#
attribute etcSrcDir
# List of methods that must be extracted to make
# the u_vcm.tcl customization file.
#
attribute uVcmMethodList
# Map prefix to integration name.
#
attribute prefixToIntegration
attribute extracter
}
constructor VSInstallManager {class this} {
set this [InstallManager::constructor $class $this]
# Start constructor user section
$this createInterface
set home [m4_var get M4_home]
$this tclSrcDir [path_name concat $home tcl]
$this etcSrcDir [path_name concat $home etc]
$this extracter [MethodExtracter new]
$this uVcmMethodList "vsObjectUserPath vsObjectVSPath vsFileUserPath vsFileVSPath"
$this addAllFiles
$this prefixToIntegration [Dictionary new]
[$this prefixToIntegration] set razor "Razor"
[$this prefixToIntegration] set cc "ClearCase"
[$this prefixToIntegration] set cont "Continuus"
set integration [[$this prefixToIntegration] set [$this prefix]]
[$this installWindow] title "$integration integration installation"
# End constructor user section
return $this
}
method VSInstallManager::destructor {this} {
# Start destructor user section
# End destructor user section
$this InstallManager::destructor
}
# Make project selection box and add
# push buttons for installing etc.
#
method VSInstallManager::createInterface {this} {
# project list part
interface DlgColumn .main.row.projCol {
Label label {
text "Projects:"
}
TextList projectList {
selectionPolicy MULTIPLE
}
}
.main.row.projCol.projectList entrySet [$this getProjects]
# push buttons
interface DlgColumn .main.row.buttonCol {
PushButton install {
label Install
sensitive 0
}
PushButton uninstall {
label Uninstall
sensitive 0
}
PushButton showCurrent {
label "Show current installation"
}
PushButton exit {
label Exit
activated { exit }
}
}
.main.row.buttonCol.install activated "$this handleInstall"
.main.row.buttonCol.uninstall activated "$this handleUninstall"
.main.row.buttonCol.showCurrent activated "$this handleShowCurrent"
# enable install if selection is made
.main.row.projCol.projectList selectionChanged {
if { [%this selectedSet] != "" } {
[[%this parent] parent].buttonCol.install sensitive 1
[[%this parent] parent].buttonCol.uninstall sensitive 1
} else {
[[%this parent] parent].buttonCol.install sensitive 0
[[%this parent] parent].buttonCol.uninstall sensitive 0
}
}
}
# Callback for install button.
#
method VSInstallManager::handleInstall {this} {
set projects [.main.row.projCol.projectList selectedSet]
set oldInstallation [$this getOldInstallation]
set warnings ""
set errors ""
# check old installation for conflicts
foreach project $projects {
set oldPrefix [$oldInstallation set $project]
if { $oldPrefix != "" } {
set integration [[$this prefixToIntegration] set $oldPrefix]
set message "\nProject $project already has $integration installed"
append message "\nDo you want to continue?"
if { $oldPrefix!= [$this prefix] } {
append errors $message
} else {
append warnings $message
}
}
}
if { $errors != "" } {
ErrorDialog new .main.error -message $errors -okPressed { %this delete }
.main.error delHelpButton
.main.error popUp
return
}
if { $warnings != "" } {
WarningDialog new .main.warning -message $warnings \
-okPressed "$this doInstall $projects"
.main.warning delHelpButton
.main.warning popUp
return
}
$this doInstall $projects
}
# Callback for uninstall button.
#
method VSInstallManager::handleUninstall {this} {
set projects [.main.row.projCol.projectList selectedSet]
set oldInstallation [$this getOldInstallation]
set errors ""
# check old installation for conflicts
foreach project $projects {
set oldPrefix [$oldInstallation set $project]
if { [string trim $oldPrefix] == "" } {
append errors "\nProject $project has no VCM integration installed"
} else {
set integration [[$this prefixToIntegration] set $oldPrefix]
if { $oldPrefix!= [$this prefix] } {
append errors "\nProject $project has $integration installed"
}
}
}
if { $errors != "" } {
ErrorDialog new .main.error -message $errors -okPressed { %this delete }
.main.error delHelpButton
.main.error popUp
return
}
$this doUninstall $projects
}
# Install in the given projects.
#
method VSInstallManager::doInstall {this newInstallation} {
foreach project $newInstallation {
$this install $project
}
$this showSuccess "installed"
}
# Uninstall in specified projects.
#
method VSInstallManager::doUninstall {this newInstallation} {
foreach project $newInstallation {
$this unInstall $project
}
$this showSuccess "uninstalled"
}
# Show current installation status of projects.
#
method VSInstallManager::handleShowCurrent {this} {
set formatString "%-30s\t%s"
set infoString [format $formatString "Project" "VCM Integration\n"]
[$this getOldInstallation] foreach project prefix {
append infoString "\n"
set integration [[$this prefixToIntegration] set $prefix]
if { $integration == "" } {
set integration "None"
}
append infoString [format $formatString $project $integration]
}
InfoDialog new .main.info \
-title "Current installation" \
-okPressed { %this delete } \
-message $infoString \
-font "courier-normal-12"
.main.info delHelpButton
.main.info popUp
}
# Construct message: integration name, succesfully, action
# and show in info box.
#
method VSInstallManager::showSuccess {this action} {
set message "[[$this prefixToIntegration] set [$this prefix]]"
append message " integration $action successfully"
append message "\nPlease restart your browser"
InfoDialog new .main.ok -message $message
.main.ok delHelpButton
.main.ok okPressed {
%this delete
}
.main.ok popUp
}
# Return list of available projects.
#
method VSInstallManager::getProjects {this} {
set corporate [[ClientContext::global] currentCorporate]
set projects ""
foreach project [$corporate projects] {
append projects " [$project name]"
}
return $projects
}
# Return current installation using project name as key
# and install prefix as value.
#
method VSInstallManager::getOldInstallation {this} {
set installation [Dictionary new]
foreach project [$this getProjects] {
$installation set $project [$this getCurrentIntegration $project]
}
return $installation
}
# Add given Tcl file to the customFile list,
# using tclSrcDir.
#
method VSInstallManager::addTclFile {this name type} {
set customFile [InstallableCustomFile new $name $type $this]
$customFile source [$this tclSrcDir]
$customFile incremental 0
return $customFile
}
# Add given etc file to the customFile list,
# using the prefix and etcSrcDir.
#
method VSInstallManager::addEtcFile {this name type} {
set customFile [InstallableCustomFile new $name $type $this]
$customFile source [$this etcSrcDir]
$customFile sourcePrefix [$this prefix]
$customFile incremental 1
return $customFile
}
# Construct customFile list.
#
method VSInstallManager::addAllFiles {this} {
[$this addEtcFile desk mnu] sourcePrefix vs
$this addEtcFile desk mnu
$this addEtcFile desk vie
[$this addTclFile u_uce tcl] sourcePrefix [$this prefix]
[$this addTclFile s_otsh tcl] sourcePrefix [$this prefix]
[$this addEtcFile vcmtype vcmtype] incremental 0
[$this addTclFile fstorage tcl] sourcePrefix vs
set uVcm [$this addTclFile u_vcm tcl]
$uVcm source ""
# the following method will be evaluated in the context of
# InstallableCustomFile so $this will reference an InstallableCustomFile
# object
$uVcm sourceMethod {
set tmpFile [BasicFS::tmpFile]
set prefix [[$this manager] prefix]
set tclSrcDir [[$this manager] tclSrcDir]
set uVcmSourceFile [string range "${prefix}system" 0 9]
set uVcmSourcePath [path_name concat $tclSrcDir "$uVcmSourceFile.tcl"]
set extractArgs [list $uVcmSourcePath $tmpFile]
[[$this manager] extracter] extract \
[concat $extractArgs [[$this manager] uVcmMethodList]]
set tmpFile
}
}
# Configure given project for VCM integration: set property
# with value. If value is empty the project is
# effectively configured for ObjectTeam VCM (uninstall).
#
method VSInstallManager::configureProject {this project value} {
set corporate [[ClientContext::global] currentCorporate]
set project [$corporate findProject $project]
$project setProperty vcmIntegration $value
}
# Adds the given value to the corporate
# property vcmIntegrationList if not
# yet in this list.
#
method VSInstallManager::addToCorporate {this value} {
set corporate [[ClientContext::global] currentCorporate]
set list [$corporate getPropertyValue vcmIntegrationList]
if { [lsearch $list $value] == -1 } {
append list " $value"
$corporate setProperty vcmIntegrationList $list
}
}
# Check if there are any projects left with the integration
# specified by value, if not remove it from the
# corporate property vcmIntegrationList.
#
method VSInstallManager::removeFromCorporate {this value} {
[$this getOldInstallation] foreach project integration {
if { $integration == $value } {
return
}
}
set corporate [[ClientContext::global] currentCorporate]
set oldList [$corporate getPropertyValue vcmIntegrationList]
set oldValueIndex [lsearch $oldList $value]
if { $oldValueIndex == -1 } {
# this should not happen
return
}
set newList [join [lreplace $oldList $oldValueIndex $oldValueIndex ""]]
$corporate setProperty vcmIntegrationList $newList
}
# Return prefix of integration currently installed in project.
#
method VSInstallManager::getCurrentIntegration {this project} {
set corporate [[ClientContext::global] currentCorporate]
set project [$corporate findProject $project]
return [$project getPropertyValue vcmIntegration]
}
# Install VCM integration in specified project
# (project being the project name).
#
method VSInstallManager::install {this project} {
.main busy 1
$this installCustomFiles $project
$this configureProject $project [$this prefix]
$this addToCorporate [$this prefix]
$this showMessage ""
.main busy 0
}
method VSInstallManager::unInstall {this project} {
.main busy 1
$this unInstallCustomFiles $project
$this configureProject $project ""
$this removeFromCorporate [$this prefix]
$this showMessage ""
.main busy 0
}
# Do not delete this line -- regeneration end marker