home *** CD-ROM | disk | FTP | other *** search
/ PC World 1997 November / PCWorld_1997-11_cd.bin / software / programy / komix / DATA.Z / browser.tcl < prev    next >
Text File  |  1996-12-05  |  8KB  |  335 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1996
  4. #
  5. #      File:           @(#)browser.tcl    /main/hindenburg/15
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)browser.tcl    /main/hindenburg/15   5 Dec 1996 Copyright 1996 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12. require "browseropt.tcl"
  13. require "brsymb2url.tcl"
  14. require "classmaker.tcl"
  15. require "copyenvdia.tcl"
  16. require "dragbrowsv.tcl"
  17. require "infoobject.tcl"
  18. require "showversio.tcl"
  19. # End user added include file section
  20.  
  21. require "commonbrow.tcl"
  22.  
  23. # Definition of Browser class.
  24. # This class contains basic operations of the browsers.
  25.  
  26. Class Browser : {CommonBrowser} {
  27.     method destructor
  28.     constructor
  29.     method createInterface
  30.     method flatView
  31.     method helpOnContext
  32.     method helpOnName
  33.     method initView
  34.     method popUp
  35.     method selectedObjSet
  36.     method selectedNameSet
  37.     method selectionChanged
  38.     method setViewButton
  39.     method setViewMode
  40.     method treeView
  41.     method updateView
  42.     method getStatus
  43.     method setStatus
  44.     method removeStatus
  45.     attribute _selectedObjSet
  46.     attribute _selectedNameSet
  47.     attribute initialContext
  48.     attribute undoButton
  49.     attribute options
  50.     attribute propKnowledgeDB
  51.     attribute status
  52. }
  53.  
  54. method Browser::destructor {this} {
  55.     # Start destructor user section
  56.  
  57.     if [$this opened] {
  58.         $this saveWindowGeometry desk
  59.     }
  60.     catch {
  61.         [$this options] delete
  62.         [$this propKnowledgeDB] delete
  63.     }
  64.  
  65.     # End destructor user section
  66.     $this CommonBrowser::destructor
  67. }
  68.  
  69. constructor Browser {class this name} {
  70.     set this [CommonBrowser::constructor $class $this $name desk]
  71.  
  72.     # Return if an error box is already popped up
  73.     if [isCommand .main.error] {
  74.     return $this
  75.     }
  76.  
  77.     $this status [Dictionary new]
  78.  
  79.     $this options [BrowserOptions new $this.options]
  80.     [$this options] setContexts editor {"" DoctextSection}
  81.     [$this options] setContexts previewer {"" DoctextSection EpsfSection 
  82.     EpsiSection EpsSection PropertySection PsSection}
  83.     [$this options] setContexts viewer {"" DoctextSection PropertySection}
  84.  
  85.     $this propKnowledgeDB [PropKnowledgeDB new $this.propKnowledgeDB]
  86.  
  87.     # create flat view
  88.     [$this infoView] area [DragBrowsView new [$this infoView].area \
  89.     -selectionChanged {.main selectionChanged} \
  90.     -mode [m4_var get M4_infoview_mode -context desk] \
  91.     -font "[m4_var get M4_font -context desk]" \
  92.     -columnCount 46 \
  93.     -selectionPolicy EXTENDED]
  94.  
  95.     # create popup menu for view
  96.     ViewPopUpMenu new [[$this infoView] area].pop  \
  97.     -poppedUp {
  98.         [[.main infoView] area].pop entrySet \
  99.         [[.main menuHdlr] getValidPopUpEntrySet]
  100.     }
  101.  
  102.     # config interface
  103.     [$this navigationView] config \
  104.     -selectionChanged {%this updateSelected} \
  105.     -font "[m4_var get M4_font -context desk]" \
  106.     -rowCount 12 \
  107.     -columnCount 32
  108.     $this notSavedM4Vars {
  109.     M4_corproles__*
  110.     M4_projroles__*
  111.     M4_levelpath_ids
  112.     }
  113.     $this setWindowGeometry desk
  114.  
  115.     [$this treeView] view [$this flatView]
  116.     [$this flatView] tree [$this treeView]
  117.  
  118.     return $this
  119. }
  120.  
  121. method Browser::createInterface {this} {
  122.     $this CommonBrowser::createInterface
  123.     $this viewSelector [$this menuBar].view.menu
  124.     $this exitButton [$this menuBar].file.menu.exit
  125.     $this undoButton [$this menuBar].edit.menu.undo
  126. }
  127.  
  128. method Browser::flatView {this} {
  129.     return [[$this infoView] area]
  130. }
  131.  
  132. method Browser::helpOnContext {this} {
  133.     if {[llength [$this selectedObjSet]] == 1} {
  134.     set prefix ""
  135.     set obj [lindex [$this selectedObjSet] 0]
  136.     } else {
  137.     set prefix "crnt_"
  138.     set currentObj [$this currentObj]
  139.     if {"$currentObj" == ""} {
  140.         set obj [$this corporateObj]
  141.     } else {
  142.         set obj [$currentObj browsUiObj]
  143.     }
  144.     }
  145.  
  146.     set browserObjType [$obj browserObjType]
  147.     case "$browserObjType" in {
  148.     {CustFVDbObj DSysVDbObj ExtFUiObj LocalSection
  149.      PSysVDbObj SFileLDbObj SSysVDbObj UsrLDbObj} {
  150.         set localKey "${prefix}$browserObjType"
  151.     }
  152.     default {
  153.         set localKey "${prefix}[$obj browserType]"
  154.     }
  155.     }
  156.  
  157.     $this helpOnName $localKey
  158. }
  159.  
  160. method Browser::helpOnName {this name} {
  161.     global short2url
  162.     if {! [catch {set url $short2url($name)}]} {
  163.     showHelp $url
  164.     return
  165.     }
  166.  
  167.     if [regsub "crnt_" $name "" name] {
  168.     $this helpOnName $name
  169.     return
  170.     }
  171.  
  172.     wmtkerror "Sorry, no help available for '$name'"
  173. }
  174.  
  175. method Browser::initView {this} {
  176.     busy {
  177.     wmtkmessage "Loading ..."
  178.  
  179.     $this open
  180.  
  181.     # Initialize according to the initialContext
  182.     if {"[$this initialContext]" == ""} {
  183.         set treeNode [lindex [[$this treeView] rootSet] 0]
  184.     } else {
  185.         set treeNode ""
  186.         foreach objId [$this initialContext] {
  187.         if {"$treeNode" == ""} {
  188.             set childSet [[$this treeView] rootSet]
  189.         } else {
  190.             $treeNode foldState 0
  191.             $treeNode appendChildren
  192.             set childSet [$treeNode childSet]
  193.         }
  194.         set found 0
  195.         foreach childNode $childSet {
  196.             set identity [[$childNode browsUiObj] uiIdentity]
  197.             if {"$identity" == "$objId"} {
  198.             set found 1
  199.             break
  200.             }
  201.         }
  202.         if {! $found} {
  203.             break
  204.         }
  205.         set treeNode $childNode
  206.         if {! [[$treeNode browsUiObj] hasChildren]} {
  207.             break
  208.         }
  209.         }
  210.     }
  211.     BrowserProcs::initializeInfo [$treeNode browsUiObj] $treeNode
  212.     $treeNode open
  213.     $this setViewButton
  214.  
  215.     wmtkmessage Done
  216.     }
  217. }
  218.  
  219. method Browser::popUp {this} {
  220.     $this CommonBrowser::popUp
  221.     $this setViewButton
  222. }
  223.  
  224. method Browser::selectedObjSet {this} {
  225.     set selectedObjSet [$this _selectedObjSet]
  226.     if {"$selectedObjSet" == "undefined"} {
  227.     set selectedObjSet ""
  228.     foreach obj [[$this flatView] selectedSet] {
  229.         lappend selectedObjSet [$obj browsUiObj]
  230.     }
  231.     $this _selectedObjSet $selectedObjSet
  232.     }
  233.     return $selectedObjSet
  234. }
  235.  
  236. method Browser::selectedNameSet {this} {
  237.     set selectedNameSet [$this _selectedNameSet]
  238.     if {"$selectedNameSet" == "undefined"} {
  239.     set selectedNameSet ""
  240.     foreach obj [[$this flatView] selectedSet] {
  241.         set browsUiObj [$obj browsUiObj]
  242.         lappend selectedNameSet [list \
  243.         "[$browsUiObj getInfo Name]" "[$browsUiObj getInfo Type]" \
  244.         ]
  245.     }
  246.     $this _selectedNameSet $selectedNameSet
  247.     }
  248.     return $selectedNameSet
  249. }
  250.  
  251.  
  252. # This function is called when the selected state
  253. # has changed.
  254. #
  255. method Browser::selectionChanged {this {keepSelection 0}} {
  256.     if $keepSelection {
  257.     # Keep the selected objects that still exist selected
  258.     set selectedSet ""
  259.     foreach obj [[$this flatView] selectedSet] {
  260.         if [$obj filteredOutState] continue
  261.         lappend selectedSet $obj
  262.     }
  263.     [$this flatView] selectedSet $selectedSet
  264.     }
  265.  
  266.     [$this status] contents ""
  267.  
  268.     $this _selectedObjSet "undefined"
  269.     $this _selectedIdSet "undefined"
  270.     $this _selectedNameSet "undefined"
  271.     $this _selectedNameTypeSet "undefined"
  272.  
  273.     $this CommonBrowser::selectionChanged
  274.  
  275.     [$this flatView] updateConversionSet
  276. }
  277.  
  278.  
  279. # Select the view-radioButton button according to the
  280. # view-mode of the current view.
  281. #
  282. method Browser::setViewButton {this} {
  283.     set arbiter [$this menuBar].view.menu.menuarbiter
  284.     if {! [isCommand $arbiter]} return
  285.  
  286.     case "[[$this flatView] mode]" in {
  287.     {ICON}        {$arbiter currentButton 0}
  288.     {SMALLICON} {$arbiter currentButton 1}
  289.     {DETAIL}    {$arbiter currentButton 2}
  290.     }
  291. }
  292.  
  293.  
  294. # Set the mode of the view according to the current
  295. # selected view-radioButton.
  296. #
  297. method Browser::setViewMode {this} {
  298.     set arbiter [$this menuBar].view.menu.menuarbiter
  299.     if {! [isCommand $arbiter]} return
  300.  
  301.     case "[$arbiter currentButton]" in {
  302.     {0} {[$this flatView] mode ICON}
  303.     {1} {[$this flatView] mode SMALLICON}
  304.     {2} {[$this flatView] mode DETAIL}
  305.     }
  306.     m4_var set M4_infoview_mode [[$this flatView] mode] -context desk
  307. }
  308.  
  309. method Browser::treeView {this} {
  310.     return [$this navigationView]
  311. }
  312.  
  313. method Browser::updateView {this} {
  314.     busy {
  315.     [.main treeView] rebuild
  316.     [$this infoView] display ""
  317.     .main selectionChanged 1
  318.     }
  319. }
  320.  
  321. # Do not delete this line -- regeneration end marker
  322.  
  323. method Browser::getStatus {this value} {
  324.     return [[$this status] set $value]
  325. }
  326.  
  327. method Browser::setStatus {this value newStatus} {
  328.     [$this status] set $value $newStatus
  329. }
  330.  
  331. method Browser::removeStatus {this value} {
  332.     [$this status] unset $value
  333. }
  334.  
  335.