home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / ccfile.tcl < prev    next >
Encoding:
Text File  |  1997-05-16  |  6.0 KB  |  223 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1997
  4. #
  5. #      File:           @(#)ccfile.tcl    /main/hindenburg/5
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)ccfile.tcl    /main/hindenburg/5   16 May 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 ClearCase file.
  17.  
  18. Class CCFile : {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 unCheckOut
  29.     method checkIn
  30.     method createBranch
  31.     method destroyBranch
  32.     method reserve
  33.     method unreserve
  34.     method setComment
  35.     method getReference
  36.     method deleteReference
  37.     method setAttribute
  38.     method getAttributeValue
  39. }
  40.  
  41. constructor CCFile {class this name type system} {
  42.     set this [VSFile::constructor $class $this $name $type $system]
  43.     # Start constructor user section
  44.     # End constructor user section
  45.     return $this
  46. }
  47.  
  48. method CCFile::destructor {this} {
  49.     # Start destructor user section
  50.     # End destructor user section
  51.     $this VSFile::destructor
  52. }
  53.  
  54. method CCFile::createVSPath {this} {
  55.     $this VSFile::createVSPath CC
  56. }
  57.  
  58. method CCFile::createUserPath {this} {
  59.     $this VSFile::createUserPath CC
  60. }
  61.  
  62. method CCFile::createInVS {this args} {
  63.     set path [$this path]
  64.     set dir [path_name directory $path]
  65.     set arguments [lindex $args 0]
  66.     set comment [lindex $arguments 0]
  67.  
  68.     # create path if necessary
  69.     if { ![file isdirectory $dir] } {
  70.     if { ![$this createUserPath] } {
  71.         return 0
  72.     }
  73.     }
  74.  
  75.     # check out directory if necessary
  76.     if  { ![CCSystem::checkOutDirectory $dir \
  77.         "Checked out by ObjectTeam for file creation"] } {
  78.     return 0
  79.     }
  80.  
  81.     # create the element itself
  82.     set ccType [[[$this systemVersion] typeMapper] map [$this type]]
  83.     set createCommand [CCCommand::createElem $path $ccType $comment]
  84.     return [vsCommandHandler execute $createCommand]
  85. }
  86.  
  87. method CCFile::removeFromVS {this} {
  88.     set path [$this path]
  89.     set dir [path_name directory $path]
  90.  
  91.     # check out directory if necessary
  92.     if  { ![CCSystem::checkOutDirectory $dir \
  93.         "Checked out by ObjectTeam for file removal"] } {
  94.     return 0
  95.     }
  96.  
  97.     set removeCommand [CCCommand::removeName $path]
  98.     if [vsCommandHandler execute $removeCommand] {
  99.     # remove in user environment if remove in ClearCase succeeded
  100.     if [file exists $path] {
  101.         BasicFS::removeFile $path
  102.     }
  103.     return 1
  104.     }
  105.  
  106.     return 0
  107. }
  108.  
  109. method CCFile::renameInVS {this oldName} {
  110.     set dir [path_name directory [$this path]]
  111.  
  112.     # check out directory if necessary
  113.     if  { ![CCSystem::checkOutDirectory $dir \
  114.         "Checked out by ObjectTeam for file rename"] } {
  115.     return 0
  116.     }
  117.  
  118.     # construct old path from new path and old name
  119.     set fullName [path_name file [$this path]]
  120.     regsub ^[$this name] $fullName "" extensionPart
  121.     set oldPath [path_name concat [path_name directory [$this path]] \
  122.         "${oldName}$extensionPart"]
  123.  
  124.     set renameCommand [CCCommand::rename $oldPath [$this path]]
  125.     return [vsCommandHandler execute $renameCommand]
  126. }
  127.  
  128.  
  129. # Returns whether the file selected in the view
  130. # is checked out i.e. writable. For performance there is no
  131. # check if the file is actually in the vob.
  132. #
  133. method CCFile::isCheckedOut {this} {
  134.     return [file writable [$this path]]
  135. }
  136.  
  137. method CCFile::checkOut {this comment {reserved 1}} {
  138.     set checkoutCommand [CCCommand::checkOut [$this path] $comment $reserved]
  139.     return [vsCommandHandler execute $checkoutCommand]
  140. }
  141.  
  142. method CCFile::unCheckOut {this keepPrivate} {
  143.     set unCheckOutCommand [CCCommand::unCheckOut [$this path] $keepPrivate]
  144.     return [vsCommandHandler execute $unCheckOutCommand]
  145. }
  146.  
  147. method CCFile::checkIn {this noComment comment} {
  148.     set checkInCommand [CCCommand::checkIn [$this path] $noComment $comment]
  149.     return [vsCommandHandler execute $checkInCommand]
  150. }
  151.  
  152.  
  153. # Create the named branch on this file.
  154. #
  155. method CCFile::createBranch {this type comment} {
  156.     set createBranchCommand [CCCommand::createBranch [$this path] $type $comment]
  157.     return [vsCommandHandler execute $createBranchCommand]
  158. }
  159.  
  160. method CCFile::destroyBranch {this branch} {
  161.     set destroyBranchCommand [CCCommand::destroyBranch $branch]
  162.     return [vsCommandHandler execute $destroyBranchCommand]
  163. }
  164.  
  165.  
  166. # Reserve the checkout of this file.
  167. #
  168. method CCFile::reserve {this} {
  169.     set reserveCommand [CCCommand::reserve [$this path]]
  170.     return [vsCommandHandler execute $reserveCommand]
  171. }
  172.  
  173.  
  174. # Unreserve the checkout for this file.
  175. #
  176. method CCFile::unreserve {this} {
  177.     set unreserveCommand [CCCommand::unreserve [$this path]]
  178.     return [vsCommandHandler execute $unreserveCommand]
  179. }
  180.  
  181.  
  182. # Set the file comment to the specified comment.
  183. #
  184. method CCFile::setComment {this comment} {
  185.     set setCommentCommand [CCCommand::changeComment [$this path] $comment]
  186.     return [vsCommandHandler execute $setCommentCommand]
  187. }
  188.  
  189.  
  190. # Returns the version extended pathname to the specified version.
  191. #
  192. method CCFile::getReference {this {version ""}} {
  193.     if { $version == "" } {
  194.     return [$this path]
  195.     }
  196.     return "[$this path]\@\@$version"
  197. }
  198.  
  199.  
  200. # Does nothing.
  201. #
  202. method CCFile::deleteReference {this path} {
  203. }
  204.  
  205.  
  206. # Sets the specified ClearCase attribute to the
  207. # specified value.
  208. #
  209. method CCFile::setAttribute {this name value} {
  210.     set setCommand [CCCommand::setAttribute [$this path] $name $value]
  211.     return [vsCommandHandler executeSilent $setCommand]
  212. }
  213.  
  214.  
  215. # Get the value of the specified ClearCase attribute.
  216. #
  217. method CCFile::getAttributeValue {this name} {
  218.     return [CCCommand::getAttributeValue [$this path] $name]
  219. }
  220.  
  221. # Do not delete this line -- regeneration end marker
  222.  
  223.