--- /dev/null
+<html>\r
+<head>\r
+ <title>The source code</title>\r
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body onload="prettyPrint();">\r
+ <pre class="prettyprint lang-js"><div id="cls-Ext.tree.TreePanel"></div>/**\r
+ * @class Ext.tree.TreePanel\r
+ * @extends Ext.Panel\r
+ * <p>The TreePanel provides tree-structured UI representation of tree-structured data.</p>\r
+ * <p>{@link Ext.tree.TreeNode TreeNode}s added to the TreePanel may each contain metadata\r
+ * used by your application in their {@link Ext.tree.TreeNode#attributes attributes} property.</p>\r
+ * <p><b>A TreePanel must have a {@link #root} node before it is rendered.</b> This may either be\r
+ * specified using the {@link #root} config option, or using the {@link #setRootNode} method.\r
+ * <p>An example of tree rendered to an existing div:</p><pre><code>\r
+var tree = new Ext.tree.TreePanel({\r
+ renderTo: 'tree-div',\r
+ useArrows: true,\r
+ autoScroll: true,\r
+ animate: true,\r
+ enableDD: true,\r
+ containerScroll: true,\r
+ border: false,\r
+ // auto create TreeLoader\r
+ dataUrl: 'get-nodes.php',\r
+\r
+ root: {\r
+ nodeType: 'async',\r
+ text: 'Ext JS',\r
+ draggable: false,\r
+ id: 'source'\r
+ }\r
+});\r
+\r
+tree.getRootNode().expand();\r
+ * </code></pre>\r
+ * <p>The example above would work with a data packet similar to this:</p><pre><code>\r
+[{\r
+ "text": "adapter",\r
+ "id": "source\/adapter",\r
+ "cls": "folder"\r
+}, {\r
+ "text": "dd",\r
+ "id": "source\/dd",\r
+ "cls": "folder"\r
+}, {\r
+ "text": "debug.js",\r
+ "id": "source\/debug.js",\r
+ "leaf": true,\r
+ "cls": "file"\r
+}]\r
+ * </code></pre>\r
+ * <p>An example of tree within a Viewport:</p><pre><code>\r
+new Ext.Viewport({\r
+ layout: 'border',\r
+ items: [{\r
+ region: 'west',\r
+ collapsible: true,\r
+ title: 'Navigation',\r
+ xtype: 'treepanel',\r
+ width: 200,\r
+ autoScroll: true,\r
+ split: true,\r
+ loader: new Ext.tree.TreeLoader(),\r
+ root: new Ext.tree.AsyncTreeNode({\r
+ expanded: true,\r
+ children: [{\r
+ text: 'Menu Option 1',\r
+ leaf: true\r
+ }, {\r
+ text: 'Menu Option 2',\r
+ leaf: true\r
+ }, {\r
+ text: 'Menu Option 3',\r
+ leaf: true\r
+ }]\r
+ }),\r
+ rootVisible: false,\r
+ listeners: {\r
+ click: function(n) {\r
+ Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.text + '"');\r
+ }\r
+ }\r
+ }, {\r
+ region: 'center',\r
+ xtype: 'tabpanel',\r
+ // remaining code not shown ...\r
+ }]\r
+});\r
+</code></pre>\r
+ *\r
+ * @cfg {Ext.tree.TreeNode} root The root node for the tree.\r
+ * @cfg {Boolean} rootVisible <tt>false</tt> to hide the root node (defaults to <tt>true</tt>)\r
+ * @cfg {Boolean} lines <tt>false</tt> to disable tree lines (defaults to <tt>true</tt>)\r
+ * @cfg {Boolean} enableDD <tt>true</tt> to enable drag and drop\r
+ * @cfg {Boolean} enableDrag <tt>true</tt> to enable just drag\r
+ * @cfg {Boolean} enableDrop <tt>true</tt> to enable just drop\r
+ * @cfg {Object} dragConfig Custom config to pass to the {@link Ext.tree.TreeDragZone} instance\r
+ * @cfg {Object} dropConfig Custom config to pass to the {@link Ext.tree.TreeDropZone} instance\r
+ * @cfg {String} ddGroup The DD group this TreePanel belongs to\r
+ * @cfg {Boolean} ddAppendOnly <tt>true</tt> if the tree should only allow append drops (use for trees which are sorted)\r
+ * @cfg {Boolean} ddScroll <tt>true</tt> to enable body scrolling\r
+ * @cfg {Boolean} containerScroll <tt>true</tt> to register this container with ScrollManager\r
+ * @cfg {Boolean} hlDrop <tt>false</tt> to disable node highlight on drop (defaults to the value of {@link Ext#enableFx})\r
+ * @cfg {String} hlColor The color of the node highlight (defaults to <tt>'C3DAF9'</tt>)\r
+ * @cfg {Boolean} animate <tt>true</tt> to enable animated expand/collapse (defaults to the value of {@link Ext#enableFx})\r
+ * @cfg {Boolean} singleExpand <tt>true</tt> if only 1 node per branch may be expanded\r
+ * @cfg {Object} selModel A tree selection model to use with this TreePanel (defaults to an {@link Ext.tree.DefaultSelectionModel})\r
+ * @cfg {Boolean} trackMouseOver <tt>false</tt> to disable mouse over highlighting\r
+ * @cfg {Ext.tree.TreeLoader} loader A {@link Ext.tree.TreeLoader} for use with this TreePanel\r
+ * @cfg {String} pathSeparator The token used to separate sub-paths in path strings (defaults to <tt>'/'</tt>)\r
+ * @cfg {Boolean} useArrows <tt>true</tt> to use Vista-style arrows in the tree (defaults to <tt>false</tt>)\r
+ * @cfg {String} requestMethod The HTTP request method for loading data (defaults to the value of {@link Ext.Ajax#method}).\r
+ *\r
+ * @constructor\r
+ * @param {Object} config\r
+ * @xtype treepanel\r
+ */\r
+Ext.tree.TreePanel = Ext.extend(Ext.Panel, {\r
+ rootVisible : true,\r
+ animate: Ext.enableFx,\r
+ lines : true,\r
+ enableDD : false,\r
+ hlDrop : Ext.enableFx,\r
+ pathSeparator: "/",\r
+\r
+ initComponent : function(){\r
+ Ext.tree.TreePanel.superclass.initComponent.call(this);\r
+\r
+ if(!this.eventModel){\r
+ this.eventModel = new Ext.tree.TreeEventModel(this);\r
+ }\r
+\r
+ // initialize the loader\r
+ var l = this.loader;\r
+ if(!l){\r
+ l = new Ext.tree.TreeLoader({\r
+ dataUrl: this.dataUrl,\r
+ requestMethod: this.requestMethod\r
+ });\r
+ }else if(typeof l == 'object' && !l.load){\r
+ l = new Ext.tree.TreeLoader(l);\r
+ }\r
+ this.loader = l;\r
+\r
+ this.nodeHash = {};\r
+\r
+ /**\r
+ * The root node of this tree.\r
+ * @type Ext.tree.TreeNode\r
+ * @property root\r
+ */\r
+ if(this.root){\r
+ var r = this.root;\r
+ delete this.root;\r
+ this.setRootNode(r);\r
+ }\r
+\r
+\r
+ this.addEvents(\r
+\r
+ /**\r
+ * @event append\r
+ * Fires when a new child node is appended to a node in this tree.\r
+ * @param {Tree} tree The owner tree\r
+ * @param {Node} parent The parent node\r
+ * @param {Node} node The newly appended node\r
+ * @param {Number} index The index of the newly appended node\r
+ */\r
+ "append",\r
+ /**\r
+ * @event remove\r
+ * Fires when a child node is removed from a node in this tree.\r
+ * @param {Tree} tree The owner tree\r
+ * @param {Node} parent The parent node\r
+ * @param {Node} node The child node removed\r
+ */\r
+ "remove",\r
+ /**\r
+ * @event movenode\r
+ * Fires when a node is moved to a new location in the tree\r
+ * @param {Tree} tree The owner tree\r
+ * @param {Node} node The node moved\r
+ * @param {Node} oldParent The old parent of this node\r
+ * @param {Node} newParent The new parent of this node\r
+ * @param {Number} index The index it was moved to\r
+ */\r
+ "movenode",\r
+ /**\r
+ * @event insert\r
+ * Fires when a new child node is inserted in a node in this tree.\r
+ * @param {Tree} tree The owner tree\r
+ * @param {Node} parent The parent node\r
+ * @param {Node} node The child node inserted\r
+ * @param {Node} refNode The child node the node was inserted before\r
+ */\r
+ "insert",\r
+ /**\r
+ * @event beforeappend\r
+ * Fires before a new child is appended to a node in this tree, return false to cancel the append.\r
+ * @param {Tree} tree The owner tree\r
+ * @param {Node} parent The parent node\r
+ * @param {Node} node The child node to be appended\r
+ */\r
+ "beforeappend",\r
+ /**\r
+ * @event beforeremove\r
+ * Fires before a child is removed from a node in this tree, return false to cancel the remove.\r
+ * @param {Tree} tree The owner tree\r
+ * @param {Node} parent The parent node\r
+ * @param {Node} node The child node to be removed\r
+ */\r
+ "beforeremove",\r
+ /**\r
+ * @event beforemovenode\r
+ * Fires before a node is moved to a new location in the tree. Return false to cancel the move.\r
+ * @param {Tree} tree The owner tree\r
+ * @param {Node} node The node being moved\r
+ * @param {Node} oldParent The parent of the node\r
+ * @param {Node} newParent The new parent the node is moving to\r
+ * @param {Number} index The index it is being moved to\r
+ */\r
+ "beforemovenode",\r
+ /**\r
+ * @event beforeinsert\r
+ * Fires before a new child is inserted in a node in this tree, return false to cancel the insert.\r
+ * @param {Tree} tree The owner tree\r
+ * @param {Node} parent The parent node\r
+ * @param {Node} node The child node to be inserted\r
+ * @param {Node} refNode The child node the node is being inserted before\r
+ */\r
+ "beforeinsert",\r
+\r
+ /**\r
+ * @event beforeload\r
+ * Fires before a node is loaded, return false to cancel\r
+ * @param {Node} node The node being loaded\r
+ */\r
+ "beforeload",\r
+ /**\r
+ * @event load\r
+ * Fires when a node is loaded\r
+ * @param {Node} node The node that was loaded\r
+ */\r
+ "load",\r
+ /**\r
+ * @event textchange\r
+ * Fires when the text for a node is changed\r
+ * @param {Node} node The node\r
+ * @param {String} text The new text\r
+ * @param {String} oldText The old text\r
+ */\r
+ "textchange",\r
+ /**\r
+ * @event beforeexpandnode\r
+ * Fires before a node is expanded, return false to cancel.\r
+ * @param {Node} node The node\r
+ * @param {Boolean} deep\r
+ * @param {Boolean} anim\r
+ */\r
+ "beforeexpandnode",\r
+ /**\r
+ * @event beforecollapsenode\r
+ * Fires before a node is collapsed, return false to cancel.\r
+ * @param {Node} node The node\r
+ * @param {Boolean} deep\r
+ * @param {Boolean} anim\r
+ */\r
+ "beforecollapsenode",\r
+ /**\r
+ * @event expandnode\r
+ * Fires when a node is expanded\r
+ * @param {Node} node The node\r
+ */\r
+ "expandnode",\r
+ /**\r
+ * @event disabledchange\r
+ * Fires when the disabled status of a node changes\r
+ * @param {Node} node The node\r
+ * @param {Boolean} disabled\r
+ */\r
+ "disabledchange",\r
+ /**\r
+ * @event collapsenode\r
+ * Fires when a node is collapsed\r
+ * @param {Node} node The node\r
+ */\r
+ "collapsenode",\r
+ /**\r
+ * @event beforeclick\r
+ * Fires before click processing on a node. Return false to cancel the default action.\r
+ * @param {Node} node The node\r
+ * @param {Ext.EventObject} e The event object\r
+ */\r
+ "beforeclick",\r
+ /**\r
+ * @event click\r
+ * Fires when a node is clicked\r
+ * @param {Node} node The node\r
+ * @param {Ext.EventObject} e The event object\r
+ */\r
+ "click",\r
+ /**\r
+ * @event checkchange\r
+ * Fires when a node with a checkbox's checked property changes\r
+ * @param {Node} this This node\r
+ * @param {Boolean} checked\r
+ */\r
+ "checkchange",\r
+ /**\r
+ * @event dblclick\r
+ * Fires when a node is double clicked\r
+ * @param {Node} node The node\r
+ * @param {Ext.EventObject} e The event object\r
+ */\r
+ "dblclick",\r
+ /**\r
+ * @event contextmenu\r
+ * Fires when a node is right clicked. To display a context menu in response to this\r
+ * event, first create a Menu object (see {@link Ext.menu.Menu} for details), then add\r
+ * a handler for this event:<pre><code>\r
+new Ext.tree.TreePanel({\r
+ title: 'My TreePanel',\r
+ root: new Ext.tree.AsyncTreeNode({\r
+ text: 'The Root',\r
+ children: [\r
+ { text: 'Child node 1', leaf: true },\r
+ { text: 'Child node 2', leaf: true }\r
+ ]\r
+ }),\r
+ contextMenu: new Ext.menu.Menu({\r
+ items: [{\r
+ id: 'delete-node',\r
+ text: 'Delete Node'\r
+ }],\r
+ listeners: {\r
+ itemclick: function(item) {\r
+ switch (item.id) {\r
+ case 'delete-node':\r
+ var n = item.parentMenu.contextNode;\r
+ if (n.parentNode) {\r
+ n.remove();\r
+ }\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }),\r
+ listeners: {\r
+ contextmenu: function(node, e) {\r
+// Register the context node with the menu so that a Menu Item's handler function can access\r
+// it via its {@link Ext.menu.BaseItem#parentMenu parentMenu} property.\r
+ node.select();\r
+ var c = node.getOwnerTree().contextMenu;\r
+ c.contextNode = node;\r
+ c.showAt(e.getXY());\r
+ }\r
+ }\r
+});\r
+</code></pre>\r
+ * @param {Node} node The node\r
+ * @param {Ext.EventObject} e The event object\r
+ */\r
+ "contextmenu",\r
+ /**\r
+ * @event beforechildrenrendered\r
+ * Fires right before the child nodes for a node are rendered\r
+ * @param {Node} node The node\r
+ */\r
+ "beforechildrenrendered",\r
+ /**\r
+ * @event startdrag\r
+ * Fires when a node starts being dragged\r
+ * @param {Ext.tree.TreePanel} this\r
+ * @param {Ext.tree.TreeNode} node\r
+ * @param {event} e The raw browser event\r
+ */\r
+ "startdrag",\r
+ /**\r
+ * @event enddrag\r
+ * Fires when a drag operation is complete\r
+ * @param {Ext.tree.TreePanel} this\r
+ * @param {Ext.tree.TreeNode} node\r
+ * @param {event} e The raw browser event\r
+ */\r
+ "enddrag",\r
+ /**\r
+ * @event dragdrop\r
+ * Fires when a dragged node is dropped on a valid DD target\r
+ * @param {Ext.tree.TreePanel} this\r
+ * @param {Ext.tree.TreeNode} node\r
+ * @param {DD} dd The dd it was dropped on\r
+ * @param {event} e The raw browser event\r
+ */\r
+ "dragdrop",\r
+ /**\r
+ * @event beforenodedrop\r
+ * Fires when a DD object is dropped on a node in this tree for preprocessing. Return false to cancel the drop. The dropEvent\r
+ * passed to handlers has the following properties:<br />\r
+ * <ul style="padding:5px;padding-left:16px;">\r
+ * <li>tree - The TreePanel</li>\r
+ * <li>target - The node being targeted for the drop</li>\r
+ * <li>data - The drag data from the drag source</li>\r
+ * <li>point - The point of the drop - append, above or below</li>\r
+ * <li>source - The drag source</li>\r
+ * <li>rawEvent - Raw mouse event</li>\r
+ * <li>dropNode - Drop node(s) provided by the source <b>OR</b> you can supply node(s)\r
+ * to be inserted by setting them on this object.</li>\r
+ * <li>cancel - Set this to true to cancel the drop.</li>\r
+ * <li>dropStatus - If the default drop action is cancelled but the drop is valid, setting this to true\r
+ * will prevent the animated "repair" from appearing.</li>\r
+ * </ul>\r
+ * @param {Object} dropEvent\r
+ */\r
+ "beforenodedrop",\r
+ /**\r
+ * @event nodedrop\r
+ * Fires after a DD object is dropped on a node in this tree. The dropEvent\r
+ * passed to handlers has the following properties:<br />\r
+ * <ul style="padding:5px;padding-left:16px;">\r
+ * <li>tree - The TreePanel</li>\r
+ * <li>target - The node being targeted for the drop</li>\r
+ * <li>data - The drag data from the drag source</li>\r
+ * <li>point - The point of the drop - append, above or below</li>\r
+ * <li>source - The drag source</li>\r
+ * <li>rawEvent - Raw mouse event</li>\r
+ * <li>dropNode - Dropped node(s).</li>\r
+ * </ul>\r
+ * @param {Object} dropEvent\r
+ */\r
+ "nodedrop",\r
+ /**\r
+ * @event nodedragover\r
+ * Fires when a tree node is being targeted for a drag drop, return false to signal drop not allowed. The dragOverEvent\r
+ * passed to handlers has the following properties:<br />\r
+ * <ul style="padding:5px;padding-left:16px;">\r
+ * <li>tree - The TreePanel</li>\r
+ * <li>target - The node being targeted for the drop</li>\r
+ * <li>data - The drag data from the drag source</li>\r
+ * <li>point - The point of the drop - append, above or below</li>\r
+ * <li>source - The drag source</li>\r
+ * <li>rawEvent - Raw mouse event</li>\r
+ * <li>dropNode - Drop node(s) provided by the source.</li>\r
+ * <li>cancel - Set this to true to signal drop not allowed.</li>\r
+ * </ul>\r
+ * @param {Object} dragOverEvent\r
+ */\r
+ "nodedragover"\r
+ );\r
+ if(this.singleExpand){\r
+ this.on("beforeexpandnode", this.restrictExpand, this);\r
+ }\r
+ },\r
+\r
+ // private\r
+ proxyNodeEvent : function(ename, a1, a2, a3, a4, a5, a6){\r
+ if(ename == 'collapse' || ename == 'expand' || ename == 'beforecollapse' || ename == 'beforeexpand' || ename == 'move' || ename == 'beforemove'){\r
+ ename = ename+'node';\r
+ }\r
+ // args inline for performance while bubbling events\r
+ return this.fireEvent(ename, a1, a2, a3, a4, a5, a6);\r
+ },\r
+\r
+\r
+ /**\r
+ * Returns this root node for this tree\r
+ * @return {Node}\r
+ */\r
+ getRootNode : function(){\r
+ return this.root;\r
+ },\r
+\r
+ /**\r
+ * Sets the root node for this tree. If the TreePanel has already rendered a root node, the\r
+ * previous root node (and all of its descendants) are destroyed before the new root node is rendered.\r
+ * @param {Node} node\r
+ * @return {Node}\r
+ */\r
+ setRootNode : function(node){\r
+ Ext.destroy(this.root);\r
+ if(!node.render){ // attributes passed\r
+ node = this.loader.createNode(node);\r
+ }\r
+ this.root = node;\r
+ node.ownerTree = this;\r
+ node.isRoot = true;\r
+ this.registerNode(node);\r
+ if(!this.rootVisible){\r
+ var uiP = node.attributes.uiProvider;\r
+ node.ui = uiP ? new uiP(node) : new Ext.tree.RootTreeNodeUI(node);\r
+ }\r
+ if (this.innerCt) {\r
+ this.innerCt.update('');\r
+ this.afterRender();\r
+ }\r
+ return node;\r
+ },\r
+\r
+ /**\r
+ * Gets a node in this tree by its id\r
+ * @param {String} id\r
+ * @return {Node}\r
+ */\r
+ getNodeById : function(id){\r
+ return this.nodeHash[id];\r
+ },\r
+\r
+ // private\r
+ registerNode : function(node){\r
+ this.nodeHash[node.id] = node;\r
+ },\r
+\r
+ // private\r
+ unregisterNode : function(node){\r
+ delete this.nodeHash[node.id];\r
+ },\r
+\r
+ // private\r
+ toString : function(){\r
+ return "[Tree"+(this.id?" "+this.id:"")+"]";\r
+ },\r
+\r
+ // private\r
+ restrictExpand : function(node){\r
+ var p = node.parentNode;\r
+ if(p){\r
+ if(p.expandedChild && p.expandedChild.parentNode == p){\r
+ p.expandedChild.collapse();\r
+ }\r
+ p.expandedChild = node;\r
+ }\r
+ },\r
+\r
+ /**\r
+ * Retrieve an array of checked nodes, or an array of a specific attribute of checked nodes (e.g. "id")\r
+ * @param {String} attribute (optional) Defaults to null (return the actual nodes)\r
+ * @param {TreeNode} startNode (optional) The node to start from, defaults to the root\r
+ * @return {Array}\r
+ */\r
+ getChecked : function(a, startNode){\r
+ startNode = startNode || this.root;\r
+ var r = [];\r
+ var f = function(){\r
+ if(this.attributes.checked){\r
+ r.push(!a ? this : (a == 'id' ? this.id : this.attributes[a]));\r
+ }\r
+ };\r
+ startNode.cascade(f);\r
+ return r;\r
+ },\r
+\r
+ /**\r
+ * Returns the container element for this TreePanel.\r
+ * @return {Element} The container element for this TreePanel.\r
+ */\r
+ getEl : function(){\r
+ return this.el;\r
+ },\r
+\r
+ /**\r
+ * Returns the default {@link Ext.tree.TreeLoader} for this TreePanel.\r
+ * @return {Ext.tree.TreeLoader} The TreeLoader for this TreePanel.\r
+ */\r
+ getLoader : function(){\r
+ return this.loader;\r
+ },\r
+\r
+ /**\r
+ * Expand all nodes\r
+ */\r
+ expandAll : function(){\r
+ this.root.expand(true);\r
+ },\r
+\r
+ /**\r
+ * Collapse all nodes\r
+ */\r
+ collapseAll : function(){\r
+ this.root.collapse(true);\r
+ },\r
+\r
+ /**\r
+ * Returns the selection model used by this TreePanel.\r
+ * @return {TreeSelectionModel} The selection model used by this TreePanel\r
+ */\r
+ getSelectionModel : function(){\r
+ if(!this.selModel){\r
+ this.selModel = new Ext.tree.DefaultSelectionModel();\r
+ }\r
+ return this.selModel;\r
+ },\r
+\r
+ /**\r
+ * Expands a specified path in this TreePanel. A path can be retrieved from a node with {@link Ext.data.Node#getPath}\r
+ * @param {String} path\r
+ * @param {String} attr (optional) The attribute used in the path (see {@link Ext.data.Node#getPath} for more info)\r
+ * @param {Function} callback (optional) The callback to call when the expand is complete. The callback will be called with\r
+ * (bSuccess, oLastNode) where bSuccess is if the expand was successful and oLastNode is the last node that was expanded.\r
+ */\r
+ expandPath : function(path, attr, callback){\r
+ attr = attr || "id";\r
+ var keys = path.split(this.pathSeparator);\r
+ var curNode = this.root;\r
+ if(curNode.attributes[attr] != keys[1]){ // invalid root\r
+ if(callback){\r
+ callback(false, null);\r
+ }\r
+ return;\r
+ }\r
+ var index = 1;\r
+ var f = function(){\r
+ if(++index == keys.length){\r
+ if(callback){\r
+ callback(true, curNode);\r
+ }\r
+ return;\r
+ }\r
+ var c = curNode.findChild(attr, keys[index]);\r
+ if(!c){\r
+ if(callback){\r
+ callback(false, curNode);\r
+ }\r
+ return;\r
+ }\r
+ curNode = c;\r
+ c.expand(false, false, f);\r
+ };\r
+ curNode.expand(false, false, f);\r
+ },\r
+\r
+ /**\r
+ * Selects the node in this tree at the specified path. A path can be retrieved from a node with {@link Ext.data.Node#getPath}\r
+ * @param {String} path\r
+ * @param {String} attr (optional) The attribute used in the path (see {@link Ext.data.Node#getPath} for more info)\r
+ * @param {Function} callback (optional) The callback to call when the selection is complete. The callback will be called with\r
+ * (bSuccess, oSelNode) where bSuccess is if the selection was successful and oSelNode is the selected node.\r
+ */\r
+ selectPath : function(path, attr, callback){\r
+ attr = attr || "id";\r
+ var keys = path.split(this.pathSeparator);\r
+ var v = keys.pop();\r
+ if(keys.length > 0){\r
+ var f = function(success, node){\r
+ if(success && node){\r
+ var n = node.findChild(attr, v);\r
+ if(n){\r
+ n.select();\r
+ if(callback){\r
+ callback(true, n);\r
+ }\r
+ }else if(callback){\r
+ callback(false, n);\r
+ }\r
+ }else{\r
+ if(callback){\r
+ callback(false, n);\r
+ }\r
+ }\r
+ };\r
+ this.expandPath(keys.join(this.pathSeparator), attr, f);\r
+ }else{\r
+ this.root.select();\r
+ if(callback){\r
+ callback(true, this.root);\r
+ }\r
+ }\r
+ },\r
+\r
+ /**\r
+ * Returns the underlying Element for this tree\r
+ * @return {Ext.Element} The Element\r
+ */\r
+ getTreeEl : function(){\r
+ return this.body;\r
+ },\r
+\r
+ // private\r
+ onRender : function(ct, position){\r
+ Ext.tree.TreePanel.superclass.onRender.call(this, ct, position);\r
+ this.el.addClass('x-tree');\r
+ this.innerCt = this.body.createChild({tag:"ul",\r
+ cls:"x-tree-root-ct " +\r
+ (this.useArrows ? 'x-tree-arrows' : this.lines ? "x-tree-lines" : "x-tree-no-lines")});\r
+ },\r
+\r
+ // private\r
+ initEvents : function(){\r
+ Ext.tree.TreePanel.superclass.initEvents.call(this);\r
+\r
+ if(this.containerScroll){\r
+ Ext.dd.ScrollManager.register(this.body);\r
+ }\r
+ if((this.enableDD || this.enableDrop) && !this.dropZone){\r
+ /**\r
+ * The dropZone used by this tree if drop is enabled (see {@link #enableDD} or {@link #enableDrop})\r
+ * @property dropZone\r
+ * @type Ext.tree.TreeDropZone\r
+ */\r
+ this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || {\r
+ ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true\r
+ });\r
+ }\r
+ if((this.enableDD || this.enableDrag) && !this.dragZone){\r
+ /**\r
+ * The dragZone used by this tree if drag is enabled (see {@link #enableDD} or {@link #enableDrag})\r
+ * @property dragZone\r
+ * @type Ext.tree.TreeDragZone\r
+ */\r
+ this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || {\r
+ ddGroup: this.ddGroup || "TreeDD",\r
+ scroll: this.ddScroll\r
+ });\r
+ }\r
+ this.getSelectionModel().init(this);\r
+ },\r
+\r
+ // private\r
+ afterRender : function(){\r
+ Ext.tree.TreePanel.superclass.afterRender.call(this);\r
+ this.root.render();\r
+ if(!this.rootVisible){\r
+ this.root.renderChildren();\r
+ }\r
+ },\r
+\r
+ onDestroy : function(){\r
+ if(this.rendered){\r
+ this.body.removeAllListeners();\r
+ Ext.dd.ScrollManager.unregister(this.body);\r
+ if(this.dropZone){\r
+ this.dropZone.unreg();\r
+ }\r
+ if(this.dragZone){\r
+ this.dragZone.unreg();\r
+ }\r
+ }\r
+ this.root.destroy();\r
+ this.nodeHash = null;\r
+ Ext.tree.TreePanel.superclass.onDestroy.call(this);\r
+ }\r
+\r
+ /**\r
+ * @cfg {String/Number} activeItem\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {Boolean} autoDestroy\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {Object/String/Function} autoLoad\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {Boolean} autoWidth\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {Boolean/Number} bufferResize\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {String} defaultType\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {Object} defaults\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {Boolean} hideBorders\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {Mixed} items\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {String} layout\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {Object} layoutConfig\r
+ * @hide\r
+ */\r
+ /**\r
+ * @cfg {Boolean} monitorResize\r
+ * @hide\r
+ */\r
+ /**\r
+ * @property items\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method cascade\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method doLayout\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method find\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method findBy\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method findById\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method findByType\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method getComponent\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method getLayout\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method getUpdater\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method insert\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method load\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method remove\r
+ * @hide\r
+ */\r
+ /**\r
+ * @event add\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method removeAll\r
+ * @hide\r
+ */\r
+ /**\r
+ * @event afterLayout\r
+ * @hide\r
+ */\r
+ /**\r
+ * @event beforeadd\r
+ * @hide\r
+ */\r
+ /**\r
+ * @event beforeremove\r
+ * @hide\r
+ */\r
+ /**\r
+ * @event remove\r
+ * @hide\r
+ */\r
+\r
+\r
+\r
+ /**\r
+ * @cfg {String} allowDomMove @hide\r
+ */\r
+ /**\r
+ * @cfg {String} autoEl @hide\r
+ */\r
+ /**\r
+ * @cfg {String} applyTo @hide\r
+ */\r
+ /**\r
+ * @cfg {String} contentEl @hide\r
+ */\r
+ /**\r
+ * @cfg {String} disabledClass @hide\r
+ */\r
+ /**\r
+ * @cfg {String} elements @hide\r
+ */\r
+ /**\r
+ * @cfg {String} html @hide\r
+ */\r
+ /**\r
+ * @cfg {Boolean} preventBodyReset\r
+ * @hide\r
+ */\r
+ /**\r
+ * @property disabled\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method applyToMarkup\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method enable\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method disable\r
+ * @hide\r
+ */\r
+ /**\r
+ * @method setDisabled\r
+ * @hide\r
+ */\r
+});\r
+\r
+Ext.tree.TreePanel.nodeTypes = {};\r
+\r
+Ext.reg('treepanel', Ext.tree.TreePanel);</pre> \r
+</body>\r
+</html>
\ No newline at end of file