Main Page | Packages | Class Tree | Index | Help

xp.controls

class TreeView

MovieClip
  |
  +--xp.system.UIControl
        |
        +--xp.controls.ScrollSelectView
              |
              +--xp.controls.TreeView


class TreeView
extends ScrollSelectView

Allows a user to manipulate hierarchical information.

The TreeView component allows a user to view hierarchical data. The tree appears in a box like the ListBox component, but each item in a tree is called a node and can be either a leaf or a branch. By default, a leaf is represented by a text label beside a file icon, and a branch is represented by a text label beside a folder icon with an expander arrow (disclosure triangle) that a user can open to expose children. The children of a branch can be leaves or branches.
The data of a tree component must be provided from an XML data source.

The list receives focus when you click it or tab to it, and you can then use the following keys to control it:
KeyDescription
Alphanumeric keysJump to the next item that has Key.getAscii() as the first character in its label.
Down ArrowSelection moves down one item.
Up ArrowSelection moves up one item
Right ArrowOpens a selected branch node. If a branch is already open, moves to first child node.
Left ArrowCloses a selected branch node. If on a leaf node of a closed branch node, moves to parent node.
SpaceOpens or closes a selected branch node.
EndMoves selection to the bottom of the list.
HomeSelection moves to the top of the list.
Page Down
Page Up
ControlAllows multiple noncontiguous selections.
ShiftAllows multiple noncontiguous selections.

The TreeView component is designed to display hierarchical data structures using XML as the data model.
Event summary for the TreeView class
The following table lists events of the TreeView class.










EventTypeDescription
xp.events.SelectedIndexChangedEventselectedIndexChangedBroadcast whenever user interaction causes the selection to change.
xp.events.ValueChangedEventvalueChangedBroadcast whenever user interaction causes the selection value to change.
xp.events.ItemRollOverEventitemRollOverBroadcast when the pointer rolls over list items.
xp.events.ItemRollOutEventitemRollOutBroadcast when the pointer rolls over and then off of list items.
xp.events.ApplyUpdatesEventapplyUpdatesBroadcast when a node value has been edited before it is applied.
xp.events.NodeEventnodeOpeningBroadcast immediately before a node is opened. This event is cancelable.
xp.events.NodeEventnodeClosingBroadcast immediately before a node is closed. This event is cancelable.
xp.events.NodeEventnodeOpenBroadcast immediately after a node is opened.
xp.events.NodeEventnodeClosedBroadcast immediately after a node is closed.
xp.events.DragDropEventdrop/td>Broadcast immediately before a node is dropped. This event is cancelable


Author:
ProWin Computers Ltd. - Rob Edgar

Version:
3.0.0.000

See also:


Field Summary

public
allowDrag: Boolean
Gets or sets a value indicating whether this element can be used as the source of a drag-and-drop operation

public
allowDrop: Boolean
Gets or sets a value indicating whether this element can be used as the target of a drag-and-drop operation

public static
classInfo: Object
A static class information object

public
disableAcceptButton: Boolean
Disables the global accept button whilst this control has focus

public
disableCancelButton: Boolean
Disables the global cancel button whilst this control has focus

public
editor
Reference to the cell edit manager

public
iconBinding: Binding
The binding of the child node or attibute of the row node containing the icon to display in the label control

public
iconFormatter: Object
The formatter for the icon field

public
iconFormatterOptions: String
Options for the formatter

public
iconPath: String
The path or name of the child node or attibute of the row node containing the icon to display in the label control

public
itemIndent
The standard value to indent the child items per level of the tree

public
itemStyle: Object
The list item styles

public
labelBinding: Binding
The binding of the child node or attibute of the row node containing the text to display in the label

public
labelFormatter: Object
The formatter for the label field

public
labelFormatterOptions: String
Options for the formatter

public
labelPath: String
The path or name of the child node or attibute of the row node containing the text to display in the label

public
maxNodeDepth
The maximum depth of nodes in the tree that will be read

public
rowStyle: Object
The list row styles

public
styleClass: String
The name of the style class this instance will use.

Fields inherited from class xp.controls.ScrollSelectView

