1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>qooxdoo » Demo » Sample</title>
<link type="text/css" rel="stylesheet" href="../../css/layout.css"/>
<!--[if IE]>
<link type="text/css" rel="stylesheet" href="../../css/layout_ie.css"/>
<![endif]-->
<script type="text/javascript" src="../../script/sample.js"></script>
</head>
<body>
<script type="text/javascript" src="../../script/layout.js"></script>
<div id="demoDescription">
<p>Shows a tree, with user-defined icons for some nodes. This tests
listening for tree events. A separate alert is generated upon opening a
folder that has contents; when opening a folder that has no contents; and
closing a folder.</p><p>We also demonstrate changing the default value of
'allowShowPlusMinusSymbol' so that all folders initially have a plus/minus
symbol. Then, upon opening an empty folder, we remove that
icon.</p><p>Lastly, we demonstrate in the alert presented by tree events,
use of the getHierarchy() method to obtain a full "path" for a tree
node.</p>
</div>
<script type="text/javascript">
qx.core.Init.getInstance().defineMain(function()
{
/*
* Reset the default of always showing the plus/minus symbol. The
* default is 'false'. We want to always display it for each folder
* (and then stop displaying it if we determine upon open that there are
* no contents).
*
* The changeProperty() function assumes that it is being called
* shortly after defineClass() is called. We therefore need to kludge
* qx.Proto to point to the right place.
*
* TODO: There should be a mechanism to change a property attribute
* without having to jump through these hoops.
*/
var constructor = qx.OO.classes["qx.ui.treefullcontrol.TreeFolder"];
qx.Proto = constructor.prototype;
qx.OO.changeProperty({ name : "alwaysShowPlusMinusSymbol", type : "boolean", defaultValue : true });
var trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Root");
var t = new qx.ui.treefullcontrol.Tree(trs);
/*
* All subtrees will use this root node's event listeners. Create event
* listeners for each of the possible events.
*/
t.addEventListener("treeOpenWithContent", function(e) {
alert('treeOpenWithContent ' + e.getData().getHierarchy(new Array()).join("/"));
});
t.addEventListener("treeClose", function(e) {
alert('treeClose ' + e.getData().getHierarchy(new Array()).join("/"));
});
/*
* We handle opening an empty folder specially. We demonstrate how to
* disable the plus/minus sign once we've determined there's nothing in
* it. This feature might be used to dynamically retrieve the contents
* of the folder, and if nothing is available, indicate it by removing
* the plus/minus sign.
*/
t.addEventListener("treeOpenWhileEmpty", function(e) {
alert('treeOpenWhileEmpty ' + e.getData().getHierarchy(new Array()).join("/"));
e.getData().setAlwaysShowPlusMinusSymbol(false);
});
with(t)
{
setBackgroundColor(255);
setBorder(qx.renderer.border.BorderPresets.getInstance().inset);
setOverflow("scrollY");
setHeight(null);
setTop(48);
setLeft(20);
setWidth(200);
setBottom(48);
};
qx.ui.core.ClientDocument.getInstance().add(t);
// One icon for selected and one for unselected states
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Desktop", "icon/16/places/user-desktop.png", "icon/16/apps/accessories-dictionary.png");
var te1 = new qx.ui.treefullcontrol.TreeFolder(trs);
t.add(te1);
desktop = te1;
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Files");
var te1_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Workspace");
var te1_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Network");
var te1_3 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Trash");
var te1_4 = new qx.ui.treefullcontrol.TreeFolder(trs);
te1.add(te1_1, te1_2, te1_3, te1_4);
// One icon specified, and used for both selected unselected states
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Windows (C:)", "icon/16/devices/drive-harddisk.png");
var te1_2_1 = new qx.ui.treefullcontrol.TreeFile(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Documents (D:)", "icon/16/devices/drive-harddisk.png");
var te1_2_2 = new qx.ui.treefullcontrol.TreeFile(trs);
te1_2.add(te1_2_1, te1_2_2);
arbeitsplatz = te1_2;
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Inbox");
var te2 = new qx.ui.treefullcontrol.TreeFolder(trs);
posteingang = te2;
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Presets");
var te2_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Sent");
var te2_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Trash", "icon/16/places/user-trash.png");
var te2_3 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Data");
var te2_4 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Edit");
var te2_5 = new qx.ui.treefullcontrol.TreeFolder(trs);
editieren = te2_5;
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Chat");
var te2_5_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Pustefix");
var te2_5_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("TINC");
var te2_5_3 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Announce");
var te2_5_3_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Devel");
var te2_5_3_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
te2_5_3.add(te2_5_3_1, te2_5_3_2);
te2_5.add(te2_5_1, te2_5_2, te2_5_3);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Lists");
var te2_6 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Relations");
var te2_6_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Company");
var te2_6_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Questions");
var te2_6_3 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Internal");
var te2_6_4 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Products");
var te2_6_5 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Press");
var te2_6_6 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Development");
var te2_6_7 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Competition");
var te2_6_8 = new qx.ui.treefullcontrol.TreeFolder(trs);
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);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Personal");
var te2_7 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Bugs");
var te2_7_1 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Family");
var te2_7_2 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Projects");
var te2_7_3 = new qx.ui.treefullcontrol.TreeFolder(trs);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Holiday");
var te2_7_4 = new qx.ui.treefullcontrol.TreeFolder(trs);
te2_7.add(te2_7_1, te2_7_2, te2_7_3, te2_7_4);
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Big");
var te2_8 = new qx.ui.treefullcontrol.TreeFolder(trs);
for (var i=0;i<50; i++) {
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Item " + i);
te2_8.add(new qx.ui.treefullcontrol.TreeFolder(trs));
};
trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Spam");
var te2_9 = new qx.ui.treefullcontrol.TreeFolder(trs);
spam = te2_9;
te2.add(te2_1, te2_2, te2_3, te2_4, te2_5, te2_6, te2_7, te2_8, te2_9);
t.add(te2);
qx.ui.core.ClientDocument.getInstance().add(t);
var commandFrame = new qx.ui.groupbox.GroupBox("Control");
with(commandFrame)
{
setTop(48);
setLeft(250);
setWidth("auto");
setHeight("auto");
};
qx.ui.core.ClientDocument.getInstance().add(commandFrame);
var tCurrentLabel = new qx.ui.basic.Atom("Current Folder: ");
with(tCurrentLabel)
{
setLeft(0);
setTop(0);
};
commandFrame.add(tCurrentLabel);
var tCurrentInput = new qx.ui.form.TextField;
with(tCurrentInput)
{
setLeft(0);
setRight(0);
setTop(20);
setReadOnly(true);
};
commandFrame.add(tCurrentInput);
t.getManager().addEventListener("changeSelection", function(e) {
tCurrentInput.setValue(e.getData()[0]._labelObject.getHtml());
});
var tDoubleClick = new qx.ui.form.CheckBox("Use double click?");
with(tDoubleClick) {
setTop(60);
setLeft(0);
};
commandFrame.add(tDoubleClick);
tDoubleClick.addEventListener("changeChecked", function(e) { t.setUseDoubleClick(e.getData()); });
var tTreeLines = new qx.ui.form.CheckBox("Use tree lines?");
with(tTreeLines) {
setTop(80);
setLeft(0);
setChecked(true);
};
commandFrame.add(tTreeLines);
tTreeLines.addEventListener("changeChecked", function(e) { t.setUseTreeLines(e.getData()); });
var tHideNode = new qx.ui.form.CheckBox("Hide the root node?");
with(tHideNode) {
setTop(100);
setLeft(0);
setChecked(false);
};
commandFrame.add(tHideNode);
tHideNode.addEventListener("changeChecked", function(e) { t.setHideNode(e.getData()); });
});
</script>
</body>
</html>
|