home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / cbpropview.tcl < prev    next >
Text File  |  1996-05-29  |  6KB  |  197 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cadre Technologies Inc.    1996
  4. #
  5. #      File:           @(#)cbpropview.tcl    1.12
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)cbpropview.tcl    1.12   04 Apr 1996 Copyright 1996 Cadre Technologies Inc.
  10.  
  11. # Start user added include file section
  12. require "cbpropcmpl.tcl"
  13. require "cbpropcomp.tcl"
  14. require "cbproplabe.tcl"
  15. require "cbpropitem.tcl"
  16. require "cbpropcont.tcl"
  17.  
  18. require "propstruct.tcl"
  19. require "propertydi.tcl"
  20. require "labelpartn.tcl"
  21. require "cblongname.tcl"
  22. # End user added include file section
  23.  
  24.  
  25. Class CBPropViewer : {Object} {
  26.     constructor
  27.     method destructor
  28.     method showProperties
  29.     method createPropContainers
  30.     method indent
  31.     method releasePropContainers
  32.     method addPropContainer
  33.     method removePropContainer
  34.     attribute propContainerSet
  35.     attribute propKnowledgeDB
  36. }
  37.  
  38. constructor CBPropViewer {class this name propKnowledgeDB} {
  39.     set this [Object::constructor $class $this $name]
  40.     $this propKnowledgeDB $propKnowledgeDB
  41.     $this propContainerSet [List new]
  42.     # Start constructor user section
  43.     # End constructor user section
  44.     return $this
  45. }
  46.  
  47. method CBPropViewer::destructor {this} {
  48.     # Start destructor user section
  49.     # End destructor user section
  50. }
  51.  
  52. method CBPropViewer::showProperties {this entry} {
  53.     set systemLevelIds [$classBrowser phaseLevelpathIds]
  54.     set currentClass [$classBrowser currentOpenedClass]
  55.     if {$currentClass != ""} {
  56.         set systemV [$currentClass getDefiningSystemVersion]
  57.         if {![$systemV isNil]} {
  58.             set systemLevelIds [join [concat $systemLevelIds \
  59.                 [$systemV identity]] /]
  60.         }
  61.     }
  62.     [$this propKnowledgeDB] context $systemLevelIds
  63.  
  64.     $this createPropContainers $entry
  65.     # Don't reuse a PropertyDialog:
  66.     # the initial size does not change to fit new contents.
  67.     PropertyDialog new $classBrowser.showProperties $this \
  68.         -editable 0 \
  69.         -helpPressed "$classBrowser helpOnName showProperties"
  70.     $classBrowser.showProperties popUp
  71. }
  72.  
  73. method CBPropViewer::createPropContainers {this entry} {
  74.     set cbPropCompList [CBPropCmpList new]
  75.     $entry collectPropComps $cbPropCompList
  76.     set propStructList [List new]
  77.     set phaseV [[ClientContext::global] currentPhase]
  78.     PropLocation new .propLocation \
  79.         -phaseType [[$phaseV phase] type] \
  80.         -diagramType $CAD_TYPE
  81.     set maxNameLength 0
  82.     [$cbPropCompList propComponentSet] foreach propComp {
  83.         set count 0
  84.         set compType [[$propComp component] type]
  85.         .propLocation componentType $compType
  86.         set indent [$this indent $compType]
  87.         [$propComp propLabelSet] foreach propLabel {
  88.             set labType [[$propLabel label] type]
  89.             .propLocation labelType $labType
  90.             [$propLabel propItemSet] foreach propItem {
  91.             set itemType [[$propItem item] type]
  92.             .propLocation containerKind Component
  93.             .propLocation containerType $compType
  94.             set compPropDefs [[$this propKnowledgeDB] \
  95.                 definitions .propLocation]
  96.             .propLocation containerKind Item
  97.             .propLocation containerType $itemType
  98.             set itemPropDefs [[$this propKnowledgeDB] \
  99.                 definitions .propLocation]
  100.             if {"$compPropDefs$itemPropDefs" == ""} {
  101.                 continue
  102.             }
  103.             set objName $indent[[$propItem item] name]
  104.             set objNameLength [string length $objName]
  105.             if {$objNameLength > $maxNameLength} {
  106.                 set maxNameLength $objNameLength
  107.             }
  108.             set labIdx ${compType},${labType},${itemType}
  109.             if [info exists labelPartName($labIdx)] {
  110.                 set objType $labelPartName($labIdx)
  111.             } else {
  112.                 if {[info exists multiLabelComp($compType)]} {
  113.                 set objType "$compLongName($compType)\
  114.                     $labLongName($labType)"
  115.                 } else {
  116.                 set objType $compLongName($compType)
  117.                 }
  118.             }
  119.             # Note: attribute itemRef is used to store the workItem!
  120.             $propStructList append [PropStruct new \
  121.                 -name $objName \
  122.                 -type $objType \
  123.                 -compPropDefs $compPropDefs \
  124.                 -containerKey [.propLocation asString] \
  125.                 -component [$propComp component] \
  126.                 -itemRef [$propItem workItem] \
  127.                 -itemPropDefs $itemPropDefs]
  128.             incr count
  129.             }
  130.         }
  131.         if {$count == 0} {
  132.             .propLocation containerKind Component
  133.             .propLocation containerType $compType
  134.             .propLocation labelType ""
  135.             set compPropDefs [[$this propKnowledgeDB] \
  136.                 definitions .propLocation]
  137.             if {[llength $compPropDefs] > 0} {
  138.                 $propStructList append [PropStruct new \
  139.                     -type $compLongName($compType) \
  140.                     -compPropDefs $compPropDefs \
  141.                     -containerKey [.propLocation asString] \
  142.                     -component [$propComp component]]
  143.             }
  144.         }
  145.     }
  146.     .propLocation delete
  147.     set formatString "%-*.*s  %s"
  148.     set cntList [List new]
  149.     $propStructList foreach propStruct {
  150.         set pres [format $formatString $maxNameLength $maxNameLength \
  151.             [$propStruct name] [$propStruct type]]
  152.         # Note: attribute itemRef was used to store the workItem!
  153.         set wrkItem [$propStruct itemRef]
  154.         if {$wrkItem == "" || [$wrkItem isNil]} {
  155.             set itemProperties [ORB::nil]
  156.         } else {
  157.             set itemProperties [$wrkItem properties]
  158.         }
  159.         set cnt [CBPropContainer new -editable 0 \
  160.             -propertyKey [$propStruct containerKey] \
  161.             -propertyPresentation $pres \
  162.             -holderComp [$propStruct component] \
  163.             -holderItemProperties $itemProperties]
  164.         foreach propDef [$propStruct compPropDefs] {
  165.             $cnt addSpecificPropDef $propDef holderComp
  166.         }
  167.         foreach propDef [$propStruct itemPropDefs] {
  168.             $cnt addSpecificPropDef $propDef holderItemProperties
  169.         }
  170.         $cntList append $cnt
  171.     }
  172.     $this propContainerSet $cntList
  173. }
  174.  
  175. method CBPropViewer::indent {this compType} {
  176.     if {$compType == $CDM_PARAM} {
  177.         return "    "
  178.     }
  179.     return ""
  180. }
  181.  
  182. method CBPropViewer::releasePropContainers {this} {
  183.     # Not applicable !!
  184. }
  185.  
  186. # Do not delete this line -- regeneration end marker
  187.  
  188. method CBPropViewer::addPropContainer {this newPropContainer} {
  189.     [$this propContainerSet] append $newPropContainer
  190.  
  191. }
  192.  
  193. method CBPropViewer::removePropContainer {this oldPropContainer} {
  194.     [$this propContainerSet] removeValue $oldPropContainer
  195. }
  196.  
  197.