/** * A "dynamic" implementation of the standard TreeFolder class. * */ qx.Class.define("org.argeo.ria.components.DynamicTreeFolder", { extend : qx.ui.tree.TreeFolder, properties : { /** * The current state of the folder, usually "empty" => "loading" => "loaded" */ "state" : { check : "String", init : "empty", apply : "_applyState" }, /** * String to display as a child node during loading */ "loadingString" : { check : "String", init : "Loading..." }, /** * Function that will load the children of this folder */ "loader" : { check : "Function", init : function(treeFolder){treeFolder.setLoaded();} }, /** * Optionnal data describing the "drag" behaviour of the created children. * First level is "file" or "folder", and for each of them, supported keys are "type" and "action". */ "dragData": { check : "Map", init : {} } }, /** * Creates a new instance of DynamicTreeFolder * @param label {String} Label of the folder * @param loader {Function} Function that will load the children * @param loadingString {String} String to display as a child node during loading * @param dragData {Map} Optionnal data describing the "drag" behaviour of the created children. */ construct : function(label, loader, loadingString, dragData){ this.base(arguments, label); if(loader) this.setLoader(loader); if(loadingString) this.setLoadingString(loadingString); if(dragData) this.setDragData(dragData); this.addListener("changeOpen", function(e){ if(e.getData() && this.getState() == "loading"){ this.load(); } }, this); this.setState("loading"); }, members : { /** * Add an item to the folder * @param varargs {Mixed} One or many children to add */ add : function(varargs){ this.base(arguments, varargs); for (var i=0, l=arguments.length; i