home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
browser.tcl
< prev
next >
Wrap
Text File
|
1997-11-05
|
10KB
|
405 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)browser.tcl /main/titanic/25
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)browser.tcl /main/titanic/25 5 Nov 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
require "browseropt.tcl"
require "brsymb2url.tcl"
require "classmaker.tcl"
require "dragbrowsv.tcl"
require "infoobject.tcl"
require "showversio.tcl"
# End user added include file section
require "commonbrow.tcl"
# Definition of Browser class.
# This class contains basic operations of the browsers.
Class Browser : {CommonBrowser} {
method destructor
constructor
method createInterface
method editCut
method getExpandedSelection
method helpOnContext
method helpOnName
method initView
method popUp
method selectedObjSet
method selectedNameSet
method selectionChanged
method setViewButton
method setViewMode
method updateView
method getStatus
method setStatus
method removeStatus
attribute _selectedObjSet
attribute _selectedNameSet
attribute initialContext
attribute undoButton
attribute propKnowledgeDB
attribute status
}
method Browser::destructor {this} {
# Start destructor user section
if [$this opened] {
$this saveWindowGeometry desk
}
catch {
[$this propKnowledgeDB] delete
}
# End destructor user section
$this CommonBrowser::destructor
}
constructor Browser {class this name} {
set this [CommonBrowser::constructor $class $this $name desk]
# Return if an error box is already popped up
if [isCommand .main.error] {
return $this
}
$this status [Dictionary new]
$this propKnowledgeDB [PropKnowledgeDB new \
$this.propKnowledgeDB [$this moduleHdlr]]
# create flat view
[$this infoView] area [DragBrowsView new [$this infoView].area \
-selectionChanged {.main selectionChanged} \
-mode [m4_var get M4_infoview_mode -context desk] \
-font "[m4_var get M4_font -context desk]" \
-columnCount 46 \
-selectionPolicy EXTENDED]
# create popup menu for view
ViewPopUpMenu new [[$this infoView] area].pop \
-poppedUp {
[[.main infoView] area].pop entrySet \
[[.main menuHdlr] validPopUpEntrySet]
}
# config interface
[$this navigationView] config \
-selectionChanged {%this updateSelected} \
-font "[m4_var get M4_font -context desk]" \
-rowCount 12 \
-columnCount 32
$this notSavedM4Vars {
M4_corproles__*
M4_projroles__*
M4_levelpath_ids
M4_parent_pid
}
$this setWindowGeometry desk
[$this treeView] view [$this flatView]
[$this flatView] tree [$this treeView]
return $this
}
method Browser::createInterface {this} {
$this CommonBrowser::createInterface
$this viewSelector [$this menuBar].view.menu
$this exitButton [$this menuBar].file.menu.exit
$this undoButton [$this menuBar].edit.menu.undo
}
# Redefine editCut to expand the
# selection in the browser using copyspecs.
#
method Browser::editCut {this} {
set oldSelection [$this selectedSet]
$this selectedSet [$this getExpandedSelection $oldSelection]
$this CommonBrowser::editCut
$this selectedSet $oldSelection
}
# If selectedSet contains FileVersions
# expand the selection using copyspecs and
# return it.
#
method Browser::getExpandedSelection {this selection} {
if { ![[[lindex $selection 0] browsUiObj] isA FileVersion] } {
return $selection
}
set fileVersions {}
foreach object $selection {
lappend fileVersions [$object browsUiObj]
}
# retrieve config and system to invoke the action
set cc [ClientContext::global]
set sysV [$cc currentSystem]
set confV [$cc currentConfig]
if { [$sysV isNil] || [$confV isNil] } {
# this should not happen
return $selection
}
# this action may take a while
busy {
$sysV SystemVersion::copy -specified $fileVersions noCopy files $confV
# find related browser objects
set objects {}
if { [$this selectionOwner] == [$this flatView] } {
foreach file $files {
lappend objects [$file infoObject]
}
} else {
foreach file $files {
global ${file}::treeNode
lappend objects [set ${file}::treeNode]
}
}
}
return $objects
}
method Browser::helpOnContext {this} {
if {[llength [$this selectedObjSet]] == 1} {
set prefix ""
set obj [lindex [$this selectedObjSet] 0]
} else {
set prefix "crnt_"
set currentObj [$this currentObj]
if {"$currentObj" == ""} {
set obj [$this corporateObj]
} else {
set obj [$currentObj browsUiObj]
}
}
set browserObjType [$obj browserObjType]
case "$browserObjType" in {
{CustFVDbObj DSysVDbObj ExtFUiObj LocalSection
PSysVDbObj SFileLDbObj SSysVDbObj UsrLDbObj} {
set localKey "${prefix}$browserObjType"
}
ExtFVDbObj {
set phType [[$obj phase] type]
if {$phType == "Implementation"} {
# fixed one, if separate help is developed
# we need the else case again + module adaption
set localKey extFileInImpl
} else {
# default
set localKey "${prefix}[$obj browserType]"
}
}
default {
set localKey "${prefix}[$obj browserType]"
}
}
$this helpOnName $localKey
}
method Browser::helpOnName {this name} {
global short2url
if {! [catch {set url $short2url($name)}]} {
showHelp $url
return
}
if [regsub "crnt_" $name "" name] {
$this helpOnName $name
return
}
wmtkerror "Sorry, no help available for '$name'"
}
method Browser::initView {this} {
busy {
wmtkmessage "Loading ..."
$this open
# Initialize according to the initialContext
if {"[$this initialContext]" == ""} {
set treeNode [lindex [[$this treeView] rootSet] 0]
} else {
set treeNode ""
foreach objId [$this initialContext] {
if {"$treeNode" == ""} {
set childSet [[$this treeView] rootSet]
} else {
$treeNode foldState 0
$treeNode appendChildren
set childSet [$treeNode childSet]
}
set found 0
foreach childNode $childSet {
set identity [[$childNode browsUiObj] uiIdentity]
if {"$identity" == "$objId"} {
set found 1
break
}
}
if {! $found} {
break
}
set treeNode $childNode
if {! [[$treeNode browsUiObj] hasChildren]} {
break
}
}
}
BrowserProcs::initializeInfo [$treeNode browsUiObj] $treeNode
$treeNode open
$this setViewButton
checkModuleWarnings
wmtkmessage Done
}
}
method Browser::popUp {this} {
$this CommonBrowser::popUp
$this setViewButton
}
method Browser::selectedObjSet {this} {
set selectedObjSet [$this _selectedObjSet]
if {"$selectedObjSet" == "undefined"} {
set selectedObjSet ""
set selection [concat \
[[$this treeView] selected] \
[[$this flatView] selectedSet] \
]
foreach obj $selection {
lappend selectedObjSet [$obj browsUiObj]
}
$this _selectedObjSet $selectedObjSet
}
if $makeSelectionUpToDate {
foreach obj $selectedObjSet {
$obj makeUpToDate
}
}
return $selectedObjSet
}
method Browser::selectedNameSet {this} {
set selectedNameSet [$this _selectedNameSet]
if {"$selectedNameSet" == "undefined"} {
set selectedNameSet ""
set selection [concat \
[[$this treeView] selected] \
[[$this flatView] selectedSet] \
]
foreach obj $selection {
set browsUiObj [$obj browsUiObj]
lappend selectedNameSet [list \
"[$browsUiObj getInfo Name]" "[$browsUiObj getInfo Type]" \
]
}
$this _selectedNameSet $selectedNameSet
}
return $selectedNameSet
}
# This function is called when the selected state
# has changed.
#
method Browser::selectionChanged {this {keepSelection 0}} {
if $keepSelection {
# Keep the selected objects that still exist selected
set selectedSet ""
foreach obj [[$this flatView] selectedSet] {
if [$obj filteredOutState] continue
lappend selectedSet $obj
}
[$this flatView] selectedSet $selectedSet
}
[$this status] contents ""
$this _selectedObjSet "undefined"
$this _selectedIdSet "undefined"
$this _selectedNameSet "undefined"
$this _selectedNameTypeSet "undefined"
$this CommonBrowser::selectionChanged
[$this flatView] updateConversionSet
}
# Select the view-radioButton button according to the
# view-mode of the current view.
#
method Browser::setViewButton {this} {
set arbiter [$this menuBar].view.menu.menuarbiter
if {! [isCommand $arbiter]} return
case "[[$this flatView] mode]" in {
{ICON} {$arbiter currentButton 0}
{SMALLICON} {$arbiter currentButton 1}
{DETAIL} {$arbiter currentButton 2}
}
}
# Set the mode of the view according to the current
# selected view-radioButton.
#
method Browser::setViewMode {this} {
set arbiter [$this menuBar].view.menu.menuarbiter
if {! [isCommand $arbiter]} return
case "[$arbiter currentButton]" in {
{0} {[$this flatView] mode ICON}
{1} {[$this flatView] mode SMALLICON}
{2} {[$this flatView] mode DETAIL}
}
m4_var set M4_infoview_mode [[$this flatView] mode] -context desk
}
method Browser::updateView {this} {
global makeSelectionUpToDate
set makeSelectionUpToDate 0
busy {
[$this infoView] display ""
[.main treeView] rebuild
.main selectionChanged 1
}
set makeSelectionUpToDate 1
}
# Do not delete this line -- regeneration end marker
method Browser::getStatus {this value} {
return [[$this status] set $value]
}
method Browser::setStatus {this value newStatus} {
[$this status] set $value $newStatus
}
method Browser::removeStatus {this value} {
[$this status] unset $value
}