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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>qooxdoo » Demo</title>
<link type="text/css" rel="stylesheet" href="../../resource/css/layout.css"/>
<!--[if IE]>
<link
type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
<![endif]-->
<script type="text/javascript" src="../../script/qx.js"></script>
</head>
<body>
<script type="text/javascript" src="../../script/layout.js"></script>
<div id="demoDescription">
<p>
A simple LDB browser.
</div>
<script type="text/javascript">
/*
Root is as found by:
source/bin/ldbsearch -H /usr/local/samba/private/sam.ldb -b '' \
-s base defaultNamingContext
Schema page:
source/bin/ldbsearch -H /usr/local/samba/private/sam.ldb -b '' \
-s base subschemaSubentry
source/bin/ldbsearch -H /usr/local/samba/private/sam.ldb -b \
'CN=Aggregate,CN=Schema,CN=Configuration,DC=workgroup,DC=example,DC=com' \
-s base objectClasses attributeTypes matchingRules ldapSyntaxes
*/
function setAppearances()
{
// Modify the default appearance of a ComboBox for use in Search tab:
// use most of the available width.
//
// If we had multiple uses, we'd create a new appearance. Since we don't,
// we can just modify this default appearance.
//
// See http://qooxdoo.org/documentation/user_manual/appearance for an
// explanation of what's going on here. The missing significant point in
// the discussion is that in the current qooxdoo appearance
// implementation, it's not possible to override a specific widget's
// appearance with explicit settings just for that widget (stupid!). I
// expect that to change in a future version.
var appMgr = qx.manager.object.AppearanceManager.getInstance();
var theme = appMgr.getAppearanceTheme();
var appearance = theme._appearances["combo-box"];
if (! appearance)
{
return;
}
var oldInitial = appearance.initial;
appearance.initial = function(vTheme)
{
var res = oldInitial ? oldInitial.apply(this, arguments) : {};
res.width = "90%";
return res;
}
}
function setupMenu(clientDocument)
{
var c1 = new qx.client.Command();
c1.addEventListener("execute", function(e) {
this.debug("Execute: " + e.getData().getLabel());
});
// Create the File menu pulldown
var fileMenu_ = new qx.ui.menu.Menu();
// Create items for within File menu
var fileMenu_NewTab_ = new qx.ui.menu.Menu();
{
var fileMenu_NewTab_Search =
new qx.ui.menu.MenuButton("Search", null, c1);
var fileMenu_NewTab_Browse =
new qx.ui.menu.MenuButton("Browse", null, c1);
var fileMenu_NewTab_Schema =
new qx.ui.menu.MenuButton("Schema", null, c1);
fileMenu_NewTab_.add(fileMenu_NewTab_Search,
fileMenu_NewTab_Browse,
fileMenu_NewTab_Schema);
}
var fileMenu_NewTab =
new qx.ui.menu.MenuButton("New tab", null, null, fileMenu_NewTab_);
var fileMenu_Preferences =
new qx.ui.menu.MenuButton("Preferences", null, c1);
var fileMenu_CloseTab =
new qx.ui.menu.MenuButton("Close Tab", null, c1);
var fileMenu_ShowMessageLog =
new qx.ui.menu.MenuButton("Show Message Log", null, c1);
var fileMenu_Quit =
new qx.ui.menu.MenuButton("Quit", null, c1);
// Add the menu items to the menu
fileMenu_.add(fileMenu_NewTab,
fileMenu_Preferences,
fileMenu_CloseTab,
fileMenu_ShowMessageLog,
fileMenu_Quit);
// Create the Filter menu pulldown
var filterMenu_ = new qx.ui.menu.Menu();
// Create items for within Filter menu
var filterMenu_NewFilter =
new qx.ui.menu.MenuButton("New Filter", null, c1);
var filterMenu_EditFilters =
new qx.ui.menu.MenuButton("Edit Filters", null, c1);
var filterMenu_Separator =
new qx.ui.menu.MenuSeparator();
// Add the menu items to the menu
filterMenu_.add(filterMenu_NewFilter,
filterMenu_EditFilters,
filterMenu_Separator);
// Add the menu items to the document
clientDocument.add(fileMenu_,
fileMenu_NewTab_,
filterMenu_);
// Create and position the toolbar which will act as our menubar
var toolBar = new qx.ui.toolbar.ToolBar();
toolBar.set(
{
top: 28,
left: 20,
right: 300
});
// Create the toolbar menu items and associate them with the pulldowns
var fileMenuButton =
new qx.ui.toolbar.ToolBarMenuButton("File", fileMenu_);
var filterMenuButton =
new qx.ui.toolbar.ToolBarMenuButton("Filters", filterMenu_);
// Add the toolbar items to the toolbar
toolBar.add(fileMenuButton,
filterMenuButton);
// Add the toolbar to the document
clientDocument.add(toolBar);
// Give 'em what we built!
return toolBar;
}
function setupTabs(clientDocument)
{
// Create and position the tabview
var tabView_ = new qx.ui.pageview.tabview.TabView;
tabView_.set(
{
top: 60,
left: 20,
right: 300,
bottom: 30
});
// Create each of the tabs
var tabView_Search =
new qx.ui.pageview.tabview.TabViewButton("Search");
var tabView_Browse =
new qx.ui.pageview.tabview.TabViewButton("Browse");
var tabView_Schema =
new qx.ui.pageview.tabview.TabViewButton("Schema");
// Specify the initially-selected tab
tabView_Search.setChecked(true);
// Add each of the tabs to the tabview
tabView_.getBar().add(tabView_Search,
tabView_Browse,
tabView_Schema);
// Create the pages to display when each tab is selected
var tabViewPage_Search =
new qx.ui.pageview.tabview.TabViewPage(tabView_Search);
var tabViewPage_Browse =
new qx.ui.pageview.tabview.TabViewPage(tabView_Browse);
var tabViewPage_Schema =
new qx.ui.pageview.tabview.TabViewPage(tabView_Schema);
// Build the search page
var searchResultsTable = buildPageSearch(tabViewPage_Search);
// Provide access to the search results table
tabView_.searchResultTable = searchResultsTable;
// Build the browse page
buildPageBrowse(tabViewPage_Browse);
// Build the schema page
buildPageSchema(tabViewPage_Schema);
// Add the pages to the tabview
tabView_.getPane().add(tabViewPage_Search,
tabViewPage_Browse,
tabViewPage_Schema);
// Add the tabview to the document
clientDocument.add(tabView_);
// Give 'em what we built!
return tabView_;
}
function buildPageSearch(page)
{
// We need a horizontal layout for the combox box and "Find" button
var layout = new qx.ui.layout.HorizontalBoxLayout();
layout.setWidth("100%");
// Create a combo box for entry of the search expression
var search = new qx.ui.form.ComboBox();
search.getField().setWidth("100%");
search.setEditable(true);
// Add the combo box to the horizontal layout
layout.add(search);
// Right-justify the 'Find' button
var spacer = new qx.ui.basic.HorizontalSpacer;
layout.add(spacer);
// Create the 'Find' button
var find = new qx.ui.form.Button('Find');
// We'll be setting url and service upon execute; no need to do it now.
var rpc = new qx.io.remote.Rpc();
rpc.setTimeout(10000);
var mycall = null;
find.addEventListener("execute", function()
{
// Set the URL and Service
rpc.setUrl("/services/");
rpc.setServiceName("samba.ldb");
rpc.setCrossDomain(false);
find.setEnabled(false);
// abort.setEnabled(true);
mycall = rpc.callAsync(function(result, ex, id)
{
mycall = null;
if (ex == null)
{
var rowData = [];
for (var i = 0; i < result.length; i++)
{
var o = result[i];
if (typeof(o) != "object")
{
alert("Found unexpected result, type " +
typeof(o) +
", " +
o +
"\n");
continue;
}
for (var field in o)
{
// skip dn and distinguishedName fields;
// they're shown in each row anyway.
if (field == "dn" || field == "distinguishedName")
{
continue;
}
rowData.push( [
o["dn"],
field,
o[field]
] );
}
// Tell the table to use the new data
tableModel.setData(rowData);
}
}
else
{
alert("Async(" + id + ") exception: " + ex);
}
find.setEnabled(true);
// abort.setEnabled(false);
},
"search", // method
db_handle, // database handle
search.getValue(), // search expression
"", // baseDN
"default", // scope
[ "*" ]); // attributes
});
// Add the button to horizontal layout
layout.add(find);
// Add the horizontal box layout to the page
page.add(layout);
// Create a simple table model
var tableModel = new qx.ui.table.SimpleTableModel();
tableModel.setColumns([ "Distinguished Name", "Attribute", "Value" ]);
tableModel.setColumnEditable(0, false);
tableModel.setColumnEditable(1, false);
tableModel.setColumnEditable(2, false);
// Create a table
var table = new qx.ui.table.Table(tableModel);
with (table)
{
set({
top: 40,
left: 0,
right: 0,
bottom: 10,
statusBarVisible: false,
columnVisibilityButtonVisible: false
});
setColumnWidth(0, 300);
setColumnWidth(1, 180);
setColumnWidth(2, 240);
setMetaColumnCounts([ 1, -1 ]); // h-scroll attribute and value together
};
page.add(table);
return table;
}
function buildPageBrowse(page)
{
// Create a vertical splitpane for tree (top) and table (bottom)
var splitpane = new qx.ui.splitpane.VerticalSplitPane("1*", "2*");
splitpane.setEdge(0);
// Create a tree row structure for the tree root
var trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Root");
// Create the tree and set its characteristics
var tree = new qx.ui.treefullcontrol.Tree(trs);
tree.set(
{
backgroundColor: 255,
border: qx.renderer.border.BorderPresets.getInstance().inset,
overflow: "auto",
height: null,
top: 10,
left: 0,
right: 0,
bottom: 10
});
// Add the tree to the page.
splitpane.addTop(tree);
// Create a simple table model
var tableModel = new qx.ui.table.SimpleTableModel();
tableModel.setColumns([ "Attribute", "Value" ]);
// Add some garbage data to it
var attributeNames =
[
[ "Nickname" ],
[ "Hostname" ],
[ "Port" ],
[ "Connection caching" ],
[ "TLS" ],
[ "Client-side caching" ],
[ "Connections so far" ],
[ "LDAP protocol version" ],
[ "Vendor Name" ],
[ "Vendor Version" ],
[ "Support LDAP Version" ],
[ "Supported SASL Mechanisms" ],
[ "Junk 1" ],
[ "Junk 2" ],
[ "Junk 3" ]
];
var rowData = [];
for (var row = 0; row < attributeNames.length; row++)
{
rowData.push([ attributeNames[row], "" + (Math.random() * 10000) ]);
}
tableModel.setData(rowData);
tableModel.setColumnEditable(0, false);
tableModel.setColumnEditable(1, true);
// Create a table
var table = new qx.ui.table.Table(tableModel);
with (table) {
set({
top: 10,
left: 0,
right: 0,
bottom: 10,
statusBarVisible: false,
columnVisibilityButtonVisible: false
});
setColumnWidth(0, 200);
setColumnWidth(1, 440);
setMetaColumnCounts([1, -1]);
};
splitpane.addBottom(table);
// Add the first splitpane to the page
page.add(splitpane);
}
function buildPageSchema(page)
{
// Create a vertical splitpane for tree (top) and remainder (bottom)
var splitpane1 = new qx.ui.splitpane.VerticalSplitPane("1*", "2*");
splitpane1.setEdge(0);
// Create a tree row structure for the tree root
var trs = qx.ui.treefullcontrol.TreeRowStructure.getInstance().standard("Root");
// Create the tree and set its characteristics
var tree = new qx.ui.treefullcontrol.Tree(trs);
tree.set(
{
backgroundColor: 255,
border: qx.renderer.border.BorderPresets.getInstance().inset,
overflow: "auto",
height: null,
top: 10,
left: 0,
right: 0,
bottom: 10
});
// Add the tree to the page.
splitpane1.addTop(tree);
// Create another vertical splitpane for table (top) and required/allowed
// attributes lists (bottom)
var splitpane2 = new qx.ui.splitpane.VerticalSplitPane("1*", "2*");
splitpane2.setEdge(0);
// Create a simple table model
var tableModel = new qx.ui.table.SimpleTableModel();
tableModel.setColumns([ "Attribute", "Value" ]);
// Add some garbage data to it
var attributeNames =
[
[ "Nickname" ],
[ "Hostname" ],
[ "Port" ],
[ "Connection caching" ],
[ "TLS" ],
[ "Client-side caching" ],
[ "Connections so far" ],
[ "LDAP protocol version" ],
[ "Vendor Name" ],
[ "Vendor Version" ],
[ "Support LDAP Version" ],
[ "Supported SASL Mechanisms" ],
[ "Junk 1" ],
[ "Junk 2" ],
[ "Junk 3" ]
];
var rowData = [];
for (var row = 0; row < attributeNames.length; row++)
{
rowData.push([ attributeNames[row], "" + (Math.random() * 10000) ]);
}
tableModel.setData(rowData);
tableModel.setColumnEditable(0, false);
tableModel.setColumnEditable(1, true);
// Create a table
var table = new qx.ui.table.Table(tableModel);
with (table) {
set({
top: 10,
left: 0,
right: 0,
bottom: 10,
statusBarVisible: false,
columnVisibilityButtonVisible: false
});
setColumnWidth(0, 200);
setColumnWidth(1, 440);
setMetaColumnCounts([1, -1]);
};
splitpane2.addTop(table);
// Create a horizontal splitpane for required attributes (left) and
// allowed attributes (right)
var splitpane3 = new qx.ui.splitpane.HorizontalSplitPane("1*", "1*");
splitpane3.setEdge(0);
// Create a vertical box layout for a label and list
var layout = new qx.ui.layout.VerticalBoxLayout();
layout.setWidth("100%");
layout.setHeight("100%");
// Create a label for the list of required attributes
var label = new qx.ui.basic.Atom("Required Attributes");
// Add the label to the vertical box layout
layout.add(label);
// Create a list for required attributes
var requiredAttributes = new qx.ui.form.List();
requiredAttributes.setWidth("100%");
requiredAttributes.set(
{
top: 0,
left: 0,
width: "98%",
height: "90%",
overflow : "scrollY"
});
var item;
for( var i=1; i<=35; i++ )
{
item = new qx.ui.form.ListItem("Item No " + i);
!(i % 9) && (item.setEnabled(false));
requiredAttributes.add(item);
};
// Add the required attributes to the layout
layout.add(requiredAttributes);
// Add the vertical box layout to the left of the third splitpane
splitpane3.addLeft(layout);
// Create a vertical box layout for a label and list
layout = new qx.ui.layout.VerticalBoxLayout();
layout.set(
{
width: "100%",
height: "100%"
});
// Create a label for the list of allowed attributes
var label = new qx.ui.basic.Atom("Allowed Attributes");
label.setLeft(10);
// Add the label to the vertical box layout
layout.add(label);
// Create a list for allowed attributes
var allowedAttributes = new qx.ui.form.List();
allowedAttributes.setWidth("100%");
allowedAttributes.set(
{
top: 0,
left: 10,
width: "98%",
height: "90%",
overflow : "scrollY"
});
var item;
for( var i=1; i<=35; i++ )
{
item = new qx.ui.form.ListItem("Item No " + i);
!(i % 9) && (item.setEnabled(false));
allowedAttributes.add(item);
};
// Add the allowed attributes to the layout
layout.add(allowedAttributes);
// Add the vertical box layout to the left of the third splitpane
splitpane3.addRight(layout);
// Add the third splitpane to the bottom of the second splitpane
splitpane2.addBottom(splitpane3);
// Add the second splitpane to the bottom of the first splitpane
splitpane1.addBottom(splitpane2);
// Add the first splitpane to the page
page.add(splitpane1);
}
qx.core.Init.getInstance().defineMain(
function()
{
// Enable JSON-RPC debugging
qx.Settings.setCustomOfClass("qx.io.Json", "enableDebug", true);
if (false)
{
// We'd like all table columns to do "live resize". Unfortunately,
// it's too slow. Maybe someone wants to work on it...
var constructor = qx.OO.classes["qx.ui.table.TablePaneScroller"];
qx.Proto = constructor.prototype;
qx.OO.changeProperty(
{
name : "liveResize",
type : qx.constant.Type.BOOLEAN,
defaultValue : true
});
}
// Set appearances for this application
setAppearances();
// Get the client document
var clientDocument = qx.ui.core.ClientDocument.getInstance();
// Create the toolbar and attach it to the client document
var toolBar = setupMenu(clientDocument);
// Create the tabs and their windows, and attach to client document
var tabView = setupTabs(clientDocument);
// Open a database connection. Uses the dangerous sync request.
var rpc = new qx.io.remote.Rpc();
rpc.setUrl("/services/");
rpc.setServiceName("samba.ldb");
rpc.setCrossDomain(false);
try
{
// db_handle is global!!! no 'var' is intentional.
db_handle = rpc.callSync("connect",
"/usr/local/samba/private/sam.ldb");
}
catch (ex)
{
alert("Sync exception: " + ex);
}
});
/*
* Local Variables:
* mode: c
* End:
*/
</script>
</body>
</html>
|