home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)reparchdia.tcl /main/titanic/13
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)reparchdia.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 RepArchDialog : {RepToolDialog} {
- constructor
- method destructor
- method popUp
- method checkOk
- method pressedOk
- method archiveFinished
- method browseDirectory
- method browseArchive
- method browseCommand
- method setDirectory
- method setDestination
- method setCommand
- method dumpDirectory
- method dumpedObject
- attribute dirLabel
- attribute dirField
- attribute dstField
- attribute cmdField
- attribute shutdownButton
- attribute currentRepositoryName
- attribute currentRepositoryDir
- }
-
- constructor RepArchDialog {class this name view} {
- set this [RepToolDialog::constructor $class $this $name $view]
- # Start constructor user section
-
- $this autoPopDown 0
-
- interface DlgColumn $this.c {
- Label dirLabel { text "Directory" }
- DlgRow r {
- spaceType NONE
- DlgColumn n {
- spaceType EVEN
- horStretchFactor 100
- SingleLineText dir {
- text ""
- columnCount 30
- horStretchFactor 100
- }
- }
- DlgColumn b {
- spaceType EVEN
- horStretchFactor 0
- PushButton browse {
- horStretchFactor 0
- label "Browse..."
- }
- }
- }
- Label note {
- font times-normal-14
- text "Note: the archive command runs in the parent directory\
- of this."
- }
- CheckButton shut {
- label "Shutdown dbservers before archiving."
- state 1
- }
- Label l { text "Destination" }
- DlgRow d {
- spaceType NONE
- DlgColumn r {
- spaceType EVEN
- horStretchFactor 100
- SingleLineText dst {
- text ""
- columnCount 40
- horStretchFactor 100
- }
- }
- 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..."
- }
- }
- }
- }
-
- $this dirLabel $this.c.dirLabel
- $this dirField $this.c.r.n.dir
- $this dstField $this.c.d.r.dst
- $this cmdField $this.c.c.c.cmd
- $this shutdownButton $this.c.shut
-
- $this okPressed "$this pressedOk"
- [$this dirField] editable 0
- [$this dirField] textModified "$this checkOk"
- [$this cmdField] textModified "$this checkOk"
- $this.c.r.b.browse activated "$this browseDirectory"
- $this.c.d.b.browse activated "$this browseArchive"
- $this.c.c.b.browse activated "$this browseCommand"
-
- set repDir [[$view rep] lastRepDir]
- $this setDirectory $repDir
- [$this dstField] text [Repository::defaultDumpFile $repDir]
-
- # End constructor user section
- return $this
- }
-
- method RepArchDialog::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this RepToolDialog::destructor
- }
-
- method RepArchDialog::popUp {this} {
- set ctx [string tolower [$this objType]]
- [$this cmdField] text [m4_var get M4_archive_cmd -context $ctx]
-
- set dumpDir [$this dumpDirectory]
- if {$dumpDir != ""} {
- $this setDirectory $dumpDir
- [$this dstField] text [Repository::defaultDumpFile $dumpDir]
- }
-
- $this checkOk
- $this RepToolDialog::popUp
- }
-
- method RepArchDialog::checkOk {this} {
- $this okSensitive [expr {
- [[$this dirField] text] != "" &&
- [[$this dstField] text] != "" &&
- [[$this cmdField] text] != ""
- }]
- }
-
- method RepArchDialog::pressedOk {this} {
- $this busy 1
-
- set ctx [string tolower [$this objType]]
- m4_var set M4_archive_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
- }
- }
-
- if ![$this archive] {
- $this busy 0
- }
- }
-
- method RepArchDialog::archiveFinished {this exitCode} {
- $this busy 0
- if {$exitCode == 0} {
- $this popDown
- [$this view] message "Archived [$this objDescription] successfully."
- } else {
- [$this view] message "Failed to archive [$this objDescription]."
- }
- }
-
- method RepArchDialog::browseDirectory {this} {
- set dirBrowser [$this view].dirBrowser
- if ![isCommand $dirBrowser] {
- RepDirBrowser new $dirBrowser 0 1 \
- -title "Select [$this objType] Directory" \
- -okPressed "%this handleOk ; $this setDirectory \[%this selected]"
- }
-
- $dirBrowser selected [[$this dirField] text]
- $dirBrowser popUp
- }
-
- method RepArchDialog::browseArchive {this} {
- set archiveBrowser [$this view].archiveBrowser
- if ![isCommand $archiveBrowser] {
- FileChooser new $archiveBrowser \
- -selectionPolicy BROWSE \
- -title "Select Destination Archive" \
- -okPressed "$this setDestination \[lindex \[%this selectedSet] 0]"
- $archiveBrowser delHelpButton
- }
-
- set file [Repository::expandFileName [[$this dstField] text]]
- Repository::expandDirName [file dir $file] existingDir
-
- $archiveBrowser selectedSet [list $file]
- $archiveBrowser directory $existingDir
- $archiveBrowser popUp
- }
-
- method RepArchDialog::browseCommand {this} {
- set commandBrowser [$this view].commandBrowser
- if ![isCommand $commandBrowser] {
- FileChooser new $commandBrowser \
- -selectionPolicy BROWSE \
- -title "Select Archive 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 RepArchDialog::setDirectory {this dir} {
- [$this dirField] text $dir
- $this checkOk
- }
-
- method RepArchDialog::setDestination {this file} {
- [$this dstField] text $file
- $this checkOk
- }
-
- method RepArchDialog::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 RepArchDialog::dumpDirectory {this} {
- set type [$this objType]
- set view [$this view]
- set dumpDialog $view.RepDump${type}Dialog
- if [isCommand $dumpDialog] {
- return [$dumpDialog dumpDirectory]
- }
- return ""
- }
-
- method RepArchDialog::dumpedObject {this} {
- set type [$this objType]
- set view [$this view]
- set dumpDialog $view.RepDump${type}Dialog
- if [isCommand $dumpDialog] {
- return [$dumpDialog dumpedObject]
- }
- return [ORB::nil]
- }
-
- # Do not delete this line -- regeneration end marker
-
-