home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
represtore.tcl
< prev
next >
Wrap
Text File
|
1997-05-13
|
10KB
|
350 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)represtore.tcl /main/hindenburg/18
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)represtore.tcl /main/hindenburg/18 13 May 1997 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
# End user added include file section
require "repdbdialo.tcl"
Class RepRestoreDialog : {RepDbDialog} {
constructor
method destructor
method popUp
method ok
method checkOk
method restoreFinished
method shutdownServers
method browseDir
method browseArchive
attribute name
attribute dir
attribute unarchiveCmd
attribute unarchiveButton
attribute unarchiveSrc
attribute archiveBrowser
attribute dirBrowser
}
constructor RepRestoreDialog {class this name view} {
set this [RepDbDialog::constructor $class $this $name $view]
# Start constructor user section
set rep [[$this view] rep]
set name [$rep currentName]
$this config \
-title "Restore Repository" \
-okPressed { busy { %this ok } } \
-helpPressed { [%this view] helpOnName restoreRepository }
interface DlgColumn $this.gui {
verStretchFactor 0
DlgColumn name {
Label l { text "Corporate Name" }
SingleLineText name {
columnCount 30
}
}
DlgColumn dir {
Label l {
text "Directory in which to restore repository"
alignment LEFT
horStretchFactor 100
}
DlgRow r {
spaceType NONE
DlgColumn d {
spaceType EVEN
horStretchFactor 100
SingleLineText dir {
columnCount 30
horStretchFactor 100
}
}
}
}
NamedGroup options {
label "Options"
DlgColumn options {
CheckButton register {
label "Register Implementation"
state 0
}
CheckButton overwrite {
label "Overwrite Existing Database"
state 0
}
}
}
NamedGroup unarchive {
label "Unarchive"
DlgColumn c {
CheckButton unarchive {
label "Unarchive Dump"
state 1
}
DlgColumn src {
Label l {
text "Source File"
horStretchFactor 100
}
DlgRow r {
spaceType NONE
DlgColumn d {
spaceType EVEN
horStretchFactor 100
SingleLineText src {
columnCount 30
horStretchFactor 100
}
}
DlgColumn b {
spaceType EVEN
horStretchFactor 0
PushButton browse {
horStretchFactor 0
label "Browse..."
}
}
}
}
DlgColumn cmd {
Label l {
text "Command to unarchive repository archive"
}
SingleLineText cmd {
columnCount 30
}
}
}
}
NamedGroup db {
label "Database to create/overwrite"
DlgColumn attr {
verStretchFactor 0
}
}
}
if !$win95 {
interface DlgColumn $this.gui.dir.r.b {
spaceType EVEN
horStretchFactor 0
PushButton browse {
horStretchFactor 0
label "Browse..."
}
}
$this.gui.dir.r.b.browse activated "$this browseDir"
}
PushButton new $this.shutdown \
-label "Shutdown" \
-activated "busy { $this shutdownServers }"
$this name $this.gui.name.name
[$this name] textModified "$this checkOk"
$this dir $this.gui.dir.r.d.dir
[$this dir] textModified "$this checkOk"
set a $this.gui.unarchive.c
$this unarchiveButton $a.unarchive
$this unarchiveCmd $a.cmd.cmd
$this unarchiveSrc $a.src.r.d.src
set unarchiveBrowse $a.src.r.b.browse
$unarchiveBrowse activated "$this browseArchive"
[$this unarchiveCmd] textModified "$this checkOk"
[$this unarchiveButton] stateChanged "
[$this unarchiveCmd] sensitive \[%this state]
[$this unarchiveSrc] sensitive \[%this state]
$unarchiveBrowse sensitive \[%this state]
$this checkOk
"
$this createDbInterface $this.gui.db.attr 30
$this setDbFields
[$this dbname] textModified "$this checkOk"
# Initialize some fields, but only when first created.
#
set corp [[[$this view] rep] currentCorporate]
if [$corp isNil] {
$this.gui.options.options.register state 1
$this.gui.options.options.overwrite state 0
} else {
[$this name] text [$corp name]
[$this dir] text [$corp location]
$this.gui.options.options.register state 0
$this.gui.options.options.overwrite state 1
}
# End constructor user section
return $this
}
method RepRestoreDialog::destructor {this} {
# Start destructor user section
# End destructor user section
$this RepDbDialog::destructor
}
method RepRestoreDialog::popUp {this} {
[$this unarchiveCmd] text [m4_var get M4_unarchive_cmd]
# Set sensitivity of "OK" and "Shutdown" buttons.
$this checkOk
$this RepDbDialog::popUp
}
method RepRestoreDialog::ok {this} {
m4_var set M4_unarchive_cmd [[$this unarchiveCmd] text]
if ![$this getDbFields cmdInfo] {
[$this view] message "Repository not restored."
return
}
set rep [[$this view] rep]
set name [[$this name] text]
if {[string length $name] == 0} {
[$this view] error "No repository name specified."
[$this view] message "Repository not restored."
return
}
set dir [Repository::expandDirName [[$this dir] text]]
if {[string length $dir] == 0} {
[$this view] error "No repository directory specified."
[$this view] message "Repository not restored."
return
}
if ![file exists $dir] {
set dlg [QuestionDialog new [$this view].createdir \
-title "Create Directory" \
-message "Repository directory '$dir' does not\
exist.\nCreate it?" \
-okPressed "BasicFS::makeDir $dir; $this ok" \
-cancelPressed "return"]
$dlg delHelpButton
$dlg popUp
return
}
set options ""
if [$this.gui.options.options.register state] {
append options " -i"
}
if [$this.gui.options.options.overwrite state] {
append options " -o"
}
set unarchive [[$this unarchiveButton] state]
if $unarchive {
set src [Repository::expandFileName [[$this unarchiveSrc] text]]
set cmd [[$this unarchiveCmd] text]
if {[string length $cmd] == 0} {
[$this view] error "No unarchive command specified."
[$this view] message "Repository not restored."
return
}
} else {
set src ""
set cmd ""
}
$rep restoreRepository "$this restoreFinished" cmdInfo \
$options $name $dir {} $unarchive $src
}
method RepRestoreDialog::checkOk {this} {
if {[string length [[$this name] text]] > 0} {
$this.shutdown sensitive 1
} else {
$this.shutdown sensitive 0
}
if {[string length [[$this name] text]] > 0 &&
[string length [[$this dir] text]] > 0 &&
[string length [[$this dbname] text]] > 0 &&
[$this passwordOk]} {
if {[[$this unarchiveButton] state] &&
[string length [[$this unarchiveCmd] text]] == 0} {
$this okSensitive 0
} else {
$this okSensitive 1
}
} else {
$this okSensitive 0
}
}
method RepRestoreDialog::restoreFinished {this exitCode} {
set rep [[$this view] rep]
set name [[$this name] text]
if {$exitCode == 0} {
[$this view] updateRepositories
[$this view] viewRefresh
[$this view] message "Restored repository '$name' successfully."
} else {
[$this view] message "Restore of repository '$name' failed."
}
}
method RepRestoreDialog::shutdownServers {this} {
set rep [[$this view] rep]
set name [[$this name] text]
$rep shutdownDbServers $name
}
method RepRestoreDialog::browseDir {this} {
if {[$this dirBrowser] == ""} {
$this dirBrowser [FileChooser new [$this view].dirbrowser \
-selectionPolicy SINGLE \
-title "Select Parent Repository Directory" \
-okPressed "[$this dir] text \[%this directory]"]
[$this dirBrowser] delHelpButton
}
set dir [Repository::expandDirName [[$this dir] text] existingDir]
[$this dirBrowser] selectedSet $dir
[$this dirBrowser] directory $existingDir
[$this dirBrowser] popUp
}
method RepRestoreDialog::browseArchive {this} {
if {[$this archiveBrowser] == ""} {
$this archiveBrowser [FileChooser new [$this view].archivebrowser \
-selectionPolicy SINGLE \
-title "Select Destination Archive" \
-okPressed \
"[$this unarchiveSrc] text \[lindex \[%this selectedSet] 0]"]
[$this archiveBrowser] delHelpButton
}
set file [Repository::expandFileName [[$this unarchiveSrc] text]]
Repository::expandDirName [file dir $file] existingDir
[$this archiveBrowser] selectedSet $file
[$this archiveBrowser] directory $existingDir
[$this archiveBrowser] popUp
}
# Do not delete this line -- regeneration end marker