__alternateColor, __backgroundColor, __hGridLineColor, __highlightColor, __selectColor, __selectedValueFormatter, __selectedValuePath, __vGridLineColor, autoSync, body, canEdit, canInsert, classInfo, editable, editorType, editRow, footer, header, hGridLines, hLargeScroll, hscrollbar, hScrollPolicy, hSmallScroll, isSelectionRequired, scrollMode, statusbar, tabStop, textHighlightColor, textSelectColor, titlebar, topIndex, useRollOver, vGridLines, vLargeScroll, vscrollbar, vScrollPolicy, vSmallScroll

Fields inherited from class xp.system.UIControl

__layout, allowDrop, autoLayout, bindingDefaultValue, bindingFormatter, bindingPath, bindingSource, bindingType, bindingValidator, border, causesValidation, classInfo, clickOnENTER, clickOnSPACE, container, context, data, disableAcceptButton, disableCancelButton, enableBGMouseEvents, enableDblClickEvent, enableKeyDownEvents, enableKeyEvents, enableKeyUpEvents, enableMouseWheelEvents, formatterOptions, horizontalAlignment, index, isBinding, itemId, logEnabled, parent, parentContainer, parentForm, percentageHeight, percentageWidth, styleClass, tabIndex, tabStop, tooltip, tree, verticalAlignment

Property Summary

public
dataProvider: Object (read, write)
Gets or set the list items

public
displayRowCount: Number (read-only)
Number of rows of data we are currently trying to display

public
document: XMLNode (read, write)
ITEMSOURCE////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public
itemsSource: XMLDataSource (read, write)
Gets or set the XMLDataSource

public
rowCount (read-only)
Number of rows actually visible in the viewport

public
selectedNode: XMLNode (read, write)
Specifies the selected node in a TreeView instance.

public
selectedRow: Object (read-only)
Returns the currently selected row node

public
virtualRowCount: Number (read-only)
The number row buffers used for the visible scroll window

Properties inherited from class xp.controls.ScrollSelectView

alternateColor, backgroundColor, contentHeight, contentPixelHeight, contentWidth, hGridLineColor, highlightColor, hPosition, rowAutosize, rowHeight, rowWidth, sbHHeight, sbVWidth, selectColor, selectedIndex, selectedIndices, selectedItem, selectedItems, selectedValue, selectedValueFormatter, selectedValuePath, selectionMode, variableRowHeight, vGridLineColor, viewportHeight, viewportLeft, viewportPixelHeight, viewportTop, viewportWidth, virtualMode, vPosition

Properties inherited from class xp.system.UIControl

alpha, autosize, background, backgroundVisible, bindings, borderBrush, borderRadius, borderShadow, borderStyle, borderThickness, bottom, dataSource, enableMouseEvents, focusManager, height, id, isEnabled, isFocused, isMouseOver, isPressed, isSelected, isValid, layout, left, margin, maxHeight, maxWidth, measuredHeight, measuredMinHeight, measuredMinWidth, measuredWidth, minHeight, minWidth, padding, readOnly, resources, right, styleName, top, triggers, visible, width, x, y

Constructor

public
TreeView ( )
Constructor - This should not be called directly.


Method Summary

public
addNode ( parentNode: XMLNode, node: XMLNode ): XMLNode
Adds a child node at the specified index on the tree node

public
addNodeAt ( index: Number, parentNode: XMLNode, node: XMLNode ): XMLNode
Adds a child node at the specified index on the tree node

public
addTreeNode ( parent: XMLNode, name: String, label: String, data, id, isBranch: Boolean ): XMLNode
Appends a child node at the end of the tree node

public
addTreeNodeAt ( index: Number, parentNode: XMLNode, name: String, label: String, data, id, isBranch: Boolean ): XMLNode
Adds a child node at the specified index on the tree node

public
collapseRow ( row: Object, refresh: Boolean ): Void
Collapses a row

public
createElement ( nodeName: String ): XMLNode
creates a new XML element with the name specified in the parameter

public
expandRow ( row: Object, refresh: Boolean ): Void
Expands a row

public
getClass ( ): Function
Returns a reference to the components static class

public
getDisplayIndex ( node: XMLNode ): Number
Returns the display index of a given node.

