Package | impression.utilities |
Class | public class TreeView |
Inheritance | TreeView ![]() |
The TreeView class was designed to support Impression LessonMap objects, but can be used to display any XML document. Each element in the document is given its own node, and a user-specified attribute present in each element is used as the node's text.
Property | Defined By | ||
---|---|---|---|
attributeName : String [read-only]
The name of the attribute in each XML element to use for the associated node's text. | TreeView | ||
selected : TreeNode
The selected TreeNode. | TreeView | ||
source : XML [read-only]
The XML object containing the data used to build the TreeView. | TreeView |
Method | Defined By | ||
---|---|---|---|
TreeView(scrollPane:* = null)
Creates a new instance of the TreeView class. | TreeView | ||
clearNodeStyle(styleName:String, style:String):void
Deletes a TreeNode style property. | TreeView | ||
clearStyle(style:String):void
Deletes a style property. | TreeView | ||
Collapses a TreeNode. | TreeView | ||
collapseAll():void
Collapses all nodes. | TreeView | ||
ensureVisible(node:TreeNode):void
Ensures that a TreeNode is visible. | TreeView | ||
Expands a TreeNode. | TreeView | ||
expandAll():void
Expands all nodes. | TreeView | ||
getNodeStyle(styleName:String, style:String):Object
Retrieves a TreeNode style property. | TreeView | ||
getNodeStyleDefinition():Object [static]
Retrieves the default style map for TreeNode object. | TreeView | ||
getStyle(style:String):Object
Retrieves a style property. | TreeView | ||
getStyleDefinition():Object [static]
Retrieves the default style map for the treeview. | TreeView | ||
loadXML(source:XML, attributeName:String):void
Builds the tree from an XML object. | TreeView | ||
Returns the TreeNode associated with an XML element. | TreeView | ||
redraw():void
Forces a complete redraw of the tree. | TreeView | ||
setNodeStyle(styleName:String, style:String, value:Object):void
Sets a TreeNode style property. | TreeView | ||
setSize(width:Number, height:Number):void
Sets the object to the specified width and height. | TreeView | ||
setStyle(style:String, value:Object):void
Sets a style property. | TreeView |
Event | Summary | Defined By | ||
---|---|---|---|---|
Dispatched when a TreeNode is collapsed. | TreeView | |||
Dispatched when a TreeNode is expanded. | TreeView | |||
Dispatched when an XML object is loaded. | TreeView | |||
Dispatched after a TreeNode is selected. | TreeView | |||
Dispatched before a TreeNode is selected. | TreeView |
attributeName | property |
attributeName:String
[read-only] The name of the attribute in each XML element to use for the associated node's text.
public function get attributeName():String
selected | property |
selected:TreeNode
The selected TreeNode.
When this property is set to a new value, the TreeView dispatches a
TreeViewRequestEvent.SELECT_REQUEST
event with a reason
value of
TreeViewEventReasons.CODE
.
If the select request event is not cancelled, the event's newNode
value is
selected, and a TreeViewEvent.SELECT
event with a reason
value of
TreeViewEventReasons.CODE
is dispatched.
public function get selected():TreeNode
public function set selected(value:TreeNode):void
See also
source | property |
source:XML
[read-only] The XML object containing the data used to build the TreeView.
public function get source():XML
TreeView | () | Constructor |
public function TreeView(scrollPane:* = null)
Creates a new instance of the TreeView class.
ParametersscrollPane:* (default = null ) — A ScrollPane or other object that can act as a container for the TreeView content.
|
ArgumentError — scrollPane cannot be null (ArgumentError)
|
clearNodeStyle | () | method |
public function clearNodeStyle(styleName:String, style:String):void
Deletes a TreeNode style property.
If styleName
is null
or the empty string (""), the
style property referenced is the default style property value to use for all nodes. If
styleName
is not null
or the empty string, the style property
references is the style property value to use for all nodes with a styleName
property value matching the styleName
parameter.
The style
parameter value should be one of the styles defined in the TreeNode object.
Parameters
styleName:String — The node style name associated with the style.
| |
style:String — The name of the style property.
|
See also
clearStyle | () | method |
public function clearStyle(style:String):void
Deletes a style property.
Parameters
style:String — The name of the style property.
|
See also
collapse | () | method |
public function collapse(node:TreeNode):void
Collapses a TreeNode.
If the node.hasChildren
property is false
or the
node.expand
property is false
, invoking this method has
no effect.
If the node.hasChildren
property is false
or the
node.expand
property is false
, invoking this method has
no effect. If the node was expanded, a TreeViewEvent.COLLAPSE
event
with a reason
value of TreeViewEventReasons.CODE
is
dispatched.
Parameters
node:TreeNode — The TreeNode to collapse.
|
See also
collapseAll | () | method |
public function collapseAll():void
Collapses all nodes.
If any nodes were collapsed, a single TreeViewEvent.COLLAPSE
with a reason
value of TreeViewEventReasons.CODE
is dispatched.
See also
ensureVisible | () | method |
public function ensureVisible(node:TreeNode):void
Ensures that a TreeNode is visible.
If necessary, this routine will expand any collapsed ancestors of node
and adjust the scroll pane so that the node is displayed within the visible area. If any
nodes were expanded, a single TreeViewEvent.EXPAND
with a reason
value of TreeViewEventReasons.CODE
is dispatched.
Parameters
node:TreeNode — The TreeNode to ensure the visibility of.
|
See also
expand | () | method |
public function expand(node:TreeNode):void
Expands a TreeNode.
If the node.hasChildren
property is false
or the
node.expand
property is true
, invoking this method has
no effect. If the node was expanded, a TreeViewEvent.EXPAND
event
with a reason
value of TreeViewEventReasons.CODE
is
dispatched.
Parameters
node:TreeNode — The TreeNode to expand.
|
See also
expandAll | () | method |
public function expandAll():void
Expands all nodes.
If any nodes were expanded, a single TreeViewEvent.EXPAND
with a reason
value of TreeViewEventReasons.CODE
is dispatched.
See also
getNodeStyle | () | method |
public function getNodeStyle(styleName:String, style:String):Object
Retrieves a TreeNode style property.
If styleName
is null
or the empty string (""), the
style property referenced is the default style property value to use for all nodes. If
styleName
is not null
or the empty string, the style property
referenced is the style property value to use for all nodes with a styleName
property value matching the styleName
parameter.
The style
parameter value should be one of the styles defined in the TreeNode object.
Parameters
styleName:String — The node style name associated with the style.
| |
style:String — The name of the style property.
|
Object — Style value.
|
See also
getNodeStyleDefinition | () | method |
public static function getNodeStyleDefinition():Object
Retrieves the default style map for TreeNode object.
ReturnsObject — Default styles object.
|
See also
getStyle | () | method |
public function getStyle(style:String):Object
Retrieves a style property.
Parameters
style:String — The name of the style property.
|
Object — Style value.
|
See also
getStyleDefinition | () | method |
public static function getStyleDefinition():Object
Retrieves the default style map for the treeview.
ReturnsObject — Default styles object.
|
See also
loadXML | () | method |
public function loadXML(source:XML, attributeName:String):void
Builds the tree from an XML object.
Once the tree is built, this object dispatches a TreeViewRequestEvent.SELECT_REQUEST
event with a reason
value of TreeViewEventReasons.LOAD_COMPLETE
, and values
of null
for both the oldNode
and newNode
properties.
If the select request event is not cancelled, the selected node is set to the value of the
event's newNode
value, and a TreeViewEvent.SELECT
event with a
reason
value of TreeViewEventReasons.LOAD_COMPLETE
is dispatched.
Finally, a TreeViewEvent.LOAD_COMPLETE
event is dispatched.
Parameters
source:XML — The XML object to build the tree from.
| |
attributeName:String — The name of the attribute to use for each node's text.
|
See also
nodeOf | () | method |
public function nodeOf(source:XML):TreeNode
Returns the TreeNode associated with an XML element.
If an associated TreeNode cannot be found, the method returns null
.
Parameters
source:XML — The XML object to find the node of.
|
TreeNode — The TreeNode associated with source .
|
redraw | () | method |
public function redraw():void
Forces a complete redraw of the tree.
All nodes are rebuilt from the XML object. If possible, the last node selected will be selected again. Note that no events are dispatched as a result of invoking this method.
setNodeStyle | () | method |
public function setNodeStyle(styleName:String, style:String, value:Object):void
Sets a TreeNode style property.
If styleName
is null
or the empty string (""), the
style property referenced is the default style property value to use for all nodes. If
styleName
is not null
or the empty string, the style property
references is the style property value to use for all nodes with a styleName
property value matching the styleName
parameter.
The style
parameter value should be one of the styles defined in the TreeNode object.
Parameters
styleName:String — The node style name associated with the style.
| |
style:String — The name of the style property.
| |
value:Object — The value of the style.
|
See also
setSize | () | method |
public function setSize(width:Number, height:Number):void
Sets the object to the specified width and height.
This method attempts to invoke the setSize()
method on the ScrollPane
object. If the object does not support the setSize()
method, invoking this
method has no effect.
Parameters
width:Number — The width of the object, in pixels.
| |
height:Number — The height of the object, in pixels.
|
setStyle | () | method |
public function setStyle(style:String, value:Object):void
Sets a style property.
Parameters
style:String — The name of the style property.
| |
value:Object — The value of the style.
|
See also
treeviewCollapse | Event |
impression.events.TreeViewEvent
TreeViewEvent.COLLAPSE
Dispatched when a TreeNode is collapsed.
Note that only one collapse event will be dispatched per action, even if the action caused multiple nodes to be collapsed.
See also
treeviewExpand | Event |
impression.events.TreeViewEvent
TreeViewEvent.EXPAND
Dispatched when a TreeNode is expanded.
Note that only one expand event will be dispatched per action, even if the action caused multiple nodes to be expanded.
See also
treeviewLoadComplete | Event |
impression.events.TreeViewEvent
TreeViewEvent.LOAD_COMPLETE
Dispatched when an XML object is loaded.
This event is dispatched after any selection related events.
See also
treeviewSelect | Event |
impression.events.TreeViewEvent
TreeViewEvent.SELECT
Dispatched after a TreeNode is selected.
See also
treeviewSelectRequest | Event |
impression.events.TreeViewRequestEvent
TreeViewRequestEvent.SELECT_REQUEST
Dispatched before a TreeNode is selected.
If this event is cancelled, the node will not be selected. Note that
the newNode
event property is read-write; changing the
newNode
event property value will change the node to be
selected.
See also