home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)browsuiobj.tcl /main/titanic/12
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)browsuiobj.tcl /main/titanic/12 29 Sep 1997 Copyright 1997 Cayenne Software Inc.
-
- # Start user added include file section
- # End user added include file section
-
-
- Class BrowsUiObj : {Object} {
- method destructor
- constructor
- method promoter
- method allowsDrop
- method browserObjType
- method browserType
- method canBeDragged
- method canBeMoved
- method cleanup
- method customLevelVersion
- method displayName
- method filterType
- method getIndentation
- method getParent
- method hasChildren
- method initializeChildSet
- method initializeInfo
- method makeUpToDate
- method recursiveIdSet
- method recursiveObjSet
- method rules
- method setIndentation
- method typeInLabel
- method uiClass
- method uiIdentity
- method versionInLabel
- method infoObject
- method getChildSet
- method setChildSet
- method removeChildSet
- method getInfo
- method setInfo
- method removeInfo
- attribute uiName
- attribute uiPrefix
- attribute uiText
- attribute treeNode
- attribute _infoObject
- attribute parent
- attribute childSet
- attribute info
- }
-
- method BrowsUiObj::destructor {this} {
- set ref [$this _infoObject]
- if {$ref != ""} {
- $ref _browsUiObj ""
- }
- # Start destructor user section
- # End destructor user section
- }
-
- constructor BrowsUiObj {class this name} {
- set this [Object::constructor $class $this $name]
- $this promoter
- return $this
- }
-
- method BrowsUiObj::promoter {this} {
- if {! [isCommand [$this info]]} {
- $this info [Dictionary new]
- }
- if {! [isCommand [$this childSet]]} {
- $this childSet [Dictionary new]
- }
-
- if [info exists ${this}::treeNode] {
- BrowserProcs::initializeInfo $this [set ${this}::treeNode]
- }
- }
-
- method BrowsUiObj::allowsDrop {this uiClass} {
- return 0
- }
-
- method BrowsUiObj::browserObjType {this} {
- return "[$this objType]"
- }
-
- method BrowsUiObj::browserType {this} {
- return "[$this uiClass]"
- }
-
- method BrowsUiObj::canBeDragged {this} {
- return 0
- }
-
- method BrowsUiObj::canBeMoved {this} {
- return 0
- }
-
- method BrowsUiObj::cleanup {this association} {
- if [isCommand [$this $association]] {
- [$this $association] delete
- $this $association ""
- }
- $this removeChildSet $association
- }
-
- method BrowsUiObj::customLevelVersion {this} {
- set dbObj [$this getParent BrowsDbObj]
- if {"$dbObj" == ""} {
- return [ORB::nil]
- }
- return [$dbObj customLevelVersion]
- }
-
- method BrowsUiObj::displayName {this} {
- return "[$this uiName]"
- }
-
- method BrowsUiObj::filterType {this} {
- return [$this browserType]
- }
-
- method BrowsUiObj::getIndentation {this} {
- set uiPrefix "[$this uiPrefix]"
- if {"$uiPrefix" == "-"} {
- set indent -1
- } else {
- set indent [expr [string length "$uiPrefix"] / 4]
- }
- return $indent
- }
-
- method BrowsUiObj::getParent {this type} {
- for {set obj [$this parent]} \
- {"$obj" != ""} \
- {set obj [$obj parent]} {
- if {[$obj isA $type]} {
- return $obj
- }
- }
- return ""
- }
-
- method BrowsUiObj::hasChildren {this} {
- return 1
- }
-
- method BrowsUiObj::initializeChildSet {this assocList} {
- [$this childSet] contents ""
- set errorStack ""
-
- if [lempty $assocList] {
- set assocList [[$this browserObjType]::associations]
- }
- foreach association $assocList {
- if [catch {$this setChildSet $association [$this $association]} msg] {
- if {"$errorStack" != ""} {
- append errorStack "\n"
- }
- append errorStack $msg
- }
- }
-
- return $errorStack
- }
-
- method BrowsUiObj::initializeInfo {this arg} {
- [$this info] contents [list \
- Name "[$this displayName]" \
- Type "[$this browserType]" \
- Identity "[$this uiIdentity]" \
- Text "[$this uiText]" \
- ]
- }
-
- method BrowsUiObj::makeUpToDate {this} {
- # dummy call to server
- }
-
- method BrowsUiObj::recursiveIdSet {this skipList} {
- set idList ""
- foreach browsUiObj [$this recursiveObjSet $skipList] {
- lappend idList [$browsUiObj getInfo Identity]
- }
- return "$idList"
- }
-
- method BrowsUiObj::recursiveObjSet {this skipList} {
- set objList ""
- set found 0
- foreach obj [[$wmttoolObj flatView] objectSet] {
- set browsUiObj [$obj browsUiObj]
- if {"$browsUiObj" != "$this" && (! $found)} continue
- if {$browsUiObj == $this} {
- set found 1
- set indentation [$browsUiObj getIndentation]
- if {$indentation < 0} break
- } elseif {[$browsUiObj getIndentation] <= $indentation} {
- break
- }
-
- set skip 0
- foreach type $skipList {
- if [$browsUiObj isA $type] {
- set skip 1
- break
- }
- }
- if $skip continue
-
- lappend objList $browsUiObj
- }
- return "$objList"
- }
-
- method BrowsUiObj::rules {this} {
- # Check if the related BrowsDbObj is a Controlled
- if [$this isA BrowsDbObj] {
- set dbObj $this
- } else {
- set dbObj [$this getParent BrowsDbObj]
- }
- if {! [$dbObj isA Controlled]} {
- return ""
- }
-
- # Make the access attribute for each RuleUiObj empty
- foreach ruleUiObj [[$this RuleUiObj] values] {
- $ruleUiObj access ""
- }
-
- # Update or create one RuleUiObj
- # for each controlled action of each RoleRight
- if [$dbObj isA ControlledList] {
- set roleRightList [concat [$dbObj newChildRights] [$dbObj rights]]
- } else {
- set roleRightList [$dbObj rights]
- }
- foreach roleRight $roleRightList {
- set role [[$roleRight role] name]
- set type [$roleRight type]
- if {"$type" == "childRight"} {
- set actionList "[BrowserProcs::action2String 1023]"
- set prefix "new elements of "
- } else {
- set actionList [$dbObj getInfo "Controlled Actions"]
- set prefix ""
- }
- foreach action $actionList {
- if [$roleRight allows $action] {
- set access "Allowed"
- } elseif [$roleRight prohibits $action] {
- set access "Prohibited"
- } else {
- set access "Undefined"
- }
- regsub -all " |\\." "${role}${action}${type}" "" ruleId
- set ruleUiObj [$this getRuleUiObj $ruleId]
- if {"$ruleUiObj" == ""} {
- set ruleUiObj \
- [RuleUiObj new $this.${RuleUiObj::uiClass}:$ruleId \
- -parent $this \
- -uiName $action \
- -uiText "$action access rule for role '$role' \
- on ${prefix}[$dbObj getInfo Text]" \
- -roleName "$role" \
- -type $type \
- -access "$access" \
- ]
- $this setRuleUiObj $ruleId $ruleUiObj
- } else {
- $ruleUiObj access $access
- }
- }
- }
-
- # Remove all RuleUiObj objects with an empty access attribute
- foreach ruleId [[$this RuleUiObj] names] {
- if {"[[$this getRuleUiObj $ruleId] access]" == ""} {
- $this removeRuleUiObj $ruleId
- }
- }
-
- return [[$this RuleUiObj] values]
- }
-
- method BrowsUiObj::setIndentation {this indent} {
- if {$indent < 0} {
- set uiPrefix "-"
- } else {
- set uiPrefix ""
- for {set i 0} {$i < $indent} {incr i 1} {
- set uiPrefix "$uiPrefix "
- }
- }
- $this uiPrefix "$uiPrefix"
- }
-
- method BrowsUiObj::typeInLabel {this} {
- return 0
- }
-
- method BrowsUiObj::uiClass {this} {
- return [set [$this browserObjType]::uiClass]
- }
-
- method BrowsUiObj::uiIdentity {this} {
- return "[string range $this [expr [string last . $this] + 1] end]"
- }
-
- method BrowsUiObj::versionInLabel {this} {
- return 0
- }
-
- # Do not delete this line -- regeneration end marker
-
- method BrowsUiObj::infoObject {this args} {
- if {$args == ""} {
- return [$this _infoObject]
- }
- set ref [$this _infoObject]
- if {$ref != ""} {
- $ref _browsUiObj ""
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- $obj _browsUiObj $this
- }
- $this _infoObject $obj
- }
-
- method BrowsUiObj::getChildSet {this association} {
- return [[$this childSet] set $association]
- }
-
- method BrowsUiObj::setChildSet {this association newChildSet} {
- [$this childSet] set $association $newChildSet
- }
-
- method BrowsUiObj::removeChildSet {this association} {
- [$this childSet] unset $association
- }
-
- method BrowsUiObj::getInfo {this header} {
- return [[$this info] set $header]
- }
-
- method BrowsUiObj::setInfo {this header newInfo} {
- [$this info] set $header $newInfo
- }
-
- method BrowsUiObj::removeInfo {this header} {
- [$this info] unset $header
- }
-
-