Current: IAccessElement;
The Current property returns the current element.
Executing the example requires the Button component named Button1 and the TreeList component named TreeList1 on the form. 5 columns must be created for the TreeList component: Name, ReadAccess, WriteAccess, DeleteAccess, AccessAccess. The repository should also contain an MDM dictionary with the DICT_1 identifier.
Class UserForm: Form
Button1: Button;
TreeList1: TreeList;
Sub FillViewer(Iterator: IAccessElementsIterator; currentlevel: integer; parentNode: ITreeListNode);
Var
level: integer;
node: ITreeListNode;
element: IAccessElement;
Begin
level := iterator.Next;
If level <> -1 Then
element := iterator.Current;
node := TreeList1.Nodes.AddChild(GetParent(parentNode, currentlevel, level), element.Name);
node.Data := element;
node.ColumnText(1) := element.AttributeAccess(AccessElementAttributes.Read).ToString;
node.ColumnText(2) := element.AttributeAccess(AccessElementAttributes.Write).ToString;
node.ColumnText(3) := element.AttributeAccess(AccessElementAttributes.Delete).ToString;
node.ColumnText(4) := element.AttributeAccess(AccessElementAttributes.Access).ToString;
FillViewer(iterator, level, node);
End If;
End Sub FillViewer;
Function GetParent(node: ITreeListNode; currentLevel: integer; level: integer): ITreeListNode;
Begin
If (level - currentLevel) = 1 Then
Return node;
End If;
If currentLevel >= level Then
currentLevel := currentLevel - 1;
Else
level := level - 1;
End If;
Return GetParent(node.Parent, currentLevel, level);
End Function GetParent;
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
MB: IMetabase;
MDesc: IMetabaseObjectDescriptor;
SD: ISecurityDescriptor;
AOS: IAccessObjectSecurity;
Iterator: IAccessElementsIterator;
Begin
MB := MetabaseClass.Active;
MDesc := MB.ItemById("DICT_1");
AOS := Object.GetSecurity;
Iterator := AOS.GetElements;
FillViewer(Iterator, -1, Null);
End Sub Button1OnClick;
End Class UserForm;
Clicking the button displays a tree of MDM dictionary elements in the TreeList component and the values, stored in access attributes, are displayed in respective columns for each element.
See also: