home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / contfile.tcl < prev    next >
Text File  |  1997-06-06  |  5KB  |  186 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1997
  4. #
  5. #      File:           @(#)contfile.tcl    /main/hindenburg/5
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)contfile.tcl    /main/hindenburg/5   6 Jun 1997 Copyright 1997 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12. # End user added include file section
  13.  
  14. require_module_file "vsfile.tcl" vcm
  15.  
  16. # This class represents a Continuus file.
  17.  
  18. Class ContFile : {VSFile} {
  19.     constructor
  20.     method destructor
  21.     method createVSPath
  22.     method createUserPath
  23.     method createInVS
  24.     method removeFromVS
  25.     method renameInVS
  26.     method isCheckedOut
  27.     method checkOut
  28.     method deleteVersion
  29.     method unuseVersion
  30.     method getReference
  31.     method deleteReference
  32.     method setAttribute
  33.     method getAttributeValue
  34. }
  35.  
  36. constructor ContFile {class this name type system} {
  37.     set this [VSFile::constructor $class $this $name $type $system]
  38.     # Start constructor user section
  39.     # End constructor user section
  40.     return $this
  41. }
  42.  
  43. method ContFile::destructor {this} {
  44.     # Start destructor user section
  45.     # End destructor user section
  46.     $this VSFile::destructor
  47. }
  48.  
  49. method ContFile::createVSPath {this} {
  50.     $this VSFile::createVSPath Cont
  51. }
  52.  
  53. method ContFile::createUserPath {this} {
  54.     $this VSFile::createUserPath Cont
  55. }
  56.  
  57. method ContFile::createInVS {this args} {
  58.     set path [$this path]
  59.     set dir [path_name directory $path]
  60.  
  61.     # do some incomprehensible args manipulation
  62.     set arguments [lindex $args 0]
  63.     set comment [lindex $arguments 0]
  64.  
  65.     # check if there is a task argument
  66.     # this is given by the browser but not by code generation.
  67.     if { [llength $arguments] > 1 } {
  68.     set task [lindex $arguments 1]
  69.     } else {
  70.     set task 0
  71.     }
  72.  
  73.     # create path if necessary
  74.     if { ![file isdirectory $dir] } {
  75.     if { ![$this createUserPath] } {
  76.         return 0
  77.     }
  78.     }
  79.  
  80.     # create the element itself
  81.     set contType [[[$this systemVersion] typeMapper] map [$this type]]
  82.     set createCommand [ContCommand::createObject $path $contType $comment $task]
  83.     return [vsCommandHandler execute $createCommand]
  84. }
  85.  
  86. method ContFile::removeFromVS {this} {
  87.     set removeCommand [ContCommand::deleteObject [$this path]]
  88.     return [vsCommandHandler execute $removeCommand]
  89. }
  90.  
  91. method ContFile::renameInVS {this oldName} {
  92.     # construct old path from new path and old name
  93.     set fullName [path_name file [$this path]]
  94.     regsub ^[$this name] $fullName "" extensionPart
  95.     set oldPath [path_name concat [path_name directory [$this path]] \
  96.         "${oldName}$extensionPart"]
  97.  
  98.     set renameCommand [ContCommand::rename $oldPath [$this path]]
  99.     return [vsCommandHandler execute $renameCommand]
  100. }
  101.  
  102.  
  103. # Returns whether the currently selected version of this file
  104. # is in working state.
  105. #
  106. method ContFile::isCheckedOut {this} {
  107.     # just test writable
  108.     return [file writable [$this path]]
  109. }
  110.  
  111. method ContFile::checkOut {this comment args} {
  112.     set checkOutCommand [ContCommand::checkOut [$this path] $comment]
  113.     return [vsCommandHandler execute $checkOutCommand]
  114. }
  115.  
  116.  
  117. # Delete and replace current version of this file.
  118. #
  119. method ContFile::deleteVersion {this} {
  120.     set deleteCommand [ContCommand::deleteVersion [$this path]]
  121.     return [vsCommandHandler execute $deleteCommand]
  122. }
  123.  
  124.  
  125. # Unuse and replace current version of this file.
  126. #
  127. method ContFile::unuseVersion {this} {
  128.     set unuseCommand [ContCommand::unuseVersion [$this path]]
  129.     return [vsCommandHandler execute $unuseCommand]
  130. }
  131.  
  132. method ContFile::getReference {this {version ""}} {
  133.     if { $version == "" } {
  134.     return [$this path]
  135.     }
  136.  
  137.     set path [args_file {}]
  138.     if [ContCommand::getVersion [$this path] $version $path] {
  139.     $this references "[$this references] [list $path]"
  140.     return $path
  141.     }
  142.  
  143.     # don't know what went wrong, try to remove the file just in case
  144.     catch { BasicFS::removeFile $path }
  145.     return ""
  146. }
  147.  
  148. method ContFile::deleteReference {this path} {
  149.     set splitPath [file_split $path]
  150.     set refFound 0
  151.     set newList {}
  152.     foreach ref [$this references] {
  153.     if { [file_split $ref] == $splitPath } {
  154.         set refFound 1
  155.     } else {
  156.         lappend newList [list $ref]
  157.     }
  158.     }
  159.     if !$refFound {
  160.     return
  161.     }
  162.  
  163.     # reference was a temporary file, delete from list and file system
  164.     $this references $newList
  165.     BasicFS::removeFile $path
  166. }
  167.  
  168.  
  169. # Sets the specified Continuus attribute to the
  170. # specified value for this file.
  171. #
  172. method ContFile::setAttribute {this name value} {
  173.     set setCommand [ContCommand::setAttribute [$this path] $name $value]
  174.     return [vsCommandHandler execute $setCommand]
  175. }
  176.  
  177.  
  178. # Get the value of the specified attribute for this file.
  179. #
  180. method ContFile::getAttributeValue {this name} {
  181.     return [ContCommand::getAttributeValue [$this path] $name]
  182. }
  183.  
  184. # Do not delete this line -- regeneration end marker
  185.  
  186.