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

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cadre Technologies Inc.    1996
  4. #
  5. #      File:           @(#)localsecti.tcl    /main/hindenburg/4
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)localsecti.tcl    /main/hindenburg/4   19 Sep 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. require "extfvdbobj.tcl"
  16.  
  17. Class LocalSection : {DocSection ExtFVDbObj} {
  18.     method destructor
  19.     constructor
  20.     method promoter
  21.     method browserObjType
  22.     method canBeDragged
  23.     method edit
  24.     method generateStructure
  25.     method generateContents
  26.     method generateTypeContents
  27.     method isDocDirUpToDate
  28.     method updateDocDir
  29.     method type
  30.     method uiName
  31.     method uiClass
  32. }
  33.  
  34. method LocalSection::destructor {this} {
  35.     # Start destructor user section
  36.     # End destructor user section
  37.     $this DocSection::destructor
  38.     $this ExtFVDbObj::destructor
  39. }
  40.  
  41. constructor LocalSection {class this name document} {
  42.     set this [ExtFVDbObj::constructor $class $this $name]
  43.     set this [DocSection::constructor $class $this $name $document]
  44.     return $this
  45. }
  46.  
  47. selfPromoter ExtFVDbObj {this} {
  48.     if [info exists SysVDbObj::this] {
  49.         set sysV ${SysVDbObj::this}
  50.         if {! [isCommand $sysV]} return
  51.     } else {
  52.         set sysV [[ClientContext::global] currentSystem]
  53.     }
  54.     if [$sysV isNil] return
  55.     if [[$sysV findFileVersionLink -byFileVersion $this] isNil] return
  56.     if {"[[$sysV system] type]" != "document"} return
  57.     set editor [$sysV editor]
  58.     if {! [isCommand $editor]} return
  59.  
  60.     set editorName [$editor name]
  61.     set editorVersion [$editor version]
  62.     set type [[$this file] type]
  63.     set class [Document::getClass $editorName $editorVersion $type]
  64.  
  65.     if {$class != ""} {
  66.         $class promote $this $sysV
  67.     }
  68. }
  69.  
  70. method LocalSection::promoter {this document} {
  71.     $this DocSection::promoter $document
  72. }
  73.  
  74. proc LocalSection::associations {} {
  75.     return "[ExtFVDbObj::associations]"
  76. }
  77.  
  78. method LocalSection::browserObjType {this} {
  79.     return "LocalSection"
  80. }
  81.  
  82. method LocalSection::canBeDragged {this} {
  83.     return 0
  84. }
  85.  
  86. proc LocalSection::childTypes {assoc} {
  87.     if {[lsearch -exact "[LocalSection::associations]" "$assoc"] == -1} {
  88.         return ""
  89.     }
  90.     return "[BrowserProcs::childTypes $assoc]"
  91. }
  92.  
  93. proc LocalSection::controlledLists {} {
  94.     return "[ExtFVDbObj::controlledLists]"
  95. }
  96.  
  97. proc LocalSection::infoProperties {} {
  98.     return "[ExtFVDbObj::infoProperties]"
  99. }
  100.  
  101. method LocalSection::edit {this} {
  102.     $this DocSection::edit
  103. }
  104.  
  105. method LocalSection::generateStructure {this withContents} {
  106.  
  107.     # read the property structureGen of the section
  108.     set structureGen [$this findProperty structureGen]
  109.  
  110.     if [$structureGen isNil] {
  111.         return
  112.     }
  113.     set structureGen [$structureGen value]
  114.     regsub -all " |\\t" "$structureGen" "" strippedValue
  115.     if {"$strippedValue" == ""} {
  116.         return
  117.     }
  118.     set tmpFile [args_file {}]
  119.     if [catch {eval "$structureGen [list $tmpFile] $this"} msg] {
  120.         wmtkerror "Error while executing structure generator\
  121.         procedure '$structureGen'\n\tfor section '[$this uiName]'.\
  122.         \n\t:$msg"
  123.     }
  124.     generator generateSection $this $tmpFile $withContents
  125.     unlink $tmpFile
  126. }
  127.  
  128. method LocalSection::generateContents {this} {
  129.  
  130.     # read the property contentsGen of the section
  131.     set contentsGen [$this findProperty contentsGen]
  132.  
  133.     # check if there's a generate defined with this section
  134.     # if not, generate contents according to the section type
  135.     wmtkmessage "Generate contents for section '[$this uiName]'"
  136.     if [$contentsGen isNil] {
  137.         $this generateTypeContents
  138.         return
  139.     }
  140.     set contentsGen [$contentsGen value]
  141.     regsub -all " |\\t" "$contentsGen" "" strippedValue
  142.     if {"$strippedValue" == ""} {
  143.         $this generateTypeContents
  144.         return
  145.     }
  146.     if [catch {eval "dispatchContentsGen $contentsGen $this"} msg] {
  147.         wmtkerror "Error while executing contents generator\
  148.         procedure '$contentsGen'\n\tfor section '[$this uiName]'.\
  149.         :\n\t$msg"
  150.     }
  151. }
  152.  
  153. method LocalSection::generateTypeContents {this} {
  154.  
  155.     # default no contents generated
  156. }
  157.  
  158. method LocalSection::isDocDirUpToDate {this} {
  159.  
  160.     # do not update if document is frozen
  161.     if {"[[$this document] getInfo Status]" == "frozen"} {
  162.         return 1
  163.     }
  164.  
  165.     if {! [file exists [$this docLocation]]} {
  166.         return 0
  167.     }
  168.  
  169.     # do not update frozen section
  170.     if {"[$this getInfo Status]" == "frozen"} {
  171.         return 1
  172.     }
  173.  
  174.     if {[[[$this document] editor] printsIncluded] == "y"} {
  175.         # check also the 'not-localsection-children'
  176.         [$this childSectionSet] foreach child {
  177.             if {![$child isA LocalSection]} {
  178.                 if {![$child isDocDirUpToDate]} {
  179.                     return 0
  180.                 }
  181.             }
  182.         }
  183.     }
  184.     return 1
  185. }
  186.  
  187. method LocalSection::updateDocDir {this} {
  188.  
  189.     set path [$this docLocation]
  190.     if {"[$this getInfo Status]" != "working"} {
  191.         catch {BasicFS::removeFile $path}
  192.     }
  193.     if {! [file exists $path]} {
  194.         $this synchWithFileSystem
  195.         set retval 0
  196.     } else {
  197.         set retval 1
  198.     }
  199.  
  200.     if {[[[$this document] editor] printsIncluded] == "y"} {
  201.         # update also the 'not-localsection-children'
  202.         [$this childSectionSet] foreach child {
  203.             if {![$child isA LocalSection]} {
  204.                 if {![$child updateDocDir]} {
  205.                     set retval 0
  206.                 }
  207.             }
  208.         }
  209.     }
  210.     return $retval
  211. }
  212.  
  213. method LocalSection::type {this} {
  214.     return [[$this file] type]
  215. }
  216.  
  217. method LocalSection::uiName {this args} {
  218.  
  219.     if {$args == ""} {
  220.         return [[$this file] name]
  221.     } else {
  222.         # can not change name (yet)
  223.     }
  224. }
  225.  
  226. method LocalSection::uiClass {this} {
  227.     return LocalSection
  228. }
  229.  
  230. # Do not delete this line -- regeneration end marker
  231.  
  232.