summaryrefslogtreecommitdiff
path: root/webapps/swat/source
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2007-01-20 18:38:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:43:53 -0500
commit00f77d9fafe1bc81c1e4540bdb58f45e90704756 (patch)
tree753db9650ff083c5e44350b6874ad17faecb9631 /webapps/swat/source
parentbf86c2744052aa34fe9140ade368570a995b98bb (diff)
downloadsamba-00f77d9fafe1bc81c1e4540bdb58f45e90704756.tar.gz
samba-00f77d9fafe1bc81c1e4540bdb58f45e90704756.tar.bz2
samba-00f77d9fafe1bc81c1e4540bdb58f45e90704756.zip
r20924: Change the way searches are performed, also change a bit the layouts
Derrel I am experimenting, let me know if you see anything really disgusting :) (This used to be commit 702048f618d625c53201cd16a161b706435c44c2)
Diffstat (limited to 'webapps/swat/source')
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js16
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/Gui.js272
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/ldifViewer.js84
3 files changed, 182 insertions, 190 deletions
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js b/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
index d24f156e4f..9843fa6ee2 100644
--- a/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
+++ b/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
@@ -29,7 +29,7 @@ qx.Proto.buildFsm = function(module)
* - if returning from RPC, display the result
*
* Transition on:
- * "execute" on find button
+ * "execute" on search button
* "treeopenwhileempty" on tree
* "changeselection" on tree
*/
@@ -78,11 +78,11 @@ qx.Proto.buildFsm = function(module)
"events" :
{
- // If the find button is activated, issue a find request
+ // If the search button is activated, issue a seacrh request
"execute" :
{
- "find" :
- "Transition_Idle_to_AwaitRpcResult_via_find"
+ "search" :
+ "Transition_Idle_to_AwaitRpcResult_via_search"
},
// If a previously unexpanded tree node is expanded, issue a request
@@ -112,13 +112,13 @@ qx.Proto.buildFsm = function(module)
/*
* Transition: Idle to AwaitRpcResult
*
- * Cause: "execute" on find button
+ * Cause: "execute" on search button
*
* Action:
* Issue a search request
*/
var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_find",
+ "Transition_Idle_to_AwaitRpcResult_via_search",
{
"nextState" :
"State_AwaitRpcResult",
@@ -139,7 +139,7 @@ qx.Proto.buildFsm = function(module)
var baseDN = fsm.getObject("baseDN").getValue();
// Retrieve the selected scope
- var scope = fsm.getObject("scope").getSelected().getValue();
+ var scope = fsm.getObject("scope").getValue();
// We want all attributes
var attributes = [ "*" ];
@@ -158,7 +158,7 @@ qx.Proto.buildFsm = function(module)
// When we get the result, we'll need to know what type of request
// we made.
- request.setUserData("requestType", "find");
+ request.setUserData("requestType", "search");
}
});
state.addTransition(trans);
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js b/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
index 38d10768ee..fcdbe1c058 100644
--- a/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
+++ b/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
@@ -73,31 +73,31 @@ qx.Proto.buildGui = function(module)
});
// Create each of the tabs
- var tabView_Search =
- new qx.ui.pageview.tabview.Button("Search");
var tabView_Browse =
new qx.ui.pageview.tabview.Button("Browse");
+ var tabView_Search =
+ new qx.ui.pageview.tabview.Button("Search");
// Specify the initially-selected tab
- tabView_Search.setChecked(true);
+ tabView_Browse.setChecked(true);
// Add each of the tabs to the tabview
- tabView_.getBar().add(tabView_Search, tabView_Browse);
+ tabView_.getBar().add(tabView_Browse, tabView_Search);
// Create the pages to display when each tab is selected
- var tabViewPage_Search =
- new qx.ui.pageview.tabview.Page(tabView_Search);
var tabViewPage_Browse =
new qx.ui.pageview.tabview.Page(tabView_Browse);
-
- // Build the search page
- this._buildPageSearch(module, tabViewPage_Search);
+ var tabViewPage_Search =
+ new qx.ui.pageview.tabview.Page(tabView_Search);
// Build the browse page
this._buildPageBrowse(module, tabViewPage_Browse);
+ // Build the search page
+ this._buildPageSearch(module, tabViewPage_Search);
+
// Add the pages to the tabview
- tabView_.getPane().add(tabViewPage_Search, tabViewPage_Browse);
+ tabView_.getPane().add(tabViewPage_Browse, tabViewPage_Search);
// Add the tabview to our canvas
module.canvas.add(tabView_);
@@ -132,8 +132,8 @@ qx.Proto.displayData = function(module, rpcRequest)
// Dispatch to the appropriate handler, depending on the request type
switch(requestType)
{
- case "find":
- this._displayFindResults(module, rpcRequest);
+ case "search":
+ this._displaySearchResults(module, rpcRequest);
break;
case "tree_open":
@@ -199,147 +199,105 @@ qx.Proto._buildPageSearch = function(module, page)
// We need a vertical box layout for the various input fields
var vlayout = new qx.ui.layout.VerticalBoxLayout();
- vlayout.setWidth("100%");
-
- // We need a horizontal box layout for the search combo box and its label
- var hlayout = new qx.ui.layout.HorizontalBoxLayout();
- hlayout.setWidth("100%");
- hlayout.setHeight(25);
+ vlayout.set({
+ overflow: "hidden",
+ height: 120,
+ top: 10,
+ left: 0,
+ right: 0,
+ bottom: 10
+ });
// Create a label for the list of required attributes
- var label = new qx.ui.basic.Atom("Search Expression:");
- label.setWidth(100);
- label.setHorizontalChildrenAlign("right");
+ var label = new qx.ui.basic.Atom("Search Expression");
+ label.setHorizontalChildrenAlign("left");
// Add the label to the horizontal layout
- hlayout.add(label);
+ vlayout.add(label);
// Create a combo box for entry of the search expression
- var search = new qx.ui.form.ComboBox();
- search.getField().setWidth("100%");
- search.setEditable(true);
- fsm.addObject("searchExpr", search);
+ var filter = new qx.ui.form.TextField();
+ filter.set({ width:300 });
+ fsm.addObject("searchExpr", filter);
// Add the combo box to the horizontal layout
- hlayout.add(search);
-
- // Add the horizontal layout to the vertical layout
- vlayout.add(hlayout);
-
- // We need a horizontal box layout for the base combo box and its label
- hlayout = new qx.ui.layout.HorizontalBoxLayout();
- hlayout.setWidth("100%");
- hlayout.setHeight(25);
+ vlayout.add(filter);
// Create a label for the list of required attributes
- var label = new qx.ui.basic.Atom("Base:");
- label.setWidth(100);
- label.setHorizontalChildrenAlign("right");
+ var label = new qx.ui.basic.Atom("Base");
+ label.setHorizontalChildrenAlign("left");
// Add the label to the horizontal layout
- hlayout.add(label);
+ vlayout.add(label);
// Create a combo box for entry of the search expression
- var base = new qx.ui.form.ComboBox();
- base.getField().setWidth("100%");
- base.setEditable(true);
+ var base = new qx.ui.form.TextField();
+ base.set({ width:300 });
fsm.addObject("baseDN", base);
// Add the combo box to the horizontal layout
- hlayout.add(base);
-
- // Add the horizontal layout to the vertical layout
- vlayout.add(hlayout);
-
- // We need a horizontal box layout for scope radio buttons
- hlayout = new qx.ui.layout.HorizontalBoxLayout();
- hlayout.setWidth("100%");
- hlayout.setHeight(25);
+ vlayout.add(base);
// Create a label for the list of required attributes
- var label = new qx.ui.basic.Atom("Scope:");
+ var label = new qx.ui.basic.Atom("Scope");
label.setWidth(100);
- label.setHorizontalChildrenAlign("right");
+ label.setHorizontalChildrenAlign("left");
- // Add the label to the horizontal layout
- hlayout.add(label);
-
- // Create a radio button for each scope
- var rbDefault = new qx.ui.form.RadioButton("Default", "default");
- var rbBase = new qx.ui.form.RadioButton("Base", "base");
- var rbOne = new qx.ui.form.RadioButton("One Level", "one");
- var rbSubtree = new qx.ui.form.RadioButton("Subtree", "subtree");
-
- // Use a default of "Default"
- rbBase.setChecked(true);
-
- // Add the radio buttons to the horizontal layout
- hlayout.add(rbDefault, rbBase, rbOne, rbSubtree);
-
- // Group the radio buttons so only one in the group may be selected
- var scope = new qx.manager.selection.RadioManager("scope",
- [
- rbDefault,
- rbBase,
- rbOne,
- rbSubtree
- ]);
- fsm.addObject("scope", scope);
-
- // Right-justify the 'Find' button
- var spacer = new qx.ui.basic.HorizontalSpacer;
- hlayout.add(spacer);
+ // Add the label to the scope vertical layout
+ vlayout.add(label);
+
+ // Use a horizontal box layout to keep the search button aligned
+ var hlayout = new qx.ui.layout.HorizontalBoxLayout();
+ hlayout.setWidth(300);
+ hlayout.setHeight(30);
+
+ var cbScope = new qx.ui.form.ComboBoxEx();
+ cbScope.setSelection([ ["subtree", "Subtree"], ["one", "One Level"], ["base", "Base"]]);
+ cbScope.setSelectedIndex(0);
+
+ fsm.addObject("scope", cbScope);
- // Create the 'Find' button
- var find = new qx.ui.form.Button('Find');
- find.setWidth(100);
- find.addEventListener("execute", fsm.eventListener, fsm);
+ hlayout.add(cbScope);
- // We'll be receiving events on the find object, so save its friendly name
- fsm.addObject("find", find, "swat.main.fsmUtils.disable_during_rpc");
+ // Add a sapcer
+ hlayout.add(new qx.ui.basic.HorizontalSpacer());
- hlayout.add(find);
+ // Create the 'Search' button
+ var search = new qx.ui.form.Button('Search');
+ search.setWidth(100);
+ search.addEventListener("execute", fsm.eventListener, fsm);
+
+ // We'll be receiving events on the search object, so save its friendly name
+ fsm.addObject("search", search, "swat.main.fsmUtils.disable_during_rpc");
+
+ // Add the search button to the vertical layout
+ hlayout.add(search);
- // Add the Find button line to the vertical layout
vlayout.add(hlayout);
- // Add the horizontal box layout to the page
+ // Add the vlayout to the page
page.add(vlayout);
- // 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);
- fsm.addObject("tableModel:search", tableModel);
+ var ldifView = new swat.module.ldbbrowse.ldifViewer();
+ ldifView.set({
+ top: 130,
+ left: 10,
+ right: 10,
+ bottom: 10
+ });
- // Create a table
- var table = new qx.ui.table.Table(tableModel);
- table.set({
- top: 80,
- left: 0,
- right: 0,
- bottom: 10,
- statusBarVisible: false,
- columnVisibilityButtonVisible: false
- });
- table.setColumnWidth(0, 300);
- table.setColumnWidth(1, 180);
- table.setColumnWidth(2, 240);
- table.setMetaColumnCounts([ 1, -1 ]);// h-scroll attribute and value together
- fsm.addObject("table:search", table);
+ fsm.addObject("ldifView", ldifView);
- page.add(table);
+ // Add the output area to the page
+ page.add(ldifView);
};
qx.Proto._buildPageBrowse = function(module, page)
{
var fsm = module.fsm;
- // Create a vertical splitpane for tree (top) and table (bottom)
- var splitpane = new qx.ui.splitpane.VerticalSplitPane("1*", "2*");
+ // Create a horizontal splitpane for tree (left) and table (right)
+ var splitpane = new qx.ui.splitpane.HorizontalSplitPane("1*", "2*");
splitpane.setEdge(0);
// Create a tree row structure for the tree root
@@ -376,7 +334,7 @@ qx.Proto._buildPageBrowse = function(module, page)
fsm.addObject("tree:manager", tree.getManager());
// Add the tree to the page.
- splitpane.addTop(tree);
+ splitpane.addLeft(tree);
// Create a simple table model
var tableModel = new qx.ui.table.SimpleTableModel();
@@ -396,26 +354,27 @@ qx.Proto._buildPageBrowse = function(module, page)
statusBarVisible: false,
columnVisibilityButtonVisible: false
});
- table.setColumnWidth(0, 200);
- table.setColumnWidth(1, 440);
+ table.setColumnWidth(0, 180);
+ table.setColumnWidth(1, 320);
table.setMetaColumnCounts([1, -1]);
fsm.addObject("table:browse", table);
// Add the table to the bottom portion of the splitpane
- splitpane.addBottom(table);
+ splitpane.addRight(table);
// Add the first splitpane to the page
page.add(splitpane);
};
-qx.Proto._displayFindResults = function(module, rpcRequest)
+qx.Proto._displaySearchResults = function(module, rpcRequest)
{
- var rowData = [];
var fsm = module.fsm;
- // Track the maximum length of the attribute values
- var maxLen = 0;
+ // Obtain the table and tableModel objects
+ var ldifView = fsm.getObject("ldifView");
+
+ ldifView.reset();
// Obtain the result object
result = rpcRequest.getUserData("result").data;
@@ -425,74 +384,22 @@ qx.Proto._displayFindResults = function(module, rpcRequest)
len = result["length"];
for (var i = 0; i < result["length"]; i++)
{
- var o = result[i];
- if (typeof(o) != "object")
+ var obj = result[i];
+ if (typeof(obj) != "object")
{
alert("Found unexpected result, type " +
- typeof(o) +
+ typeof(obj) +
", " +
- o +
+ obj +
"\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;
- }
-
- // If it's multi-valued (type is an array)...
- if (typeof(o[field]) == "object")
- {
- // ... then add each value with same name
- var a = o[field];
- for (var i = 0; i < a.length; i++)
- {
- if (a[i].length > maxLen)
- {
- maxLen = a[i].length;
- }
- rowData.push( [
- o["dn"],
- field,
- a[i]
- ] );
- }
- }
- else // single-valued
- {
- // ... add its name and value to the table
- // dataset
- if (o[field].length > maxLen)
- {
- maxLen = o[field].length;
- }
- rowData.push( [
- o["dn"],
- field,
- o[field]
- ] );
- }
- }
-
- // Obtain the table and tableModel objects
- var table = fsm.getObject("table:search");
- var tableModel = fsm.getObject("tableModel:search");
-
- // Adjust the width of the value column based on
- // maxLen
- table.setColumnWidth(2, maxLen * 7);
-
- // Tell the table to use the new data
- tableModel.setData(rowData);
+ ldifView.appendObject(obj);
}
}
else
{
- alert("No rows returned.");
+ alert("No results.");
}
};
@@ -532,6 +439,7 @@ qx.Proto._displayTreeOpenResults = function(module, rpcRequest)
}
else
{
+ //FIXME: must check for escapes, as ',' is also a valid value, not only a separator
name = child["dn"].split(",")[0];
}
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/ldifViewer.js b/webapps/swat/source/class/swat/module/ldbbrowse/ldifViewer.js
new file mode 100644
index 0000000000..61f04bd3e1
--- /dev/null
+++ b/webapps/swat/source/class/swat/module/ldbbrowse/ldifViewer.js
@@ -0,0 +1,84 @@
+/*
+ * Copyright::
+ * (C) 2006 by Simo Sorce
+ *
+ * License:
+ * GPL v2 or later
+ */
+
+/**
+ * Swat LDB Browser class graphical user interface
+ */
+
+qx.OO.defineClass("swat.module.ldbbrowse.ldifViewer", qx.ui.embed.HtmlEmbed,
+function()
+{
+ qx.ui.embed.HtmlEmbed.call(this, "");
+
+ this.setStyleProperty("whiteSpace", "nowrap");
+ this.setStyleProperty("textOverflow", "ellipsis");
+
+ this.setOverflow("auto");
+ this.setSelectable(true);
+
+ this.innerText = "";
+});
+
+//qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "???" });
+
+qx.OO.addProperty({ name : "innerText", type : "string" });
+
+swat.module.ldbbrowse.ldifViewer.empty = {
+ html : "",
+ innerText : ""
+}
+
+qx.Proto.reset = function() {
+ this.innerText = "";
+ this.setHtml("");
+}
+
+qx.Proto._update = function() {
+ this.setHtml("<pre>" + this.innerText + "</pre>");
+}
+
+qx.Proto.appendComment = function(aText) {
+ this.innerText = this.innerText + "# " + a Text + "\n\n";
+ this._update();
+}
+
+qx.Proto.appendObject = function(o) {
+
+ // First print the Object name as comment
+ // TODO: Prettify it later
+ var ldifRecord = "# " + o["dn"] + "\n";
+
+ // Now the dn
+ ldifRecord = ldifRecord + "dn: " + o["dn"] + "\n";
+
+ // Now the attributes;
+ for (var field in o)
+ {
+
+ // If it's multi-valued (type is an array)...
+ if (typeof(o[field]) == "object")
+ {
+ // ... then add each value with same name
+ var a = o[field];
+ for (var i = 0; i < a.length; i++)
+ {
+ ldifRecord = ldifRecord + field + ": " + a[i] + "\n";
+ }
+ }
+ else // single-valued
+ {
+ ldifRecord = ldifRecord + field + ": " + o[field] + "\n";
+ }
+ }
+
+ // Terminate the record with an empty line
+ ldifRecord = ldifRecord + "\n";
+
+ this.innerText = this.innerText + ldifRecord;
+ this._update();
+}