home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / defstoredi.tcl < prev    next >
Text File  |  1996-10-23  |  8KB  |  298 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cadre Technologies Inc.    1996
  4. #
  5. #      File:           @(#)defstoredi.tcl    /main/hindenburg/1
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)defstoredi.tcl    /main/hindenburg/1   23 Oct 1996 Copyright 1996 Cadre Technologies Inc.
  10.  
  11. # Start user added include file section
  12. # End user added include file section
  13.  
  14. require "definedial.tcl"
  15.  
  16. Class DefStoreDialog : {DefineDialog} {
  17.     method destructor
  18.     constructor
  19.     method createInterface
  20.     method clearInterface
  21.     method setPossibleScope
  22.     method objScope
  23.     method objReadOnly
  24.     method cancelled
  25.     method getPhase
  26.     method setPhase
  27.     method removePhase
  28.     attribute sPage
  29.     attribute phase
  30. }
  31.  
  32. method DefStoreDialog::destructor {this} {
  33.     # Start destructor user section
  34.     # End destructor user section
  35.     $this DefineDialog::destructor
  36. }
  37.  
  38. constructor DefStoreDialog {class this name} {
  39.     set this [DefineDialog::constructor $class $this $name]
  40.     return $this
  41. }
  42.  
  43. method DefStoreDialog::createInterface {this} {
  44.     #indentation of this function is 4 spaces to make it easier to read
  45.  
  46.     # read phases file
  47.     $this phase [Dictionary new]
  48.     getPhases
  49.  
  50.     $this cancelPressed "$this cancelled"
  51.  
  52.     # create "storage" page
  53.     set page $this.storageNBP
  54.     interface NoteBkPage $page {
  55.         label Storage
  56.         DlgRow NG {
  57.             DlgColumn DC {
  58.                 NamedGroup NG1 {
  59.                     verStretchFactor 0
  60.                     label Scope
  61.                     DlgColumn DC {
  62.                         Label L1 { text Project }
  63.                         SingleLineText projectSLT {}
  64.                         Label L2 { text Configuration }
  65.                         SingleLineText configSLT {}
  66.                         NamedGroup NG1 {
  67.                             label Phase
  68.                             DlgRow DR {}
  69.             }
  70.                         NamedGroup NG2 {
  71.                             label System
  72.                             DlgRow DR {
  73.                                 DlgColumn DC {
  74.                                     CheckButton SysCB {
  75.                                         label system
  76.                                     }
  77.                                     CheckButton DocCB {
  78.                                         label document
  79.                                     }
  80.                                 }
  81.                             }
  82.             }
  83.                     }
  84.                 }
  85.                 NamedGroup NG2 {
  86.                     verStretchFactor 0
  87.                     DlgRow DR {
  88.                         CheckButton readOnlyCB {
  89.                             label "Read Only"
  90.                         }
  91.                     }
  92.                 }
  93.             }
  94.         }
  95.     }
  96.     $this sPage $page.NG.DC
  97.     set count 0
  98.     set phasesRow [$this sPage].NG1.DC.NG1.DR
  99.     foreach phase ${BrowserProcs::phases} {
  100.     set phaseType [lindex $phase 1]
  101.     if [[$this phase] exists "$phaseType"] continue
  102.     if {[expr $count % 2] == 0} {
  103.         set DC [DlgColumn new $phasesRow.DC$count]
  104.     }
  105.     $this setPhase "$phaseType" \
  106.         [CheckButton new $DC.CB$count -label "$phaseType"]
  107.     incr count 1
  108.     }
  109.     $page lowered "$this checkLevelChanged"
  110. }
  111.  
  112. method DefStoreDialog::clearInterface {this} {
  113.     # clean page "Storage"
  114.     [$this sPage].NG1.DC.projectSLT text ""
  115.     [$this sPage].NG1.DC.configSLT text ""
  116.     foreach CB [[$this phase] values] {
  117.         $CB state 0
  118.     }
  119.     [$this sPage].NG1.DC.NG2.DR.DC.SysCB state 0
  120.     [$this sPage].NG1.DC.NG2.DR.DC.DocCB state 0
  121.     [$this sPage].NG2.DR.readOnlyCB state 0
  122. }
  123.  
  124. method DefStoreDialog::setPossibleScope {this} {
  125.     [$this sPage].NG1.DC.projectSLT sensitive 0
  126.     [$this sPage].NG1.DC.configSLT sensitive 0
  127.     foreach CB [[$this phase] values] {
  128.         $CB sensitive 0
  129.     }
  130.     [$this sPage].NG1.DC.NG2.DR.DC.SysCB sensitive 0
  131.     [$this sPage].NG1.DC.NG2.DR.DC.DocCB sensitive 0
  132.  
  133.     case "[[.main editorArea] _level]" in {
  134.         {corporate user} {
  135.             [$this sPage].NG1.DC.projectSLT sensitive 1
  136.             [$this sPage].NG1.DC.configSLT sensitive 1
  137.             foreach CB [[$this phase] values] {
  138.                 $CB sensitive 1
  139.             }
  140.             [$this sPage].NG1.DC.NG2.DR.DC.SysCB sensitive 1
  141.             [$this sPage].NG1.DC.NG2.DR.DC.DocCB sensitive 1
  142.         }
  143.         {project} {
  144.             [$this sPage].NG1.DC.configSLT sensitive 1
  145.             foreach CB [[$this phase] values] {
  146.                 $CB sensitive 1
  147.             }
  148.             [$this sPage].NG1.DC.NG2.DR.DC.SysCB sensitive 1
  149.             [$this sPage].NG1.DC.NG2.DR.DC.DocCB sensitive 1
  150.         }
  151.         {config} {
  152.             foreach CB [[$this phase] values] {
  153.                 $CB sensitive 1
  154.             }
  155.             [$this sPage].NG1.DC.NG2.DR.DC.SysCB sensitive 1
  156.             [$this sPage].NG1.DC.NG2.DR.DC.DocCB sensitive 1
  157.         }
  158.         {phase} {
  159.             [$this sPage].NG1.DC.NG2.DR.DC.SysCB sensitive 1
  160.             [$this sPage].NG1.DC.NG2.DR.DC.DocCB sensitive 1
  161.         }
  162.         {system} {
  163.             # nothing can be changed (always this specific system)
  164.         }
  165.     }
  166. }
  167.  
  168. method DefStoreDialog::objScope {this args} {
  169.     #indentation of this function is 4 spaces to make it easier to read
  170.     if {$args == ""} {
  171.     set scope "\{[[$this sPage].NG1.DC.projectSLT text]\}"
  172.     set scope "$scope \{[[$this sPage].NG1.DC.configSLT text]\}"
  173.     set phase {}
  174.     set phaseCount 0
  175.     [$this phase] foreach phaseType CB {
  176.         if [$CB state] {
  177.         lappend phase "$phaseType"
  178.         incr phaseCount
  179.         }
  180.     }
  181.     if {$phaseCount == [[$this phase] size]} {
  182.         set phase "*"
  183.     }
  184.     set scope "$scope \{$phase\}"
  185.     set system {}
  186.     set systemCount 0
  187.     if [[$this sPage].NG1.DC.NG2.DR.DC.SysCB state] {
  188.         lappend system [[$this sPage].NG1.DC.NG2.DR.DC.SysCB label]
  189.         incr systemCount
  190.     }
  191.     if [[$this sPage].NG1.DC.NG2.DR.DC.DocCB state] {
  192.         lappend system [[$this sPage].NG1.DC.NG2.DR.DC.DocCB label]
  193.         incr systemCount
  194.     }
  195.     if {$systemCount == 2} {
  196.         set system "*"
  197.     }
  198.     set scope "$scope \{$system\}"
  199.     set retScope ""
  200.     set scopeLength -1
  201.     set index 0
  202.     foreach i $scope {
  203.         if {[llength $i] > 1} {
  204.         if {$retScope == ""} {
  205.             set retScope "\{$i\}"
  206.         } else {
  207.             set retScope "$retScope \{$i\}"
  208.         }
  209.         set scopeLength $index
  210.         } elseif [lempty $i] {
  211.         # no spec means "*"
  212.         set retScope "$retScope *"
  213.         } else {
  214.         if {$retScope == ""} {
  215.             set retScope "$i"
  216.         } else {
  217.             set retScope "$retScope $i"
  218.         }
  219.         set scopeLength $index
  220.         }
  221.         incr index
  222.     }
  223.     return [lrange $retScope 0 $scopeLength]
  224.     } else {
  225.     set argc 0
  226.     set args [lvarpop args]
  227.     foreach i $args {
  228.         if {$argc == 0} {
  229.         [$this sPage].NG1.DC.projectSLT text $i
  230.         }
  231.         if {$argc == 1} {
  232.         [$this sPage].NG1.DC.configSLT text $i
  233.         }
  234.         if {$argc == 2} {
  235.         if {[lsearch $i "\\*"] != -1} {
  236.             foreach CB [[$this phase] values] {
  237.             $CB state 1
  238.             }
  239.         } else {
  240.             [$this phase] foreach phaseType CB {
  241.             if {[lsearch $i "$phaseType"] != -1} {
  242.                 $CB state 1
  243.             }
  244.             }
  245.         }
  246.         }
  247.         if {$argc == 3} {
  248.         if {[lsearch $i "\\*"] != -1} {
  249.             [$this sPage].NG1.DC.NG2.DR.DC.SysCB state 1
  250.             [$this sPage].NG1.DC.NG2.DR.DC.DocCB state 1
  251.             continue
  252.         } else {
  253.             set obj [$this sPage].NG1.DC.NG2.DR.DC.SysCB
  254.             if {[lsearch $i [$obj label]] != -1} {
  255.             $obj state 1
  256.             }
  257.             set obj [$this sPage].NG1.DC.NG2.DR.DC.DocCB
  258.             if {[lsearch $i [$obj label]] != -1} {
  259.             $obj state 1
  260.             }
  261.         }
  262.         }
  263.         incr argc
  264.     }
  265.     }
  266. }
  267.  
  268. method DefStoreDialog::objReadOnly {this args} {
  269.     if {$args == ""} {
  270.         return [[$this sPage].NG2.DR.readOnlyCB state]
  271.     } else {
  272.         [$this sPage].NG2.DR.readOnlyCB state $args
  273.     }
  274. }
  275.  
  276. method DefStoreDialog::cancelled {this} {
  277.  
  278.     # if cancelled, and the object was redefined, remove the object
  279.     if {[[$this curObject] redefined] == 1} {
  280.         [$this curObject] delete
  281.     }
  282. }
  283.  
  284. # Do not delete this line -- regeneration end marker
  285.  
  286. method DefStoreDialog::getPhase {this phaseType} {
  287.     return [[$this phase] set $phaseType]
  288. }
  289.  
  290. method DefStoreDialog::setPhase {this phaseType newPhase} {
  291.     [$this phase] set $phaseType $newPhase
  292. }
  293.  
  294. method DefStoreDialog::removePhase {this phaseType} {
  295.     [$this phase] unset $phaseType
  296. }
  297.  
  298.