home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / custbrowso.tcl < prev    next >
Text File  |  1996-06-12  |  4KB  |  200 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cadre Technologies Inc.    1996
  4. #
  5. #      File:           @(#)custbrowso.tcl    /main/3
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)custbrowso.tcl    /main/3   12 Jun 1996 Copyright 1996 Cadre Technologies Inc.
  10.  
  11. # Start user added include file section
  12. # End user added include file section
  13.  
  14.  
  15. Class CustBrowsObject : {Object} {
  16.     constructor
  17.     method destructor
  18.     method visible
  19.     method validScope
  20.     method validEnvironment
  21.     method validSpecLevel
  22.     method displayName
  23.     method infoList
  24.     attribute editable
  25.     attribute specLevel
  26.     attribute readOnly
  27.     attribute scope
  28.     attribute name
  29.     attribute objSpec
  30.     attribute type
  31.     attribute userDefined
  32.     attribute alwaysInScope
  33.     attribute alwaysVisible
  34.     attribute _visible
  35.     attribute _displayName
  36. }
  37.  
  38. constructor CustBrowsObject {class this name_1} {
  39.     set this [Object::constructor $class $this $name_1]
  40.     $this editable 0
  41.     # Start constructor user section
  42.  
  43.     $this readOnly 0
  44.     $this scope {}
  45.     $this userDefined 0
  46.     $this alwaysInScope 1
  47.     $this alwaysVisible 1
  48.     $this _visible {1 1 1 1 1}
  49.  
  50.     # End constructor user section
  51.     return $this
  52. }
  53.  
  54. method CustBrowsObject::destructor {this} {
  55.     # Start destructor user section
  56.     # End destructor user section
  57. }
  58.  
  59. method CustBrowsObject::visible {this args} {
  60.  
  61.     set visible {}
  62.  
  63.     if {$args == ""} {
  64.         return [$this _visible]
  65.     } else {
  66.         set count 0
  67.         $this _visible [join $args]
  68.         $this alwaysVisible 0
  69.         if {[lsearch [$this _visible] 0] == -1} {
  70.             $this alwaysVisible 1
  71.         }
  72.     }
  73. }
  74.  
  75. method CustBrowsObject::validScope {this curPath} {
  76.  
  77.     if [$this alwaysInScope] {
  78.         return 1
  79.     }
  80.  
  81.     # extract corporate 
  82.     set curPath [lreplace $curPath 0 0]
  83.  
  84.     # if curPath is corporate, the object is always in scope
  85.     if [lempty $curPath] {
  86.         return 1
  87.     }
  88.  
  89.     set index 0
  90.     set objScope [$this scope]
  91.     foreach i $curPath {
  92.         set x [lindex $objScope $index]
  93.         if { $x != ""  && $x != "*" } {
  94.             if {$index == 3} {
  95.                 if [$i isA Document] {
  96.                     if {[lsearch $x "document"] == -1} {
  97.                         return 0
  98.                     }
  99.                 } else {
  100.                     if {[lsearch $x "system"] == -1} {
  101.                         return 0
  102.                     }
  103.                 }
  104.             } else {
  105.                 if {$index == 0}  {
  106.                     set name [$i name] 
  107.                 } else {
  108.                     set name [[$i \
  109.                         $icaseLevelNames($index)] name]
  110.                 }
  111.                 if {[lsearch $x $name] == -1} {
  112.                     return 0
  113.                 }
  114.             }
  115.         }
  116.         incr index
  117.     }
  118.     return 1
  119. }
  120.  
  121. method CustBrowsObject::validEnvironment {this curPath} {
  122.  
  123.     # extract corporate 
  124.     set curPathLen [expr {[llength $curPath]-1}]
  125.  
  126.     if {![$this alwaysVisible]} {
  127.         # check if the object is visible on this level
  128.         if {[lindex [$this visible] $curPathLen] == 0 } {
  129.             return 0
  130.         }
  131.     }
  132.  
  133.     set objScope [$this scope]
  134.     if {$curPathLen < [llength $objScope]} {
  135.         return 0
  136.     }
  137.  
  138.     return [$this validScope $curPath]
  139. }
  140.  
  141. method CustBrowsObject::validSpecLevel {this curLevel} {
  142.  
  143.     set objScope [$this scope]
  144.     set level 0
  145.  
  146.     # user defines are always read in level corporate, do not check
  147.     if [$this userDefined] {
  148.         return 1
  149.     }
  150.  
  151.     if {$objScope == "" && $curLevel != "corporate"} {
  152.         return 0
  153.     }
  154.  
  155.     foreach i $objScope {
  156.         if {$i == "*" || [llength $i] > 1} {
  157.             break
  158.         } else {
  159.             incr level
  160.         }
  161.     }
  162.  
  163.     if {$icaseLevel($level) != $curLevel} {
  164.         return 0
  165.     } else {
  166.         return 1
  167.     }
  168. }
  169.  
  170. method CustBrowsObject::displayName {this args} {
  171.     
  172.     if {$args == ""} {
  173.         return [$this _displayName]
  174.     } else {
  175.         $this _displayName [join $args]
  176.     }
  177. }
  178.  
  179. method CustBrowsObject::infoList {this} {
  180.  
  181.     set readOnly "Yes"
  182.     if ![$this readOnly] {
  183.         set readOnly "No"
  184.     }
  185.     set userDefined "Yes"
  186.     if ![$this userDefined] {
  187.         set userDefined "No"
  188.     }
  189.  
  190.     return "Name \{[$this displayName]\} \
  191.         Type    [$this type] \
  192.         {Specification Level} [$this specLevel]
  193.         Scope    \{[$this scope]\} \
  194.         ReadOnly $readOnly \
  195.         UserDefined $userDefined "
  196. }
  197.  
  198. # Do not delete this line -- regeneration end marker
  199.  
  200.