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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2007 Derrell Lipman
License:
LGPL: http://www.gnu.org/licenses/lgpl.html
EPL: http://www.eclipse.org/org/documents/epl-v10.php
See the LICENSE file in the project's top-level directory for details.
Authors:
* Derrell Lipman (derrell)
************************************************************************ */
/* ************************************************************************
#module(treevirtual)
************************************************************************ */
/**
* A data cell renderer for the tree column of a simple tree
*/
qx.OO.defineClass("qx.ui.treevirtual.SimpleTreeDataCellRenderer",
qx.ui.table.AbstractDataCellRenderer,
function()
{
qx.ui.table.AbstractDataCellRenderer.call(this);
// Base URL used for indent images
var Am = qx.manager.object.AliasManager;
this.WIDGET_TREE_URI = Am.getInstance().resolvePath("widget/tree/");
this.STATIC_IMAGE_URI = Am.getInstance().resolvePath("static/image/")
});
/**
* Set whether lines linking tree children shall be drawn on the tree.
*/
qx.OO.addProperty({
name : "useTreeLines",
type : "boolean",
defaultValue : true,
getAlias : "useTreeLines"
});
/**
* Set whether the open/close button should be displayed on a branch, even if
* the branch has no children.
*/
qx.OO.addProperty({
name : "alwaysShowOpenCloseSymbol",
type : "boolean",
defaultValue : false
});
/**
* When true, exclude only the first-level tree lines, creating, effectively,
* multiple unrelated root nodes.
*/
qx.OO.addProperty({
name : "jensLautenbacherMode",
type : "boolean",
defaultValue : false
});
// overridden
qx.Proto._getCellStyle = function(cellInfo)
{
var node = cellInfo.value;
// Return the style for the div for the cell. If there's cell-specific
// style information provided, append it.
var html =
qx.ui.treevirtual.SimpleTreeDataCellRenderer.MAIN_DIV_STYLE +
(node.cellStyle ? node.cellStyle + ";" : "");
return html;
};
// overridden
qx.Proto._getContentHtml = function(cellInfo)
{
var html = "";
var node = cellInfo.value;
var imageUrl;
var _this = this;
var Stdcr = qx.ui.treevirtual.SimpleTreeDataCellRenderer;
function addImage(urlAndToolTip)
{
var html = Stdcr.IMG_START;
var Am = qx.manager.object.AliasManager;
if (qx.core.Client.getInstance().isMshtml() &&
/\.png$/i.test(urlAndToolTip.url))
{
html +=
this.STATIC_IMAGE_URI + "blank.gif" +
'" style="filter:' +
"progid:DXImageTransform.Microsoft.AlphaImageLoader(" +
" src='" + urlAndToolTip.url + "',sizingMethod='scale')";
}
else
{
var imageUrl = Am.getInstance().resolvePath(urlAndToolTip.url);
html += imageUrl + '" style="';
}
if (urlAndToolTip.imageWidth && urlAndToolTip.imageHeight)
{
html +=
';width:' + urlAndToolTip.imageWidth + 'px' +
';height:' + urlAndToolTip.imageHeight + 'px';
}
var tooltip = urlAndToolTip.tooltip;
if (tooltip != null)
{
html += Stdcr.IMG_TITLE_START + tooltip;
}
html += Stdcr.IMG_END;
return html;
}
// Generate the indentation. Obtain icon determination values once rather
// than each time through the loop.
var bUseTreeLines = this.getUseTreeLines();
var bJensLautenbacherMode = this.getJensLautenbacherMode();
var bAlwaysShowOpenCloseSymbol = this.getAlwaysShowOpenCloseSymbol();
for (var i = 0; i < node.level; i++)
{
imageUrl = this._getIndentSymbol(i,
node,
bUseTreeLines,
bAlwaysShowOpenCloseSymbol,
bJensLautenbacherMode);
html += addImage({
url : imageUrl,
imageWidth : 19,
imageHeight : 16
});
}
// Add the node's icon
imageUrl = (node.bSelected ? node.iconSelected : node.icon);
if (! imageUrl)
{
if (node.type == qx.ui.treevirtual.SimpleTreeDataModel.Type.LEAF)
{
imageUrl = (node.bSelected
? "icon/16/actions/document-open.png"
: "icon/16/actions/document-new.png");
}
else
{
imageUrl = (node.bSelected
? "icon/16/status/folder-open.png"
: "icon/16/places/folder.png");
}
}
html += addImage({ url:imageUrl });
// Add the node's label. We calculate the "left" property with: each tree
// line (indentation) icon is 19 pixels wide; the folder icon is 16 pixels
// wide, there are two pixels of padding at the left, and we want 2 pixels
// between the folder icon and the label
html +=
'<div style="position:absolute;' +
'left:' + ((node.level * 19) + 16 + 2 + 2) + ';' +
'top:0' +
(node.labelStyle ? ";" + node.labelStyle : "") +
';">' +
node.label +
'</div>';
return html;
};
qx.Proto._getIndentSymbol = function(column,
node,
bUseTreeLines,
bAlwaysShowOpenCloseSymbol,
bJensLautenbacherMode)
{
// If we're in column 0 and jensLautenbacherMode is enabled, then we treat
// this as if no tree lines were requested.
if (column == 0 && bJensLautenbacherMode)
{
bUseTreeLines = false;
}
// If we're not on the final column...
if (column < node.level - 1)
{
// then return either a line or a blank icon, depending on bUseTreeLines
return (bUseTreeLines && ! node.lastChild[column]
? this.WIDGET_TREE_URI + "line.gif"
: this.STATIC_IMAGE_URI + "blank.gif");
}
var bLastChild = node.lastChild[node.lastChild.length - 1];
// Is this a branch node?
if (node.type == qx.ui.treevirtual.SimpleTreeDataModel.Type.BRANCH &&
(node.opened === true || node.opened === false))
{
// Determine if this node has any children
var child = null;
for (child in node.children)
{
// If we find even one, we're done here.
break;
}
// Does this node have any children, or do we always want the open/close
// symbol to be shown?
if (child !== null || bAlwaysShowOpenCloseSymbol)
{
// If we're not showing tree lines...
if (! bUseTreeLines)
{
// ... then just use a plus or minus
return (node.opened
? this.WIDGET_TREE_URI + "minus.gif"
: this.WIDGET_TREE_URI + "plus.gif");
}
// Are we looking at a top-level, first child of its parent?
if (column == 0 && node.bFirstChild)
{
// Yup. If it's also a last child...
if (bLastChild)
{
// ... then use no tree lines.
return (node.opened
? this.WIDGET_TREE_URI + "only_minus.gif"
: this.WIDGET_TREE_URI + "only_plus.gif");
}
else
{
// otherwise, use descender lines but no ascender.
return (node.opened
? this.WIDGET_TREE_URI + "start_minus.gif"
: this.WIDGET_TREE_URI + "start_plus.gif");
}
}
// It's not a top-level, first child. Is this the last child of its
// parent?
if (bLastChild)
{
// Yup. Return an ending plus or minus, or blank if node.opened so
// indicates.
return (node.opened
? this.WIDGET_TREE_URI + "end_minus.gif"
: this.WIDGET_TREE_URI + "end_plus.gif");
}
// Otherwise, return a crossing plus or minus, or a blank if
// node.opened so indicates.
return (node.opened
? this.WIDGET_TREE_URI + "cross_minus.gif"
: this.WIDGET_TREE_URI + "cross_plus.gif");
}
}
// This node does not have any children. Return an end or cross, if we're
// using tree lines.
if (bUseTreeLines)
{
// If this is a last child, return and ending line; otherwise cross.
return (bLastChild
? this.WIDGET_TREE_URI + "end.gif"
: this.WIDGET_TREE_URI + "cross.gif");
}
return this.STATIC_IMAGE_URI + "blank.gif";
}
// overridden
qx.Proto._createCellStyle_array_join = function(cellInfo, htmlArr)
{
throw new Error("USE_ARRAY_JOIN not supported");
};
qx.Proto._createContentHtml_array_join = function(cellInfo, htmlArr)
{
throw new Error("USE_ARRAY_JOIN not supported");
};
qx.Class.MAIN_DIV_STYLE =
';overflow:hidden;white-space:nowrap;border-right:1px solid #eeeeee;' +
'padding-left:2px;padding-right:2px;cursor:default' +
(qx.core.Client.getInstance().isMshtml() ? '' : ';-moz-user-select:none;');
qx.Class.IMG_START = '<img src="';
qx.Class.IMG_END = '"/>';
qx.Class.IMG_TITLE_START = '" title="';
|