Packagecom.yworks.ui.tree
Classpublic class HierarchyTreeView
InheritanceHierarchyTreeView Inheritance Object
Implements mx.collections.ICollectionView, mx.core.IMXMLObject

Utility class that helps in visualizing an INodeHierarchy in a mx.controls.Tree.

Instances of this class can be installed as a dataProvider which represents a given INodeHierarchy to a Tree.

Actionscript:
     var htv:HierarchyTreeView = new HierarchyTreeView();
     htv.graphCanvasComponent = graphCanvasComponent;
     tree.dataProvider = htv;
     
MXML:
     <mx:Tree>
       <mx:dataProvider>
         <tree:HierarchyTreeView id="htv" graphCanvasComponent="graphCanvas"/>
       </mx:dataProvider>
     </mx:Tree>
     

If the HierarchyTreeView is intended to display flat graphs, DefaultGraph's groupingSupported property must be set to true, anyhow, otherwise there will be no INodeHierarchy available.

The HierarchyTreeView can also serve as data provider for mx.contrlos.Lists. Note, that in this case only the nodes in the root will be displayed.



Public Properties
 PropertyDefined By
  filterFunction : Function
The filter to apply.
HierarchyTreeView
  graphCanvas : GraphCanvasComponent
[write-only] The GraphCanvasComponent whose graph is this instance's model.
HierarchyTreeView
  labelFunction : Function
A user-supplied function to run on each item to determine its label.
HierarchyTreeView
  length : int
[read-only] The number of children of the root.
HierarchyTreeView
  model : INodeHierarchy
The model to be used with this instance.
HierarchyTreeView
  sort : Sort
The sorting function to apply.
HierarchyTreeView
Public Methods
 MethodDefined By
  
HierarchyTreeView(tree:Tree = null, model:INodeHierarchy = null)
Creates a new instance.
HierarchyTreeView
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Adds an EventListener.
HierarchyTreeView
  
contains(item:Object):Boolean
Whether the given Object is a child of the root.
HierarchyTreeView
  
createCursor():IViewCursor
A cursor over the root elements.
HierarchyTreeView
  
Disables automatic update.
HierarchyTreeView
  
dispatchEvent(event:Event):Boolean
Dispatches the given event.
HierarchyTreeView
  
Enables automatic update.
HierarchyTreeView
  
Returns the TreeNode representation of a given node.
HierarchyTreeView
  
hasEventListener(type:String):Boolean
Whether an event listener for the given type is registered.
HierarchyTreeView
  
initialized(document:Object, id:String):void
Called after the implementing object has been created and all component properties specified on the MXML tag have been initialized.
HierarchyTreeView
  
itemUpdated(item:Object, property:Object = null, oldValue:Object = null, newValue:Object = null):void
Called when an item is updated.
HierarchyTreeView
  
publishItemChanged(kind:String = null, location:int = -1, oldLocation:int = -1, items:Array = null):void
Forces a repaint.
HierarchyTreeView
  
refresh():Boolean
Refresh the view.
HierarchyTreeView
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes an event listener.
HierarchyTreeView
  
willTrigger(type:String):Boolean
Whether this implementation can dispatch events of the given type.
HierarchyTreeView
Protected Methods
 MethodDefined By
  
onGraphChanged(oldGraph:IGraph, newGraph:IGraph):void
Callback when the graph property of the graphCanvasComponent changed.
HierarchyTreeView
  
treeLabelFunction(item:Object):String
Delegate function which is returns a String representation of the given item to be displayed in the tree view.
HierarchyTreeView
Property Detail
filterFunctionproperty
filterFunction:Function

The filter to apply. By default, no filter is applied


Implementation
    public function get filterFunction():Function
    public function set filterFunction(value:Function):void

See also

mx.collections.ICollectionView
graphCanvasproperty 
graphCanvas:GraphCanvasComponent  [write-only]

The GraphCanvasComponent whose graph is this instance's model.


Implementation
    public function set graphCanvas(value:GraphCanvasComponent):void
labelFunctionproperty 
labelFunction:Function

A user-supplied function to run on each item to determine its label.

The label function takes a single argument which is the item, represented by a TreeNode, and returns a String:

		 myLabelFunction(item:Object):String
		 
The actual node can be found in the TreeNode's item property.

After setting this property to a new value, publishItemChanged() will be called in order to redraw the tree.

The default value is this.treeLabelFunction.


Implementation
    public function get labelFunction():Function
    public function set labelFunction(value:Function):void

See also

lengthproperty 
length:int  [read-only]

The number of children of the root.


Implementation
    public function get length():int

See also

mx.collections.ICollectionView
modelproperty 
model:INodeHierarchy

