home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / reptool.tcl < prev    next >
Text File  |  1997-03-21  |  6KB  |  238 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1996
  4. #
  5. #      File:           @(#)reptool.tcl    /main/hindenburg/11
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)reptool.tcl    /main/hindenburg/11   21 Mar 1997 Copyright 1996 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12. require showversio.tcl
  13. require reptoolfon.tcl
  14. require reptoolurl.tcl
  15. # End user added include file section
  16.  
  17. require "wmttool.tcl"
  18.  
  19. Class RepTool : {MainWindow WmtTool} {
  20.     method destructor
  21.     constructor
  22.     method viewTitle
  23.     method viewIconTitle
  24.     method viewFile
  25.     method viewName
  26.     method viewIcon
  27.     method error
  28.     method warning
  29.     method message
  30.     method startView
  31.     method setFont
  32.     method getFont
  33.     method selectionChanged
  34.     method selectedObjSet
  35.     method fileOpen
  36.     method fileExit
  37.     method optionsFont
  38.     method helpOnContext
  39.     method helpOnName
  40.     attribute levelPath
  41.     attribute levelPathIds
  42.     attribute menuHandler
  43.     attribute viewInfo
  44.     attribute fontChooser
  45. }
  46.  
  47. method RepTool::destructor {this} {
  48.     # Start destructor user section
  49.  
  50.         $this saveWindowGeometry reptool
  51.     $this saveMessageAreaPresence reptool
  52.  
  53.     # End destructor user section
  54.     $this WmtTool::destructor
  55. }
  56.  
  57. constructor RepTool {class this name} {
  58.     set this [MainWindow::constructor $class $this $name]
  59.     set this [WmtTool::constructor $class $this $name]
  60.  
  61.     # Configure the main window.
  62.     #
  63.     $this config \
  64.     -title "ObjectTeam Repository Tool" \
  65.     -closed {%this fileExit} \
  66.         -exitButton $this.bar.file.menu.exit \
  67.     -iconTitle "Repository Tool" \
  68.     -icon rep_tool_64
  69.  
  70.     $this setWindowGeometry reptool
  71.  
  72.     # Define views.
  73.     #
  74.     set list [List new]
  75.     $list contents {
  76.         {corp "Corporate Management" corpmanvie CorpManView rep_corp_32}
  77.         {uenv "User Environment" userenvvie UserEnvView rep_uenv_32}
  78.         {lock "Lock Management" lockmanvie LockManView rep_lock_32}
  79.         {conf "Client/Server Configuration" csconfigvi CSConfigView rep_conf_32}
  80.     }
  81.  
  82.     # Create component user interface parts.
  83.     # Default row and column counts are based on default font
  84.     # courier-normal-12.
  85.     #
  86.     MenuBar new $this.bar
  87.     interface DlgColumn $this.gui {
  88.         BrowsView views {
  89.             mode ICON
  90.             selectionPolicy SINGLE
  91.             columnCount 69
  92.             rowCount 3
  93.         }
  94.     }
  95.     $this.gui.views selectionChanged "$this selectionChanged"
  96.     $this.gui.views font [m4_var get M4_font -context reptool]
  97.  
  98.     # Make a dictionary for fast view lookup.
  99.     #
  100.     $this viewInfo [Dictionary new]
  101.  
  102.     # Create view browser objects.
  103.     #
  104.     $list foreach view {
  105.         set key [lindex $view 0]
  106.         [$this viewInfo] set $key [lrange $view 1 end]
  107.         BrowsObject new $this.gui.views.$key \
  108.         -activated "$this startView $key" \
  109.         -smallIcon [$this viewIcon $key] \
  110.         -largeIcon [$this viewIcon $key] \
  111.         -label [$this viewIconTitle $key]
  112.     }
  113.  
  114.     # Install menu handler.
  115.     #
  116.     $this menuHandler [CustBrMenuHandler new reptool]
  117.     catch {[$this menuHandler] setCurrentContext}
  118.     catch {[$this menuHandler] selectionChanged}
  119.  
  120.     $this setMessageAreaPresence reptool
  121.  
  122.     return $this
  123. }
  124.  
  125. method RepTool::viewTitle {this name} {
  126.     return [lindex [[$this viewInfo] set $name] 0]
  127. }
  128.  
  129. method RepTool::viewIconTitle {this name} {
  130.     set title [lindex [[$this viewInfo] set $name] 0]
  131.     regsub -all " " $title "\n" title
  132.     return $title
  133. }
  134.  
  135. method RepTool::viewFile {this name} {
  136.     return [lindex [[$this viewInfo] set $name] 1].tcl
  137. }
  138.  
  139. method RepTool::viewName {this name} {
  140.     return [lindex [[$this viewInfo] set $name] 2]
  141. }
  142.  
  143. method RepTool::viewIcon {this name} {
  144.     return [lindex [[$this viewInfo] set $name] 3]
  145. }
  146.  
  147. method RepTool::error {this msg} {
  148.     global errorCode
  149.     set errorCode 0
  150.  
  151.     wmtkerror $msg
  152. }
  153.  
  154. method RepTool::warning {this msg} {
  155.     wmtkwarning $msg
  156. }
  157.  
  158. method RepTool::message {this msg} {
  159.     wmtkmessage $msg    
  160. }
  161.  
  162. method RepTool::startView {this name} {
  163.     $this message "Starting '[$this viewTitle $name]' tool..."
  164.  
  165.     SystemUtilities::fork otk reptoolpop \
  166.         -caller [get_comm_name] \
  167.         -levelPath [$this levelPath] \
  168.         -levelPathIds [$this levelPathIds] \
  169.         [$this viewFile $name]
  170. }
  171.  
  172. method RepTool::setFont {this font} {
  173.     if [catch {m4_var set M4_font $font -context reptool}] {
  174.     $this error "Unable to set font for Repository Tool."
  175.     }
  176.     $this.gui.views font $font
  177. }
  178.  
  179. method RepTool::getFont {this} {
  180.     return [$this.gui.views font]
  181. }
  182.  
  183. method RepTool::selectionChanged {this} {
  184.     set handler [$this menuHandler]
  185.     if {$handler != ""} {
  186.         $handler selectionChanged
  187.     }
  188. }
  189.  
  190. method RepTool::selectedObjSet {this} {
  191.     return [$this.gui.views selectedSet]
  192. }
  193.  
  194. method RepTool::fileOpen {this} {
  195.     set names [split [$this.gui.views selectedSet] .]
  196.     set end [llength $names]
  197.     incr end -1
  198.     $this startView [lindex $names $end]
  199. }
  200.  
  201. method RepTool::fileExit {this} {
  202.     $this message "Exiting..."
  203.     $this stop
  204. }
  205.  
  206. method RepTool::optionsFont {this} {
  207.     if {[$this fontChooser] == ""} {
  208.         $this fontChooser [RepToolFontChooser new $this.fontdlg $this]
  209.     }
  210.     [$this fontChooser] popUp
  211. }
  212.  
  213. method RepTool::helpOnContext {this} {
  214.     set obj [$this selectedObjSet]
  215.     if ![lempty $obj] {
  216.     set names [split $obj .]
  217.     set end [llength $names]
  218.     incr end -1
  219.     set name [lindex $names $end]
  220.  
  221.         $this helpOnName "repTool[$this viewName $name]"
  222.     } else {
  223.         $this helpOnName "repToolMain"
  224.     }
  225. }
  226.  
  227. method RepTool::helpOnName {this name} {
  228.     global short2url
  229.     if [catch {set url $short2url($name)}] {
  230.     $this error "Sorry, no help available for '$name'"
  231.     } else {
  232.     showHelp $url
  233.     }
  234. }
  235.  
  236. # Do not delete this line -- regeneration end marker
  237.  
  238.