3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>qooxdoo » Demo</title>
5 <link type="text/css" rel="stylesheet" href="../../resource/css/layout.css"/>
8 type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
10 <script type="text/javascript" src="../../script/qx.js"></script>
13 <script type="text/javascript" src="../../script/layout.js"></script>
16 <div id="demoDescription">
18 Shows a tree which listens for tree events. This script communicates via
19 JSON-RPC to a backend server. Each time a new tree node is opened, the
20 children are requested from the server. See the server-side functions
21 at backend/php/services/qooxdoo/fs.php.
24 <script type="text/javascript">
25 qx.core.Init.getInstance().defineMain(
28 var addChildren = function(parent, children)
34 for (i = 0; i < children.length; i++)
38 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().newRow();
40 // Here's our indentation and tree-lines
43 // If not a file or directory, change the icon
44 var bIsDirectory = ((child.mode & 0040000) != 0);
45 var bIsFile = ((child.mode & 0100000) != 0);
46 if (! bIsDirectory && ! bIsFile)
48 trs.addIcon("icon/16/desktop.png",
49 "icon/16/dictionary.png");
57 trs.addLabel(child.name);
59 // All else should be right justified
60 obj = new qx.ui.basic.HorizontalSpacer;
61 trs.addObject(obj, true);
63 // Add the permissions
65 mode = ((child.mode & 0001) ? "x" : "-") + mode;
66 mode = ((child.mode & 0002) ? "w" : "-") + mode;
67 mode = ((child.mode & 0004) ? "r" : "-") + mode;
68 mode = ((child.mode & 0010) ? "x" : "-") + mode;
69 mode = ((child.mode & 0020) ? "w" : "-") + mode;
70 mode = ((child.mode & 0040) ? "r" : "-") + mode;
71 mode = ((child.mode & 0100) ? "x" : "-") + mode;
72 mode = ((child.mode & 0200) ? "w" : "-") + mode;
73 mode = ((child.mode & 0400) ? "r" : "-") + mode;
74 obj = new qx.ui.basic.Label(mode);
76 obj.setStyleProperty("fontFamily", "monospace");
77 trs.addObject(obj, true);
79 // Add a file size, date and mode
80 obj = new qx.ui.basic.Label(child.size + "");
82 obj.setStyleProperty("fontFamily", "monospace");
83 trs.addObject(obj, true);
86 d.setTime(child.mtime * 1000);
87 obj = new qx.ui.basic.Label(d.toString().slice(0,33));
89 obj.setStyleProperty("fontFamily", "monospace");
90 trs.addObject(obj, true);
94 t = new qx.ui.treefullcontrol.TreeFolder(trs);
98 t = new qx.ui.treefullcontrol.TreeFile(trs);
105 * Reset the default of always showing the plus/minus symbol. The
106 * default is 'false'. We want to always display it for each folder
107 * (and then stop displaying it if we determine upon open that there
110 var constructor = qx.OO.classes["qx.ui.treefullcontrol.TreeFolder"];
111 qx.Proto = constructor.prototype;
112 qx.OO.changeProperty({
113 name : "alwaysShowPlusMinusSymbol",
114 type : qx.constant.Type.BOOLEAN,
115 defaultValue : true });
117 var rpc = new qx.io.remote.Rpc();
118 rpc.setTimeout(10000);
119 rpc.setUrl("/services/");
120 rpc.setServiceName("qooxdoo.fs");
121 rpc.setCrossDomain(false);
125 var trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Root");
126 var t = new qx.ui.treefullcontrol.Tree(trs);
130 setBackgroundColor(255);
131 setBorder(qx.renderer.border.BorderPresets.getInstance().inset);
132 setOverflow("scrollY");
140 setHideNode(true); // hide the root node
141 setUseTreeLines(true); // display tree lines
145 * All subtrees will use this root node's event listeners. Create an
146 * event listener for an open while empty.
149 qx.constant.Event.TREEOPENWHILEEMPTY,
152 var parent = e.getData();
153 var hierarchy = parent.getHierarchy(new Array());
155 parent.debug("Requesting children...");
157 // Strip off the root node
160 mycall = rpc.callAsync(
161 function(result, ex, id)
165 parent.debug("Children obtained. Rendering...");
166 addChildren(parent, result);
167 parent.debug("Rendering complete.");
169 alert("Async(" + id + ") exception: " + ex);
177 qx.ui.core.ClientDocument.getInstance().add(t);
179 var trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Sandbox");
180 var tf = new qx.ui.treefullcontrol.TreeFolder(trs);