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

  1. Class GenItemProp : {Object} {
  2.     method destructor
  3.     constructor
  4.     method getDocStructure
  5.     method getStructureLines
  6.     method match
  7.     attribute document
  8. }
  9.  
  10. method GenItemProp::destructor {this} {
  11.     # Start destructor user section
  12.     # End destructor user section
  13. }
  14.  
  15. constructor GenItemProp {class this name document} {
  16.     set this [Object::constructor $class $this $name]
  17.     $this document $document
  18.     # Start constructor user section
  19.     # End constructor user section
  20.     return $this
  21. }
  22.  
  23. method GenItemProp::getDocStructure {this fileTypes itemType componentType labelType properties} {
  24.  
  25.     set structure ""
  26.     set first 1
  27.  
  28.         set sv [[$this document] documentedSystem]
  29.  
  30.     if [$sv isNil] {
  31.         wmtkerror "Invalid documented system"
  32.         return $structure
  33.     }
  34.  
  35.     foreach fv [$sv localFileVersions] {
  36.         if [$this match $fileTypes $fv] {
  37.             set strLine [$this getStructureLines $fv $itemType \
  38.                 $componentType $labelType $properties $first]
  39.             if {![lempty $strLine]} {
  40.                 if {$first == "1"} {
  41.                     set structure $strLine
  42.                 } else {
  43.                     set structure "$structure\n$strLine"
  44.                 }
  45.                 set first 0
  46.             }
  47.         }
  48.     }
  49.  
  50.     return $structure
  51. }
  52.  
  53. method GenItemProp::match {this fileTypes fileVersion} {
  54.  
  55.     if {[lsearch $fileTypes [[$fileVersion file] type]] == -1} {
  56.         return 0
  57.     }
  58.     return 1
  59. }
  60.  
  61. method GenItemProp::getStructureLines {this fileVersion itemType componentType labelType properties first} {
  62.  
  63.     set indent "+"
  64.     set line ""
  65.     set lines ""
  66.  
  67.     # get all the items with given componentType and itemType
  68.  
  69.     if {![$fileVersion isA Diagram]} {
  70.         return $lines
  71.     }
  72.     foreach comp [$fileVersion components] {
  73.         if {[$comp type] != $componentType} continue
  74.  
  75.         foreach label [$comp labels] {
  76.             if {[$label type] != $labelType} continue
  77.  
  78.             set lab [rmWhiteSpace [$label value]]
  79.  
  80.             # add propertieNames to get unique names
  81.             # max 2 prop names
  82.             if {$properties != "*"} {
  83.                 set prCount 0
  84.                 foreach prop $properties {
  85.                     if {$prCount > 1} {
  86.                         break
  87.                     }    
  88.                     incr prCount
  89.                     set lab "${lab}_$prop"
  90.                 }
  91.             }
  92.             foreach itemRef [$label itemRefs] {
  93.                 set item [$itemRef item]
  94.                 if {[$item type] != $itemType} continue
  95.  
  96.                 set workItem [$fileVersion \
  97.                     findDeclaration $item \
  98.                     [[ClientContext::global] \
  99.                     currentConfig]]
  100.  
  101.                 # skip phaseRef workItems
  102.                 if {[$workItem scope] == "phaseRef"} continue
  103.  
  104.                 # skip when there are no properties
  105.                 set prop [$workItem properties]
  106.                 if {[$prop isNil] ||
  107.                     [lempty [$prop properties]]} continue
  108.                 if {!$first} {
  109.                     set indent "="
  110.                 } else {
  111.                     set first 0
  112.                 }
  113.                 set itemKeeper [$workItem owner]
  114.                 if [$itemKeeper isA SystemVersion] {
  115.                     set name [[$itemKeeper system] name]
  116.                 } else {
  117.                     set name [[$itemKeeper file] name]
  118.                 }
  119.                 set line "\
  120.                     p_${name}_${itemType}_$lab | $indent \
  121.                     | | Itemprop | | | $fileVersion \
  122.                     | $workItem | $properties | Itemprop"
  123.                 set lines "$lines\n$line"
  124.             }
  125.         }
  126.     }
  127.  
  128.     return $lines
  129. }
  130.  
  131. # Do not delete this line -- regeneration end marker
  132.  
  133.