public
getDocumentElement ( ): XMLNode
returns the document element this tree is bound to

public
getIsBranch ( node: XMLNode ): Boolean
Specifies whether a node is a branch (has a folder icon and expander arrow).

public
getIsOpen ( node: XMLNode ): Boolean
Indicates whether a node is open or closed.

public
getItemAt ( index: Number ): Object
given an index find the item from the source

public
getNodeDisplayedAt ( index: Number ): XMLNode
Maps a display index of the tree onto the node that is displayed there.

public
getRowDisplayedAt ( index: Number ): Object
Returns the row object at the specified index.

public
moveFirst ( ): Void
Move to the first row in the ListDataSource

public
moveLast ( ): Void
Move to the last row in the ListDataSource

public
moveSelBy ( inc: Number ): Void
Move the selection pointer by the amount specifed in the inc param

public static
newInstance ( owner, instanceId, depth, initObj )
Creates a new Instance of this class

public
setIsBranch ( node: XMLNode, isBranch: Boolean )
Specifies whether a node is a branch (has a folder icon and expander arrow).

public
setIsOpen ( node: XMLNode, open: Boolean )
Opens or closes a node.

public
showDragRibbon ( state: Boolean ): Void
Displays the drop target ribbon over a cell

public
toggleRow ( node: Object ): Void
Toggle a row

public
updateDisplayedRowCount ( count: Number ): Void


Methods inherited from class xp.controls.ScrollSelectView

clearSelected, drawComponent, getClass, getItemAt, getItemIndex, getItemValue, getValueIndex, isSelected, setScrollContentVPos, setSelectedIndices, setSelectedItems

Methods inherited from class xp.system.UIControl

addBinding, addBindings, addEventListener, addPropertyTrigger, applyStyle, beginDeferUpdate, canUpdate, centerContent, checkState, containsFocus, destroy, destroyObject, drawFocus, endDeferUpdate, findFocusFromObject, findFocusInChildren, getBinding, getBounds, getCenter, getClass, getFocus, getFocusManager, getFocusRect, getLocation, getPropertyValue, getSize, getStateName, getTrigger, globalToLocalPoint, invalidate, invalidateLayout, invalidateSize, invalidateSizeAndLayout, invalidChild, isChild, isMouseDirectlyOver, isParent, localToGlobalPoint, localToLocalPoint, measure, mouseWheel, move, onChildFocus, onKillFocus, onSetFocus, processEnterKey, processEscapeKey, processTabKey, redraw, refresh, removeEventListener, routeEvent, setBounds, setFocus, setLocation, setPropertyValue, setSize, setValueChanged, update, validate



Field Documentation

allowDrag

public var allowDrag: Boolean
Gets or sets a value indicating whether this element can be used as the source of a drag-and-drop operation

Nodes can be dragged and dropped within a tree and across trees.

allowDrop

public var allowDrop: Boolean
Gets or sets a value indicating whether this element can be used as the target of a drag-and-drop operation

Nodes can be dragged and dropped within a tree and across trees.

classInfo

public static var classInfo: Object
A static class information object

Every class has an associated classInfo object that holds the version and other static information. The classInfo can be accessed either directly by referencing the static class or by calling getClass() on any class instance.

disableAcceptButton

public var disableAcceptButton: Boolean
Disables the global accept button whilst this control has focus

disableCancelButton

public var disableCancelButton: Boolean
Disables the global cancel button whilst this control has focus

editor

public var editor
Reference to the cell edit manager

iconBinding

public var iconBinding: Binding
The binding of the child node or attibute of the row node containing the icon to display in the label control

iconFormatter

public var iconFormatter: Object
The formatter for the icon field

iconFormatterOptions

public var iconFormatterOptions: String
Options for the formatter

iconPath

public var iconPath: String
The path or name of the child node or attibute of the row node containing the icon to display in the label control

itemIndent

public var itemIndent
The standard value to indent the child items per level of the tree

itemStyle

public var itemStyle: Object
The list item styles

labelBinding

public var labelBinding: Binding
The binding of the child node or attibute of the row node containing the text to display in the label

labelFormatter

public var labelFormatter: Object
The formatter for the label field

