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

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1997
  4. #
  5. #      File:           @(#)razorfileu.tcl    /main/hindenburg/5
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)razorfileu.tcl    /main/hindenburg/5   30 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 "razorfile.tcl" razor
  15. require_module_file "vsfileobj.tcl" vcm
  16.  
  17. Class RazorFileUiObj : {RazorFile VSFileObj} {
  18.     constructor
  19.     method destructor
  20.     method initializeInfo
  21.     method showDiff
  22.     method path
  23.     method previousVersion
  24.     method promoter
  25.     method otherVersions
  26. }
  27.  
  28. constructor RazorFileUiObj {class this name type system i_name} {
  29.     set this [RazorFile::constructor $class $this $name $type $system]
  30.     set this [VSFileObj::constructor $class $this $i_name]
  31.     # Start constructor user section
  32.     # End constructor user section
  33.     return $this
  34. }
  35.  
  36. method RazorFileUiObj::destructor {this} {
  37.     # Start destructor user section
  38.     # End destructor user section
  39.     $this RazorFile::destructor
  40.     $this VSFileObj::destructor
  41. }
  42.  
  43.  
  44. # Reuse assocations of VSFileObj
  45. #
  46. proc RazorFileUiObj::associations {} {
  47.     return "[VSFileObj::associations]"
  48. }
  49.  
  50.  
  51. # Reuse child types of VSFileObj.
  52. #
  53. proc RazorFileUiObj::childTypes {assoc} {
  54.     return "[VSFileObj::childTypes $assoc]"
  55. }
  56.  
  57.  
  58. # Reuse controlledLists of VSFileObj.
  59. #
  60. proc RazorFileUiObj::controlledLists {} {
  61.     return "[VSFileObj::controlledLists]"
  62. }
  63.  
  64.  
  65. # Return properties of Razor File, apart from
  66. # standard properties these are: 
  67. # Status, Version, Title, Description, Issues, Path, Platform, Branch.
  68. #
  69. proc RazorFileUiObj::infoProperties {} {
  70.         return [concat \
  71.         [VSFileObj::infoProperties] \
  72.         {Version Status Owner "Last Modification" "Checked In" \
  73.         Path Title Description Issues "Razor Type" Platform State Branch} \
  74.         ]
  75. }
  76.  
  77.  
  78. # Initialize all info.
  79. #
  80. method RazorFileUiObj::initializeInfo {this dummy} {
  81.     $this VSFileObj::initializeInfo $dummy
  82.     $this setInfo Text "Razor File [file tail [$this path]]"
  83.     $this setInfo Path [$this vsPath]
  84.     set infoDict [Dictionary new]
  85.     RazorCommand::getProperties [$this vsPath] $infoDict
  86.  
  87.     # check if there is a result, if so copy properties
  88.     if { [$infoDict set Version] != "" } {
  89.     $infoDict foreach key value {
  90.         $this setInfo $key $value
  91.     }
  92.     } else {
  93.     # clear properties and indicate not found status
  94.     $this setInfo Version ""
  95.     $this setInfo "Last Modification" ""
  96.     $this setInfo "Checked In" ""
  97.     $this setInfo Status "<not found>"
  98.     $this setInfo Owner ""
  99.     $this setInfo State ""
  100.     $this setInfo "Razor Type" ""
  101.     $this setInfo Platform ""
  102.     $this setInfo Title ""
  103.     $this setInfo Issues ""
  104.     $this setInfo Description ""
  105.     }
  106.  
  107.     $this setInfo Branch [$this branchName]
  108. }
  109.  
  110.  
  111. # Show diff with version using a standard diff in a 
  112. # monitoring window. (Unix only).
  113. #
  114. method RazorFileUiObj::showDiff {this version {options ""}} {
  115.     set latestVersion [$this getReference]
  116.     set otherVersion [$this getReference $version]
  117.  
  118.     # check we actually got the references
  119.     if { ($latestVersion == "" ) || ($otherVersion == "") } {
  120.     return
  121.     }
  122.  
  123.     set diffCommand [VSCommand new "diff $latestVersion $otherVersion" "Diff"]
  124.     set endCommand "$this deleteReference $latestVersion"
  125.     set endCommand "$endCommand; $this deleteReference $otherVersion"
  126.  
  127.     vsCommandHandler executeExternal $diffCommand mtool $endCommand
  128. }
  129.  
  130.  
  131. # Returns result of path of RazorFile.
  132. #
  133. method RazorFileUiObj::path {this} {
  134.     return [$this RazorFile::path]
  135. }
  136.  
  137. method RazorFileUiObj::previousVersion {this} {
  138.     set owner [RazorCommand::getOwner [$this infoPath]]
  139.     if { "$owner" == "[M4Login::getUserName]" } {
  140.     return [$this getInfo Version]
  141.     }
  142.  
  143.     return [RazorCommand::getPredecessor [$this historyPath]]
  144. }
  145.  
  146. method RazorFileUiObj::promoter {this} {
  147.     $this RazorFile::promoter
  148.     $this VSFileObj::promoter
  149. }
  150.  
  151. method RazorFileUiObj::otherVersions {this} {
  152.     set versions [RazorCommand::getVersions [$this historyPath]]
  153.  
  154.     # remove latest version unless the current user has checked it out.
  155.     set owner [RazorCommand::getOwner [$this infoPath]]
  156.     if { "$owner" == "[M4Login::getUserName]" } {
  157.     return $versions
  158.     }
  159.  
  160.     set currentVersion [$this getInfo Version]
  161.     set currentVersionIndex [lsearch -exact $versions $currentVersion]
  162.     if { $currentVersionIndex == -1 } {
  163.     return $versions
  164.     }
  165.     return [join [lreplace $versions $currentVersionIndex $currentVersionIndex ""]]
  166. }
  167.  
  168. # Do not delete this line -- regeneration end marker
  169.  
  170.