forked from jbaron/qx-typed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.ts
181 lines (148 loc) · 4.84 KB
/
application.ts
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
/**
* Create a button
*/
function createButton(): qx.ui.form.Button {
var button1 = new qx.ui.form.Button("First Button", "icon/22/apps/internet-web-browser.png");
// Add an event listener
button1.addListener("execute", function(e) {
alert("Hello World!");
});
return button1;
}
/**
* Create a sample form.
*/
function createForm(): qx.ui.core.Widget {
var form = new qx.ui.form.Form();
// add the first headline
form.addGroupHeader("Registration");
// add usernamne
var userName = new qx.ui.form.TextField();
userName.setRequired(true);
form.add(userName, "Name");
// add password
var password = new qx.ui.form.PasswordField();
password.setRequired(true);
form.add(password, "Password");
// add a save checkbox
form.add(new qx.ui.form.CheckBox(), "Save?");
// add the second header
form.addGroupHeader("Personal Information");
// add some additional widgets
form.add(new qx.ui.form.Spinner(), "Age");
form.add(new qx.ui.form.TextField(), "Country");
var genderBox = new qx.ui.form.SelectBox();
genderBox.add(new qx.ui.form.ListItem("male"));
genderBox.add(new qx.ui.form.ListItem("female"));
form.add(genderBox, "Gender");
form.add(new qx.ui.form.TextArea(), "Bio");
// send button with validation
var sendButton = new qx.ui.form.Button("Send");
sendButton.addListener("execute", function() {
if (form.validate()) {
alert("send...");
}
}, this);
form.addButton(sendButton);
// reset button
var resetButton = new qx.ui.form.Button("Reset");
resetButton.addListener("execute", function() {
form.reset();
}, this);
form.addButton(resetButton);
// create the form and return it
return new qx.ui.form.renderer.Single(form);
}
/**
* Create some reandom rows for the table example
*/
function createRandomRows(rowCount:number) {
var rowData = [];
var now = new Date().getTime();
var dateRange = 400 * 24 * 60 * 60 * 1000; // 400 days
var nextId = 0;
for (var row = 0; row < rowCount; row++) {
var date = new Date(now + Math.random() * dateRange - dateRange / 2);
rowData.push([nextId++, Math.random() * 10000, date, (Math.random() > 0.5)]);
}
return rowData;
}
/**
* Create an example using the table widget showing some basic
* funcitonality
*/
function createTable(): qx.ui.core.Widget {
// table model
var tableModel = new qx.ui.table.model.Simple();
tableModel.setColumns(["Billing-ID", "Amount", "Date", "Paid"]);
tableModel.setData(createRandomRows(100));
// make second column editable
tableModel.setColumnEditable(1, true);
// table
var table = new qx.ui.table.Table(tableModel);
table.set({
decorator: null
});
var tcm = table.getTableColumnModel();
// Display a checkbox in column 3
tcm.setDataCellRenderer(3, new qx.ui.table.cellrenderer.Boolean());
return table;
}
/**
* Create a sample tree
*/
function createTree(): qx.ui.core.Widget {
// create the tree
var tree = new qx.ui.tree.Tree();
tree.set({ width: 150, height: 300 });
// create and set the tree root
var root = new qx.ui.tree.TreeFolder("Desktop");
tree.setRoot(root);
// create some subitems
var f1 = new qx.ui.tree.TreeFolder("Logos");
var f2 = new qx.ui.tree.TreeFolder("TODO");
var f3 = new qx.ui.tree.TreeFile("jsmag_js9.pdf");
f3.setIcon("icon/22/mimetypes/text-html.png");
root.add(f1, f2, f3);
// create a third layer
var f11 = new qx.ui.tree.TreeFile("Logo1.png");
f11.setIcon("icon/22/mimetypes/media-image.png");
var f12 = new qx.ui.tree.TreeFile("Logo2.png");
f12.setIcon("icon/22/mimetypes/media-image.png");
var f13 = new qx.ui.tree.TreeFile("Logo3.png");
f13.setIcon("icon/22/mimetypes/media-image.png");
f1.add(f11, f12, f13);
// open the folders
root.setOpen(true);
f1.setOpen(true);
return tree;
}
/**
* Simple class extension example
*/
class MyPage extends qx.ui.tabview.Page {
constructor(name) {
super(name);
this.setLayout(new qx.ui.layout.Flow());
this.setShowCloseButton(true);
}
}
/**
* This is the main function that will be called from the Qooxdoo application
* to start everything.
*/
function qooxdooMain(app: qx.application.Standalone) {
var demo: Function[] = [createButton, createTable, createTree, createForm];
// Document is the application root container
var doc = <qx.ui.container.Composite>app.getRoot();
// Lets create the container for the tabs
var t = new qx.ui.tabview.TabView();
//And now lets add some tabs
for (var x = 0; x < demo.length; x++) {
var p = new MyPage((<any>demo[x]).name);
p.add(demo[x]());
t.add(p);
}
doc.add(t,{ edge: 0});
}
qx.registry.registerMainMethod(qooxdooMain);