labelFormatterOptions

public var labelFormatterOptions: String
Options for the formatter

labelPath

public var labelPath: String
The path or name of the child node or attibute of the row node containing the text to display in the label

maxNodeDepth

public var maxNodeDepth
The maximum depth of nodes in the tree that will be read

This can be used to limit the depth of nodes displayed in a tree. By default there is no limit on the depth.

rowStyle

public var rowStyle: Object
The list row styles

styleClass

public var styleClass: String
The name of the style class this instance will use.


Property Documentation

dataProvider

public dataProvider: Object (read, write)
Gets or set the list items

An array of list items. When this property is set, internally the array is wrapped in a ListDataSource and passed to the itemsSource property

displayRowCount

public displayRowCount: Number (read-only)
Number of rows of data we are currently trying to display

A count of the total number of nodes that are open plus their chlldren. Some rows maybe be currentlyout of site scrolled above or below the current viewport window. See rowCount for the number of rows that can be seen at any one time in the TreeView viewport window.

Value:
The number of displayed rows

document

public document: XMLNode (read, write)
ITEMSOURCE////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

itemsSource

public itemsSource: XMLDataSource (read, write)
Gets or set the XMLDataSource

The itemsSource is the model for items viewed in a tree. The data source wraps an XML object. This is an array of XMLNodes.

rowCount

public rowCount (read-only)
Number of rows actually visible in the viewport

Value:
The number of visible rows

selectedNode

public selectedNode: XMLNode (read, write)
Specifies the selected node in a TreeView instance.

selectedRow

public selectedRow: Object (read-only)
Returns the currently selected row node

virtualRowCount

public virtualRowCount: Number (read-only)
The number row buffers used for the visible scroll window

The number of acutal number of child nodes of all type whether visible or not in the ItemsControl.


Constructor Documentation

TreeView

public function TreeView()
Constructor - This should not be called directly.

If you want to dynamically create a new instance of a control use its static newInstance method


Method Documentation

addNode

public function addNode(parentNode: XMLNode,
 node: XMLNode): XMLNode
Adds a child node at the specified index on the tree node

Parameters:
parentNode
parent the parent node
node
the child node
Returns:
the new node

addNodeAt

public function addNodeAt(index: Number,
 parentNode: XMLNode,
 node: XMLNode): XMLNode
Adds a child node at the specified index on the tree node

Parameters:
index
the position (in the tree's root node's children) for the node
parentNode
parent the parent node
node
the child node
Returns:
the new node

addTreeNode

public function addTreeNode(parent: XMLNode,
 name: String,
 label: String,
 data,
 id,
 isBranch: Boolean): XMLNode
Appends a child node at the end of the tree node

Parameters:
parent
the parent node
name
the tag name for the node
label
the text for the node
data
the data for the node
id
the id for the node
isBranch
is this node a branch
Returns:
the new node

addTreeNodeAt

public function addTreeNodeAt(index: Number,
 parentNode: XMLNode,
 name: String,
 label: String,
 data,
 id,
 isBranch: Boolean): XMLNode
Adds a child node at the specified index on the tree node

Parameters:
index
the position (in the tree's root node's children) for the node
parentNode
parent the parent node
name
the tag name for the node
label
the text for the node
data
the data for the node
id
the id for the node
isBranch
is this node a branch
Returns:
the new node

collapseRow

public function collapseRow(row: Object,
 refresh: Boolean): Void
Collapses a row

Closes a row by making all its children invisible.

Parameters:
row
node The row node to close
refresh
If true the body layout is forced to update

createElement

public function createElement(nodeName: String): XMLNode
creates a new XML element with the name specified in the parameter

The new element initially has no parent, no children, and no siblings. The method returns a reference to the newly created XML object that represents the element. This method and the XML.createTextNode() method are the constructor methods for creating nodes for an XML object.

Parameters:
nodeName
The tag name of the XML element being created.
Returns:
An XMLNode; an XML element.

expandRow

public function expandRow(row: Object,
 refresh: Boolean): Void
Expands a row

Opens a node by making all its children visible.

Parameters:
row
node The row node to open
refresh
If true the body layout is forced to update

getClass

