home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1996
- #
- # File: @(#)repdeleted.tcl /main/titanic/15
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)repdeleted.tcl /main/titanic/15 28 Nov 1997 Copyright 1996 Cayenne Software Inc.
-
- # Start user added include file section
- require "repository.tcl"
- # End user added include file section
-
- require "repdbdialo.tcl"
-
- Class RepDeleteDialog : {RepDbDialog} {
- constructor
- method destructor
- method doDelete
- method popUp
- method checkOk
- method ok
- attribute parts
- }
-
- constructor RepDeleteDialog {class this name view} {
- set this [RepDbDialog::constructor $class $this $name $view]
- # Start constructor user section
-
- set rep [[$this view] rep]
- set corp [$rep currentCorporate]
- set name [$rep currentName]
-
- $this config \
- -title "Delete Repository '$name'" \
- -okPressed { busy { %this ok } } \
- -helpPressed { [%this view] helpOnName deleteRepository }
-
- interface DlgColumn $this.gui {
- verStretchFactor 0
- NamedGroup delete {
- label "Delete Repository"
- DlgColumn c {
- verStretchFactor 0
- CheckButton dir {
- label "Directory"
- state 1
- }
- CheckButton db {
- label "Database"
- state 1
- }
- CheckButton entry {
- label "Server Entry"
- state 1
- }
- }
- }
- CheckButton shut {
- label "Shutdown dbservers before deletion."
- state 1
- }
- NamedGroup db {
- label "Database"
- DlgColumn attr {
- verStretchFactor 0
- }
- }
- }
-
- $this parts $this.gui.delete.c
- [$this parts].db stateChanged "$this checkOk"
- [$this parts].dir stateChanged "$this checkOk"
- [$this parts].entry stateChanged "$this checkOk"
-
- $this createDbInterface $this.gui.db.attr
- $this setDbFields
- $this setupForPassword
-
- # End constructor user section
- return $this
- }
-
- method RepDeleteDialog::destructor {this} {
- # Start destructor user section
- # End destructor user section
- $this RepDbDialog::destructor
- }
-
- method RepDeleteDialog::doDelete {this db dir entry} {
- set rep [[$this view] rep]
- set name [$rep currentName]
- set corp [$rep currentCorporate]
-
- if {[$this.gui.shut state] && ![$rep shutdownDbServers $name]} {
- [$this view] message "Repository not deleted."
- return
- }
-
- set dirError 0
- if $dir {
- if [$corp isNil] {
- set dirError 1
- [$this view] warning \
- "Repository could not be accessed. Directory not deleted."
- } else {
- set loc [path_name concat [$corp location] $name]
- if $win95 {
- regsub -all {/} $loc {\\} loc
- }
- [$this view] message "Deleting repository directory '$loc' ..."
- if [$rep deleteRepositoryDir] {
- [$this parts].dir state 0
- [$this view] message \
- "Repository directory '$loc' deleted successfully."
- } else {
- set dirError 1
- [$this view] message \
- "Repository directory '$loc' not deleted."
- }
- }
- }
-
- set dbError 0
- if $db {
- if [$this getDbFields cmdInfo] {
- set database $cmdInfo(dbname)
- [$this view] message "Deleting database '$database' ..."
- if [$rep deleteRepositoryDb cmdInfo] {
- [$this parts].db state 0
- [$this view] message \
- "Database '$database' deleted successfully."
- } else {
- set dbError 1
- [$this view] message \
- "Database '$database' not deleted."
- }
- } else {
- set dbError 1
- [$this view] message \
- "Database not deleted."
- }
- }
-
- if {$entry && !$dbError && !$dirError} {
- [$this view] message "Deleting server entry of '$name' ..."
- if [$rep deleteServerEntry] {
- [$this view] message \
- "Server entry of '$name' deleted successfully."
- [$this view] updateRepositories
- [$this view] selectRepository ""
- [$this view] viewRefresh
- } else {
- [$this view] message \
- "Server entry of '$name' not deleted."
- }
- }
- }
-
- method RepDeleteDialog::popUp {this} {
- $this checkOk
- $this RepDbDialog::popUp
- }
-
- method RepDeleteDialog::checkOk {this} {
- set corp [[[$this view] rep] currentCorporate]
- if {[$corp isNil] && [[$this parts].dir state] && ![$this passwordOk]} {
- $this okSensitive 0
- return
- }
-
- if {[[$this parts].db state] && ![$this passwordOk]} {
- $this okSensitive 0
- return
- }
-
- if {![[$this parts].db state] &&
- ![[$this parts].dir state] &&
- ![[$this parts].entry state]} {
- $this okSensitive 0
- return
- }
-
- $this okSensitive 1
- }
-
- method RepDeleteDialog::ok {this} {
- set rep [[$this view] rep]
- set corp [$rep currentCorporate]
- set name [$rep currentName]
-
- set db [[$this parts].db state]
- set dir [[$this parts].dir state]
- set entry [[$this parts].entry state]
-
- if {$db || $dir} {
- if ![$this getDbFields cmdInfo] {
- return
- }
- set database $cmdInfo(dbname)
- }
-
- set what ""
- if $dir {
- set location ""
- if ![$corp isNil] {
- set location [path_name concat [$corp location] [$corp name]]
- } else {
- if [$rep getInfoFromDatabase cmdInfo $database dbInfo] {
- set location [path_name concat $dbInfo(location) $dbInfo(name)]
- } else {
- set location ""
- }
- }
- if $win95 {
- regsub -all {/} $location {\\} location
- }
- if {$location != ""} {
- append what "\n - directory '$location'"
- }
- }
- if $db {
- append what "\n - database '$database'"
- }
- if $entry {
- append what "\n - server entry of '$name'"
- }
- if {$what == ""} {
- set dlg [InfoDialog new [$this view].delinfodlg \
- -title "Repository Delete" \
- -message "Nothing to delete." \
- -okPressed { %this delete }]
- $dlg delHelpButton
- $dlg popUp
- return
- }
-
- set msg "This action will cause loss of data if\n"
- append msg "the repository is not backed up first!\n\n"
- append msg "Are you sure you want to delete $what?"
-
- set dlg [YesNoWarningDialog new [$this view].deleterepconfirm \
- -title "Confirm Repository Delete" \
- -message $msg \
- -yesPressed "busy { $this doDelete $db $dir $entry }"]
-
- $dlg delCancelButton
- $dlg delHelpButton
- $dlg popUp
- }
-
- # Do not delete this line -- regeneration end marker
-
-