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
|
<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>Demonstrate use of multiple columns in a tree.</p>
</div>
<script type="text/javascript">
qx.core.Init.getInstance().defineMain(function()
{
// tree
var tree = new qx.ui.treevirtual.TreeVirtual([ "Tree", "Permissions" ]);
with (tree)
{
set({
left : 10,
top : 30,
width : 506,
bottom : 30,
border : qx.renderer.border.BorderPresets.getInstance().thinInset
});
setAlwaysShowOpenCloseSymbol(true);
setColumnWidth(0, 400);
setColumnWidth(1, 100);
};
tree.addToDocument();
// tree data model
var dataModel = tree.getDataModel();
var te1 = dataModel.addBranch(null, "Desktop", true);
dataModel.setState(te1,
{
labelStyle :
"background-color: red; " +
"color: white;" +
"font-weight: bold;"
});
var te1_1;
dataModel.addBranch(te1, "Files", true);
te1_1 = dataModel.addBranch(te1, "Workspace", true);
te = dataModel.addLeaf(te1_1, "Windows (C:)");
dataModel.setColumnData(te, 1, "-rwxr-xr-x");
te = dataModel.addLeaf(te1_1, "Documents (D:)");
dataModel.setColumnData(te, 1, "-rwxr-xr-x");
dataModel.addBranch(te1, "Network", true);
te = dataModel.addBranch(te1, "Trash", true);
dataModel.setState(te,
{
cellStyle : "background-color: cyan;"
});
var te2 = dataModel.addBranch(null, "Inbox", true);
te = dataModel.addBranch(te2, "Spam", false);
for (var i = 1; i < 3000; i++)
{
dataModel.addLeaf(te, "Spam Message #" + i);
}
dataModel.addBranch(te2, "Sent", false);
dataModel.addBranch(te2, "Trash", false);
dataModel.addBranch(te2, "Data", false);
dataModel.addBranch(te2, "Edit", false);
dataModel.setData();
var commandFrame = new qx.ui.groupbox.GroupBox("Control");
commandFrame.set({ top: 48, left: 520, width: "auto", height: "auto" });
commandFrame.addToDocument();
var o = new qx.ui.basic.Atom("Current Selection: ");
o.set({ left: 0, top: 6 });
commandFrame.add(o);
o = new qx.ui.form.TextField();
o.set({ left: 4, right: 0, top: 20, readOnly: true });
commandFrame.add(o);
tree.addEventListener(
"changeSelection",
function(e)
{
// Get the list of selected nodes. We're in single-selection mode, so
// there will be only one of them.
var nodes = e.getData();
this.setValue(tree.getHierarchy(nodes[0].nodeId).join('/'));
buttonRemove.setEnabled(true);
},
o);
var buttonRemove = new qx.ui.form.Button("Remove");
buttonRemove.set({ top: 42, left: 0, enabled: false });
commandFrame.add(buttonRemove);
buttonRemove.addEventListener(
"execute",
function(e)
{
selectedNodes = tree.getSelectedNodes();
for (var i = 0; i < selectedNodes.length; i++)
{
dataModel.prune(selectedNodes[i].nodeId);
dataModel.setData();
}
});
o = new qx.ui.form.CheckBox("Use tree lines?");
o.set({ top: 80, left: 0, checked: true });
commandFrame.add(o);
o.addEventListener("changeChecked",
function(e)
{
tree.setUseTreeLines(e.getData());
});
o = new qx.ui.form.CheckBox("Jens Lautenbacher mode?");
o.set({ top: 100, left: 0, checked: false });
commandFrame.add(o);
o.addEventListener("changeChecked",
function(e)
{
tree.setJensLautenbacherMode(e.getData());
});
o = new qx.ui.form.CheckBox("Always show open/close symbol?");
o.set({ top: 120, left: 0, checked: true });
commandFrame.add(o);
o.addEventListener("changeChecked",
function(e)
{
tree.setAlwaysShowOpenCloseSymbol(e.getData());
});
o = new qx.ui.form.CheckBox("Remove open/close if found empty?");
o.set({ top: 140, left: 0, checked: true });
commandFrame.add(o);
tree.addEventListener("treeOpenWhileEmpty",
function(e)
{
if (this.getChecked())
{
var node = e.getData();
tree.setState(node.nodeId, { opened : null });
}
},
o);
o = new qx.ui.form.CheckBox("Open/close click selects row?");
o.set({ top: 160, left: 0, checked: false });
commandFrame.add(o);
o.addEventListener("changeChecked",
function(e)
{
tree.setOpenCloseClickSelectsRow(e.getData());
});
});
</script>
</body>
</html>
|