The model to be used with this instance. Usually the INodeHierarchy of the current grouped graph.

Setting the graphCanvasComponent property will automatically set this property, too.


Implementation
    public function get model():INodeHierarchy
    public function set model(value:INodeHierarchy):void
sortproperty 
sort:Sort

The sorting function to apply. By default, no sorting is applied.


Implementation
    public function get sort():Sort
    public function set sort(value:Sort):void

See also

mx.collections.ICollectionView
Constructor Detail
HierarchyTreeView()Constructor
public function HierarchyTreeView(tree:Tree = null, model:INodeHierarchy = null)

Creates a new instance.

The recommended use is to use the standard constructor and set the created instance as dataProvider to the tree and the graphCanvasComponent property to the current GraphCanvasComponent.

For backward compatibility, it is possible to pass a Tree. The new instance will install itself to that tree as dataProvider representing the given INodeHierarchy.

Parameters
tree:Tree (default = null) — The tree to initialize.
 
model:INodeHierarchy (default = null) — The INodeHierarchy to represent. Usually the INodeHierarchy of the current grouped graph.
Method Detail
addEventListener()method
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Adds an EventListener.

Parameters

type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)

See also

flash.events.IEventDispatcher
contains()method 
public function contains(item:Object):Boolean

Whether the given Object is a child of the root.

Parameters

item:Object — The item to check.

Returns
Booleantrue if the given item is child of the root.

See also

mx.collections.ICollectionView
createCursor()method 
public function createCursor():IViewCursor

A cursor over the root elements.

Returns
IViewCursor — A cursor over the view.

See also

mx.collections.ICollectionView
disableAutoUpdate()method 
public function disableAutoUpdate():void

Disables automatic update.

See also

mx.collections.ICollectionView
dispatchEvent()method 
public function dispatchEvent(event:Event):Boolean

Dispatches the given event.

Parameters

event:Event

Returns
Boolean

See also

flash.events.IEventDispatcher
enableAutoUpdate()method 
public function enableAutoUpdate():void

Enables automatic update.

See also

mx.collections.ICollectionView
findNode()method 
public function findNode(node:INode):TreeNode

Returns the TreeNode representation of a given node.

Parameters

node:INode — The node to search the TreeNode representation for.

Returns
TreeNode — The TreeNode which represents the given node or null.
hasEventListener()method 
public function hasEventListener(type:String):Boolean

Whether an event listener for the given type is registered.

Parameters

type:String

Returns
Boolean

See also

flash.events.IEventDispatcher
initialized()method 
public function initialized(document:Object, id:String):void

Called after the implementing object has been created and all component properties specified on the MXML tag have been initialized.

This implementation does nothing.

Parameters

document:Object — The MXML document that created this object.
 
id:String — The identifier used by document to refer to this object. If the object is a deep property on document, id is null.

itemUpdated()method 
public function itemUpdated(item:Object, property:Object = null, oldValue:Object = null, newValue:Object = null):void

Called when an item is updated.

Parameters

item:Object
 
property:Object (default = null)
 
oldValue:Object (default = null)
 
newValue:Object (default = null)

See also

mx.collections.ICollectionView
onGraphChanged()method 
protected function onGraphChanged(oldGraph:IGraph, newGraph:IGraph):void

Callback when the graph property of the graphCanvasComponent changed.

Parameters

oldGraph:IGraph — The graph before the change.
 
newGraph:IGraph — The current graph.

publishItemChanged()method 
public function publishItemChanged(kind:String = null, location:int = -1, oldLocation:int = -1, items:Array = null):void

Forces a repaint.

Parameters

kind:String (default = null)
 
location:int (default = -1)
 
oldLocation:int (default = -1)
 
items:Array (default = null)

refresh()method 
public function refresh():Boolean

Refresh the view.

Returns
Boolean

See also

mx.collections.ICollectionView
removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Removes an event listener.

Parameters

type:String
 
listener:Function
 
useCapture:Boolean (default = false)

See also

flash.events.IEventDispatcher
treeLabelFunction()method 
protected function treeLabelFunction(item:Object):String

Delegate function which is returns a String representation of the given item to be displayed in the tree view.

This implementation returns the text of the first label of the node if there is one. Otherwise it returns an empty String.

Parameters

item:Object — A TreeNode with the item to get the text for.

Returns
String — A String representation of the given item.

See also

mx.controls.Tree.labelFunction
TreeNode
willTrigger()method 
public function willTrigger(type:String):Boolean

Whether this implementation can dispatch events of the given type.

Parameters

type:String

Returns
Boolean

See also

flash.events.IEventDispatcher