home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / repoptimdi.tcl < prev    next >
Text File  |  1997-01-08  |  5KB  |  181 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1996
  4. #
  5. #      File:           @(#)repoptimdi.tcl    /main/hindenburg/7
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)repoptimdi.tcl    /main/hindenburg/7   8 Jan 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 RepOptimDialog : {RepDbDialog} {
  18.     constructor
  19.     method destructor
  20.     method popUp
  21.     method checkOk
  22.     method ok
  23.     method optimizeFinished
  24.     attribute projects
  25. }
  26.  
  27. constructor RepOptimDialog {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 "Optimize Repository '$name'" \
  37.             -okPressed { busy { %this ok } } \
  38.         -helpPressed { [%this view] helpOnName optimizeRepository }
  39.  
  40.         interface DlgColumn $this.gui {
  41.         verStretchFactor 0
  42.             NamedGroup options {
  43.                 label "Options"
  44.                 DlgRow r {
  45.             DlgColumn l {
  46.             verStretchFactor 0
  47.             CheckButton corp {
  48.                 label "Corporate"
  49.                 state 1
  50.             }
  51.             CheckButton all {
  52.                 label "All Projects"
  53.                 state 1
  54.             }
  55.             }
  56.             DlgColumn r {
  57.             verStretchFactor 0
  58.             CheckButton drop {
  59.                 label "Drop Indices"
  60.                 state 0
  61.             }
  62.             CheckButton create {
  63.                 label "Create Indices"
  64.                 state 0
  65.             }
  66.             CheckButton template {
  67.                 label "Template Optimizations"
  68.                 state 1
  69.             }
  70.             }
  71.                 }
  72.             }
  73.             NamedGroup projects {
  74.                 label "Projects"
  75.         TextList list {
  76.             verStretchFactor 100
  77.             selectionPolicy EXTENDED
  78.             rowCount 5
  79.                 }
  80.             }
  81.             NamedGroup db {
  82.                 label "Database"
  83.                 DlgColumn attr {
  84.             verStretchFactor 0
  85.                 }
  86.             }
  87.         }
  88.  
  89.         $this projects $this.gui.projects.list
  90.  
  91.         if ![$corp isNil] {
  92.         [$this projects] entrySet [lsort [query -s name [$corp projects]]]
  93.         }
  94.  
  95.         [$this projects] selectionChanged "
  96.             $this.gui.options.r.l.all state 0
  97.             $this checkOk"
  98.  
  99.         $this.gui.options.r.l.corp stateChanged "
  100.             $this checkOk"
  101.  
  102.         $this.gui.options.r.l.all stateChanged "
  103.             [$this projects] selectedSet {}
  104.             $this checkOk"
  105.  
  106.         $this createDbInterface $this.gui.db.attr
  107.         $this setDbFields
  108.         $this setupForPassword
  109.  
  110.     # End constructor user section
  111.     return $this
  112. }
  113.  
  114. method RepOptimDialog::destructor {this} {
  115.     # Start destructor user section
  116.     # End destructor user section
  117.     $this RepDbDialog::destructor
  118. }
  119.  
  120. method RepOptimDialog::popUp {this} {
  121.     $this checkOk
  122.     $this RepDbDialog::popUp
  123. }
  124.  
  125. method RepOptimDialog::checkOk {this} {
  126.     if {([$this.gui.options.r.l.corp state] ||
  127.          [$this.gui.options.r.l.all state] ||
  128.          ![lempty [[$this projects] selectedSet]]) &&
  129.         [$this passwordOk]} {
  130.  
  131.         $this okSensitive 1
  132.     } else {
  133.         $this okSensitive 0
  134.     }
  135. }
  136.  
  137. method RepOptimDialog::ok {this} {
  138.     set rep [[$this view] rep]
  139.  
  140.     if ![$this getDbFields cmdInfo] {
  141.     [$this view] message "Repository not optimized."
  142.         return
  143.     }
  144.  
  145.     set options ""
  146.     set projects {}
  147.  
  148.     if [$this.gui.options.r.l.corp state] {
  149.         append options " -c"
  150.     }
  151.     if [$this.gui.options.r.l.all state] {
  152.     append options " -a"
  153.     } else {
  154.         set projects [[$this projects] selectedSet]
  155.     }
  156.  
  157.     if [$this.gui.options.r.r.drop state] {
  158.         append options " -I"
  159.     }
  160.     if [$this.gui.options.r.r.create state] {
  161.         append options " -i"
  162.     }
  163.     if [$this.gui.options.r.r.template state] {
  164.         append options " -t"
  165.     }
  166.  
  167.     [[$this view] rep] optimizeRepository "$this optimizeFinished" cmdInfo \
  168.                 $options [$rep currentName] $projects
  169. }
  170.  
  171. method RepOptimDialog::optimizeFinished {this exitCode} {
  172.     if {$exitCode == 0} {
  173.         [$this view] message "Repository optimized successfully."
  174.     } else {
  175.         [$this view] message "Repository not optimized."
  176.     }
  177. }
  178.  
  179. # Do not delete this line -- regeneration end marker
  180.  
  181.