A basic implementation of the
INodeHierarchy interface.
root:INode [read-only]
Gets the root node of the hierarchy.
Implementation
public function get root():INode
public function DefaultNodeHierarchy(rootValue:INode = null, mapper:IMapper = null)
Creates a new instance using the provided parameter as the root element
and the given mapper to do the mapping.
Parameters
| rootValue:INode (default = null) — The value for the root element, or null.
|
| |
| mapper:IMapper (default = null) — The instance to do the mapping of the items in the hierarchy to the internally used data structure.
If no mapper is passed, a DictionaryMapper is used.
|
See also
public function addChild(parent:INode, child:INode):void
Modifies the hierarchy by adding another child to the given parent.
child may not be part of the hierarchy prior to this call.
This triggers the itemAdded event.
Parameters
| parent:INode — The parent to add the child to.
|
| |
| child:INode — The child to add to the parent.
|
public function contains(item:INode):Boolean
Determines whether the given node is part of this hierarchy.
Parameters
| item:INode — The node to check
|
Returns
| Boolean — Whether the node is contained in the hierarchy.
|
public function getChildCount(parent:INode):int
Returns the number of children for the given parent item.
Parameters
| parent:INode — The parent to get the number of child items for.
|
Returns
| int — The number of children.
|
public function getChildren(item:INode):Iterable
Returns an iterable over the children of the provided item.
Parameters
| item:INode — The item for which to return the children.
|
Returns
| Iterable —
All items that have item as their parent.
|
yworks_internal function getHierarchyItem(item:INode):MyNodeHierarchyItemParameters
Returns
public function getParent(child:INode):INode
Returns the parent item of the item or root
if child is a top-level item.
Parameters
| child:INode — The item to retrieve the parent item for.
|
Returns
| INode —
The parent item in this hierarchy or root.
|
public function isLeaf(item:INode):Boolean
Returns whether the given item is considered a leaf item.
Leaves may not have children. However, a non-leaf item does not
necessarily need to have children.
Parameters
| item:INode — The item to check.
|
Returns
| Boolean — Whether the item is considered a leaf.
|
public function iterator():Iterator
Returns an iterator over a set of elements.
Returns
public function lookup(type:Class):Object
Returns an instance that implements the given type or null.
Typically, this method will be called in order to obtain a different view or
aspect of the current instance. This is quite similar to casting or using
a super type or interface of this instance, but is not limited to inheritance or
compile time constraints. An instance implementing this method is not
required to return non-null implementations for the types, nor does it
have to return the same instance any time. Also it depends on the
type and context whether the instance returned stays up to date or needs to
be reobtained for subsequent use.
Parameters
| type:Class — the type for which an instance shall be returned
|
Returns
| Object — an instance that is assignable to type or null
|
protected function onItemAdded(item:INode, parent:INode):void
Dispatches the itemAdded event.
Parameters
| item:INode — The item that is added.
|
| |
| parent:INode — The parent of the item.
|
protected function onItemChanged(item:INode, parent:INode):void
Dispatches the itemChanged event.
Parameters
| item:INode — The item that is changed.
|
| |
| parent:INode — The parent of the item.
|
protected function onItemMoved(item:INode, oldParent:INode, newParent:INode):void
Dispatches the itemMoved event.
Parameters
| item:INode — he item that is reparented.
|
| |
| oldParent:INode — The old parent of the item.
|
| |
| newParent:INode — The new parent of the item.
|
protected function onItemRemoved(item:INode, oldParent:INode):void
Dispatches the itemRemoved event.
Parameters
| item:INode — The item that is removed.
|
| |
| oldParent:INode — The parent of the item.
|
public function publishItemChanged(item:INode):void
Triggers the firing of an itemChanged event for the given node.
Parameters
| item:INode — The item that has changed.
|
public function remove(child:INode):void
Removes the given item from its parent and this hierarchy.
This will trigger the itemRemoved event.
Parameters
| child:INode — The child to remove from this hierarchy.
|
public function setLeaf(item:INode, leaf:Boolean):void
Determines whether the given item should be considered a leaf.
Leaves may not have children. However, a non-leaf item does not
necessarily need to have children.
Parameters
| item:INode — The item to set.
|
| |
| leaf:Boolean — Whether to make the item a leaf.
|
public function setParent(child:INode, parent:INode):void
Reparents a child item that already belongs to this hierarchy instance
to a new parent.
This will trigger the itemMoved event.
Note that child may not be an ancestor of parent.
Parameters
| child:INode — The child to reparent.
|
| |
| parent:INode — The new parent.
|