/* Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license */ package com.yahoo.astra.fl.controls.treeClasses { import flash.events.EventDispatcher; import fl.events.DataChangeEvent; import fl.events.DataChangeType; import RangeError; import fl.data.DataProvider; //-------------------------------------- // Class description //-------------------------------------- /** * The TreeDataProvider class provides methods and properties that allow you to query and modify * the data in a Tree Component. * *
A TreeDataProvider is the current linear representation of the state of the Tree component. * However, even if some nodes are not visible, the TreeDataProvider holds information about them in member * fields of the visible nodes. For example, consider the following tree: *
* <node label=\"Folder 1\">
*
<node label=\"File 1\"/>
*
<node label=\"File 2\"/>
*
</node>
*
<node label=\"Folder 2\">
*
<node label=\"File 3\"/>
*
<node label=\"File 4\"/>
*
</node>
*
When the TreeDataProvider is initialized with the XML shown above, it will contain two items: one with label * "Folder 1", and one with label "Folder 2". However, each of these items will have a number of fields that tie * them to the Tree structure. These fields are: nodeType (either branch or leaf), nodeState * (either open or closed), nodeLevel (the depth within the tree), and nodeChildren (a set of * references to all of the node's children, if applicable. In the example, the node with label "Folder 1" will * have nodeType set to "branch node", nodeState set to "closed node", nodeLevel to 0, * and nodeChildren would contain references to nodes with labels "File 1" and "File 2". *
* When the node "Folder 1" is expanded, the TreeDataProvider will contain 4 items: "Folder 1", "File 1", * "File 2", "Folder 2". *
* * @author Allen Rabinovich * @langversion 3.0 * @playerversion Flash 9.0.28.0 * *
* Example usage:
*
* var mytree:Tree = new Tree();
* var myxml:XML = <node label=\"Folder 1\"><node label=\"File 2\"/></node>;
* mytree.dp = new TreeDataProvider(myxml);
* addChild(mytree);
*
*
nodeType - Can be either BRANCH_NODE or LEAF_NODE. Represents * whether a Node has any children.
*nodeState - If the node is a BRANCH_NODE, represents whether it's currently * open or closed. The value can be either OPEN_NODE or CLOSED_NODE
*nodeLevel - The depth of the Node within the Tree. Can be used for indenting the node * by the cell renderer.
*nodeChildren - An Array of pointers to the objects representing children of the current node.
* * @param data The XML data that is used to create the DataProvider. * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function TreeDataProvider(value:Object=null) { data = []; super(value); } /** * Toggles the node state of a branch node. If the node is currently open, it becomes closed; and vice versa. * The effect on the dataProvider is as follows: if the node is being opened, all of its children are added * to the dataProvider below the node; if the node is being closed, all of its children are removed from the * dataProvider. *The state of the child nodes of the current node is preserved; that is, if a child node of the current node * is a branch node and was open when its parent node was closed, it will be open when the parent node is * reopened.
*This method is deprecated. Use BranchNode.openNode()
and BranchNode.closeNode()
instead.