home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
viewdefine.tcl
< prev
next >
Wrap
Text File
|
1997-10-23
|
19KB
|
738 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)viewdefine.tcl /main/titanic/4
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)viewdefine.tcl /main/titanic/4 23 Oct 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
require commandpag.tcl
require custfileut.tcl
require propview.tcl
# End user added include file section
require "defstoredi.tcl"
Class ViewDefineDialog : {DefStoreDialog} {
constructor
method destructor
method createInterface
method clearInterface
method sensitive
method fromInterface
method toInterface
method levelChanged
method associationChanged
method load
method save
method objName
method readAllMenuEntries
method createMenuObjects
method getRepTypeScope
method setRepTypeScope
method removeRepTypeScope
attribute iPage
attribute pPage
attribute sortPage
attribute allMenuEntries
attribute possibleMenuEntries
attribute repTypeScope
}
constructor ViewDefineDialog {class this name} {
set this [DefStoreDialog::constructor $class $this $name]
$this repTypeScope [Dictionary new]
# Start constructor user section
$this readAllMenuEntries
$this helpPressed \
".main helpOnName viewProp\[\[$this currentPage] label]Page"
$this setRepTypeScope contents {
ConfigVersion {0 0 1 0 0}
ControlledClass {1 1 0 0 0}
ControlledClasses {1 1 0 0 0}
Corporate {1 0 0 0 0}
CorporateGroupVersion {1 0 0 0 0}
CorporateGroupVersions {1 0 0 0 0}
CustomFileVersions {0 1 1 1 1}
CustomFiles {1 0 0 0 0}
ExternalFileVersion {1 0 0 0 1}
ExternalLink {0 0 0 0 1}
Graph {1 0 0 0 1}
GroupVersion {0 0 0 0 1}
Matrix {1 0 0 0 1}
PhaseVersion {0 0 0 1 0}
Project {0 1 0 0 0}
Role {1 1 0 0 0}
Roles {1 1 0 0 0}
SavedGroupVersion {1 0 0 0 1}
SavedGroupVersions {0 0 0 0 1}
SystemFileReference {0 0 0 0 1}
SystemVersion {0 0 0 0 1}
DocumentVersion {0 0 0 0 1}
UserCustomFiles {1 0 0 0 0}
Users {1 0 0 0 0}
WorkItems {0 0 0 0 1}
}
# read phases file
getPhases
foreach phase ${BrowserProcs::phases} {
set phaseType [lindex $phase 1]
if [[$this repTypeScope] exists "$phaseType"] continue
$this setRepTypeScope "$phaseType" \
[$this getRepTypeScope PhaseVersion]
}
# End constructor user section
return $this
}
method ViewDefineDialog::destructor {this} {
# Start destructor user section
# End destructor user section
$this DefStoreDialog::destructor
}
method ViewDefineDialog::createInterface {this} {
#indentation of this function is 4 spaces to make it easier to read
$this DefStoreDialog::createInterface
# create "interface" page
interface NoteBkPage $this.InterfaceNBP {
label Interface
NamedGroup NG {
HorSplitter HS {
DlgRow DR {
verStretchFactor 0
NamedGroup NG {
label Name
SingleLineText nameSLT {}
}
}
DlgRow DR {
sizeEqual 1
NamedGroup NG {
label Associations
TextList associationsTL {
rowCount 5
selectionPolicy MULTIPLE
}
}
NamedGroup NG {
label Types
TextList typesTL {
rowCount 5
selectionPolicy MULTIPLE
}
}
}
DlgRow DR {
NamedGroup NG {
label ToolBarEntries
TextList toolBarEntriesTL {
rowCount 10
selectionPolicy MULTIPLE
}
}
}
}
}
}
# create "properties" page
interface NoteBkPage $this.PropertyNBP {
label Properties
DlgColumn DC {
NamedGroup NG {
label "Visible Properties"
PropView propertiesBV {
mode DETAIL
rowCount 6
BrowsHeader nameBH {
label "Name"
width 15
}
BrowsHeader widthBH {
label "Width"
width 8
}
BrowsHeader sortKindBH {
label "Sort Kind"
width 12
}
BrowsHeader sortPolBH {
label "Sort Policy"
width 12
}
BrowsHeader sortOrderBH {
label "Sort Order"
width 13
}
}
}
NamedGroup NG {
label "Hidden Properties"
PropView hidpropertiesBV {
mode DETAIL
rowCount 6
BrowsHeader nameBH {
label "Name"
width 15
}
BrowsHeader widthBH {
label "Width"
width 8
}
BrowsHeader sortKindBH {
label "Sort Kind"
width 12
}
BrowsHeader sortPolBH {
label "Sort Policy"
width 12
}
BrowsHeader sortOrderBH {
label "Sort Order"
width 13
}
}
}
}
}
# create "sort command page" page
interface NoteBkPage $this.SortCommandNBP {
label "Sort Command"
NamedGroup NG {
label "Sort Command"
DlgColumn DC {
SingleLineText sortProcSLT {
}
}
}
}
$this iPage $this.InterfaceNBP.NG.HS.DR.NG
$this pPage $this.PropertyNBP.DC.NG
$this sortPage $this.SortCommandNBP.NG
[$this iPage].associationsTL selectionChanged "$this associationChanged"
}
method ViewDefineDialog::clearInterface {this} {
$this DefStoreDialog::clearInterface
[$this iPage].nameSLT text ""
[$this iPage].associationsTL selectedSet {}
$this associationChanged
[$this iPage].typesTL selectedSet {}
[$this iPage].toolBarEntriesTL selectedSet {}
[$this sortPage].DC.sortProcSLT text ""
}
method ViewDefineDialog::sensitive {this args} {
$this DefStoreDialog::sensitive $args
if {[llength $args] == 0} {
return [[$this iPage].nameSLT sensitive]
} else {
set sensitive [lindex $args 0]
}
[$this iPage].nameSLT sensitive $sensitive
[$this iPage].associationsTL sensitive $sensitive
[$this iPage].typesTL sensitive $sensitive
[$this iPage].toolBarEntriesTL sensitive $sensitive
[$this sortPage].DC.sortProcSLT sensitive $sensitive
[$this pPage].propertiesBV sensitive $sensitive
[$this pPage].hidpropertiesBV sensitive $sensitive
return $sensitive
}
method ViewDefineDialog::fromInterface {this} {
set sortCommand [[$this sortPage].DC.sortProcSLT text]
if ![CommandPage::checkBraces $sortCommand] {
wmtkerror "Brace mismatch in Sort Command"
return ""
}
# save page "Interface"
set i [$this iPage]
set spec [list associations [$i.associationsTL selectedSet]]
lappend spec objectTypes [$i.typesTL selectedSet]
#find the tcl name of the choosen entries
set selIdx [$i.toolBarEntriesTL selectedIndexSet]
set selObjects {}
set objects [$this possibleMenuEntries]
foreach i $selIdx {
lappend selObjects [lindex [lindex $objects $i] 1]
}
lappend spec toolBarEntries $selObjects
# save page "Properties"
set props [[$this pPage].propertiesBV objectSet]
set order {}
foreach prop [[$this pPage].propertiesBV objectSet] {
if {[lindex [$prop details] 2] != "none"} {
lappend order [lindex [$prop details] 3]
}
}
set ordercount [expr {[llength $order] +1}]
# check if sortorder is correct
for {set i 1} {$i < $ordercount} {incr i} {
if {[lsearch $order $i] == -1} {
wmtkerror "Invalid sort order, order '$i' not found."
return ""
}
}
set spec "$spec properties \{"
foreach prop [[$this pPage].propertiesBV objectSet] {
set details [$prop details]
if {[llength [$prop label]] != 1} {
set de \{[$prop label]\}
} else {
set de [$prop label]
}
lappend de "[lindex $details 0]"
lappend de "[lindex $details 1]"
set policy [lindex $details 2]
if {$policy != "none"} {
set lst [list "[lindex $details 2]" "[lindex $details 3]"]
lappend de $lst
} else {
set lst [lindex $details 2]
set de "$de \{$lst\}"
}
set spec "$spec \{$de\}\n\t\t\t\t"
}
set spec "$spec\}"
if {$sortCommand != ""} {
set spec "$spec sortScript \{$sortCommand\}"
}
return $spec
}
method ViewDefineDialog::toInterface {this key value} {
# page "Interface"
if {$key == "displayName"} {
[$this iPage].nameSLT text $value
return
}
if {$key == "associations"} {
[$this iPage].associationsTL selectedSet $value
$this associationChanged
return
}
if {$key == "objectTypes"} {
[$this iPage].typesTL selectedSet $value
return
}
if {$key == "toolBarEntries"} {
#find the display name of the choosen entries
set selObjects $value
set selIdx {}
set selNames {}
set objects [$this possibleMenuEntries]
foreach i $selObjects {
set count 0
foreach j $objects {
if {$i == [lindex $j 1]} {
lappend selIdx $count
}
incr count
}
}
[$this iPage].toolBarEntriesTL selectedIndexSet $selIdx
return
}
# page "Properties"
if {$key == "properties"} {
set propSet [[$this pPage].hidpropertiesBV objectSet]
set index 1
foreach i $value {
set propName [lindex $i 0]
foreach prop $propSet {
if {![isCommand $prop]} {
continue
}
if {$propName == [$prop label]} {
set de [$prop details]
set de [lreplace $de 0 0 [lindex $i 1]]
set de [lreplace $de 1 1 [lindex $i 2]]
set j [lindex $i 3]
set de [lreplace $de 2 2 [lindex $j 0]]
set de [lreplace $de 3 3 [lindex $j 1]]
$prop details $de
set prop [$prop reParent \
[$this pPage].propertiesBV]
$prop index $index
}
}
incr index
}
}
if {$key == "sortScript"} {
[$this sortPage].DC.sortProcSLT text $value
}
}
method ViewDefineDialog::levelChanged {this newLevel} {
set menus {}
set menuObjects {}
foreach i [$this allMenuEntries] {
set uiName [lindex $i 0]
set name [lindex $i 1]
set visible [lindex $i 2]
set scope [lindex $i 3]
# check if the object is visible on this level
if {[lindex $visible $newLevel] == 0 } {
continue
}
if {[llength $scope] > [llength [$this objScope]]} {
continue
}
set in 1
foreach x [$this objScope] {
set index 0
foreach y $x {
set z [lindex $scope $index]
if { $z != "" && $z != "*" } {
if {[lsearch $z $y] == -1} {
set in 0
}
}
incr index
}
}
if { $in == 1 } {
lappend menus [format "%-25s path: %s" $uiName $name]
lappend menuObjects $i
}
}
$this possibleMenuEntries $menuObjects
[$this iPage].toolBarEntriesTL entrySet $menus
}
method ViewDefineDialog::associationChanged {this} {
set typeList ""
set orgSelectedSet [[$this iPage].typesTL selectedSet]
set selAsso [[$this iPage].associationsTL selectedSet]
set class /
foreach asso $selAsso {
set object [$this curObject]
set objClass [.main getBrowsObj [$object repositoryType]]
# determine the right system type
if {$objClass == "SSysVDbObj"} {
# assocs are different for a Document
if {[$object browserType] == "DocumentVersion"} {
set types [DSysVDbObj::childTypes $asso]
} else {
# because if not possible to determine
# the right phase, take all the possibilities
set types [concat \
[PSysVDbObj::childTypes $asso] \
[SSysVDbObj::childTypes $asso]]
}
} else {
set types [$objClass::childTypes $asso]
}
foreach i $types {
set idx [lsearch $typeList $i]
# if this type is not in the current list, add it
if {$idx == -1} {
set typeList [concat $typeList $i]
}
}
}
[$this iPage].typesTL entrySet $typeList
[$this iPage].typesTL selectedSet $orgSelectedSet
}
method ViewDefineDialog::load {this object} {
set associations ""
# get all the associations of the current loaded object
set objClass [.main getBrowsObj [$object repositoryType]]
if {$objClass == "SSysVDbObj"} {
# assocs are different for a Document
if {[$object browserType] == "DocumentVersion"} {
set objClass DSysVDbObj
} else {
set objClass PSysVDbObj
}
}
if {![isCommand $objClass]} {
wmtkmessage "No associations found for type \
'[$object repositoryType]'"
} else {
foreach i [$objClass::associations] {
#if this associations is not in the current list, add it
if { [lsearch $associations $i] == -1} {
lappend associations $i
}
}
}
# get the associationsClasses of the objClass
# from these classes the infoProperties must be shown
set infoProps ""
set assocClasses ""
# get all the infoProps of the associationsClasses
foreach association $associations {
case "$association" in {
{customFileVersions} {
set assocClasses {CustFVDbObj}
}
{directFileVersions fileVersions localFileVersions} {
set assocClasses {ExtFVDbObj GraphVDbObj MtrxVDbObj}
}
{definedItems} {
set assocClasses {WItemDbObj}
}
{externalFiles} {
set assocClasses {ExtFUiObj}
}
{externalLinks} {
set assocClasses {ExtLDbObj}
}
{fileVersionReferences} {
set assocClasses {SFileLDbObj}
}
{phaseVersions} {
set assocClasses {PhaseVDbObj}
}
{roleLinks userLinks} {
set assocClasses {UsrLDbObj}
}
{rules} {
set assocClasses {RuleUiObj}
}
{sections} {
set assocClasses \
{ExtFVDbObj SFileLDbObj FilePRDbObj ItemPRDbObj}
}
{default} {
set childTypes [$objClass::childTypes $association]
set assocClasses ""
foreach childType $childTypes {
lappend assocClasses [.main getBrowsObj $childType]
}
}
}
foreach class $assocClasses {
if {![isCommand $class::infoProperties]} {
continue
}
foreach prop [$class::infoProperties] {
# if this infoProp is not in the current list,
# add it
if { [lsearch $infoProps $prop] == -1} {
lappend infoProps $prop
}
}
}
}
[$this iPage].associationsTL entrySet $associations
# refresh the types that belongs to the new associations
$this associationChanged
set props [$this pPage].propertiesBV
# delete the old propertyList
foreach row [[$this pPage].propertiesBV objectSet] {
$row delete
}
foreach row [[$this pPage].hidpropertiesBV objectSet] {
$row delete
}
# build the new propertyList
set index 0
set props [$this pPage].hidpropertiesBV
foreach i $infoProps {
PropViewObject new $props.$index
$props.$index label $i
$props.$index details "10 ascii none {}"
incr index
}
$this DefineDialog::load $object
if [$object editable] {
$this sensitive 1
} else {
$this sensitive 0
}
}
method ViewDefineDialog::save {this popDown} {
if {![[$this curObject] editable]} {
if {$popDown == 1} {
$this popDown
}
return
}
# check if level is correct
set objScope [$this objScope]
set repType [[$this curObject] repositoryType]
set validScope [$this getRepTypeScope $repType]
set index [llength $objScope]
if {$validScope == "" || [lindex $validScope $index]} {
if {[$this DefineDialog::save $popDown] == 1} {
# reset redefined attribute
[$this curObject] redefined 0
}
} else {
wmtkerror "Invalid scope specified for view of repository type \
'$repType'."
}
}
method ViewDefineDialog::objName {this args} {
if {$args == ""} {
return [[$this iPage].nameSLT text]
} else {
[$this iPage].nameSLT text [join $args]
}
}
method ViewDefineDialog::readAllMenuEntries {this} {
# use the current object to get all the specified menu's
# for this we need 'context' again
# don't read 'user' if it's curLevel is not 'user'
set menuName [[.main editorArea] _curName]
eval "proc registerObject {spec} {$this createMenuObjects \$spec}"
if { [[.main editorArea] _level] == "user"} {
# read always corporate
set corp [[ClientContext::global] currentCorporate]
CustFileUtilities::read $corp $menuName mnu etc
set file [path_name concat \
[path_name concat ~ icase] $menuName.mnu \
]
read_if_exist $file
} else {
foreach level [[.main editorArea] _path] {
CustFileUtilities::read $level $menuName mnu etc
}
}
}
method ViewDefineDialog::createMenuObjects {this spec} {
set objType ""
set objName ""
set objVisible ""
set objScope ""
set objUiName ""
set objPixmap ""
if {[string first toolBarPixmap $spec] == -1} {
return
}
while {![lempty $spec]} {
set key [lvarpop spec]
set value [lvarpop spec]
if {$key == "type"} {
set objType $value
if {$objType != "CustMenuPushButton" &&
$objType != "CheckButtonNode" &&
$objType != "CustMenuRadioButton"} {
return
}
} elseif {$key == "name"} {
set objName $value
} elseif {$key == "visible"} {
set objVisible $value
} elseif {$key == "scope"} {
set objScope $value
} elseif {$key == "objSpec"} {
# the label of the object itself is needed too
while {![lempty $value]} {
set key [lvarpop value]
set labelValue [lvarpop value]
if {$key == "label"} {
set objUiName $labelValue
} elseif {$key == "toolBarPixmap"} {
set objPixmap $labelValue
}
}
}
}
if {$objType == ""} {
return
}
if {$objPixmap == ""} {
return
}
$this allMenuEntries "[$this allMenuEntries] \{\"$objUiName\" \
$objName \"$objVisible\" \"$objScope\"\}"
}
# Do not delete this line -- regeneration end marker
method ViewDefineDialog::getRepTypeScope {this name} {
return [[$this repTypeScope] set $name]
}
method ViewDefineDialog::setRepTypeScope {this name newRepTypeScope} {
[$this repTypeScope] set $name $newRepTypeScope
}
method ViewDefineDialog::removeRepTypeScope {this name} {
[$this repTypeScope] unset $name
}