home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / komix / DATA.Z / repdeleted.tcl < prev    next >
Text File  |  1997-11-28  |  7KB  |  255 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1996
  4. #
  5. #      File:           @(#)repdeleted.tcl    /main/titanic/15
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)repdeleted.tcl    /main/titanic/15   28 Nov 1997 Copyright 1996 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12. require "repository.tcl"
  13. # End user added include file section
  14.  
  15. require "repdbdialo.tcl"
  16.  
  17. Class RepDeleteDialog : {RepDbDialog} {
  18.     constructor
  19.     method destructor
  20.     method doDelete
  21.     method popUp
  22.     method checkOk
  23.     method ok
  24.     attribute parts
  25. }
  26.  
  27. constructor RepDeleteDialog {class this name view} {
  28.     set this [RepDbDialog::constructor $class $this $name $view]
  29.     # Start constructor user section
  30.  
  31.         set rep [[$this view] rep]
  32.         set corp [$rep currentCorporate]
  33.         set name [$rep currentName]
  34.  
  35.         $this config \
  36.             -title "Delete Repository '$name'" \
  37.             -okPressed { busy { %this ok } } \
  38.             -helpPressed { [%this view] helpOnName deleteRepository }
  39.  
  40.         interface DlgColumn $this.gui {
  41.         verStretchFactor 0
  42.             NamedGroup delete {
  43.                 label "Delete Repository"
  44.                 DlgColumn c {
  45.             verStretchFactor 0
  46.                     CheckButton dir {
  47.                         label "Directory"
  48.                         state 1
  49.                     }
  50.                     CheckButton db {
  51.                         label "Database"
  52.                         state 1
  53.                     }
  54.                     CheckButton entry {
  55.                         label "Server Entry"
  56.                         state 1
  57.                     }
  58.                 }
  59.             }
  60.         CheckButton shut {
  61.         label "Shutdown dbservers before deletion."
  62.         state 1
  63.         }
  64.             NamedGroup db {
  65.                 label "Database"
  66.                 DlgColumn attr {
  67.             verStretchFactor 0
  68.                 }
  69.             }
  70.         }
  71.  
  72.         $this parts $this.gui.delete.c
  73.         [$this parts].db stateChanged "$this checkOk"
  74.         [$this parts].dir stateChanged "$this checkOk"
  75.         [$this parts].entry stateChanged "$this checkOk"
  76.  
  77.         $this createDbInterface $this.gui.db.attr
  78.         $this setDbFields
  79.         $this setupForPassword
  80.  
  81.     # End constructor user section
  82.     return $this
  83. }
  84.  
  85. method RepDeleteDialog::destructor {this} {
  86.     # Start destructor user section
  87.     # End destructor user section
  88.     $this RepDbDialog::destructor
  89. }
  90.  
  91. method RepDeleteDialog::doDelete {this db dir entry} {
  92.     set rep [[$this view] rep]
  93.     set name [$rep currentName]
  94.     set corp [$rep currentCorporate]
  95.  
  96.     if {[$this.gui.shut state] && ![$rep shutdownDbServers $name]} {
  97.     [$this view] message "Repository not deleted."
  98.         return
  99.     }
  100.  
  101.     set dirError 0
  102.     if $dir {
  103.         if [$corp isNil] {
  104.         set dirError 1
  105.         [$this view] warning \
  106.         "Repository could not be accessed.  Directory not deleted."
  107.         } else {
  108.         set loc [path_name concat [$corp location] $name]
  109.         if $win95 {
  110.         regsub -all {/} $loc {\\} loc
  111.         }
  112.         [$this view] message "Deleting repository directory '$loc' ..."
  113.         if [$rep deleteRepositoryDir] {
  114.         [$this parts].dir state 0
  115.         [$this view] message \
  116.             "Repository directory '$loc' deleted successfully."
  117.         } else {
  118.         set dirError 1
  119.         [$this view] message \
  120.             "Repository directory '$loc' not deleted."
  121.         }
  122.         }
  123.     }
  124.  
  125.     set dbError 0
  126.     if $db {
  127.         if [$this getDbFields cmdInfo] {
  128.         set database $cmdInfo(dbname)
  129.             [$this view] message "Deleting database '$database' ..."
  130.         if [$rep deleteRepositoryDb cmdInfo] {
  131.         [$this parts].db state 0
  132.         [$this view] message \
  133.             "Database '$database' deleted successfully."
  134.             } else {
  135.         set dbError 1
  136.         [$this view] message \
  137.             "Database '$database' not deleted."
  138.             }
  139.         } else {
  140.         set dbError 1
  141.             [$this view] message \
  142.                 "Database not deleted."
  143.         }
  144.     }
  145.  
  146.     if {$entry && !$dbError && !$dirError} {
  147.     [$this view] message "Deleting server entry of '$name' ..."
  148.         if [$rep deleteServerEntry] {
  149.             [$this view] message \
  150.                 "Server entry of '$name' deleted successfully."
  151.         [$this view] updateRepositories
  152.         [$this view] selectRepository ""
  153.         [$this view] viewRefresh
  154.         } else {
  155.             [$this view] message \
  156.                 "Server entry of '$name' not deleted."
  157.         }
  158.     }
  159. }
  160.  
  161. method RepDeleteDialog::popUp {this} {
  162.     $this checkOk
  163.     $this RepDbDialog::popUp
  164. }
  165.  
  166. method RepDeleteDialog::checkOk {this} {
  167.     set corp [[[$this view] rep] currentCorporate]
  168.     if {[$corp isNil] && [[$this parts].dir state] && ![$this passwordOk]} {
  169.         $this okSensitive 0
  170.         return
  171.     }
  172.  
  173.     if {[[$this parts].db state] && ![$this passwordOk]} {
  174.         $this okSensitive 0
  175.         return
  176.     }
  177.  
  178.     if {![[$this parts].db state] &&
  179.     ![[$this parts].dir state] &&
  180.     ![[$this parts].entry state]} {
  181.         $this okSensitive 0
  182.         return
  183.     }
  184.  
  185.     $this okSensitive 1
  186. }
  187.  
  188. method RepDeleteDialog::ok {this} {
  189.     set rep [[$this view] rep]
  190.     set corp [$rep currentCorporate]
  191.     set name [$rep currentName]
  192.  
  193.     set db [[$this parts].db state]
  194.     set dir [[$this parts].dir state]
  195.     set entry [[$this parts].entry state]
  196.  
  197.     if {$db || $dir} {
  198.     if ![$this getDbFields cmdInfo] {
  199.         return
  200.     }
  201.     set database $cmdInfo(dbname)
  202.     }
  203.  
  204.     set what ""
  205.     if $dir {
  206.     set location ""
  207.     if ![$corp isNil] {
  208.         set location [path_name concat [$corp location] [$corp name]]
  209.     } else {
  210.         if [$rep getInfoFromDatabase cmdInfo $database dbInfo] {
  211.         set location [path_name concat $dbInfo(location) $dbInfo(name)]
  212.         } else {
  213.         set location ""
  214.         }
  215.         }
  216.         if $win95 {
  217.         regsub -all {/} $location {\\} location
  218.         }
  219.         if {$location != ""} {
  220.         append what "\n    - directory '$location'"
  221.         }
  222.     }
  223.     if $db {
  224.     append what "\n    - database '$database'"
  225.     }
  226.     if $entry {
  227.     append what "\n    - server entry of '$name'"
  228.     }
  229.     if {$what == ""} {
  230.         set dlg [InfoDialog new [$this view].delinfodlg \
  231.             -title "Repository Delete" \
  232.             -message "Nothing to delete." \
  233.             -okPressed { %this delete }]
  234.         $dlg delHelpButton
  235.         $dlg popUp
  236.         return
  237.     }
  238.  
  239.     set msg "This action will cause loss of data if\n"
  240.     append msg "the repository is not backed up first!\n\n"
  241.     append msg "Are you sure you want to delete $what?"
  242.  
  243.     set dlg [YesNoWarningDialog new [$this view].deleterepconfirm \
  244.         -title "Confirm Repository Delete" \
  245.         -message $msg \
  246.         -yesPressed "busy { $this doDelete $db $dir $entry }"]
  247.  
  248.     $dlg delCancelButton
  249.     $dlg delHelpButton
  250.     $dlg popUp
  251. }
  252.  
  253. # Do not delete this line -- regeneration end marker
  254.  
  255.