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

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cadre Technologies Inc.    1996
  4. #
  5. #      File:           @(#)document.tcl    /main/hindenburg/3
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)document.tcl    /main/hindenburg/3   17 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 "dsysvdbobj.tcl"
  15.  
  16. Class Document : {DSysVDbObj} {
  17.     method destructor
  18.     constructor
  19.     method promoter
  20.     method initialize
  21.     method title
  22.     method subject
  23.     method documentedSystem
  24.     method type
  25.     method reference
  26.     method keywords
  27.     method date
  28.     method authors
  29.     method docStatus
  30.     method docEditor
  31.     method setGetProp
  32.     method directory
  33.     attribute editor
  34.     attribute docSys
  35.     attribute initialized
  36.     attribute configVersion
  37. }
  38.  
  39. method Document::destructor {this} {
  40.     # Start destructor user section
  41.     # End destructor user section
  42.     $this DSysVDbObj::destructor
  43. }
  44.  
  45. constructor Document {class this name} {
  46.     set this [DSysVDbObj::constructor $class $this $name]
  47.     return $this
  48. }
  49.  
  50. selfPromoter DSysVDbObj {this} {
  51.     Document promote $this
  52. }
  53.  
  54. method Document::promoter {this} {
  55.     $this DSysVDbObj::promoter
  56.     $this initialized 0
  57. }
  58.  
  59. method Document::initialize {this configVersion} {
  60.  
  61.     # create an instance of the documented system
  62.     $this configVersion $configVersion
  63.     set docSys [$this setGetProp doc_sys]
  64.     set phase [$this phase]
  65.     set phaseV [$configVersion findPhaseVersion \
  66.         "[$phase name]" "[$phase type]"]
  67.     if {"$docSys" == ""} {
  68.         wmtkerror "Documented system not specified\
  69.             for document '[$this getInfo Name]'"
  70.         return
  71.     }
  72.     $this docSys [$phaseV findSystemVersion $docSys system]
  73.  
  74.     if [$this initialized] {
  75.         return
  76.     }
  77.  
  78.     # create the docEditor
  79.     if {"[$this editor]" == ""} {
  80.         set docEditor [$this docEditor]
  81.         if {$docEditor == ""} {
  82.         wmtkerror "Document editor not specified\
  83.                 for document '[$this getInfo Name]'"
  84.         return
  85.         }
  86.         # read all the editor specific classes
  87.         require "[string tolower $docEditor].tcl"
  88.         # make the specific editor class
  89.         $this editor [${docEditor}DocEditor new $this.docEditor]
  90.     }
  91.  
  92.     # check the current level
  93.     case "[[ClientContext::global] currentLevel]" in {
  94.         {None Corporate Project Config} {
  95.         return
  96.         }
  97.     }
  98.     if {[[ClientContext::global] currentConfig] != $configVersion} {
  99.         return
  100.     }
  101.  
  102.     if {[[$this editor] dirExtension] != "" } {
  103.         # check if directory name is valid
  104.         set dir [$this getPropertyValue fileSystemPath]
  105.         if {![regexp ".[[$this editor] dirExtension]" $dir]} {
  106.         # invalid name set valid one
  107.         # strip "."
  108.         set name [[$this system] name]
  109.         regsub -all {\.}  $name {_} name
  110.         $this setProperty fileSystemPath \
  111.             $name.[[$this editor] dirExtension]
  112.         }
  113.     }
  114.  
  115.     set error [[$this editor] configDirectory [$this directory]]
  116.  
  117.     if {$error != ""} {
  118.         wmtkerror "$error\nChange property 'File System Path Part' to a valid value before using the document."
  119.         return
  120.     }
  121.  
  122.     $this initialized 1
  123. }
  124.  
  125. method Document::title {this args} {
  126.  
  127.     return [$this setGetProp title $args]
  128. }
  129.  
  130. method Document::subject {this args} {
  131.  
  132.     return [$this setGetProp subject $args]
  133. }
  134.  
  135. method Document::documentedSystem {this} {
  136.  
  137.     return [$this docSys]
  138. }
  139.  
  140. method Document::type {this args} {
  141.  
  142.     return [$this setGetProp type $args]
  143. }
  144.  
  145. method Document::reference {this args} {
  146.  
  147.     return [$this setGetProp ref $args]
  148. }
  149.  
  150. method Document::keywords {this args} {
  151.  
  152.     return [$this setGetProp keywords $args]
  153. }
  154.  
  155. method Document::date {this args} {
  156.  
  157.     return [$this setGetProp date $args]
  158. }
  159.  
  160. method Document::authors {this args} {
  161.  
  162.     return [$this setGetProp authors $args]
  163. }
  164.  
  165. method Document::docStatus {this args} {
  166.  
  167.     return [$this setGetProp status $args]
  168. }
  169.  
  170. method Document::docEditor {this} {
  171.  
  172.     return [$this setGetProp editor]
  173. }
  174.  
  175. method Document::setGetProp {this args} {
  176.  
  177.     set prop [lindex $args 0]
  178.     set value [lindex [lindex $args 1] 0]
  179.  
  180.     if [lempty $value] {
  181.         return [$this getPropertyValue $prop]
  182.     } else {
  183.         $this setProperty $prop $value
  184.     }
  185. }
  186.  
  187. method Document::directory {this} {
  188.  
  189.     return [$this path]
  190. }
  191.  
  192. proc Document::getClass {editor version type} {
  193.  
  194.     set firstChar [string toupper [string range $type 0 0]]
  195.     set lastPart [string tolower [string range $type 1 end]]
  196.  
  197.     set type ${firstChar}${lastPart}
  198.  
  199.     set class ${editor}${version}${type}Section
  200.     if {! [isCommand $class]} {
  201.         # try without version
  202.         set class ${editor}${type}Section
  203.         if {! [isCommand $class]} {
  204.             # try without editor name
  205.             set class ${type}Section
  206.             if {! [isCommand $class]} {
  207.                 return ""
  208.             }
  209.         }
  210.     }
  211.  
  212.     return $class
  213. }
  214.  
  215. proc Document::getFileClass {editor version type} {
  216.  
  217.     set class [Document::getClass $editor $version $type]
  218.     if {$class == ""} {
  219.         # unknown class
  220.         return externalBinary
  221.     }
  222.  
  223.     if [isCommand $class::isAscii] {
  224.         if [$class::isAscii] {
  225.             return externalText
  226.         } else {
  227.             return externalBinary
  228.         }
  229.     } else {
  230.         foreach class [Document::getSuperClasses $class] {
  231.             if [isCommand $class::isAscii] {
  232.                 if [$class::isAscii] {
  233.                     return externalText
  234.                 } else {
  235.                     return externalBinary
  236.                 }
  237.             }
  238.         }
  239.     }
  240.     # no super with isAscii proc found
  241.     return externalBinary
  242. }
  243.  
  244. proc Document::getSuperClasses {class} {
  245.  
  246.     set supers [$class info supers]
  247.  
  248.     foreach i $supers {
  249.         set supers "$supers [Document::getSuperClasses $i]"
  250.     }
  251.  
  252.     return $supers
  253. }
  254.  
  255. # Do not delete this line -- regeneration end marker
  256.  
  257.