home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
accesscont.tcl
< prev
next >
Wrap
Text File
|
1997-09-16
|
8KB
|
323 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)accesscont.tcl /main/titanic/6
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)accesscont.tcl /main/titanic/6 16 Sep 1997 Copyright 1997 Cayenne Software 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 getObjectList
method init
method addSelected
method removeSelected
method getAllowed
method setAllowed
method removeAllowed
method getProhibited
method setProhibited
method removeProhibited
attribute editable
attribute childRights
attribute errorStack
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 {}
}
}
[$this selectedSet] contents [.main selectedObjSet]
$this childRights 0
# 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 \
-selectionChanged [list $this selectedRoleRightTypeChanged]
if {![$this editable] || ![$this childRights]} {
$ruleTypeIf.type sensitive 0
}
}
method AccessControlDlg::createObjectsIf {this} {
set arrayList [$this getObjectList]
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} {
if {![$this childRights]} {
return
}
set childRights 0
if {![lempty [$this.top.row.leftCol.objects.list selectedIndexSet]]} {
set childRights 1
}
set ruleTypeIf $this.top.row.leftCol.ruleType.row.type
if $childRights {
$ruleTypeIf sensitive 1
} else {
$ruleTypeIf config \
-selected ownRight \
-sensitive 0
}
}
method AccessControlDlg::getObjectList {this} {
set list {}
[$this selectedSet] foreach obj {
lappend list "\"[$obj getInfo Name]\" \"[$obj getInfo Type]\""
}
return $list
}
method AccessControlDlg::init {this} {
set errorStack ""
set removeList ""
[$this selectedSet] foreach obj {
if [catch {$obj controlledActions} msg] {
lappend removeList $obj
if {"$errorStack" != ""} {
append errorStack "\n"
}
append errorStack $msg
}
}
$this errorStack $errorStack
foreach obj $removeList {
$this removeSelected $obj
}
}
# 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
}