home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cadre Technologies Inc. 1996
- #
- # File: @(#)accesscont.tcl /main/hindenburg/2
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)accesscont.tcl /main/hindenburg/2 11 Nov 1996 Copyright 1996 Cadre Technologies Inc.
-
- # Start user added include file section
- # End user added include file section
-
-
- Class AccessControlDlg : {TemplateDialog} {
- constructor
- method destructor
- method createActionsIf
- method createApplyIf
- method createRolesIf
- method createRoleRightTypeIf
- method createObjectsIf
- method ok
- method popDown
- method reset
- method roleRightsChanged
- method selectedObjectSetChanged
- method selectedRoleSetChanged
- method selectedRoleRightTypeChanged
- method updateActionsIf
- method updateRoleRightTypeIf
- method addSelected
- method removeSelected
- method getAllowed
- method setAllowed
- method removeAllowed
- method getProhibited
- method setProhibited
- method removeProhibited
- attribute editable
- attribute selectedSet
- attribute allowed
- attribute prohibited
- }
-
- constructor AccessControlDlg {class this name} {
- set this [TemplateDialog::constructor $class $this $name]
- $this selectedSet [List new]
- $this allowed [Dictionary new]
- $this prohibited [Dictionary new]
- # Start constructor user section
-
- $this config \
- -cancelPressed {%this delete} \
- -okPressed {%this ok}
-
- interface DlgColumn $this.top {
- Label label {}
- DlgRow row {
- DlgColumn leftCol {}
- DlgColumn rightCol {}
- }
- }
-
- foreach obj [$wmttoolObj selectedObjSet] {
- $this addSelected $obj
- }
- if [lempty [[$this selectedSet] contents]] {
- if {"[[$wmttoolObj treeView] selected]" != ""} {
- set treeNode [[$wmttoolObj treeView] selected]
- } else {
- set treeNode [$wmttoolObj currentObj]
- }
- if [isCommand $treeNode] {
- if [[$treeNode browsUiObj] isA Controlled] {
- $this addSelected [$treeNode browsUiObj]
- } else {
- $this addSelected [$treeNode getParent Controlled]
- }
- } else {
- $this addSelected [$wmttoolObj corporateObj]
- }
- }
-
- # End constructor user section
- return $this
- }
-
- method AccessControlDlg::destructor {this} {
- # Start destructor user section
- # End destructor user section
- }
-
- method AccessControlDlg::createActionsIf {this} {
- set actionsNgIf [NamedGroup new $this.top.row.rightCol.actions \
- -label "Actions" \
- -mnemonic A \
- ]
- set actionsIf [DlgColumn new $actionsNgIf.col]
- foreach action [BrowserProcs::action2String 1023] {
- set row [DlgRow new $actionsIf.$action]
- Label new $row.label \
- -text "$action: "
- HorRadioGroup new $row.access \
- -entrySet {Allowed Prohibited Undefined} \
- -sensitive [$this editable] \
- -selectionChanged [list $this roleRightsChanged $action %this]
- }
- }
-
- method AccessControlDlg::createApplyIf {this} {
- PushButton new $this.apply \
- -label Apply \
- -activated {
- set dialog [getParent %this]
- $dialog autoPopDown 0
- eval [$dialog okPressed]
- $dialog autoPopDown 1
- }
- }
-
- method AccessControlDlg::createRolesIf {this} {
- set roleList ""
- foreach role [[$wmttoolObj corporateObj] roles] {
- lappend roleList "[$role name]"
- }
-
- set rolesNgIf [NamedGroup new $this.top.row.leftCol.roles \
- -label "Roles" \
- -mnemonic R \
- ]
- set rolesIf [TextList new $rolesNgIf.list \
- -entrySet $roleList \
- -selectionChanged [list $this selectedRoleSetChanged] \
- ]
- if [$this editable] {
- $rolesIf selectionPolicy EXTENDED
- } else {
- $rolesIf selectionPolicy BROWSE
- }
- }
-
- method AccessControlDlg::createRoleRightTypeIf {this} {
- set ruleTypeNgIf [NamedGroup new $this.top.row.leftCol.ruleType \
- -label "Role Right" \
- -mnemonic c \
- -verStretchFactor 0 \
- ]
- set ruleTypeIf [DlgRow new $ruleTypeNgIf.row]
- Label new $ruleTypeIf.label \
- -text "Type: "
- OptionMenu new $ruleTypeIf.type \
- -entrySet {ownRight childRight} \
- -selected ownRight \
- -sensitive [$this editable] \
- -selectionChanged [list $this selectedRoleRightTypeChanged]
- }
-
- method AccessControlDlg::createObjectsIf {this} {
- set arrayList {}
- [$this selectedSet] foreach obj {
- lappend arrayList "\"[$obj getInfo Name]\" \"[$obj getInfo Type]\""
- }
- set entrySet ""
- set formatString "%-*.*s %-*.*s"
- set lengths [maxLengthList $arrayList {50}]
- foreach array $arrayList {
- lappend entrySet "[format $formatString \
- [lindex $lengths 0] [lindex $lengths 0] [lindex $array 0] \
- [lindex $lengths 1] [lindex $lengths 1] [lindex $array 1]]"
- }
-
- set objectsNgIf [NamedGroup new $this.top.row.leftCol.objects \
- -label "Objects" \
- -mnemonic O \
- ]
- set objectsIf [TextList new $objectsNgIf.list \
- -entrySet $entrySet \
- -selectionChanged [list $this selectedObjectSetChanged] \
- ]
- if [$this editable] {
- $objectsIf selectionPolicy EXTENDED
- } else {
- $objectsIf config \
- -selectionPolicy BROWSE \
- -selectedIndexSet {0}
- }
- }
-
- method AccessControlDlg::ok {this} {
- if [$this autoPopDown] {
- $this popDown
- }
- }
-
- method AccessControlDlg::popDown {this} {
- $this delete
- }
-
- method AccessControlDlg::reset {this} {
- foreach action [BrowserProcs::action2String 1023] {
- $this setAllowed $action 0
- $this setProhibited $action 0
- set actionIf $this.top.row.rightCol.actions.col.$action
- if [isCommand $actionIf] {
- $actionIf.label sensitive 0
- $actionIf.access sensitive 0
- }
- }
- }
-
- method AccessControlDlg::roleRightsChanged {this action access} {
- set roleList [$this.top.row.leftCol.roles.list selectedSet]
- set objectIndexList [$this.top.row.leftCol.objects.list selectedIndexSet]
- set type [$this.top.row.leftCol.ruleType.row.type selected]
-
- global $this$type
- foreach index $objectIndexList {
- foreach role $roleList {
- set ${this}${type}($index,$role,$action) [$access selected]
- }
- }
- }
-
- method AccessControlDlg::selectedObjectSetChanged {this} {
- $this reset
- }
-
- method AccessControlDlg::selectedRoleSetChanged {this} {
- $this reset
- }
-
- method AccessControlDlg::selectedRoleRightTypeChanged {this} {
- $this reset
- }
-
- method AccessControlDlg::updateActionsIf {this} {
- foreach action [BrowserProcs::action2String 1023] {
- set accessIf $this.top.row.rightCol.actions.col.$action.access
- set allowed [$this getAllowed $action]
- set prohibited [$this getProhibited $action]
- if {$prohibited > 0} {
- $accessIf selected Prohibited
- } elseif {$allowed == $prohibited} {
- $accessIf selected Undefined
- } else {
- $accessIf selected Allowed
- }
- }
- }
-
- method AccessControlDlg::updateRoleRightTypeIf {this} {
- set childRights 0
- foreach id [$this.top.row.leftCol.objects.list selectedIndexSet] {
- set obj [[$this selectedSet] index $id]
- set parent [$obj parent]
- if {"$parent" != ""} {
- if [$parent isA CListUiObj] {
- set childRights 1
- break
- }
- }
- }
-
- set ruleTypeIf $this.top.row.leftCol.ruleType.row.type
- if $childRights {
- $ruleTypeIf sensitive 1
- } else {
- $ruleTypeIf config \
- -selected ownRight \
- -sensitive 0
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method AccessControlDlg::addSelected {this newSelected} {
- [$this selectedSet] append $newSelected
-
- }
-
- method AccessControlDlg::removeSelected {this oldSelected} {
- [$this selectedSet] removeValue $oldSelected
- }
-
- method AccessControlDlg::getAllowed {this action} {
- return [[$this allowed] set $action]
- }
-
- method AccessControlDlg::setAllowed {this action newAllowed} {
- [$this allowed] set $action $newAllowed
- }
-
- method AccessControlDlg::removeAllowed {this action} {
- [$this allowed] unset $action
- }
-
- method AccessControlDlg::getProhibited {this action} {
- return [[$this prohibited] set $action]
- }
-
- method AccessControlDlg::setProhibited {this action newProhibited} {
- [$this prohibited] set $action $newProhibited
- }
-
- method AccessControlDlg::removeProhibited {this action} {
- [$this prohibited] unset $action
- }
-
-