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"/>
7 <link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
9 <script type="text/javascript" src="../../script/qx.js"></script>
12 <script type="text/javascript" src="../../script/layout.js"></script>
14 <div id="demoDescription">
15 <p>Shows a tree, with user-defined icons for some nodes. This tests
16 listening for tree events. A separate alert is generated upon opening a
17 folder that has contents; when opening a folder that has no contents; and
18 closing a folder.</p><p>We also demonstrate changing the default value of
19 'allowShowPlusMinusSymbol' so that all folders initially have a plus/minus
20 symbol. Then, upon opening an empty folder, we remove that
21 icon.</p><p>Lastly, we demonstrate in the alert presented by tree events,
22 use of the getHierarchy() method to obtain a full "path" for a tree
26 <script type="text/javascript">
27 qx.core.Init.getInstance().defineMain(function()
30 * Reset the default of always showing the plus/minus symbol. The
31 * default is 'false'. We want to always display it for each folder
32 * (and then stop displaying it if we determine upon open that there are
35 * The changeProperty() function assumes that it is being called
36 * shortly after defineClass() is called. We therefore need to kludge
37 * qx.Proto to point to the right place.
39 * TODO: There should be a mechanism to change a property attribute
40 * without having to jump through these hoops.
42 var constructor = qx.OO.classes["qx.ui.treefullcontrol.TreeFolder"];
43 qx.Proto = constructor.prototype;
44 qx.OO.changeProperty({ name : "alwaysShowPlusMinusSymbol", type : qx.constant.Type.BOOLEAN, defaultValue : true });
47 var trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Root");
48 var t = new qx.ui.treefullcontrol.Tree(trs);
51 * All subtrees will use this root node's event listeners. Create event
52 * listeners for each of the possible events.
54 t.addEventListener(qx.constant.Event.TREEOPENWITHCONTENT, function(e) {
55 alert('treeOpenWithContent ' + e.getData().getHierarchy(new Array()).join("/"));
58 t.addEventListener(qx.constant.Event.TREECLOSE, function(e) {
59 alert('treeClose ' + e.getData().getHierarchy(new Array()).join("/"));
63 * We handle opening an empty folder specially. We demonstrate how to
64 * disable the plus/minus sign once we've determined there's nothing in
65 * it. This feature might be used to dynamically retrieve the contents
66 * of the folder, and if nothing is available, indicate it by removing
67 * the plus/minus sign.
69 t.addEventListener(qx.constant.Event.TREEOPENWHILEEMPTY, function(e) {
70 alert('treeOpenWhileEmpty ' + e.getData().getHierarchy(new Array()).join("/"));
71 e.getData().setAlwaysShowPlusMinusSymbol(false);
76 setBackgroundColor(255);
77 setBorder(qx.renderer.border.BorderPresets.getInstance().inset);
78 setOverflow("scrollY");
87 qx.ui.core.ClientDocument.getInstance().add(t);
88 // One icon for selected and one for unselected states
89 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Desktop", "icon/16/desktop.png", "icon/16/dictionary.png");
90 var te1 = new qx.ui.treefullcontrol.TreeFolder(trs);
95 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Files");
96 var te1_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
97 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Workspace");
98 var te1_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
99 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Network");
100 var te1_3 = new qx.ui.treefullcontrol.TreeFolder(trs);
101 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Trash");
102 var te1_4 = new qx.ui.treefullcontrol.TreeFolder(trs);
104 te1.add(te1_1, te1_2, te1_3, te1_4);
106 // One icon specified, and used for both selected unselected states
107 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Windows (C:)", "icon/16/harddrive.png");
108 var te1_2_1 = new qx.ui.treefullcontrol.TreeFile(trs);
109 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Documents (D:)", "icon/16/harddrive.png");
110 var te1_2_2 = new qx.ui.treefullcontrol.TreeFile(trs);
112 te1_2.add(te1_2_1, te1_2_2);
114 arbeitsplatz = te1_2;
117 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Inbox");
118 var te2 = new qx.ui.treefullcontrol.TreeFolder(trs);
121 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Presets");
122 var te2_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
123 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Sent");
124 var te2_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
125 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Trash", "icon/16/trash.png");
126 var te2_3 = new qx.ui.treefullcontrol.TreeFolder(trs);
127 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Data");
128 var te2_4 = new qx.ui.treefullcontrol.TreeFolder(trs);
129 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Edit");
130 var te2_5 = new qx.ui.treefullcontrol.TreeFolder(trs);
134 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Chat");
135 var te2_5_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
136 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Pustefix");
137 var te2_5_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
138 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("TINC");
139 var te2_5_3 = new qx.ui.treefullcontrol.TreeFolder(trs);
141 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Announce");
142 var te2_5_3_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
143 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Devel");
144 var te2_5_3_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
146 te2_5_3.add(te2_5_3_1, te2_5_3_2);
148 te2_5.add(te2_5_1, te2_5_2, te2_5_3);
150 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Lists");
151 var te2_6 = new qx.ui.treefullcontrol.TreeFolder(trs);
153 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Relations");
154 var te2_6_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
155 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Company");
156 var te2_6_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
157 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Questions");
158 var te2_6_3 = new qx.ui.treefullcontrol.TreeFolder(trs);
159 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Internal");
160 var te2_6_4 = new qx.ui.treefullcontrol.TreeFolder(trs);
161 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Products");
162 var te2_6_5 = new qx.ui.treefullcontrol.TreeFolder(trs);
163 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Press");
164 var te2_6_6 = new qx.ui.treefullcontrol.TreeFolder(trs);
165 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Development");
166 var te2_6_7 = new qx.ui.treefullcontrol.TreeFolder(trs);
167 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Competition");
168 var te2_6_8 = new qx.ui.treefullcontrol.TreeFolder(trs);
170 te2_6.add(te2_6_1, te2_6_2, te2_6_3, te2_6_4, te2_6_5, te2_6_6, te2_6_7, te2_6_8);
172 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Personal");
173 var te2_7 = new qx.ui.treefullcontrol.TreeFolder(trs);
175 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Bugs");
176 var te2_7_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
177 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Family");
178 var te2_7_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
179 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Projects");
180 var te2_7_3 = new qx.ui.treefullcontrol.TreeFolder(trs);
181 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Holiday");
182 var te2_7_4 = new qx.ui.treefullcontrol.TreeFolder(trs);
184 te2_7.add(te2_7_1, te2_7_2, te2_7_3, te2_7_4);
186 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Big");
187 var te2_8 = new qx.ui.treefullcontrol.TreeFolder(trs);
189 for (var i=0;i<50; i++) {
190 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Item " + i);
191 te2_8.add(new qx.ui.treefullcontrol.TreeFolder(trs));
194 trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Spam");
195 var te2_9 = new qx.ui.treefullcontrol.TreeFolder(trs);
198 te2.add(te2_1, te2_2, te2_3, te2_4, te2_5, te2_6, te2_7, te2_8, te2_9);
201 qx.ui.core.ClientDocument.getInstance().add(t);
208 var commandFrame = new qx.ui.groupbox.GroupBox("Control");
219 qx.ui.core.ClientDocument.getInstance().add(commandFrame);
224 var tCurrentLabel = new qx.ui.basic.Atom("Current Folder: ");
232 commandFrame.add(tCurrentLabel);
236 var tCurrentInput = new qx.ui.form.TextField;
247 commandFrame.add(tCurrentInput);
249 t.getManager().addEventListener("changeSelection", function(e) {
250 tCurrentInput.setValue(e.getData()[0]._labelObject.getHtml());
255 var tDoubleClick = new qx.ui.form.CheckBox("Use double click?");
262 commandFrame.add(tDoubleClick);
264 tDoubleClick.addEventListener("changeChecked", function(e) { t.setUseDoubleClick(e.getData()); });
269 var tTreeLines = new qx.ui.form.CheckBox("Use tree lines?");
277 commandFrame.add(tTreeLines);
279 tTreeLines.addEventListener("changeChecked", function(e) { t.setUseTreeLines(e.getData()); });
282 var tHideNode = new qx.ui.form.CheckBox("Hide the root node?");
290 commandFrame.add(tHideNode);
292 tHideNode.addEventListener("changeChecked", function(e) { t.setHideNode(e.getData()); });