home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1996
- #
- # File: @(#)repbackupd.tcl /main/hindenburg/15
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)repbackupd.tcl /main/hindenburg/15 29 Nov 1996 Copyright 1996 Cayenne Software Inc.
-
- # Start user added include file section
- require "repository.tcl"
- # End user added include file section
-
- require "repdbdialo.tcl"
-
- Class RepBackupDialog : {RepDbDialog} {
- constructor
- method destructor
- method popUp
- method ok
- method checkOk
- method backupFinished
- method shutdownServers
- method browseArchive
- attribute archiveBrowser
- attribute archiveButton
- attribute archiveCmd
- attribute archiveDst
- attribute dumpButton
- }
-
- constructor RepBackupDialog {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]
- set corp [$rep currentCorporate]
-
- $this config \
- -title "Backup Repository '$name'" \
- -okPressed { busy { %this ok } } \
- -helpPressed { [%this view] helpOnName backupRepository }
-
- interface DlgColumn $this.gui {
- verStretchFactor 0
- NamedGroup backup {
- label "Backup"
- DlgColumn c {
- CheckButton dump {
- label "Dump Database"
- state 1
- }
- CheckButton archive {
- label "Archive Repository Directory"
- state 1
- }
- DlgColumn dst {
- Label l {
- text "Destination File"
- horStretchFactor 100
- }
- DlgRow r {
- spaceType NONE
- DlgColumn d {
- spaceType EVEN
- horStretchFactor 100
- SingleLineText dst {
- columnCount 30
- horStretchFactor 100
- }
- }
- DlgColumn b {
- spaceType EVEN
- horStretchFactor 0
- PushButton browse {
- label "Browse..."
- horStretchFactor 0
- }
- }
- }
- }
- DlgColumn cmd {
- Label l {
- text "Command to archive repository directory"
- }
- SingleLineText cmd {
- columnCount 30
- }
- }
- }
- }
- NamedGroup db {
- label "Database"
- DlgColumn attr {
- verStretchFactor 0
- }
- }
- }
-
- PushButton new $this.shutdown \
- -label "Shutdown" \
- -activated "busy { $this shutdownServers }"
-
- set a $this.gui.backup.c
- $this dumpButton $a.dump
- $this archiveButton $a.archive
- $this archiveCmd $a.cmd.cmd
- $this archiveDst $a.dst.r.d.dst
- set archiveBrowse $a.dst.r.b.browse
-
- [$this dumpButton] stateChanged "$this checkOk"
- [$this archiveCmd] textModified "$this checkOk"
- [$this archiveButton] stateChanged "
- [$this archiveCmd] sensitive \[%this state]
- [$this archiveDst] sensitive \[%this state]
- $archiveBrowse sensitive \[%this state]
- $this checkOk
- "
- $archiveBrowse activated "$this browseArchive"
-
- # Default destination archive: repository name with
- # "_backup" appended.
- #
- set dst [path_name concat [$corp location] ${name}_backup]
- [$this archiveDst] text $dst
-
- $this createDbInterface $this.gui.db.attr 30
- $this setDbFields
- $this setupForPassword
-
- # End constructor user section
- return $this
- }
-
- method RepBackupDialog::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this RepDbDialog::destructor
- }
-
- method RepBackupDialog::popUp {this} {
- [$this archiveCmd] text [m4_var get M4_archive_cmd]
- $this checkOk
- $this RepDbDialog::popUp
- }
-
- method RepBackupDialog::ok {this} {
- m4_var set M4_archive_cmd [[$this archiveCmd] text]
-
- if ![$this getDbFields cmdInfo] {
- [$this view] message "Repository not backed up."
- return
- }
-
- set rep [[$this view] rep]
- set name [$rep currentName]
-
- set dump [[$this dumpButton] state]
- set archive [[$this archiveButton] state]
-
- if $archive {
- set dst [Repository::expandDirName [[$this archiveDst] text]]
- set cmd [[$this archiveCmd] text]
- if {[string length $cmd] == 0} {
- [$this view] error "No archive command specified."
- [$this view] message "Repository not backed up."
- return
- }
- } else {
- set dst ""
- set cmd ""
- }
-
- if $dump {
- $rep backupRepository "$this backupFinished" cmdInfo \
- {} $name {} $archive $dst
- } elseif $archive {
- $rep archiveRepository "$this backupFinished" $dst
- } else {
- [$this view] warning "Nothing to backup."
- [$this view] message "Repository not backed up."
- }
- }
-
- method RepBackupDialog::checkOk {this} {
- if {[[$this dumpButton] state] || [[$this archiveButton] state]} {
- if {[[$this archiveButton] state] &&
- [string length [[$this archiveCmd] text]] == 0} {
- $this okSensitive 0
- } elseif {[[$this dumpButton] state] &&
- ![$this passwordOk]} {
- $this okSensitive 0
- } else {
- $this okSensitive 1
- }
- } else {
- $this okSensitive 0
- }
- }
-
- method RepBackupDialog::backupFinished {this exitCode} {
- set rep [[$this view] rep]
- set name [$rep currentName]
-
- if {$exitCode == 0} {
- [$this view] message "Backed up repository '$name' successfully."
- } else {
- [$this view] message "Backup of repository '$name' failed."
- }
- }
-
- method RepBackupDialog::shutdownServers {this} {
- set rep [[$this view] rep]
- set name [$rep currentName]
-
- $rep shutdownDbServers $name
- }
-
- method RepBackupDialog::browseArchive {this} {
- if {[$this archiveBrowser] == ""} {
- $this archiveBrowser [FileChooser new [$this view].archivebrowser \
- -selectionPolicy SINGLE \
- -title "Select Destination Archive" \
- -okPressed \
- "[$this archiveDst] text \[lindex \[%this selectedSet] 0]"]
- [$this archiveBrowser] delHelpButton
- }
-
- set file [Repository::expandFileName [[$this archiveDst] 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
-
-