home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
userenvvie.tcl
< prev
next >
Wrap
Text File
|
1996-11-11
|
13KB
|
512 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)userenvvie.tcl /main/hindenburg/16
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)userenvvie.tcl /main/hindenburg/16 11 Nov 1996 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require "browstable.tcl"
require "uenvbrobje.tcl"
# End user added include file section
require "reptoolvie.tcl"
Class UserEnvView : {RepToolView} {
method destructor
constructor
method initialize
method selectedObjSet
method repositoryChanged
method projectChanged
method configChanged
method selectionChanged
method update
method updateMessage
method onlyWorkingSelected
method anyWorkingSelected
method reload
method removeFiles
method uploadFiles
method setFont
method getFont
method fileDelete
method fileUpload
method fileShow
method editSelectWorking
method editSelectAll
method editDeselectAll
method editInvertSelection
method helpOnContext
attribute changed
attribute repositories
attribute projects
attribute configurations
attribute files
attribute project
attribute configV
}
method UserEnvView::destructor {this} {
# Start destructor user section
# End destructor user section
$this RepToolView::destructor
}
constructor UserEnvView {class this name} {
set this [RepToolView::constructor $class $this $name repuenv]
$this setTitle "User Environment" rep_uenv_64
$this firstExposed "$this initialize"
$this changed 0
$this project [[ClientContext::global] currentProject]
$this configV [[ClientContext::global] currentConfig]
# Create main interface part.
#
interface DlgColumn $this.gui.col {
HorSeparator h {
}
DlgRow r {
spaceType NONE
horStretchFactor 0
verStretchFactor 0
verShrinkFactor 0
DlgRow reps {
spaceType NONE
Label l { text "Repository:" }
OptionMenu reps {
justification CENTER
entrySet {<none>}
}
}
DlgRow proj {
spaceType NONE
horStretchFactor 100
Label l { text "Project:" }
OptionMenu proj {
horStretchFactor 100
justification CENTER
entrySet {<any>}
}
}
DlgRow conf {
spaceType NONE
horStretchFactor 100
Label l { text "Config:" }
OptionMenu conf {
horStretchFactor 100
justification CENTER
entrySet {<any>}
}
}
}
DlgColumn f {
spaceType NONE
verStretchFactor 100
verShrinkFactor 100
BrowsTable files {
verStretchFactor 100
verShrinkFactor 100
mode DETAIL
selectionPolicy EXTENDED
columnCount 72
rowCount 15
}
}
}
$this repositories $this.gui.col.r.reps.reps
$this projects $this.gui.col.r.proj.proj
$this configurations $this.gui.col.r.conf.conf
$this files $this.gui.col.f.files
[$this repositories] selectionChanged "busy {$this repositoryChanged}"
[$this repositories] entrySet \
[concat <none> [[$this rep] getAvailableRepositories]]
[$this projects] selectionChanged "busy {$this projectChanged}"
[$this configurations] selectionChanged "busy {$this configChanged}"
[$this files] font [m4_var get M4_font -context repuenv]
[$this files] selectionChanged "$this selectionChanged"
[$this files] setHeaderLabels [UEnvBrObject::headerLabels]
[$this files] format
return $this
}
proc UserEnvView::repToolClass {} {
return "UserEnvView"
}
method UserEnvView::initialize {this} {
busy {
set selected "<none>"
# No level path should be set at this point.
#
catch {set cc [ClientContext::global]}
catch {set cc [ClientContext::global]}
if {[$this levelPathIds] != ""} {
if [catch {$cc setLevelIds [$this levelPathIds]} error] {
$this error $error
$this message ""
}
} elseif {[$this levelPath] != ""} {
if [catch {$cc setLevelPath [$this levelPath]} error] {
$this error $error
$this message ""
}
}
set corp [$cc currentCorporate]
if ![$corp isNil] {
[$this repositories] selected [$corp name]
$this selectionChanged
$this repositoryChanged
}
}
}
method UserEnvView::selectedObjSet {this} {
return [[$this files] selectedSet]
}
method UserEnvView::repositoryChanged {this} {
# Clear file list.
#
[$this files] removeAllObjects
# Clear Project option menu.
#
[$this projects] entrySet <any>
[$this projects] selected <any>
$this project [ORB::nil]
# Clear Config option menu.
#
[$this configurations] entrySet <any>
[$this configurations] selected <any>
$this configV [ORB::nil]
set name [[$this repositories] selected]
if {$name == "<none>"} {
[$this rep] setCurrent ""
return
}
if [catch {[$this rep] setCurrent $name} error] {
$this message "Cannot access repository '$name'."
$this contextError $error
} else {
$this message "Selected repository '$name'."
$this contextError ""
}
[$this menuHandler] levelChanged
if {$error != 0} {
$this error $error
return
}
set names {}
set corp [[$this rep] currentCorporate]
if ![$corp isNil] {
foreach project [$corp projects] {
lappend names "[$project name]"
}
}
if {[llength $names] == 1} {
[$this projects] entrySet $names
[$this projects] selected $names
} else {
[$this projects] entrySet [concat <any> $names]
[$this projects] selected <any>
}
$this changed 1
$this updateMessage
}
method UserEnvView::projectChanged {this} {
# Clear file list.
#
[$this files] removeAllObjects
# Clear Config option menu.
#
[$this configurations] entrySet <any>
[$this configurations] selected <any>
$this configV [ORB::nil]
set sel [[$this projects] selected]
if {$sel == "<any>"} {
$this project [ORB::nil]
return
}
set names {}
set corp [[$this rep] currentCorporate]
if ![$corp isNil] {
$this project [$corp findProject $sel]
if [[$this project] isNil] {
$this error "Project '$sel' not found in corporate '[$corp name]'"
} else {
foreach configV [[$this project] configVersions] {
lappend names [[$configV config] name]:[$configV versionNumber]
}
$this updateMessage
}
}
if {[llength $names] == 1} {
[$this configurations] entrySet $names
[$this configurations] selected $names
} else {
[$this configurations] entrySet [concat <any> $names]
[$this configurations] selected <any>
}
}
method UserEnvView::configChanged {this} {
# Clear file list.
#
[$this files] removeAllObjects
set sel [[$this configurations] selected]
if {$sel == "<any>"} {
$this configV [ORB::nil]
return
}
set proj [$this project]
set nv [split $sel :]
$this configV [$proj findConfigVersion [lindex $nv 0] [lindex $nv 1]]
if [[$this configV] isNil] {
$this error "Configuration '$sel' not found in project '[$proj name]'"
} else {
$this updateMessage
}
}
method UserEnvView::selectionChanged {this} {
$this RepToolView::selectionChanged
}
method UserEnvView::update {this} {
busy { $this reload }
}
method UserEnvView::updateMessage {this} {
$this message "Use 'View > Refresh' to retrieve existing external files."
}
method UserEnvView::onlyWorkingSelected {this} {
set objects [[$this files] selectedSet]
foreach obj $objects {
if {[[$obj fileV] status] != "working"} {
return 0
}
}
return 1
}
method UserEnvView::anyWorkingSelected {this} {
set objects [[$this files] selectedSet]
foreach obj $objects {
if {[[$obj fileV] status] == "working"} {
return 1
}
}
return 0
}
method UserEnvView::reload {this} {
set files [$this files]
$files removeAllObjects
set sel [[$this repositories] selected]
if {$sel == "<none>"} {
$this message "No repository selected."
$files format
return
} elseif [[[$this rep] currentCorporate] isNil] {
$this message "Cannot access repository '$sel'."
$files format
return
}
$this message "This action may take a while, please wait..."
set proj [$this project]
set conf [$this configV]
[$this rep] getExternalFileVersions -clear
set exts [[$this rep] getExternalFileVersions -proj $proj -conf $conf]
set errors {}
set i 0
foreach ext $exts {
set fileV [lindex $ext 0]
set configV [lindex $ext 1]
if [catch {set path [$fileV path $configV]} error] {
set file [$fileV file]
set name "[$file name].[$file type] ([$fileV versionName])"
append errors "Error while determining path of $name:\n$error\n\n"
continue
}
if ![file exists $path] {
continue
}
UEnvBrObject new $files.file$i $fileV $configV $path
incr i
}
set s [expr {$i == 1 ? "" : "s"}]
$this message "Found $i file$s."
$files format
if {$errors != ""} {
$this error $errors
}
}
method UserEnvView::removeFiles {this objects} {
foreach obj $objects {
BasicFS::removeFile [$obj path]
$obj delete
}
}
method UserEnvView::uploadFiles {this objects} {
foreach obj $objects {
set fileV [$obj fileV]
if {[$fileV status] == "working"} {
$fileV upLoadWorkingContents
}
}
}
method UserEnvView::setFont {this font} {
[$this files] font $font
$this RepToolView::setFont $font
}
method UserEnvView::getFont {this} {
return [[$this files] font]
}
method UserEnvView::fileDelete {this} {
set objects [[$this files] selectedSet]
set cnt [llength $objects]
if {$cnt == 1} {
set obj [lindex $objects 0]
set what "the file\n'[$obj path]'"
} else {
set what "these $cnt files"
}
set anyWorking [$this anyWorkingSelected]
set msg ""
if $anyWorking {
append msg "This action may cause loss of data if\n"
append msg "the selected file(s) are not uploaded first!\n\n"
}
append msg "Do you really want to remove $what?"
set dlg [YesNoWarningDialog new $this.removeuenvdlg \
-title "Remove External Files" \
-message $msg \
-yesPressed "$this removeFiles [list $objects]" \
-helpPressed "$this helpOnName deleteExtFile"]
if $anyWorking {
PushButton new $dlg.upload \
-label "Upload" \
-activated "$this fileUpload { %this sensitive 0 }"
}
$dlg delCancelButton
$dlg popUp
}
method UserEnvView::fileUpload {this {activated ""}} {
set objects [[$this files] selectedSet]
set cnt [llength $objects]
if {$cnt == 1} {
set obj [lindex $objects 0]
set what "the external file version\n'[$obj fileName]'"
} else {
set what "these $cnt external file versions"
}
set script "$this uploadFiles [list $objects]"
if {$activated != ""} {
append script "; $activated"
}
set dlg [WarningDialog new $this.uploaduenvdlg \
-title "Upload External File Versions" \
-message "Do you really want to upload the working versions of $what?" \
-okPressed $script \
-helpPressed "$this helpOnName uploadExtFile"]
$dlg popUp
}
method UserEnvView::fileShow {this} {
set obj [lindex [[$this files] selectedSet] 0]
$obj show
}
method UserEnvView::editSelectWorking {this} {
set working {}
foreach obj [[$this files] objectSet] {
if {[[$obj fileV] status] == "working"} {
lappend working $obj
}
}
[$this files] selectedSet $working
$this selectionChanged
}
method UserEnvView::editSelectAll {this} {
[$this files] selectedSet [[$this files] objectSet]
$this selectionChanged
}
method UserEnvView::editDeselectAll {this} {
[$this files] selectedSet {}
$this selectionChanged
}
method UserEnvView::editInvertSelection {this} {
set selected [[$this files] selectedSet]
set inverse {}
foreach obj [[$this files] objectSet] {
if {[lsearch $selected $obj] == -1} {
lappend inverse $obj
}
}
[$this files] selectedSet $inverse
$this selectionChanged
}
method UserEnvView::helpOnContext {this} {
set selected [[$this files] selectedSet]
if ![lempty $selected] {
$this helpOnName selectedExtFile
} else {
$this helpOnName repToolUserEnvView
}
}
# Do not delete this line -- regeneration end marker