-<div id="cls-Ext.tree.DefaultSelectionModel"></div>/**\r
- * @class Ext.tree.DefaultSelectionModel\r
- * @extends Ext.util.Observable\r
- * The default single selection for a TreePanel.\r
- */\r
-Ext.tree.DefaultSelectionModel = function(config){\r
- this.selNode = null;\r
- \r
- this.addEvents(\r
- <div id="event-Ext.tree.DefaultSelectionModel-selectionchange"></div>/**\r
- * @event selectionchange\r
- * Fires when the selected node changes\r
- * @param {DefaultSelectionModel} this\r
- * @param {TreeNode} node the new selection\r
- */\r
- "selectionchange",\r
-\r
- <div id="event-Ext.tree.DefaultSelectionModel-beforeselect"></div>/**\r
- * @event beforeselect\r
- * Fires before the selected node changes, return false to cancel the change\r
- * @param {DefaultSelectionModel} this\r
- * @param {TreeNode} node the new selection\r
- * @param {TreeNode} node the old selection\r
- */\r
- "beforeselect"\r
- );\r
-\r
- Ext.apply(this, config);\r
- Ext.tree.DefaultSelectionModel.superclass.constructor.call(this);\r
-};\r
-\r
-Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, {\r
- init : function(tree){\r
- this.tree = tree;\r
- tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);\r
- tree.on("click", this.onNodeClick, this);\r
- },\r
- \r
- onNodeClick : function(node, e){\r
- this.select(node);\r
- },\r
- \r
- <div id="method-Ext.tree.DefaultSelectionModel-select"></div>/**\r
- * Select a node.\r
- * @param {TreeNode} node The node to select\r
- * @return {TreeNode} The selected node\r
- */\r
- select : function(node, /* private*/ selectNextNode){\r
- // If node is hidden, select the next node in whatever direction was being moved in.\r
- if (!Ext.fly(node.ui.wrap).isVisible() && selectNextNode) {\r
- return selectNextNode.call(this, node);\r
- }\r
- var last = this.selNode;\r
- if(node == last){\r
- node.ui.onSelectedChange(true);\r
- }else if(this.fireEvent('beforeselect', this, node, last) !== false){\r
- if(last){\r
- last.ui.onSelectedChange(false);\r
- }\r
- this.selNode = node;\r
- node.ui.onSelectedChange(true);\r
- this.fireEvent("selectionchange", this, node, last);\r
- }\r
- return node;\r
- },\r
- \r
- <div id="method-Ext.tree.DefaultSelectionModel-unselect"></div>/**\r
- * Deselect a node.\r
- * @param {TreeNode} node The node to unselect\r
- */\r
- unselect : function(node){\r
- if(this.selNode == node){\r
- this.clearSelections();\r
- } \r
- },\r
- \r
- <div id="method-Ext.tree.DefaultSelectionModel-clearSelections"></div>/**\r
- * Clear all selections\r
- */\r
- clearSelections : function(){\r
- var n = this.selNode;\r
- if(n){\r
- n.ui.onSelectedChange(false);\r
- this.selNode = null;\r
- this.fireEvent("selectionchange", this, null);\r
- }\r
- return n;\r
- },\r
- \r
- <div id="method-Ext.tree.DefaultSelectionModel-getSelectedNode"></div>/**\r
- * Get the selected node\r
- * @return {TreeNode} The selected node\r
- */\r
- getSelectedNode : function(){\r
- return this.selNode; \r
- },\r
- \r
- <div id="method-Ext.tree.DefaultSelectionModel-isSelected"></div>/**\r
- * Returns true if the node is selected\r
- * @param {TreeNode} node The node to check\r
- * @return {Boolean}\r
- */\r
- isSelected : function(node){\r
- return this.selNode == node; \r
- },\r
-\r
- <div id="method-Ext.tree.DefaultSelectionModel-selectPrevious"></div>/**\r
- * Selects the node above the selected node in the tree, intelligently walking the nodes\r
- * @return TreeNode The new selection\r
- */\r
- selectPrevious : function(/* private */ s){\r
- if(!(s = s || this.selNode || this.lastSelNode)){\r
- return null;\r
- }\r
- // Here we pass in the current function to select to indicate the direction we're moving\r
- var ps = s.previousSibling;\r
- if(ps){\r
- if(!ps.isExpanded() || ps.childNodes.length < 1){\r
- return this.select(ps, this.selectPrevious);\r
- } else{\r
- var lc = ps.lastChild;\r
- while(lc && lc.isExpanded() && Ext.fly(lc.ui.wrap).isVisible() && lc.childNodes.length > 0){\r
- lc = lc.lastChild;\r
- }\r
- return this.select(lc, this.selectPrevious);\r
- }\r
- } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){\r
- return this.select(s.parentNode, this.selectPrevious);\r
- }\r
- return null;\r
- },\r
-\r
- <div id="method-Ext.tree.DefaultSelectionModel-selectNext"></div>/**\r
- * Selects the node above the selected node in the tree, intelligently walking the nodes\r
- * @return TreeNode The new selection\r
- */\r
- selectNext : function(/* private */ s){\r
- if(!(s = s || this.selNode || this.lastSelNode)){\r
- return null;\r
- }\r
- // Here we pass in the current function to select to indicate the direction we're moving\r
- if(s.firstChild && s.isExpanded() && Ext.fly(s.ui.wrap).isVisible()){\r
- return this.select(s.firstChild, this.selectNext);\r
- }else if(s.nextSibling){\r
- return this.select(s.nextSibling, this.selectNext);\r
- }else if(s.parentNode){\r
- var newS = null;\r
- s.parentNode.bubble(function(){\r
- if(this.nextSibling){\r
- newS = this.getOwnerTree().selModel.select(this.nextSibling, this.selectNext);\r
- return false;\r
- }\r
- });\r
- return newS;\r
- }\r
- return null;\r
- },\r
-\r
- onKeyDown : function(e){\r
- var s = this.selNode || this.lastSelNode;\r
- // undesirable, but required\r
- var sm = this;\r
- if(!s){\r
- return;\r
- }\r
- var k = e.getKey();\r
- switch(k){\r
- case e.DOWN:\r
- e.stopEvent();\r
- this.selectNext();\r
- break;\r
- case e.UP:\r
- e.stopEvent();\r
- this.selectPrevious();\r
- break;\r
- case e.RIGHT:\r
- e.preventDefault();\r
- if(s.hasChildNodes()){\r
- if(!s.isExpanded()){\r
- s.expand();\r
- }else if(s.firstChild){\r
- this.select(s.firstChild, e);\r
- }\r
- }\r
- break;\r
- case e.LEFT:\r
- e.preventDefault();\r
- if(s.hasChildNodes() && s.isExpanded()){\r
- s.collapse();\r
- }else if(s.parentNode && (this.tree.rootVisible || s.parentNode != this.tree.getRootNode())){\r
- this.select(s.parentNode, e);\r
- }\r
- break;\r
- };\r
- }\r
-});\r
-\r
-<div id="cls-Ext.tree.MultiSelectionModel"></div>/**\r
- * @class Ext.tree.MultiSelectionModel\r
- * @extends Ext.util.Observable\r
- * Multi selection for a TreePanel.\r
- */\r
-Ext.tree.MultiSelectionModel = function(config){\r
- this.selNodes = [];\r
- this.selMap = {};\r
- this.addEvents(\r
- <div id="event-Ext.tree.MultiSelectionModel-selectionchange"></div>/**\r
- * @event selectionchange\r
- * Fires when the selected nodes change\r
- * @param {MultiSelectionModel} this\r
- * @param {Array} nodes Array of the selected nodes\r
- */\r
- "selectionchange"\r
- );\r
- Ext.apply(this, config);\r
- Ext.tree.MultiSelectionModel.superclass.constructor.call(this);\r
-};\r
-\r
-Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, {\r
- init : function(tree){\r
- this.tree = tree;\r
- tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);\r
- tree.on("click", this.onNodeClick, this);\r
- },\r
- \r
- onNodeClick : function(node, e){\r
- if(e.ctrlKey && this.isSelected(node)){\r
- this.unselect(node);\r
- }else{\r
- this.select(node, e, e.ctrlKey);\r
- }\r
- },\r
- \r
- <div id="method-Ext.tree.MultiSelectionModel-select"></div>/**\r
- * Select a node.\r
- * @param {TreeNode} node The node to select\r
- * @param {EventObject} e (optional) An event associated with the selection\r
- * @param {Boolean} keepExisting True to retain existing selections\r
- * @return {TreeNode} The selected node\r
- */\r
- select : function(node, e, keepExisting){\r
- if(keepExisting !== true){\r
- this.clearSelections(true);\r
- }\r
- if(this.isSelected(node)){\r
- this.lastSelNode = node;\r
- return node;\r
- }\r
- this.selNodes.push(node);\r
- this.selMap[node.id] = node;\r
- this.lastSelNode = node;\r
- node.ui.onSelectedChange(true);\r
- this.fireEvent("selectionchange", this, this.selNodes);\r
- return node;\r
- },\r
- \r
- <div id="method-Ext.tree.MultiSelectionModel-unselect"></div>/**\r
- * Deselect a node.\r
- * @param {TreeNode} node The node to unselect\r
- */\r
- unselect : function(node){\r
- if(this.selMap[node.id]){\r
- node.ui.onSelectedChange(false);\r
- var sn = this.selNodes;\r
- var index = sn.indexOf(node);\r
- if(index != -1){\r
- this.selNodes.splice(index, 1);\r
- }\r
- delete this.selMap[node.id];\r
- this.fireEvent("selectionchange", this, this.selNodes);\r
- }\r
- },\r
- \r
- <div id="method-Ext.tree.MultiSelectionModel-clearSelections"></div>/**\r
- * Clear all selections\r
- */\r
- clearSelections : function(suppressEvent){\r
- var sn = this.selNodes;\r
- if(sn.length > 0){\r
- for(var i = 0, len = sn.length; i < len; i++){\r
- sn[i].ui.onSelectedChange(false);\r
- }\r
- this.selNodes = [];\r
- this.selMap = {};\r
- if(suppressEvent !== true){\r
- this.fireEvent("selectionchange", this, this.selNodes);\r
- }\r
- }\r
- },\r
- \r
- <div id="method-Ext.tree.MultiSelectionModel-isSelected"></div>/**\r
- * Returns true if the node is selected\r
- * @param {TreeNode} node The node to check\r
- * @return {Boolean}\r
- */\r
- isSelected : function(node){\r
- return this.selMap[node.id] ? true : false; \r
- },\r
- \r
- <div id="method-Ext.tree.MultiSelectionModel-getSelectedNodes"></div>/**\r
- * Returns an array of the selected nodes\r
- * @return {Array}\r
- */\r
- getSelectedNodes : function(){\r
- return this.selNodes; \r
- },\r
-\r
- onKeyDown : Ext.tree.DefaultSelectionModel.prototype.onKeyDown,\r
-\r
- selectNext : Ext.tree.DefaultSelectionModel.prototype.selectNext,\r
-\r
- selectPrevious : Ext.tree.DefaultSelectionModel.prototype.selectPrevious\r
-});</pre>
+<div id="cls-Ext.tree.DefaultSelectionModel"></div>/**
+ * @class Ext.tree.DefaultSelectionModel
+ * @extends Ext.util.Observable
+ * The default single selection for a TreePanel.
+ */
+Ext.tree.DefaultSelectionModel = Ext.extend(Ext.util.Observable, {
+
+ constructor : function(config){
+ this.selNode = null;
+
+ this.addEvents(
+ <div id="event-Ext.tree.DefaultSelectionModel-selectionchange"></div>/**
+ * @event selectionchange
+ * Fires when the selected node changes
+ * @param {DefaultSelectionModel} this
+ * @param {TreeNode} node the new selection
+ */
+ 'selectionchange',
+
+ <div id="event-Ext.tree.DefaultSelectionModel-beforeselect"></div>/**
+ * @event beforeselect
+ * Fires before the selected node changes, return false to cancel the change
+ * @param {DefaultSelectionModel} this
+ * @param {TreeNode} node the new selection
+ * @param {TreeNode} node the old selection
+ */
+ 'beforeselect'
+ );
+
+ Ext.apply(this, config);
+ Ext.tree.DefaultSelectionModel.superclass.constructor.call(this);
+ },
+
+ init : function(tree){
+ this.tree = tree;
+ tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);
+ tree.on('click', this.onNodeClick, this);
+ },
+
+ onNodeClick : function(node, e){
+ this.select(node);
+ },
+
+ <div id="method-Ext.tree.DefaultSelectionModel-select"></div>/**
+ * Select a node.
+ * @param {TreeNode} node The node to select
+ * @return {TreeNode} The selected node
+ */
+ select : function(node, /* private*/ selectNextNode){
+ // If node is hidden, select the next node in whatever direction was being moved in.
+ if (!Ext.fly(node.ui.wrap).isVisible() && selectNextNode) {
+ return selectNextNode.call(this, node);
+ }
+ var last = this.selNode;
+ if(node == last){
+ node.ui.onSelectedChange(true);
+ }else if(this.fireEvent('beforeselect', this, node, last) !== false){
+ if(last && last.ui){
+ last.ui.onSelectedChange(false);
+ }
+ this.selNode = node;
+ node.ui.onSelectedChange(true);
+ this.fireEvent('selectionchange', this, node, last);
+ }
+ return node;
+ },
+
+ <div id="method-Ext.tree.DefaultSelectionModel-unselect"></div>/**
+ * Deselect a node.
+ * @param {TreeNode} node The node to unselect
+ * @param {Boolean} silent True to stop the selectionchange event from firing.
+ */
+ unselect : function(node, silent){
+ if(this.selNode == node){
+ this.clearSelections(silent);
+ }
+ },
+
+ <div id="method-Ext.tree.DefaultSelectionModel-clearSelections"></div>/**
+ * Clear all selections
+ * @param {Boolean} silent True to stop the selectionchange event from firing.
+ */
+ clearSelections : function(silent){
+ var n = this.selNode;
+ if(n){
+ n.ui.onSelectedChange(false);
+ this.selNode = null;
+ if(silent !== true){
+ this.fireEvent('selectionchange', this, null);
+ }
+ }
+ return n;
+ },
+
+ <div id="method-Ext.tree.DefaultSelectionModel-getSelectedNode"></div>/**
+ * Get the selected node
+ * @return {TreeNode} The selected node
+ */
+ getSelectedNode : function(){
+ return this.selNode;
+ },
+
+ <div id="method-Ext.tree.DefaultSelectionModel-isSelected"></div>/**
+ * Returns true if the node is selected
+ * @param {TreeNode} node The node to check
+ * @return {Boolean}
+ */
+ isSelected : function(node){
+ return this.selNode == node;
+ },
+
+ <div id="method-Ext.tree.DefaultSelectionModel-selectPrevious"></div>/**
+ * Selects the node above the selected node in the tree, intelligently walking the nodes
+ * @return TreeNode The new selection
+ */
+ selectPrevious : function(/* private */ s){
+ if(!(s = s || this.selNode || this.lastSelNode)){
+ return null;
+ }
+ // Here we pass in the current function to select to indicate the direction we're moving
+ var ps = s.previousSibling;
+ if(ps){
+ if(!ps.isExpanded() || ps.childNodes.length < 1){
+ return this.select(ps, this.selectPrevious);
+ } else{
+ var lc = ps.lastChild;
+ while(lc && lc.isExpanded() && Ext.fly(lc.ui.wrap).isVisible() && lc.childNodes.length > 0){
+ lc = lc.lastChild;
+ }
+ return this.select(lc, this.selectPrevious);
+ }
+ } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){
+ return this.select(s.parentNode, this.selectPrevious);
+ }
+ return null;
+ },
+
+ <div id="method-Ext.tree.DefaultSelectionModel-selectNext"></div>/**
+ * Selects the node above the selected node in the tree, intelligently walking the nodes
+ * @return TreeNode The new selection
+ */
+ selectNext : function(/* private */ s){
+ if(!(s = s || this.selNode || this.lastSelNode)){
+ return null;
+ }
+ // Here we pass in the current function to select to indicate the direction we're moving
+ if(s.firstChild && s.isExpanded() && Ext.fly(s.ui.wrap).isVisible()){
+ return this.select(s.firstChild, this.selectNext);
+ }else if(s.nextSibling){
+ return this.select(s.nextSibling, this.selectNext);
+ }else if(s.parentNode){
+ var newS = null;
+ s.parentNode.bubble(function(){
+ if(this.nextSibling){
+ newS = this.getOwnerTree().selModel.select(this.nextSibling, this.selectNext);
+ return false;
+ }
+ });
+ return newS;
+ }
+ return null;
+ },
+
+ onKeyDown : function(e){
+ var s = this.selNode || this.lastSelNode;
+ // undesirable, but required
+ var sm = this;
+ if(!s){
+ return;
+ }
+ var k = e.getKey();
+ switch(k){
+ case e.DOWN:
+ e.stopEvent();
+ this.selectNext();
+ break;
+ case e.UP:
+ e.stopEvent();
+ this.selectPrevious();
+ break;
+ case e.RIGHT:
+ e.preventDefault();
+ if(s.hasChildNodes()){
+ if(!s.isExpanded()){
+ s.expand();
+ }else if(s.firstChild){
+ this.select(s.firstChild, e);
+ }
+ }
+ break;
+ case e.LEFT:
+ e.preventDefault();
+ if(s.hasChildNodes() && s.isExpanded()){
+ s.collapse();
+ }else if(s.parentNode && (this.tree.rootVisible || s.parentNode != this.tree.getRootNode())){
+ this.select(s.parentNode, e);
+ }
+ break;
+ };
+ }
+});
+
+<div id="cls-Ext.tree.MultiSelectionModel"></div>/**
+ * @class Ext.tree.MultiSelectionModel
+ * @extends Ext.util.Observable
+ * Multi selection for a TreePanel.
+ */
+Ext.tree.MultiSelectionModel = Ext.extend(Ext.util.Observable, {
+
+ constructor : function(config){
+ this.selNodes = [];
+ this.selMap = {};
+ this.addEvents(
+ <div id="event-Ext.tree.MultiSelectionModel-selectionchange"></div>/**
+ * @event selectionchange
+ * Fires when the selected nodes change
+ * @param {MultiSelectionModel} this
+ * @param {Array} nodes Array of the selected nodes
+ */
+ 'selectionchange'
+ );
+ Ext.apply(this, config);
+ Ext.tree.MultiSelectionModel.superclass.constructor.call(this);
+ },
+
+ init : function(tree){
+ this.tree = tree;
+ tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);
+ tree.on('click', this.onNodeClick, this);
+ },
+
+ onNodeClick : function(node, e){
+ if(e.ctrlKey && this.isSelected(node)){
+ this.unselect(node);
+ }else{
+ this.select(node, e, e.ctrlKey);
+ }
+ },
+
+ <div id="method-Ext.tree.MultiSelectionModel-select"></div>/**
+ * Select a node.
+ * @param {TreeNode} node The node to select
+ * @param {EventObject} e (optional) An event associated with the selection
+ * @param {Boolean} keepExisting True to retain existing selections
+ * @return {TreeNode} The selected node
+ */
+ select : function(node, e, keepExisting){
+ if(keepExisting !== true){
+ this.clearSelections(true);
+ }
+ if(this.isSelected(node)){
+ this.lastSelNode = node;
+ return node;
+ }
+ this.selNodes.push(node);
+ this.selMap[node.id] = node;
+ this.lastSelNode = node;
+ node.ui.onSelectedChange(true);
+ this.fireEvent('selectionchange', this, this.selNodes);
+ return node;
+ },
+
+ <div id="method-Ext.tree.MultiSelectionModel-unselect"></div>/**
+ * Deselect a node.
+ * @param {TreeNode} node The node to unselect
+ */
+ unselect : function(node){
+ if(this.selMap[node.id]){
+ node.ui.onSelectedChange(false);
+ var sn = this.selNodes;
+ var index = sn.indexOf(node);
+ if(index != -1){
+ this.selNodes.splice(index, 1);
+ }
+ delete this.selMap[node.id];
+ this.fireEvent('selectionchange', this, this.selNodes);
+ }
+ },
+
+ <div id="method-Ext.tree.MultiSelectionModel-clearSelections"></div>/**
+ * Clear all selections
+ */
+ clearSelections : function(suppressEvent){
+ var sn = this.selNodes;
+ if(sn.length > 0){
+ for(var i = 0, len = sn.length; i < len; i++){
+ sn[i].ui.onSelectedChange(false);
+ }
+ this.selNodes = [];
+ this.selMap = {};
+ if(suppressEvent !== true){
+ this.fireEvent('selectionchange', this, this.selNodes);
+ }
+ }
+ },
+
+ <div id="method-Ext.tree.MultiSelectionModel-isSelected"></div>/**
+ * Returns true if the node is selected
+ * @param {TreeNode} node The node to check
+ * @return {Boolean}
+ */
+ isSelected : function(node){
+ return this.selMap[node.id] ? true : false;
+ },
+
+ <div id="method-Ext.tree.MultiSelectionModel-getSelectedNodes"></div>/**
+ * Returns an array of the selected nodes
+ * @return {Array}
+ */
+ getSelectedNodes : function(){
+ return this.selNodes.concat([]);
+ },
+
+ onKeyDown : Ext.tree.DefaultSelectionModel.prototype.onKeyDown,
+
+ selectNext : Ext.tree.DefaultSelectionModel.prototype.selectNext,
+
+ selectPrevious : Ext.tree.DefaultSelectionModel.prototype.selectPrevious
+});</pre>