home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
userenvvie.tcl
< prev
next >
Wrap
Text File
|
1997-11-18
|
15KB
|
552 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)userenvvie.tcl /main/titanic/11
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)userenvvie.tcl /main/titanic/11 18 Nov 1997 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 [$this getFont]
[$this files] selectionChanged "$this selectionChanged"
[$this files] setHeaderLabels [UEnvBrObject::headerLabels]
[$this files] format
ViewPopUpMenu new [$this files].pop -poppedUp {
[.main files].pop entrySet [[.main menuHandler] validPopUpEntrySet]
}
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 ""
set error 0
}
[$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 projectChanged
$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]
set currSel {}
foreach s [$files selectedSet] {
regsub -all {\\} [$s label] {@@@} escapedLabel
lappend currSel $escapedLabel
}
set newSel {}
$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
regsub -all {\\} $path {@@@} escapedPath
if {[lsearch -exact $currSel $escapedPath] != -1} {
lappend newSel $files.file$i
}
incr i
}
$files format
$files selectedSet $newSel
set s [expr {$i == 1 ? "" : "s"}]
$this message "Found $i file$s."
if {$errors != ""} {
$this error $errors
}
}
method UserEnvView::removeFiles {this objects} {
set count 0
set working 0
foreach obj $objects {
set fileV [$obj fileV]
if {[$fileV status] == "working"} {
incr working
}
BasicFS::removeFile [$obj path]
$obj delete
incr count
}
set s [expr {$count == 1 ? "" : "s"}]
set v [expr {$working == 1 ? "was" : "were"}]
$this message "Removed $count file$s of which $working $v working."
}
method UserEnvView::uploadFiles {this objects} {
set count 0
foreach obj $objects {
set fileV [$obj fileV]
if {[$fileV status] == "working"} {
$fileV upLoadWorkingContents
incr count
}
}
set s [expr {$count == 1 ? "" : "s"}]
$this message "Uploaded $count working file$s."
}
method UserEnvView::setFont {this font} {
[$this files] font $font
$this RepToolView::setFont $font
}
method UserEnvView::getFont {this} {
return [m4_var get M4_font -context repuenv]
}
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 "Are you sure you want to delete $what?"
set dlg [YesNoWarningDialog new $this.removeuenvdlg \
-title "Confirm External File Version Delete" \
-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 [YesNoWarningDialog new $this.uploaduenvdlg \
-title "Confirm External File Version Upload" \
-message "Are you sure you to upload the working versions of $what?" \
-yesPressed $script \
-helpPressed "$this helpOnName uploadExtFile"]
$dlg delCancelButton
$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