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

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cadre Technologies Inc.    1996
  4. #
  5. #      File:           @(#)propertyse.tcl    /main/hindenburg/3
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)propertyse.tcl    /main/hindenburg/3   8 Nov 1996 Copyright 1996 Cadre Technologies Inc.
  10.  
  11. # Start user added include file section
  12. # End user added include file section
  13.  
  14. require "docsection.tcl"
  15.  
  16. Class PropertySection : {DocSection} {
  17.     method destructor
  18.     constructor
  19.     method edit
  20.     method show
  21.     method print
  22.     method preview
  23.     method uiName
  24.     method updateDocDir
  25.     method isDocDirUpToDate
  26.     method setpropKnowledgeDB
  27.     method promoter
  28. }
  29.  
  30. method PropertySection::destructor {this} {
  31.     # Start destructor user section
  32.     # End destructor user section
  33.     $this DocSection::destructor
  34. }
  35.  
  36. constructor PropertySection {class this name document} {
  37.     set this [DocSection::constructor $class $this $name $document]
  38.     return $this
  39. }
  40.  
  41. method PropertySection::edit {this} {
  42.  
  43.     # default no edit possible
  44.     # redefine this function to be sure not the base edit is taken
  45.     wmtkerror "No edit possible for this section."
  46. }
  47.  
  48. method PropertySection::show {this} {
  49.  
  50.     set cmd [list \
  51.         "viewer PropertySection" \
  52.         [$this docLocation] \
  53.         [$this uiName] \
  54.     ]
  55.     $this execute "$cmd" m4
  56. }
  57.  
  58. method PropertySection::print {this} {
  59.  
  60.     set cmd [list \
  61.         "[m4_var get M4_a_printer] [$this docLocation]" \
  62.         [$this uiName] \
  63.     ]
  64.     $this execute "$cmd"
  65. }
  66.  
  67. method PropertySection::preview {this} {
  68.  
  69.     set cmd [list \
  70.         "previewer PropertySection" \
  71.         [$this docLocation] \
  72.         [$this uiName] \
  73.     ]
  74.     $this execute "$cmd" m4
  75. }
  76.  
  77. method PropertySection::uiName {this args} {
  78.  
  79.     return [$this name]
  80. }
  81.  
  82. method PropertySection::updateDocDir {this} {
  83.     
  84.     set filled 0
  85.     $this setpropKnowledgeDB
  86.  
  87.     set keyValues {}
  88.     set cv [[$this document] configVersion]
  89.     foreach property [$this referredProperties $cv] {
  90.         set keyValue "[$property name]"
  91.         lappend keyValue "[$property value]"
  92.         lappend keyValues $keyValue
  93.     }
  94.  
  95.     # put the properties in the file
  96.     set fid [open [$this docLocation] w]
  97.  
  98.     foreach property $keyValues {
  99.         set filled 1
  100.         set key "[lindex $property 0]"
  101.         set propDef [$this.propKnowledgeDB definition $key]
  102.         if {$propDef == ""} {
  103.             puts "'$key' not found in property database"
  104.             continue
  105.         }
  106.         set key [$propDef longName]
  107.         set value "[lindex $property 1]"
  108.         if [regexp \n $value] {
  109.             puts $fid "$key :"
  110.             puts $fid $value
  111.         } else {
  112.             puts $fid "$key : $value"
  113.         }
  114.     }
  115.  
  116.     # to keep some doc editors happy
  117.     if {$filled == 0} {
  118.         puts $fid " "
  119.     }
  120.  
  121.     close $fid
  122.     return 1
  123. }
  124.  
  125. method PropertySection::isDocDirUpToDate {this} {
  126.  
  127.     # do not update if document is frozen
  128.     if {"[[$this document] getInfo Status]" == "frozen"} {
  129.         return 1
  130.     }
  131.  
  132.     if {! [file exists [$this docLocation]]} {
  133.         return 0
  134.     }
  135.  
  136.     set cv [[$this document] configVersion]
  137.     set source [$this referredUpdateTime $cv]
  138.     file stat [$this docLocation] info
  139.     if {$source > $info(mtime)} {
  140.         return 0
  141.     }
  142.     return 1
  143. }
  144.  
  145. method PropertySection::setpropKnowledgeDB {this} {
  146.     if {![isCommand $this.propKnowledgeDB]} {
  147.         PropKnowledgeDB new $this.propKnowledgeDB
  148.         # set the right context
  149.         set corpId [[[ClientContext::global] currentCorporate] identity]
  150.         set projId [[[ClientContext::global] currentProject] identity]
  151.         set configVId [[[ClientContext::global] currentConfig] identity]
  152.         set phaseVId [[[ClientContext::global] currentPhase] identity]
  153.         set systemVId [[[$this document] documentedSystem] identity]
  154.         $this.propKnowledgeDB context\
  155.              "/$corpId/$projId/$configVId/$phaseVId/$systemVId"
  156.     }
  157. }
  158.  
  159. method PropertySection::promoter {this document} {
  160.     $this extension txt
  161.     $this DocSection::promoter $document
  162. }
  163.  
  164. # Do not delete this line -- regeneration end marker
  165.  
  166.