public function getClass(): Function
Returns a reference to the components static class

Overrides:

getDisplayIndex

public function getDisplayIndex(node: XMLNode): Number
Returns the display index of a given node.

Returns the display index of the node specified in the node parameter.

Parameters:
node
An XML node.
Returns:
The index of the specified node, or undefined if the node is not currently displayed.

getDocumentElement

public function getDocumentElement(): XMLNode
returns the document element this tree is bound to

getIsBranch

public function getIsBranch(node: XMLNode): Boolean
Specifies whether a node is a branch (has a folder icon and expander arrow).

A Boolean value that indicates whether the node is a branch (true) or not (false).

Parameters:
node
An XML node.
Returns:
A Boolean value indicating whether the node is (true) or is not (false) a branch.

getIsOpen

public function getIsOpen(node: XMLNode): Boolean
Indicates whether a node is open or closed.

A Boolean value that indicates whether the node is a open (true) or not (false).

Parameters:
node
An XML node.
Returns:
A Boolean value that indicates whether the tree is open (true) or closed (false).

getItemAt

public function getItemAt(index: Number): Object
given an index find the item from the source

Overrides:

Parameters:
index
The index of the item to return
Returns:
The reference of the item at the specified index

getNodeDisplayedAt

public function getNodeDisplayedAt(index: Number): XMLNode
Maps a display index of the tree onto the node that is displayed there.

Maps a display index of the tree onto the node that is displayed there.

Parameters:
index
An integer representing the display position in the viewable area of the tree. This number is zero-based; the node at the first position is 0, second position is 1, and so on.
Returns:
node The specified XMLNode object.

getRowDisplayedAt

public function getRowDisplayedAt(index: Number): Object
Returns the row object at the specified index.

Returns the row object at the specified index.

Parameters:
index
An integer representing the display position in the viewable area of the tree. This number is zero-based; the node at the first position is 0, second position is 1, and so on.
Returns:
node The specified row object.

moveFirst

public function moveFirst(): Void
Move to the first row in the ListDataSource

moveLast

public function moveLast(): Void
Move to the last row in the ListDataSource

moveSelBy

public function moveSelBy(inc: Number): Void
Move the selection pointer by the amount specifed in the inc param

Parameters:
inc
The number of rows to move by

newInstance

public static function newInstance(owner,
 instanceId,
 depth,
 initObj)
Creates a new Instance of this class

Creates an instance of a component at runtime. You need to use the import statement and specify the class package name before calling this method. In addition, the component must be in the FLA file’s library.

Parameters:
owner
A reference to the movie clip or object that will contains the new Instance.
instanceId
A string indicating the instance name of the new instance.(optional)
depth
A number indicating the depth of the new instance.(optional)
initObj
An object containing initialization properties for the new instance.(optional)
Returns:
A object that is an instance of the specified class.

setIsBranch

public function setIsBranch(node: XMLNode,
 isBranch: Boolean)
Specifies whether a node is a branch (has a folder icon and expander arrow).

specifies whether the node has a folder icon and expander arrow and either has children or can have children. A node is automatically set as a branch when it has children; you only need to call setIsBranch() when you want to create an empty folder. You may want to create branches that don’t yet have children if, for example, you only want child nodes to load when a user opens a folder. Calling setIsBranch() refreshes any views.

Parameters:
node
An XML node.
isBranch
A Boolean value indicating whether the node is (true) or is not (false) a branch.

setIsOpen

public function setIsOpen(node: XMLNode,
 open: Boolean)
Opens or closes a node.

Opens or closes a node.

Parameters:
node
An XML node.
open
A Boolean value that opens a node (true) or closes it (false).

showDragRibbon

public function showDragRibbon(state: Boolean): Void
Displays the drop target ribbon over a cell

Parameters:
state
If true shows the ribbon if false hides it

toggleRow

public function toggleRow(node: Object): Void
Toggle a row

If the row is open it closes it otherwsie it opens it

Parameters:
node
The row node to toggle

updateDisplayedRowCount

public function updateDisplayedRowCount(count: Number): Void

The documentation was generated from the following file:


Generated on 10/30/2005 9:34:02 PM by AS2Doc