extend : qx.ui.tree.TreeFolder,\r
\r
properties : {\r
+ /**\r
+ * The current state of the folder, usually "empty" => "loading" => "loaded"\r
+ */\r
"state" : {\r
check : "String",\r
init : "empty",\r
apply : "_applyState"\r
},\r
+ /**\r
+ * String to display as a child node during loading\r
+ */\r
"loadingString" : {\r
check : "String",\r
init : "Loading..."\r
},\r
+ /**\r
+ * Function that will load the children of this folder\r
+ */\r
"loader" : {\r
check : "Function",\r
init : function(treeFolder){treeFolder.setLoaded();}\r
},\r
+ /**\r
+ * Optionnal data describing the "drag" behaviour of the created children.\r
+ * First level is "file" or "folder", and for each of them, supported keys are "type" and "action". \r
+ */\r
"dragData": {\r
check : "Map",\r
init : {}\r
}\r
},\r
\r
+ /**\r
+ * Creates a new instance of DynamicTreeFolder\r
+ * @param label {String} Label of the folder\r
+ * @param loader {Function} Function that will load the children \r
+ * @param loadingString {String} String to display as a child node during loading\r
+ * @param dragData {Map} Optionnal data describing the "drag" behaviour of the created children.\r
+ */\r
construct : function(label, loader, loadingString, dragData){\r
this.base(arguments, label);\r
if(loader) this.setLoader(loader);\r
},\r
\r
members : {\r
- \r
+ /**\r
+ * Add an item to the folder \r
+ * @param varargs {Mixed} One or many children to add\r
+ */\r
add : function(varargs){\r
this.base(arguments, varargs);\r
for (var i=0, l=arguments.length; i<l; i++)\r
}\r
},\r
\r
+ /**\r
+ * If there is dragData set, init the drag behaviour of a child\r
+ * @param treeItem {qx.ui.tree.AbstractTreeItem} Newly created child\r
+ */\r
appendDragData : function(treeItem){\r
var dragData = this.getDragData();\r
var nodeTypeDetected = false;\r
\r
},\r
\r
+ /**\r
+ * Set the state to "loaded"\r
+ */\r
setLoaded : function(){\r
this.setState("loaded");\r
},\r
+ /**\r
+ * Called when "state" is set to a new value\r
+ * @param state {String} the new state\r
+ */\r
_applyState : function(state){\r
if(state == "loaded"){\r
if(this.loadingChild){\r
this.addLoadingChild();\r
}\r
},\r
+ /**\r
+ * Create a temporary child with the loadingString label and add it.\r
+ */\r
addLoadingChild : function(){\r
this.loadingChild = new qx.ui.tree.TreeFile(this.getLoadingString());\r
this.add(this.loadingChild);\r
},\r
+ /**\r
+ * Call loader function.\r
+ */\r
load : function(){ \r
var loaderFunc = this.getLoader();\r
loaderFunc(this);\r
},\r
+ /**\r
+ * Empty then call loader function.\r
+ */\r
reload : function(){\r
this.removeAll();\r
this.setState("loading");\r