home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
repunardia.tcl
< prev
next >
Wrap
Text File
|
1997-11-28
|
9KB
|
323 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)repunardia.tcl /main/titanic/13
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)repunardia.tcl /main/titanic/13 28 Nov 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
require "reptooldia.tcl"
Class RepUnarDialog : {RepToolDialog} {
constructor
method destructor
method popUp
method checkOk
method pressedOk
method unarchiveFinished
method browseDirectory
method browseArchive
method browseCommand
method setSource
method setDirectory
method setCommand
method doUnarchive
attribute srcField
attribute cmdField
attribute dirField
attribute dirLabel
attribute shutdownButton
attribute unarchivedDirectory
attribute intoDir
attribute oldDirs
attribute currentRepositoryName
attribute currentRepositoryDir
}
constructor RepUnarDialog {class this name view} {
set this [RepToolDialog::constructor $class $this $name $view]
# Start constructor user section
$this autoPopDown 0
interface DlgColumn $this.c {
Label l {
text "Source"
horStretchFactor 100
}
DlgRow s {
spaceType NONE
horStretchFactor 100
DlgColumn s {
spaceType EVEN
horStretchFactor 100
SingleLineText src {
horStretchFactor 100
columnCount 30
text ""
}
}
DlgColumn b {
spaceType EVEN
horStretchFactor 0
PushButton browse {
horStretchFactor 0
label "Browse..."
}
}
}
Label l { text "Command" }
DlgRow c {
spaceType NONE
horStretchFactor 100
DlgColumn c {
spaceType EVEN
horStretchFactor 100
SingleLineText cmd {
text ""
horStretchFactor 100
columnCount 30
}
}
DlgColumn b {
spaceType EVEN
horStretchFactor 0
PushButton browse {
horStretchFactor 0
label "Browse..."
}
}
}
CheckButton shut {
label "Shutdown dbservers before unarchiving."
state 1
}
Label dirLabel { text "Directory" }
DlgRow r {
spaceType NONE
DlgColumn n {
spaceType EVEN
horStretchFactor 100
SingleLineText dir {
text ""
editable 0
columnCount 30
horStretchFactor 100
}
}
}
Label note {
font times-normal-14
text "Note: the unarchive command runs in this directory."
}
}
$this srcField $this.c.s.s.src
$this cmdField $this.c.c.c.cmd
$this dirLabel $this.c.dirLabel
$this dirField $this.c.r.n.dir
$this shutdownButton $this.c.shut
$this okPressed "$this pressedOk"
[$this srcField] textModified "$this checkOk"
[$this dirField] textModified "$this checkOk"
[$this cmdField] textModified "$this checkOk"
$this.c.s.b.browse activated "$this browseArchive"
$this.c.c.b.browse activated "$this browseCommand"
# End constructor user section
return $this
}
method RepUnarDialog::destructor {this} {
# Start destructor user section
# End destructor user section
$this RepToolDialog::destructor
}
method RepUnarDialog::popUp {this} {
set ctx [string tolower [$this objType]]
[$this cmdField] text [m4_var get M4_unarchive_cmd -context $ctx]
$this checkOk
$this RepToolDialog::popUp
}
method RepUnarDialog::checkOk {this} {
$this okSensitive [expr {
[[$this srcField] text] != "" &&
[[$this cmdField] text] != "" &&
[[$this dirField] text] != ""
}]
}
method RepUnarDialog::pressedOk {this} {
$this busy 1
set ctx [string tolower [$this objType]]
m4_var set M4_unarchive_cmd [[$this cmdField] text] -context $ctx
# Save these values before shutdown for use by subclasses later on.
#
set rep [[$this view] rep]
$this currentRepositoryName [$rep currentName]
if ![[$rep currentCorporate] isNil] {
$this currentRepositoryDir [$rep currentRepDir]
} else {
$this currentRepositoryDir ""
}
if [[$this shutdownButton] state] {
set name [$this currentRepositoryName]
if {$name != "" && ![$rep shutdownDbServers $name]} {
$this busy 0
return
}
}
set dir [Repository::expandDirName [[$this dirField] text]]
if ![file exists $dir] {
set dlg [$this view].createDir
if ![isCommand $dlg] {
QuestionDialog new $dlg \
-title "Create Directory" \
-okPressed "$this doUnarchive 1" \
-cancelPressed "$this busy 0; return"
}
$dlg message "Directory '$dir' does not exist.\nCreate it?"
$dlg delHelpButton
$dlg popUp
return
}
$this doUnarchive 0
}
proc RepUnarDialog::findNewDirs {oldDirs curDirs} {
return [listSubtract $curDirs $oldDirs]
}
method RepUnarDialog::browseDirectory {this} {
set dirBrowser [$this view].dirBrowser
if ![isCommand $dirBrowser] {
RepDirBrowser new $dirBrowser 0 1 \
-title "Select Directory To Store [$this objType] Directory" \
-okPressed "%this handleOk ; $this setDirectory \[%this selected]"
}
$dirBrowser selected [[$this dirField] text]
$dirBrowser popUp
}
method RepUnarDialog::browseArchive {this} {
set archiveBrowser [$this view].unArchiveBrowser
if ![isCommand $archiveBrowser] {
FileChooser new $archiveBrowser \
-selectionPolicy BROWSE \
-title "Select Source Archive" \
-okPressed "$this setSource \[lindex \[%this selectedSet] 0]"
$archiveBrowser delHelpButton
}
set file [Repository::expandFileName [[$this srcField] text]]
Repository::expandDirName [file dir $file] existingDir
$archiveBrowser selectedSet [list $file]
$archiveBrowser directory $existingDir
$archiveBrowser popUp
}
method RepUnarDialog::browseCommand {this} {
set commandBrowser [$this view].commandBrowser
if ![isCommand $commandBrowser] {
FileChooser new $commandBrowser \
-selectionPolicy BROWSE \
-title "Select Unarchive Command" \
-okPressed "$this setCommand \[lindex \[%this selectedSet] 0]"
$commandBrowser delHelpButton
}
set cmdText [[$this cmdField] text]
protect_backslashes {cmdText cmd} { set cmd [lindex $cmdText 0] }
set file [Repository::expandFileName $cmd]
Repository::expandDirName [file dir $file] existingDir
$commandBrowser selectedSet [list $file]
$commandBrowser directory $existingDir
$commandBrowser popUp
}
method RepUnarDialog::setSource {this file} {
[$this srcField] text $file
$this checkOk
}
method RepUnarDialog::setDirectory {this dir} {
[$this dirField] text $dir
$this checkOk
}
method RepUnarDialog::setCommand {this cmd} {
set contents [[$this cmdField] text]
if [lempty $contents] {
set contents $cmd
} else {
protect_backslashes {cmd contents} {
set old [lindex $contents 0]
set oldEnd [string length [quoteIf $old]]
incr oldEnd
set contents "[quoteIf $cmd] [string range $contents $oldEnd end]"
}
}
[$this cmdField] text $contents
$this checkOk
}
method RepUnarDialog::doUnarchive {this {makeDir 0}} {
$this intoDir [Repository::expandDirName [[$this dirField] text]]
if $makeDir {
if [catch {BasicFS::makeDir [$this intoDir]} error] {
$this busy 0
error $error
return
}
}
$this oldDirs [BasicFS::readDir [$this intoDir]]
if ![$this unarchive] {
$this busy 0
}
}
method RepUnarDialog::unarchiveFinished {this exitCode} {
$this busy 0
if {$exitCode == 0} {
$this popDown
[$this view] message "Unarchived [$this objDescription] successfully."
} else {
[$this view] message "Failed to unarchive [$this objDescription]."
}
set dir [Repository::expandDirName [[$this dirField] text]]
set curDirs [BasicFS::readDir [$this intoDir]]
set newDirs [RepUnarDialog::findNewDirs [$this oldDirs] $curDirs]
if {[llength $newDirs] > 1} {
[$this view] warning "Found more than one new directory after\
unarchiving, using first one ('[lindex $newDirs 0]')."
}
if ![lempty $newDirs] {
$this unarchivedDirectory [location [$this intoDir] [lindex $newDirs 0]]
}
}
# Do not delete this line -- regeneration end marker