summaryrefslogtreecommitdiff
path: root/webapps/swat
diff options
context:
space:
mode:
Diffstat (limited to 'webapps/swat')
-rw-r--r--webapps/swat/Makefile104
-rw-r--r--webapps/swat/source/.ignore1
-rw-r--r--webapps/swat/source/class/swat/main/AbstractModule.js174
-rw-r--r--webapps/swat/source/class/swat/main/AbstractModuleFsm.js715
-rw-r--r--webapps/swat/source/class/swat/main/Authenticate.js153
-rw-r--r--webapps/swat/source/class/swat/main/Gui.js204
-rw-r--r--webapps/swat/source/class/swat/main/Main.js100
-rw-r--r--webapps/swat/source/class/swat/main/Module.js74
-rw-r--r--webapps/swat/source/class/swat/module/documentation/Documentation.js62
-rw-r--r--webapps/swat/source/class/swat/module/documentation/Fsm.js70
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js516
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/Gui.js750
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/LdbBrowse.js51
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js494
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/LdifViewer.js91
-rw-r--r--webapps/swat/source/class/swat/module/netmgr/Fsm.js223
-rw-r--r--webapps/swat/source/class/swat/module/netmgr/Gui.js285
-rw-r--r--webapps/swat/source/class/swat/module/netmgr/NetManager.js29
-rw-r--r--webapps/swat/source/class/swat/module/netmgr/UsersView.js106
-rw-r--r--webapps/swat/source/class/swat/module/statistics/Fsm.js230
-rw-r--r--webapps/swat/source/class/swat/module/statistics/Gui.js469
-rw-r--r--webapps/swat/source/class/swat/module/statistics/Statistics.js44
-rw-r--r--webapps/swat/source/index.html14
23 files changed, 0 insertions, 4959 deletions
diff --git a/webapps/swat/Makefile b/webapps/swat/Makefile
deleted file mode 100644
index afff0594c1..0000000000
--- a/webapps/swat/Makefile
+++ /dev/null
@@ -1,104 +0,0 @@
-################################################################################
-# REQUIRED SETTINGS
-################################################################################
-
-#
-# Path to the folder of your qooxdoo distribution.
-# Can either be
-# a) a path relative to the location of this Makefile (preferred) or
-# b) an absolute path starting at the root of your file system
-# Example: If you put the skeleton folder next to the qooxdoo SDK folder,
-# you can use the following relative path:
-# QOOXDOO_PATH = ../qooxdoo-0.6.5-sdk
-#
-QOOXDOO_PATH = ../qooxdoo-0.6.5-sdk
-
-#
-# Similar to above, but from the webserver point of view.
-# Starting point is now the application HTML file of the source folder
-# (source/index.html by default). In most cases just prepend a "../" to
-# QOOXDOO_PATH from above.
-# Example: QOOXDOO_URI = ../../qooxdoo-0.6.5-sdk
-#
-QOOXDOO_URI = ../../qooxdoo-0.6.5-sdk
-
-
-
-
-
-
-################################################################################
-# BASIC SETTINGS
-################################################################################
-
-#
-# Full namespace of your application
-#
-APPLICATION_NAMESPACE = swat
-
-#
-# Titles used in your API viewer and during the build process
-#
-APPLICATION_MAKE_TITLE = SWAT
-APPLICATION_API_TITLE = Swat
-
-#
-# Additional static files of your application (space separated list)
-#
-APPLICATION_FILES = index.html
-
-#
-# Locales to build (space separated list)
-# To set a specific locale like "en_US" the generic locale "en" has to be added as well
-# Example: APPLICATION_LOCALES = en en_US de de_DE es
-#
-APPLICATION_LOCALES =
-
-
-
-
-
-
-################################################################################
-# ADVANCED SETTINGS
-################################################################################
-
-#
-# Please take a look at $(QOOXDOO_PATH)/frontend/framework/tool/make/application.mk
-# for an overview of available options
-#
-
-include $(QOOXDOO_PATH)/frontend/framework/tool/make/apiviewer.mk
-
-APPLICATION_CLASSNAME = $(APPLICATION_NAMESPACE).main.Main
-APPLICATION_LINEBREAKS_BUILD = true
-APPLICATION_LINEBREAKS_SOURCE = true
-APPLICATION_OPTIMIZE_STRINGS = false
-APPLICATION_OPTIMIZE_VARIABLES = false
-APPLICATION_ADDITIONAL_CLASS_PATH = \
- --class-path $(APIVIEWER_PATH)/source/class \
- --class-uri $(APIVIEWER_PATH)/source/class
-APPLICATION_ADDITIONAL_RESOURCE = \
- --resource-input $(APIVIEWER_PATH)/source/resource \
- --resource-output $(APPLICATION_BUILD_PATH)/resource/apiviewer \
- --define-runtime-setting apiviewer.resourceUri:$(APPLICATION_PAGE_TO_TOPLEVEL)/resource/apiviewer
-APPLICATION_RESOURCE_FILTER = true
-APPLICATION_COMPLETE_SOURCE = false
-
-# Typically, we just need a "build"
-.PHONY: default
-
-default: build
-
-
-################################################################################
-# INCLUDE CORE
-################################################################################
-
-ifneq ($(QOOXDOO_PATH),PLEASE_DEFINE_QOOXDOO_PATH)
-include $(QOOXDOO_PATH)/frontend/framework/tool/make/targets.mk
-include $(QOOXDOO_PATH)/frontend/framework/tool/make/application.mk
-endif
-
-error:
- @echo " * Please configure QOOXDOO_PATH"
diff --git a/webapps/swat/source/.ignore b/webapps/swat/source/.ignore
deleted file mode 100644
index 84f7e31d99..0000000000
--- a/webapps/swat/source/.ignore
+++ /dev/null
@@ -1 +0,0 @@
-script
diff --git a/webapps/swat/source/class/swat/main/AbstractModule.js b/webapps/swat/source/class/swat/main/AbstractModule.js
deleted file mode 100644
index bf61a86fd8..0000000000
--- a/webapps/swat/source/class/swat/main/AbstractModule.js
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * Abstract Module class. All modules should extend this class.
- */
-qx.OO.defineClass("swat.main.AbstractModule", qx.core.Object,
-function()
-{
- qx.core.Object.call(this);
- this.debug("AbstractModule constructor");
-});
-
-
-/**
- * Build the initial finite state machine.
- *
- * In order to prevent long load times, as minimal as possible of an initial
- * FSM should be created. The FSM will receive an "appear" event when the
- * module is first selected (and each subsequent time), and the FSM can use
- * that event to build the complete FSM.
- *
- * @param module {swat.main.Module}
- * The module descriptor for the module.
- */
-qx.Proto.buildInitialFsm = function(module)
-{
- // Create a new finite state machine
- var fsm = new qx.util.fsm.FiniteStateMachine(module.name);
-
- // For this simple example application, show all debug messages.
- qx.Settings.setCustomOfClass(
- "qx.util.fsm.FiniteStateMachine",
- "debugFlags",
- (qx.util.fsm.FiniteStateMachine.DebugFlags.EVENTS |
- qx.util.fsm.FiniteStateMachine.DebugFlags.TRANSITIONS |
- qx.util.fsm.FiniteStateMachine.DebugFlags.FUNCTION_DETAIL |
- qx.util.fsm.FiniteStateMachine.DebugFlags.OBJECT_NOT_FOUND));
-
- /*
- * State: Idle
- *
- * Transition on:
- * "appear" on swat.main.canvas
- */
- var state = new qx.util.fsm.State(
- "State_Idle",
- {
- "events" :
- {
- // When we get an appear event the first time, run the transition
- // that will load the module's finite state machine and graphical
- // user interface.
- "appear" :
- {
- "swat.main.canvas" :
- "Transition_Idle_to_Idle_Load_Gui"
- }
- }
- });
- fsm.addState(state);
-
- /*
- * Transition: Idle to (replaced) Idle
- *
- * Cause: "appear" on canvas for the first time
- *
- * Action:
- * Load module's finite state machine and graphical user interface
- */
- var thisModule = this;
- var newModule = module;
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_Idle_Load_Gui",
- {
- "nextState" :
- qx.util.fsm.FiniteStateMachine.StateChange.CURRENT_STATE,
-
- "ontransition" :
- function(fsm, event)
- {
- // Call the module's initialAppear function to build FSM and GUI.
- // That function should *replace* this state, State_Idle, to which
- // we'll transition.
- var canvas = fsm.getObject("swat.main.canvas");
- canvas.getTopLevelWidget().setGlobalCursor("progress");
- if (! newModule.bLoaded)
- {
- window.setTimeout(
- function()
- {
- // Call the module's initial appear handler
- thisModule.initialAppear(newModule);
-
- // Regenerate the appear event, since the original one got
- // lost by doing this code inside of the timeout.
- canvas.createDispatchEvent("appear");
-
- // Reset the cursor to the default
- canvas.getTopLevelWidget().setGlobalCursor(null);
-
- }, 0);
- newModule.bLoaded = true;
- }
- }
- });
- state.addTransition(trans);
-
- // Save the finite state machine for this module
- module.fsm = fsm;
-
- // Save the module descriptor in the finite state machine
- fsm.addObject("swat.main.module", module);
-
- // Create an RPC object for use by this module
- module.rpc = new qx.io.remote.Rpc();
- module.rpc.setUrl("/services/");
- module.rpc.setTimeout(10000);
- module.rpc.setCrossDomain(false);
- module.rpc.addEventListener("completed", fsm.eventListener, fsm);
- module.rpc.addEventListener("failed", fsm.eventListener, fsm);
- module.rpc.addEventListener("timeout", fsm.eventListener, fsm);
- module.rpc.addEventListener("aborted", fsm.eventListener, fsm);
- fsm.addObject("swat.main.rpc", module.rpc);
-
- // Start the finite state machine
- fsm.start();
-};
-
-/**
- * Build the initial graphical user interface.
- *
- * Generally, this is a no-op.
- *
- * @param module {Object}
- * An object containing at least the following properties:
- * fsm -
- * The finite state machine for this module. It should be filled in
- * by this function.
- * canvas -
- * The canvas on which to create the gui for this module
- * name -
- * The name of this module
- * clazz -
- * The class for this module
- *
- */
-qx.Proto.buildInitialGui = function(module)
-{
- // nothing to do
-};
-
-qx.Proto.finalize = function(module)
-{
- this.debug("AbstractModule.finalize()");
-};
-
-
-/*
----------------------------------------------------------------------------
- DEFER SINGLETON INSTANCE
----------------------------------------------------------------------------
-*/
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/main/AbstractModuleFsm.js b/webapps/swat/source/class/swat/main/AbstractModuleFsm.js
deleted file mode 100644
index 3cf4187676..0000000000
--- a/webapps/swat/source/class/swat/main/AbstractModuleFsm.js
+++ /dev/null
@@ -1,715 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * Common facilities for modules' finite state machines. Each module's FSM
- * should extend this class.
- */
-qx.OO.defineClass("swat.main.AbstractModuleFsm", qx.core.Object, function()
-{
- qx.core.Object.call(this);
-
- // Create an array for pushing request objects
- this._requests = [ ];
-});
-
-
-qx.Proto.buildFsm = function(module)
-{
- throw new Error("Module must overload buildFsm() " +
- "to build its custom finite state machine.");
-};
-
-qx.Proto.addAwaitRpcResultState = function(module, blockedEvents)
-{
- var fsm = module.fsm;
- var _this = this;
-
- /*
- * State: AwaitRpcResult
- *
- * Actions upon entry:
- * - enable any objects in group "swat.main.fsmUtils.enable_during_rpc"
- * - disable any objects in group "swat.main.fsmUtils.disable_during_rpc"
- *
- * Actions upon exit:
- * - disable any objects in group "swat.main.fsmUtils.enable_during_rpc"
- * - enable any objects in group "swat.main.fsmUtils.disable_during_rpc"
- *
- * Transition on:
- * "completed" (on RPC)
- * "failed" (on RPC)
- * "execute" on swat.main.fsmUtils.abort_rpc
- */
-
- var stateInfo =
- {
- "autoActionsBeforeOnentry" :
- {
- // The name of a function.
- "setEnabled" :
- [
- {
- // We want to enable objects in the group
- // swat.main.fsmUtils.enable_during_rpc
- "parameters" : [ true ],
-
- // Call this.getObject(<object>).setEnabled(true) on
- // state entry, for each <object> in the group called
- // "swat.main.fsmUtils.enable_during_rpc".
- "groups" : [ "swat.main.fsmUtils.enable_during_rpc" ]
- },
-
- {
- // We want to disable objects in the group
- // swat.main.fsmUtils.disable_during_rpc
- "parameters" : [ false ],
-
- // Call this.getObject(<object>).setEnabled(false) on
- // state entry, for each <object> in the group called
- // "swat.main.fsmUtils.disable_during_rpc".
- "groups" : [ "swat.main.fsmUtils.disable_during_rpc" ]
- }
- ]
- },
-
- "autoActionsBeforeOnexit" :
- {
- // The name of a function.
- "setEnabled" :
- [
- {
- // We want to re-disable objects we had enabled, in the group
- // swat.main.fsmUtils.enable_during_rpc
- "parameters" : [ false ],
-
- // Call this.getObject(<object>).setEnabled(false) on
- // state entry, for each <object> in the group called
- // "swat.main.fsmUtils.enable_during_rpc".
- "groups" : [ "swat.main.fsmUtils.enable_during_rpc" ]
- },
-
- {
- // We want to re-enable objects we had disabled, in the group
- // swat.main.fsmUtils.disable_during_rpc
- "parameters" : [ true ],
-
- // Call this.getObject(<object>).setEnabled(true) on
- // state entry, for each <object> in the group called
- // "swat.main.fsmUtils.disable_during_rpc".
- "groups" : [ "swat.main.fsmUtils.disable_during_rpc" ]
- }
- ]
- },
-
- "onentry" :
- function(fsm, event)
- {
- var bAuthCompleted = false;
-
- // Change the cursor to indicate RPC in progress
- var canvas = fsm.getObject("swat.main.canvas");
- canvas.getTopLevelWidget().setGlobalCursor("progress");
-
- // See if we just completed an authentication
- if (fsm.getPreviousState() == "State_Authenticate" &&
- event.getType() == "complete")
- {
- bAuthCompleted = true;
- }
-
- // If we didn't just complete an authentication and we're coming
- // from some other state...
- if (! bAuthCompleted &&
- fsm.getPreviousState() != "State_AwaitRpcResult")
- {
- // ... then push the previous state onto the state stack
- fsm.pushState(false);
- }
- },
-
- "onexit" :
- function(fsm, event)
- {
- // If we're returning to the calling state (not going to the
- // Authenticate state)...
- var nextState = fsm.getNextState();
- if (nextState != "State_Authenticate" &&
- nextState != "State_AwaitRpcResult")
- {
- // ... then set the cursor back to normal
- var canvas = fsm.getObject("swat.main.canvas");
- canvas.getTopLevelWidget().setGlobalCursor(null);
- }
- },
-
- "events" :
- {
- "execute" :
- {
- "swat.main.fsmUtils.abort_rpc" :
- "Transition_AwaitRpcResult_to_AwaitRpcResult_via_button_abort"
- },
-
- "completed" :
- "Transition_AwaitRpcResult_to_PopStack_via_complete",
-
- "failed" :
- qx.util.fsm.FiniteStateMachine.EventHandling.PREDICATE
- }
- };
-
- // If there are blocked events specified...
- if (blockedEvents)
- {
- // ... then add them to the state info events object
- for (var blockedEvent in blockedEvents)
- {
- // Ensure it's not already there. Avoid programmer headaches.
- if (stateInfo["events"][blockedEvent])
- {
- throw new Error("Attempt to add blocked event " +
- blockedEvent + " but it is already handled");
- }
-
- // Add the event.
- stateInfo["events"][blockedEvent] = blockedEvents[blockedEvent];
- }
- }
-
- var state = new qx.util.fsm.State( "State_AwaitRpcResult", stateInfo);
- fsm.addState(state);
-
- /*** Transitions that use a PREDICATE appear first ***/
-
- /*
- * Transition: AwaitRpcResult to GetAuthInfo
- *
- * Cause: "failed" (on RPC) where reason is PermissionDenied
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_AwaitRpcResult_to_Authenticate",
- {
- "nextState" :
- "State_Authenticate",
-
- "predicate" :
- function(fsm, event)
- {
- var error = event.getData(); // retrieve the JSON-RPC error
-
- // Did we get get origin=Server, and either
- // code=NotLoggedIn or code=SessionExpired ?
- var origins = swat.main.AbstractModuleFsm.JsonRpc_Origin;
- var serverErrors = swat.main.AbstractModuleFsm.JsonRpc_ServerError;
- if (error.origin == origins.Server &&
- (error.code == serverErrors.NotLoggedIn ||
- error.code == serverErrors.SessionExpired))
- {
- return true;
- }
-
- // fall through to next transition, also for "failed"
- return false;
- },
-
- "ontransition" :
- function(fsm, event)
- {
- var caption;
-
- var error = event.getData(); // retrieve the JSON-RPC error
- var serverErrors = swat.main.AbstractModuleFsm.JsonRpc_ServerError;
-
- switch(error.code)
- {
- case serverErrors.NotLoggedIn:
- caption = "Please log in.";
- break;
-
- case serverErrors.SessionExpired:
- default:
- caption = "Session Expired. Please log in.";
- break;
- }
-
- // Retrieve the modal authentication window.
- var loginWin = swat.main.Authenticate.getInstance();
-
- // Ensure that it's saved in the current finite state machine
- loginWin.addToFsm(fsm);
-
- // Set the caption
- loginWin.setCaption(caption);
-
- // Set the domain info
- loginWin.setInfo(error.info);
-
- // Open the authentication window
- loginWin.open();
- }
- });
- state.addTransition(trans);
-
- /*
- * Transition: AwaitRpcResult to PopStack
- *
- * Cause: "failed" (on RPC)
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_AwaitRpcResult_to_PopStack_via_failed",
- {
- "nextState" :
- qx.util.fsm.FiniteStateMachine.StateChange.POP_STATE_STACK,
-
- "ontransition" :
- function(fsm, event)
- {
- // Get the request object
- var rpcRequest = _this.getCurrentRpcRequest();
-
- // Generate the result for a completed request
- rpcRequest.setUserData("result",
- {
- type : "failed",
- data : event.getData()
- });
- }
- });
- state.addTransition(trans);
-
- /*** Remaining transitions are accessed via the jump table ***/
-
- /*
- * Transition: AwaitRpcResult to AwaitRpcResult
- *
- * Cause: "execute" on swat.main.fsmUtils.abort_rpc
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_AwaitRpcResult_to_AwaitRpcResult_via_button_abort",
- {
- "nextState" :
- "State_AwaitRpcResult",
-
- "ontransition" :
- function(fsm, event)
- {
- // Get the request object
- var rpcRequest = _this.getCurrentRpcRequest();
-
- // Issue an abort for the pending request
- rpcRequest.request.abort();
- }
- });
- state.addTransition(trans);
-
- /*
- * Transition: AwaitRpcResult to PopStack
- *
- * Cause: "complete" (on RPC)
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_AwaitRpcResult_to_PopStack_via_complete",
- {
- "nextState" :
- qx.util.fsm.FiniteStateMachine.StateChange.POP_STATE_STACK,
-
- "ontransition" :
- function(fsm, event)
- {
- // Get the request object
- var rpcRequest = _this.getCurrentRpcRequest();
-
- // Generate the result for a completed request
- rpcRequest.setUserData("result",
- {
- type : "complete",
- data : event.getData()
- });
- }
- });
- state.addTransition(trans);
-
- /*
- * State: Authenticate
- *
- * Transition on:
- * "execute" on login_button
- */
- var state = new qx.util.fsm.State(
- "State_Authenticate",
- {
- "onentry" :
- function(fsm, event)
- {
- // Retrieve the login window object
- var win = fsm.getObject("login_window");
-
- // Clear the password field
- win.password.setValue("");
-
- // If there's no value selected for domain...
- if (win.domain.getValue() == null)
- {
- // ... then select the first value
- win.domain.setSelected(win.domain.getList().getFirstChild());
- }
-
- // Retrieve the current RPC request
- var rpcRequest = _this.getCurrentRpcRequest();
-
- // Did we just return from an RPC request and was it a login request?
- if (fsm.getPreviousState() == "State_AwaitRpcResult" &&
- rpcRequest.service == "samba.system" &&
- rpcRequest.params.length > 1 &&
- rpcRequest.params[1] == "login")
- {
- // Yup. Display the result. Pop the old request off the stack
- var loginRequest = _this.popRpcRequest();
-
- // Retrieve the result
- var result = loginRequest.getUserData("result");
-
- // Did we succeed?
- if (result.type == "failed")
- {
- // Nope. Just reset the caption, and remain in this state.
- win.setCaption("Login Failed. Try again.");
- }
- else
- {
- // Login was successful. Generate an event that will transition
- // us back to the AwaitRpcResult state to again await the result
- // of the original RPC request.
- win.dispatchEvent(new qx.event.type.Event("complete"), true);
-
- // Reissue the original request. (We already popped the login
- // request off the stack, so the current request is the original
- // one.)
- var origRequest = _this.getCurrentRpcRequest();
-
- // Retrieve the RPC object */
- var rpc = fsm.getObject("swat.main.rpc");
-
- // Set the service name
- rpc.setServiceName(origRequest.service);
-
- // Reissue the request
- origRequest.request =
- qx.io.remote.Rpc.prototype.callAsyncListeners.apply(
- rpc,
- origRequest.params);
-
- // Clear the password field, for good measure
- win.password.setValue("");
-
- // Close the login window
- win.close();
- }
-
- // Dispose of the login request
- loginRequest.request.dispose();
- loginRequest.request = null;
- }
- },
-
- "events" :
- {
- "execute" :
- {
- "login_button" :
- "Transition_Authenticate_to_AwaitRpcResult_via_button_login"
- },
-
- "complete" :
- {
- "login_window" :
- "Transition_Authenticate_to_AwaitRpcResult_via_complete"
- }
- }
- });
- fsm.addState(state);
-
- /*
- * Transition: Authenticate to AwaitRpcResult
- *
- * Cause: "execute" on login_button
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Authenticate_to_AwaitRpcResult_via_button_login",
- {
- "nextState" :
- "State_AwaitRpcResult",
-
- "ontransition" :
- function(fsm, event)
- {
- // Retrieve the login window object
- var win = fsm.getObject("login_window");
-
- // Issue a Login call
- _this.callRpc(fsm,
- "samba.system",
- "login",
- [
- win.userName.getValue(),
- win.password.getValue(),
- win.domain.getValue()
- ]);
- }
- });
- state.addTransition(trans);
-
- /*
- * Transition: Authenticate to AwaitRpcResult
- *
- * Cause: "complete" on login_window
- *
- * We've already re-issued the original request, so we have nothing to do
- * here but transition back to the AwaitRpcResult state to again await the
- * result of the original request.
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Authenticate_to_AwaitRpcResult_via_complete",
- {
- "nextState" :
- "State_AwaitRpcResult"
- });
- state.addTransition(trans);
-};
-
-
-/**
- * Issue a remote procedure call.
- *
- * @param fsm {qx.util.fsm.FiniteStateMachine}
- * The finite state machine issuing this remote procedure call.
- *
- * @param service {String}
- * The name of the remote service which provides the specified method.
- *
- * @param method {String}
- * The name of the method within the specified service.
- *
- * @param params {Array}
- * The parameters to be passed to the specified method.
- *
- * @return {Object}
- * The request object for the just-issued RPC request.
- */
-qx.Proto.callRpc = function(fsm, service, method, params)
-{
- // Create an object to hold a copy of the parameters. (We need a
- // qx.core.Object() to be able to store this in the finite state machine.)
- var rpcRequest = new qx.core.Object();
-
- // Save the service name
- rpcRequest.service = service;
-
- // Copy the parameters; we'll prefix our copy with additional params
- rpcRequest.params = params.slice(0);
-
- // Prepend the method
- rpcRequest.params.unshift(method);
-
- // Prepend the flag indicating to coalesce failure events
- rpcRequest.params.unshift(true);
-
- // Retrieve the RPC object */
- var rpc = fsm.getObject("swat.main.rpc");
-
- // Set the service name
- rpc.setServiceName(rpcRequest.service);
-
- // Issue the request
- rpcRequest.request =
- qx.io.remote.Rpc.prototype.callAsyncListeners.apply(rpc,
- rpcRequest.params);
-
- // Make the rpc request object available to the AwaitRpcResult state
- this.pushRpcRequest(rpcRequest);
-
- // Give 'em what they came for
- return rpcRequest;
-};
-
-
-/**
- * Push an RPC request onto the request stack.
- *
- * @param request {Object}
- * The just-issued rpc request object
- */
-qx.Proto.pushRpcRequest = function(rpcRequest)
-{
- this._requests.push(rpcRequest);
-};
-
-
-/**
- * Retrieve the most recent RPC request from the request stack and pop the
- * stack.
- *
- * @return {Object}
- * The rpc request object from the top of the request stack
- */
-qx.Proto.popRpcRequest = function()
-{
- if (this._requests.length == 0)
- {
- throw new Error("Attempt to pop an RPC request when list is empty.");
- }
-
- var rpcRequest = this._requests.pop();
- return rpcRequest;
-};
-
-
-/**
- * Retrieve the most recent RPC request.
- *
- * @return {Object}
- * The rpc request object at the top of the request stack
- */
-qx.Proto.getCurrentRpcRequest = function()
-{
- if (this._requests.length == 0)
- {
- throw new Error("Attempt to retrieve an RPC request when list is empty.");
- }
-
- return this._requests[this._requests.length - 1];
-};
-
-
-/**
- * JSON-RPC error origins
- */
-qx.Class.JsonRpc_Origin =
-{
- Server : 1,
- Application : 2,
- Transport : 3,
- Client : 4
-};
-
-
-/**
- * JSON-RPC Errors for origin == Server
- */
-qx.Class.JsonRpc_ServerError =
-{
- /**
- * Error code, value 0: Unknown Error
- *
- * The default error code, used only when no specific error code is passed
- * to the JsonRpcError constructor. This code should generally not be used.
- */
- Unknown : 0,
-
- /**
- * Error code, value 1: Illegal Service
- *
- * The service name contains illegal characters or is otherwise deemed
- * unacceptable to the JSON-RPC server.
- */
- IllegalService : 1,
-
- /**
- * Error code, value 2: Service Not Found
- *
- * The requested service does not exist at the JSON-RPC server.
- */
- ServiceNotFound : 2,
-
- /**
- * Error code, value 3: Class Not Found
- *
- * If the JSON-RPC server divides service methods into subsets (classes),
- * this indicates that the specified class was not found. This is slightly
- * more detailed than "Method Not Found", but that error would always also
- * be legal (and true) whenever this one is returned. (Not used in this
- * implementation)
- */
- ClassNotFound : 3, // not used in this implementation
-
- /**
- * Error code, value 4: Method Not Found
- *
- * The method specified in the request is not found in the requested
- * service.
- */
- MethodNotFound : 4,
-
- /*
- * Error code, value 5: Parameter Mismatch
- *
- * If a method discovers that the parameters (arguments) provided to it do
- * not match the requisite types for the method's parameters, it should
- * return this error code to indicate so to the caller.
- *
- * This error is also used to indicate an illegal parameter value, in server
- * scripts.
- */
- ParameterMismatch : 5,
-
- /**
- * Error code, value 6: Permission Denied
- *
- * A JSON-RPC service provider can require authentication, and that
- * authentication can be implemented such the method takes authentication
- * parameters, or such that a method or class of methods requires prior
- * authentication. If the caller has not properly authenticated to use the
- * requested method, this error code is returned.
- */
- PermissionDenied : 6,
-
- /*** Errors generated by this server which are not qooxdoo-standard ***/
-
- /*
- * Error code, value 1000: Unexpected Output
- *
- * The called method illegally generated output to the browser, which would
- * have preceeded the JSON-RPC data.
- */
- UnexpectedOutput : 1000,
-
- /*
- * Error code, value 1001: Resource Error
- *
- * Too many resources were requested, a system limitation on the total number
- * of resources has been reached, or a resource or resource id was misused.
- */
- ResourceError : 1001,
-
- /*
- * Error code, value 1002: Not Logged In
- *
- * The user has logged out and must re-authenticate, or this is a brand new
- * session and the user must log in.
- *
- */
- NotLoggedIn : 1002,
-
- /*
- * Error code, value 1003: Session Expired
- *
- * The session has expired and the user must re-authenticate.
- *
- */
- SessionExpired : 1003,
-
- /*
- * Error code, value 1004: Login Failed
- *
- * An attempt to log in failed.
- *
- */
- LoginFailed : 1004
-};
diff --git a/webapps/swat/source/class/swat/main/Authenticate.js b/webapps/swat/source/class/swat/main/Authenticate.js
deleted file mode 100644
index 83e20ce97a..0000000000
--- a/webapps/swat/source/class/swat/main/Authenticate.js
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright:
- * (C) 2007 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * Swat authentication window class
- */
-qx.OO.defineClass("swat.main.Authenticate", qx.ui.window.Window,
-function()
-{
- var o;
-
- qx.ui.window.Window.call(this);
-
- var addCaptionedWidget = function(caption, dest, addWidget)
- {
- // Add a row to the destination grid
- dest.addRow();
- var row = dest.getRowCount() - 1;
- dest.setRowHeight(row, 24);
-
- // Add the caption
- var o = new qx.ui.basic.Label(caption);
- dest.add(o, 0, row);
-
- // Add the widget
- o = addWidget();
- o.setHeight(24);
- dest.add(o, 1, row);
-
- // Give 'em the varying data label
- return o;
- };
-
-
- // Set characteristics of this window
- this.set({
- width : 380,
- height : 200,
- modal : true,
- centered : true,
- showClose : false,
- showMaximize : false,
- showMinimize : false,
- showStatusbar : false,
- allowClose : false,
- allowMaximize : false,
- allowMinimize : false,
- resizeable : false,
- moveable : false,
- zIndex : 10000
- });
-
-
- // Create a grid layout
- var grid = new qx.ui.layout.GridLayout();
- grid.setLocation(14, 14);
- grid.setDimension("90%", "90%");
- grid.setVerticalSpacing(14);
- grid.setPadding(14, 14);
- grid.setRowCount(0);
- grid.setColumnCount(2);
- grid.setColumnWidth(0, 100);
- grid.setColumnWidth(1, 200);
-
-
- // Add an input box for the user name
- this.userName = addCaptionedWidget("User Name", grid,
- function()
- {
- return new qx.ui.form.TextField();
- });
-
- // Add an input box for the password
- this.password = addCaptionedWidget("Password", grid,
- function()
- {
- return new qx.ui.form.PasswordField();
- });
-
- // Add an input box for the password
- this.domain = addCaptionedWidget("Domain", grid,
- function()
- {
- // Create a combo box for for the domain
- var combo = new qx.ui.form.ComboBox();
- combo.setEditable(false);
- return combo;
- });
-
- // Add a login button
- this.login = addCaptionedWidget("", grid,
- function()
- {
- return new qx.ui.form.Button("Login");
- });
-
- // Add the grid to the window
- this.add(grid);
-
- // Add this window to the document
- this.addToDocument();
-});
-
-
-qx.Proto.addToFsm = function(fsm)
-{
- // Have we already been here for this fsm?
- if (fsm.getObject("login_window"))
- {
- // Yup. Everything's already done. See ya!
- return;
- }
-
- // Save the login button since we receive events on it
- fsm.addObject("login_button", this.login);
-
- // We want to receive "execute" events on this button
- this.login.addEventListener("execute", fsm.eventListener, fsm);
-
- // Save the window object
- fsm.addObject("login_window", this);
-
- // We want to receive "complete" events on this window (which we generate)
- this.addEventListener("complete", fsm.eventListener, fsm);
-};
-
-
-qx.Proto.setInfo = function(info)
-{
- this.debug(info);
-
- // Remove everythingn from the domain list
- this.domain.removeAll();
-
- // Add the available domains
- for (var i = 0; i < info.length; i++)
- {
- var item = new qx.ui.form.ListItem(info[i]);
- this.domain.add(item);
- }
-};
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/main/Gui.js b/webapps/swat/source/class/swat/main/Gui.js
deleted file mode 100644
index 142b8dcba2..0000000000
--- a/webapps/swat/source/class/swat/main/Gui.js
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * The graphical user interface for the main menu
- */
-qx.OO.defineClass("swat.main.Gui");
-
-qx.Class.currentCanvas = null;
-
-qx.Class.buildGui = function(moduleList)
-{
- var o;
-
- // Header colors
- var topColor = new qx.renderer.color.Color("#ffff64");
- var bottomColor = new qx.renderer.color.Color("#3878cd");
-
- // Create the yellow bar at the top
- o = new qx.ui.basic.Terminator();
- o.set({
- top: 0,
- left: 0,
- right: 0,
- height: 40
- });
- o.setBackgroundColor(topColor);
- o.addToDocument();
-
- // Create the tag line
- var title = new qx.ui.basic.Label("Samba Web Administration Tool");
- title.set({
- top: 12,
- left: 20
- });
- title.setBackgroundColor(topColor);
- title.setFont("bold");
- title.addToDocument();
-
- // Create a small black separator between the yellow and blue bars
- o = new qx.ui.basic.Terminator();
- o.set({
- top: 40,
- left: 0,
- right: 0,
- height: 1
- });
- o.setBackgroundColor("black");
- o.addToDocument();
-
- // Create the yellow bar at the top
- o = new qx.ui.basic.Terminator();
- o.set({
- top: 41,
- left: 0,
- right: 0,
- height: 60
- });
- o.setBackgroundColor(bottomColor);
- o.addToDocument();
-
- // Create the "Samba" image
- o = new qx.ui.basic.Image("../../../images/logo.png");
- o.set({
- top: 16,
- right: 20
- });
- o.setZIndex(100000000);
- o.addToDocument();
-
- // Create a menu bar
- var menubar = new qx.ui.toolbar.ToolBar();
- menubar.set({
- top: 100,
- height: 20,
- left: 0,
- right: 0
- });
- menubar.addToDocument();
-
- // Create a menu item for selecting the requested module
- var menubutton = new qx.ui.toolbar.MenuButton("Modules");
- menubar.add(menubutton);
-
- // Create a Command to be executed upon any menu selection
- var command = new qx.client.Command();
- // command.addEventListener("execute", fsm.eventListener, fsm);
-
- // Create a radio manager for selecting one of the modules
- var moduleManager = new qx.manager.selection.RadioManager("main.gui.Module");
-
- // Create a menu containing the subitems
- var menu = new qx.ui.menu.Menu();
-
- // We'll also track the current module's canvas in the modules object
- swat.main.Gui.currentCanvas = null;
-
- // For each menu item...
- for (moduleName in moduleList)
- {
- // create a radio button menu item
- o = new qx.ui.menu.RadioButton(moduleName, command, false);
-
- // Associate this button menu item with the module list
- o.moduleName = moduleName;
-
- // Associate the menu item with the radio manager
- moduleManager.add(o);
-
- // Create this module's canvas
- var canvas = new qx.ui.layout.CanvasLayout();
- canvas.set({
- top: 120,
- bottom: 0,
- left: 0,
- right: 0
- });
- canvas.setBackgroundColor("white");
- canvas.setDisplay(false); // initially not displayed
-
- var fsm = moduleList[moduleName].fsm;
- fsm.addObject("swat.main.canvas", canvas);
- canvas.addEventListener("appear", fsm.eventListener, fsm);
- canvas.addEventListener("disappear", fsm.eventListener, fsm);
-
- // Save the canvas
- moduleList[moduleName].canvas = canvas;
-
- // Add the canvas to the document
- canvas.addToDocument();
-
- // When a Module menu item is selected:
- o.addEventListener("changeChecked", function(e)
- {
- var canvas = moduleList[this.moduleName].canvas;
-
- // If there's a current canvas, ...
- if (swat.main.Gui.currentCanvas)
- {
- // ... then remove display of it.
- swat.main.Gui.currentCanvas.setDisplay(false);
-
- // Dispatch an event on the canvas to notify old
- // module it's coming into disuse.
- canvas.createDispatchEvent("disappear");
- }
-
- // If we are being selected...
- if (e.getData())
- {
- // then display our canvas
- var canvas = moduleList[this.moduleName].canvas;
- canvas.setDisplay(true);
-
- // Track the current canvas (now ours)
- swat.main.Gui.currentCanvas = canvas;
-
- // Dispatch an event on the canvas to notify new
- // module it's coming into use.
- canvas.createDispatchEvent("appear");
-
- // Set the application title
- title.setHtml("<span>" +
- "Samba Web Administration Tool" +
- " &raquo; " +
- this.moduleName +
- "</span>");
-
- // Set the browser title as well
- document.title =
- "Swat: " + this.moduleName;
- }
- });
-
- // Add the menu item to the menu
- menu.add(o);
- }
-
- // We've built a complete menu. Add it to the document.
- menu.addToDocument();
-
- // Specify that the menu is to be displayed upon menu button selection
- menubutton.setMenu(menu);
-
- // Create a menu item for selecting debug options
- var menubutton = new qx.ui.toolbar.MenuButton("Debug");
- menubar.add(menubutton);
-
- // Create a menu containing the subitems
- var menu = new qx.ui.menu.Menu;
- var menu_01 = new qx.ui.menu.Button("Show Debug Window", null, command);
- menu.add(menu_01);
- menu.addToDocument();
-
- // Specify that the menu is to be displayed upon menu button selection
- menubutton.setMenu(menu);
-
-};
diff --git a/webapps/swat/source/class/swat/main/Main.js b/webapps/swat/source/class/swat/main/Main.js
deleted file mode 100644
index 9e65896aad..0000000000
--- a/webapps/swat/source/class/swat/main/Main.js
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/*
-#require(swat.main.Module)
-#require(swat.main.AbstractModule)
-#require(swat.main.Authenticate);
-*/
-
-/**
- * Swat main menu
- */
-qx.OO.defineClass("swat.main.Main", qx.component.AbstractApplication,
-function()
-{
- qx.component.AbstractApplication.call(this);
-});
-
-/*
- * Register our supported modules. The order listed here is the order they
- * will appear in the Modules menu.
- */
-
-//#require(swat.module.statistics.Statistics)
-new swat.main.Module("Status and Statistics",
- swat.module.statistics.Statistics);
-
-//#require(swat.module.ldbbrowse.LdbBrowse)
-new swat.main.Module("LDB Browser",
- swat.module.ldbbrowse.LdbBrowse);
-
-//#require(swat.module.netmgr.NetManager)
-new swat.main.Module("Net Manager",
- swat.module.netmgr.NetManager);
-
-//#require(swat.module.documentation.Documentation)
-//#require(apiviewer.Viewer)
-new swat.main.Module("API Documentation",
- swat.module.documentation.Documentation);
-
-
-/*
----------------------------------------------------------------------------
- METHODS
----------------------------------------------------------------------------
-*/
-
-qx.Proto.initialize = function()
-{
- // Set the resource URI
- qx.Settings.setCustom("resourceUri", "./resource");
-
- // Turn on JSON debugging for the time being
- qx.Settings.setCustomOfClass("qx.io.Json", "enableDebug", true);
-
- // For each module...
- var moduleList = swat.main.Module.getList();
- for (moduleName in moduleList)
- {
- // ... call the module's buildInitialFsm() function
- var module = moduleList[moduleName]["clazz"].getInstance();
- module.buildInitialFsm(moduleList[moduleName]);
- }
-};
-
-
-qx.Proto.main = function()
-{
- var moduleList = swat.main.Module.getList();
-
- // Initialize the gui for the main menu
- swat.main.Gui.buildGui(moduleList);
-
- // Similarly, now that we have a canvas for each module, ...
- for (moduleName in moduleList)
- {
- // ... call the module's buildInitialGui() function
- var module = moduleList[moduleName]["clazz"].getInstance();
- module.buildInitialGui(moduleList[moduleName]);
- }
-};
-
-
-qx.Proto.finalize = function()
-{
- // Call each module's finalization function
- var moduleList = swat.main.Module.getList();
- for (moduleName in moduleList)
- {
- var module = moduleList[moduleName]["clazz"].getInstance();
- module.finalize(moduleList[moduleName]);
- }
-};
-
diff --git a/webapps/swat/source/class/swat/main/Module.js b/webapps/swat/source/class/swat/main/Module.js
deleted file mode 100644
index 160e6f6ec7..0000000000
--- a/webapps/swat/source/class/swat/main/Module.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * This class defines a module descriptor (the registration of a module) and
- * maintains the list of modules that have been registered.
- *
- * A Module object contains the following public properties which may be
- * accessed directly by name:
- *
- * fsm -
- * The finite state machine for this module.
- *
- * canvas -
- * The canvas on which to create the gui for this module
- *
- * name -
- * The name of this module
- *
- * class -
- * The class for this module
- *
- * @param moduleName {String}
- * The name of the module being registered. This is the name that will
- * appear in the Modules menu.
- *
- * @param clazz {clazz}
- * The class which contains the module implementation. That class must
- * extend swat.main.AbstractModule and implement a singleton interface
- * that provides a public method called initialAppear() which takes this
- * Module object as a parameter, and creates the finite state machine for
- * the module (if applicable) and builds the graphical user interface for
- * the module.
- */
-qx.OO.defineClass("swat.main.Module", qx.core.Object,
-function(moduleName, clazz)
-{
- qx.core.Object.call(this);
-
- // Initialize commonly-used properties of a module
- this.canvas = null;
- this.fsm = null;
- this.gui = null;
-
- // Save the module name
- this.name = moduleName;
-
- // Save this class name
- this.clazz = clazz;
-
- // Add this new module to the module list.
- swat.main.Module._list[moduleName] = this;
-});
-
-
-/**
- * Return the list of modules
- */
-qx.Class.getList = function()
-{
- return swat.main.Module._list;
-};
-
-
-/**
- * The list of modules which have been registered.
- */
-qx.Class._list = { };
diff --git a/webapps/swat/source/class/swat/module/documentation/Documentation.js b/webapps/swat/source/class/swat/module/documentation/Documentation.js
deleted file mode 100644
index 696a7f0161..0000000000
--- a/webapps/swat/source/class/swat/module/documentation/Documentation.js
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/*
-#embed(apiviewer.css/*)
-#embed(apiviewer.image/*)
-*/
-
-
-/**
- * Swat statistics class
- */
-qx.OO.defineClass("swat.module.documentation.Documentation",
- swat.main.AbstractModule,
-function()
-{
- swat.main.AbstractModule.call(this);
-});
-
-
-/**
- * Load the documentation data
- *
- * This function is called the first time a module is actually selected to
- * appear. Creation of the module's GUI has been deferred until it was
- * actually needed (now), so we need to create it.
- *
- * @param module {swat.main.Module}
- * The module descriptor for the module.
- */
-qx.Proto.initialAppear = function(module)
-{
- // Define alias for custom resource path
- var am = qx.manager.object.AliasManager.getInstance();
- am.add("api", qx.Settings.getValueOfClass("apiviewer", "resourceUri"));
-
- // Include CSS file
- qx.html.StyleSheet.includeFile(am.resolvePath("api/css/apiviewer.css"));
- am.add("apiviewer", "./resource/image");
-
- // avoid redundant naming by api viewer
- qx.Settings.setCustomOfClass("apiviewer.Viewer", "title", "");
-
- var viewer = new apiviewer.Viewer();
- module.canvas.add(viewer);
- viewer.load("script/data.js");
-
- // Replace the existing (temporary) finite state machine with a null one
- swat.module.documentation.Fsm.getInstance().buildFsm(module);
-};
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/module/documentation/Fsm.js b/webapps/swat/source/class/swat/module/documentation/Fsm.js
deleted file mode 100644
index b58f57cf1f..0000000000
--- a/webapps/swat/source/class/swat/module/documentation/Fsm.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * Swat statistics class finite state machine
- */
-qx.OO.defineClass("swat.module.documentation.Fsm",
- swat.main.AbstractModuleFsm,
-function()
-{
- swat.main.AbstractModuleFsm.call(this);
-});
-
-
-qx.Proto.buildFsm = function(module)
-{
- var fsm = module.fsm;
-
- /*
- * State: Idle
- *
- * This is a null state to replace the one that loads the API viewer. The
- * API viewer does not use the finite state machine.
- */
- var state = new qx.util.fsm.State(
- "State_Idle",
- {
- "events" :
- {
- // We need at least one event listed due to FSM requirements
- "appear" :
- {
- "swat.main.canvas" :
- "Transition_Idle_to_Idle_via_appear"
- }
- }
- });
-
- // Replace the initial Idle state with this one
- fsm.replaceState(state, true);
-
- /*
- * Transition: Idle to Idle
- *
- * Cause: "appear" on canvas
- *
- * Action:
- * None.
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_Idle_via_appear",
- {
- "nextState" :
- "State_Idle"
- });
- state.addTransition(trans);
-
-};
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js b/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
deleted file mode 100644
index 02aada9ebf..0000000000
--- a/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * Swat LDB Browser class finite state machine
- */
-qx.OO.defineClass("swat.module.ldbbrowse.Fsm", swat.main.AbstractModuleFsm,
-function()
-{
- swat.main.AbstractModuleFsm.call(this);
-});
-
-
-qx.Proto.buildFsm = function(module)
-{
- var fsm = module.fsm;
- var _this = this;
-
- /*
- * State: Idle
- *
- * Actions upon entry
- * - if returning from RPC, display the result
- *
- * Transition on:
- * "execute" on search button
- * "treeopenwhileempty" on tree
- * "changeselection" on tree
- */
- var state = new qx.util.fsm.State(
- "State_Idle",
- {
- "onentry" :
- function(fsm, event)
- {
- // Did we just return from an RPC request?
- if (fsm.getPreviousState() == "State_AwaitRpcResult")
- {
- // Yup. Display the result. We need to get the request object
- var rpcRequest = _this.popRpcRequest();
-
- // Display the result
- var gui = swat.module.ldbbrowse.Gui.getInstance();
-
- // Did we get a Resource Not Found error? We'll get this after a
- // session timeout, because the request is retried but can't
- // succeed because the database has been closed by the session
- // timing out.
- var result = rpcRequest.getUserData("result");
- var origins = swat.main.AbstractModuleFsm.JsonRpc_Origin;
- var serverErrors = swat.main.AbstractModuleFsm.JsonRpc_ServerError;
- if (result.type == "failed" &&
- result.data.origin == origins.Server &&
- result.data.code == serverErrors.ResourceError)
- {
- // Yup. Re-open the database
- var dbName = fsm.getObject("dbName");
- dbName.dispatchEvent(new qx.event.type.Event("changeSelected"),
- true);
- }
- else
- {
- // Otherwise, display the result
- gui.displayData(module, rpcRequest);
- }
-
- // Dispose of the request
- rpcRequest.request.dispose();
- rpcRequest.request = null;
- }
- },
-
- "events" :
- {
- // If the search button is activated, issue a search request
- "execute" :
- {
- "search" :
- "Transition_Idle_to_AwaitRpcResult_via_search",
-
- "commit" :
- "Transition_Idle_to_AwaitRpcResult_via_commit",
-
- "delete" :
- "Transition_Idle_to_AwaitRpcResult_via_delete"
- },
-
- // If a previously unexpanded tree node is expanded, issue a request
- // to retrieve its contents.
- "treeOpenWhileEmpty":
- {
- "tree" :
- "Transition_Idle_to_AwaitRpcResult_via_tree_open"
- },
-
- // If the selection changes, issue a request to retrieve contents to
- // populate the attribute/value table.
- "changeSelection":
- {
- "tree" :
- "Transition_Idle_to_AwaitRpcResult_via_tree_selection_changed"
-
- },
-
- // If another database is selected, try to open it and refresh
- // the tree
- "changeSelected":
- {
- "dbName":
- "Transition_Idle_to_AwaitRpcResult_via_db_changed"
- }
- }
- });
-
- // Replace the initial Idle state with this one
- fsm.replaceState(state, true);
-
- /*
- * Transition: Idle to AwaitRpcResult
- *
- * Cause: "execute" on search button
- *
- * Action:
- * Issue a search request
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_search",
- {
- "nextState" :
- "State_AwaitRpcResult",
-
- "ontransition" :
- function(fsm, event)
- {
- // Get our module descriptor
- var module = fsm.getObject("swat.main.module");
-
- // Retrieve the database handle
- var dbHandle = module.dbHandle;
-
- // Retrieve the search expression
- var searchExpr = fsm.getObject("searchExpr").getValue();
-
- // Retrieve the base DN
- var baseDN = fsm.getObject("baseDN").getValue();
-
- // Retrieve the selected scope
- var scope = fsm.getObject("scope").getValue();
-
- // We want all attributes
- var attributes = [ "*" ];
-
- // Issue a Search call
- var request = _this.callRpc(fsm,
- "samba.ldb",
- "search",
- [
- dbHandle,
- searchExpr,
- baseDN,
- scope,
- attributes
- ]);
-
- // When we get the result, we'll need to know what type of request
- // we made.
- request.setUserData("requestType", "search");
- }
- });
- state.addTransition(trans);
-
- /*
- * Transition: Idle to AwaitRpcResult
- *
- * Cause: "execute" on OK button
- *
- * Action:
- * Commit modification or add new record to ldb
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_commit",
- {
- "nextState" :
- "State_AwaitRpcResult",
-
- "ontransition" :
- function(fsm, event)
- {
- // Get our module descriptor
- var module = fsm.getObject("swat.main.module");
-
- // Retrieve the database handle
- var dbHandle = module.dbHandle;
-
- // Retrieve the ldbmod object
- var ldbmod = fsm.getObject("ldbmod");
-
- var ldif = ldbmod.getLdif();
-
- // Issue a Search call
- var request = _this.callRpc(fsm,
- "samba.ldb",
- ldbmod.getOpType(),
- [ dbHandle, ldif ]);
-
- // When we get the result, we'll need to know what type of request
- // we made.
- request.setUserData("requestType", ldbmod.getOpType());
- }
- });
- state.addTransition(trans);
-
- /*
- * Transition: Idle to AwaitRpcResult
- *
- * Cause: "execute" on OK button
- *
- * Action:
- * Delete a record from ldb
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_delete",
- {
- "nextState" :
- "State_AwaitRpcResult",
-
- "ontransition" :
- function(fsm, event)
- {
- // Get our module descriptor
- var module = fsm.getObject("swat.main.module");
-
- // Retrieve the database handle
- var dbHandle = module.dbHandle;
-
- // Retrieve the ldbmod object
- var ldbmod = fsm.getObject("ldbmod");
-
- // Issue a Search call
- var request = _this.callRpc(fsm,
- "samba.ldb",
- "del",
- [ dbHandle, ldbmod.getBase() ]);
-
- // When we get the result, we'll need to know what type of request
- // we made.
- request.setUserData("requestType", "delete");
- }
- });
- state.addTransition(trans);
-
- /*
- * Transition: Idle to AwaitRpcResult
- *
- * Cause: "treeOpenWhileEmpty" on tree
- *
- * Action:
- * Issue a search request
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_tree_open",
- {
- "nextState" :
- "State_AwaitRpcResult",
-
- "ontransition" :
- function(fsm, event)
- {
- // Get the tree object
- var tree = fsm.getObject("tree");
-
- // Get the node on which the event occurred
- var node = event.getData();
-
- // Obtain the full hierarchy for this node
- var hierarchy = tree.getHierarchy(node.nodeId);
-
- tree.debug("Requesting children for node id " + node.nodeId + ": " +
- hierarchy.join("/") + "...");
-
- // Strip off the root node
- hierarchy.shift();
-
- // Determine the children. Differs depending on root or otherwise
- var attributes;
- var scope;
- var baseDN;
-
- // If parent is the root...
- if (node.parentNodeId == 0)
- {
- // ... then we want the defaultNamingContext, ...
- attributes = [ "defaultNamingContext", "namingContexts" ];
-
- // ... and we want only base scope
- scope = "base";
-
- // ... and an empty base DN
- baseDN = "";
- }
- else
- {
- // otherwise, retrieve the DN,
- attributes = [ "dn" ];
-
- // ... and we want one level of scope
- scope = "one";
-
- // ... and base DN is the parent
- baseDN = hierarchy.reverse().join(",");
- }
-
- // Build the search expression
- var searchExpr = "";
-
- // Get our module descriptor
- var module = fsm.getObject("swat.main.module");
-
- // Retrieve the database handle
- var dbHandle = module.dbHandle;
-
- // Issue a Get Statistics call
- var request = _this.callRpc(fsm,
- "samba.ldb",
- "search",
- [
- dbHandle,
- searchExpr,
- baseDN,
- scope,
- attributes
- ]);
-
- // When we get the result, we'll need to know what type of request
- // we made.
- request.setUserData("requestType", "tree_open");
-
- // We'll also need some of our parameters
- request.setUserData("parentNode", node);
- request.setUserData("attributes", attributes);
- }
- });
- state.addTransition(trans);
-
- /*
- * Transition: Idle to AwaitRpcResult
- *
- * Cause: "changeSelection" on tree
- *
- * Action:
- * Issue a search request
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_tree_selection_changed",
- {
- "nextState" :
- "State_AwaitRpcResult",
-
- "predicate" :
- function(fsm, event)
- {
- // Get the tree object
- var tree = fsm.getObject("tree");
-
- // Get the list of selected nodes. We're in single-selection mode,
- // so there will be only one of them.
- var nodes = event.getData();
- var node = nodes[0];
-
- var hierarchy = tree.getHierarchy(node.nodeId);
-
- // Strip off the root node
- hierarchy.shift();
-
- // If element is the root...
- if (node.parentNodeId == 0)
- {
- // ... then just clear out the attribute/value table.
- var tableModel = fsm.getObject("tableModel:browse");
- tableModel.setData([]);
- return null; // don't search additional transitions
- }
-
- return true;
- },
-
- "ontransition" :
- function(fsm, event)
- {
- // Get the tree object
- var tree = fsm.getObject("tree");
-
- // Get the list of selected nodes. We're in single-selection mode,
- // so there will be only one of them.
- var nodes = event.getData();
- var node = nodes[0];
-
- var hierarchy = tree.getHierarchy(node.nodeId);
-
- // Strip off the root node
- hierarchy.shift();
-
- // Determine the children. Differs depending on root or otherwise
- var attributes;
- var scope;
- var baseDN;
-
- // We want all attributes
- attributes = [ "*" ];
-
- // We want the attributes only for the current element
- scope = "base";
-
- // Base DN is the current element
- baseDN = hierarchy.reverse().join(",");
-
- // Build the search expression
- var searchExpr = "";
-
- // Get our module descriptor
- var module = fsm.getObject("swat.main.module");
-
- // Retrieve the database handle
- var dbHandle = module.dbHandle;
-
- // Issue a Get Statistics call
- var request = _this.callRpc(fsm,
- "samba.ldb",
- "search",
- [
- dbHandle,
- searchExpr,
- baseDN,
- scope,
- attributes
- ]);
-
- // When we get the result, we'll need to know what type of request
- // we made.
- request.setUserData("requestType", "tree_selection_changed");
- }
- });
- state.addTransition(trans);
-
- /*
- * Transition: Idle to AwaitRpcResult
- *
- * Cause: "changeSelection" on dbName
- *
- * Action:
- * Issue a connect request
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_db_changed",
- {
- "nextState" :
- "State_AwaitRpcResult",
-
- "ontransition" :
- function(fsm, event)
- {
- // Obtain the name of the database to be connected to
- var dbName = fsm.getObject("dbName").getValue();
-
- // Issue a Get Statistics call
- var request = _this.callRpc(fsm,
- "samba.ldb",
- "connect",
- [ dbName ]);
-
- // When we get the result, we'll need to know what type of request
- // we made.
- request.setUserData("requestType", "database_name_changed");
- }
- });
- state.addTransition(trans);
-
- // Create the list of events that should be blocked while we're awaiting the
- // results of another RPC request
- blockedEvents =
- {
- // If a previously unexpanded tree node is expanded, issue a request
- // to retrieve its contents.
- "treeOpenWhileEmpty":
- {
- "tree" :
- qx.util.fsm.FiniteStateMachine.EventHandling.BLOCKED
- },
-
- // If the selection changes, issue a request to retrieve contents to
- // populate the attribute/value table.
- "changeSelection":
- {
- "tree" :
- qx.util.fsm.FiniteStateMachine.EventHandling.BLOCKED,
-
- "dbName":
- qx.util.fsm.FiniteStateMachine.EventHandling.BLOCKED
- }
- }
-
- // Add the AwaitRpcResult state and all of its transitions
- this.addAwaitRpcResultState(module, blockedEvents);
-};
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js b/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
deleted file mode 100644
index c90151859c..0000000000
--- a/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
+++ /dev/null
@@ -1,750 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * Swat LDB Browser class graphical user interface
- */
-qx.OO.defineClass("swat.module.ldbbrowse.Gui", qx.core.Object,
-function()
-{
- qx.core.Object.call(this);
-});
-
-//qx.OO.addProperty({ name : "_table", type : "object" });
-//qx.OO.addProperty({ name : "_ldbmod", type : "object" });
-
-/**
- * Build the raw graphical user interface.
- */
-qx.Proto.buildGui = function(module)
-{
- var o;
- var fsm = module.fsm;
-
- // We need a horizontal box layout for the database name
- var hlayout = new qx.ui.layout.HorizontalBoxLayout();
- hlayout.set({
- top: 20,
- left: 20,
- right: 20,
- height: 30
- });
-
- // Create a label for the database name
- o = new qx.ui.basic.Atom("Database:");
- o.setWidth(100);
- o.setHorizontalChildrenAlign("right");
-
- // Add the label to the horizontal layout
- hlayout.add(o);
-
- // Create a combo box for for the database name
- o = new qx.ui.form.ComboBox();
- o.getField().setWidth("100%");
- o.setEditable(false);
-
- // Add our global database name (the only option, for now)
- var item = new qx.ui.form.ListItem(module.dbFile);
- o.add(item);
-
- // We want to be notified if the selection changes
- o.addEventListener("changeSelected", fsm.eventListener, fsm);
-
- // Save the database name object so we can react to changes
- fsm.addObject("dbName", o);
-
- // Add the combo box to the horizontal layout
- hlayout.add(o);
-
- // Add the database name selection to the canvas
- module.canvas.add(hlayout);
-
- // Create and position the tabview
- var tabView_ = new qx.ui.pageview.tabview.TabView;
- tabView_.set({
- top: 60,
- left: 20,
- right: 20,
- bottom: 20
- });
-
- // Create each of the tabs
- 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_Browse.setChecked(true);
-
- // Add each of the tabs to the tabview
- tabView_.getBar().add(tabView_Browse, tabView_Search);
-
- // Create the pages to display when each tab is selected
- var tabViewPage_Browse =
- new qx.ui.pageview.tabview.Page(tabView_Browse);
- 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_Browse, tabViewPage_Search);
-
- // Add the tabview to our canvas
- module.canvas.add(tabView_);
-};
-
-
-/**
- * Populate the graphical user interface with the specified data
- *
- * @param module {swat.main.Module}
- * The module descriptor for the module.
- *
- * @result {Object}
- * The result returned by SAMBA to our request. We display the data
- * provided by this result.
- */
-qx.Proto.displayData = function(module, rpcRequest)
-{
- var gui = module.gui;
- var fsm = module.fsm;
- var result = rpcRequest.getUserData("result")
- var requestType = rpcRequest.getUserData("requestType");
-
- // Did the request fail?
- if (result.type == "failed")
- {
- // Yup. We're not going to do anything particularly elegant...
- alert("Async(" + result.id + ") exception: " + result.data);
- return;
- }
-
- // Dispatch to the appropriate handler, depending on the request type
- switch(requestType)
- {
- case "search":
- this._displaySearchResults(module, rpcRequest);
- break;
-
- case "modify":
- this._displayModifyResults(module, rpcRequest);
- break;
-
- case "add":
- this._displayAddResults(module, rpcRequest);
- break;
-
- case "delete":
- this._displayDeleteResults(module, rpcRequest);
- break;
-
- case "tree_open":
- this._displayTreeOpenResults(module, rpcRequest);
- break;
-
- case "tree_selection_changed":
-
- // Always update the table, even if it is not visible
- this._displayTreeSelectionChangedResults(module, rpcRequest);
-
- // Update the base field in ldbmod
- this._displayLdbmodBaseChanged(module, rpcRequest);
-
- break;
-
- case "database_name_changed":
- this._clearAllFields(module, rpcRequest);
- break;
-
- default:
- throw new Error("Unexpected request type: " + requestType);
- }
-
- // Force flushing of pending DOM updates. This is actually a
- // work-around for a bug. Without this, occasionally, updates to the
- // gui aren't displayed until some 'action' takes place, e.g. key
- // press or mouse movement.
- qx.ui.core.Widget.flushGlobalQueues();
-};
-
-
-qx.Proto._setAppearances = function()
-{
- // Modify the default appearance of a ComboBox for use in Search tab:
- // use more of the available width.
- //
- // If we had multiple uses, we'd create a new appearance which didn't
- // contain a width. That way, we'd be able to assign a specific width to
- // each ComboBox instance. Since we don't have multiple of them, 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 = "80%";
- return res;
- }
-};
-
-
-qx.Proto._buildPageSearch = function(module, page)
-{
- var fsm = module.fsm;
-
- // We need a vertical box layout for the various input fields
- var vlayout = new qx.ui.layout.VerticalBoxLayout();
- 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.setHorizontalChildrenAlign("left");
-
- // Add the label to the horizontal layout
- vlayout.add(label);
-
- // Create a combo box for entry of the search expression
- var filter = new qx.ui.form.TextField();
- filter.set({ width:300 });
- fsm.addObject("searchExpr", filter);
-
- // Add the combo box to the horizontal layout
- vlayout.add(filter);
-
- // Create a label for the list of required attributes
- var label = new qx.ui.basic.Atom("Base");
- label.setHorizontalChildrenAlign("left");
-
- // Add the label to the horizontal layout
- vlayout.add(label);
-
- // Create a combo box for entry of the search expression
- var base = new qx.ui.form.TextField();
- base.set({ width:300 });
- fsm.addObject("baseDN", base);
-
- // Add the combo box to the horizontal layout
- vlayout.add(base);
-
- // Create a label for the list of required attributes
- var label = new qx.ui.basic.Atom("Scope");
- label.setWidth(100);
- label.setHorizontalChildrenAlign("left");
-
- // 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);
-
- hlayout.add(cbScope);
-
- // Add a spacer
- hlayout.add(new qx.ui.basic.HorizontalSpacer());
-
- // 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);
-
- vlayout.add(hlayout);
-
- // Add the vlayout to the page
- page.add(vlayout);
-
- var ldifview = new swat.module.ldbbrowse.LdifViewer();
- ldifview.set({
- top: 130,
- left: 10,
- right: 10,
- bottom: 10
- });
-
- fsm.addObject("LdifView", ldifview);
-
- // Add the output area to the page
- page.add(ldifview);
-};
-
-qx.Proto._buildPageBrowse = function(module, page)
-{
- var fsm = module.fsm;
-
- // Create a horizontal splitpane for tree (left) and table (right)
- var splitpane = new qx.ui.splitpane.HorizontalSplitPane("1*", "2*");
- splitpane.setEdge(0);
-
- // We need a vertical box layout for the tree and the buttons
- var vlayout = new qx.ui.layout.VerticalBoxLayout();
- vlayout.set({
- height: "100%",
- top: 5,
- left: 5,
- right: 5,
- bottom: 5,
- spacing: 10
- });
-
- // Create the tree and set its characteristics
- var tree = new qx.ui.treevirtual.TreeVirtual(["Browse"]);
- tree.set({
- backgroundColor: 255,
- border : qx.renderer.border.BorderPresets.getInstance().thinInset,
- overflow: "hidden",
- width: "100%",
- height: "1*",
- alwaysShowOpenCloseSymbol: true
- });
-
- // We've only got one column, so we don't need cell focus indication.
- tree.setCellFocusAttributes({ backgroundColor : "transparent" });
-
- // Get the data model
- var dataModel = tree.getDataModel();
-
- // Add the database file as the first node
- dataModel.addBranch(null, module.dbFile, false);
-
- // We're finished adding nodes.
- dataModel.setData();
-
- // Create event listeners
- tree.addEventListener("treeOpenWhileEmpty", fsm.eventListener, fsm);
- tree.addEventListener("changeSelection", fsm.eventListener, fsm);
-
- // We'll be receiving events on the tree object, so save its friendly name,
- // and cause the tree to be disabled during remote procedure calls.
- fsm.addObject("tree", tree, "swat.main.fsmUtils.disable_during_rpc");
-
- // Add the tree to the vlayout.
- vlayout.add(tree);
-
- // Add an horizonatl layout for the "New" and "Modify" buttons
- // We need a vertical box layout for the tree and the buttons
- var hlayout = new qx.ui.layout.HorizontalBoxLayout();
- hlayout.set({
- height: "auto",
- spacing: 10
- });
-
- // Add the "New" button
- this._newb = new qx.ui.form.Button("New");
- this._newb.addEventListener("execute", this._switchToNewrecord, this);
-
- // Add the button to the hlayout
- hlayout.add(this._newb);
-
- // Add the "New" button
- this._modb = new qx.ui.form.Button("Modify");
- this._modb.addEventListener("execute", this._switchToModrecord, this);
-
- // Add the button to the hlayout
- hlayout.add(this._modb);
-
- hlayout.add(new qx.ui.basic.HorizontalSpacer());
-
- // Add the "Delete" button
- this._delb = new qx.ui.form.Button("Delete");
- this._delb.addEventListener("execute", this._confirmDeleteRecord, this);
-
- // Add the button to the hlayout
- hlayout.add(this._delb);
-
- // Add the hlayout to the vlayout.
- vlayout.add(hlayout);
-
- //Add the left vlayout to the splitpane
- splitpane.addLeft(vlayout);
-
- // Create a simple table model
- var tableModel = new qx.ui.table.SimpleTableModel();
- tableModel.setColumns([ "Attribute", "Value" ]);
-
- tableModel.setColumnEditable(0, false);
- tableModel.setColumnEditable(1, false);
- fsm.addObject("tableModel:browse", tableModel);
-
- // Create a table
- this._table = new qx.ui.table.Table(tableModel);
- this._table.set({
- top: 10,
- left: 0,
- right: 0,
- bottom: 10,
- statusBarVisible: false,
- columnVisibilityButtonVisible: false
- });
- this._table.setColumnWidth(0, 180);
- this._table.setColumnWidth(1, 320);
- this._table.setMetaColumnCounts([1, -1]);
- fsm.addObject("table:browse", this._table);
-
- //table.setDisplay(false);
-
- // Add the table to the bottom portion of the splitpane
- splitpane.addRight(this._table);
-
- // Build the create/modify widget
- this._ldbmod = new swat.module.ldbbrowse.LdbModify(fsm);
- this._ldbmod.set({
- top: 10,
- left: 0,
- right: 0,
- bottom: 10
- });
- // Not displayed by default
- this._ldbmod.setDisplay(false);
-
- fsm.addObject("ldbmod", this._ldbmod);
-
- splitpane.addRight(this._ldbmod);
-
- // Add the first splitpane to the page
- page.add(splitpane);
-};
-
-qx.Proto._switchToNormal = function()
-{
- this._table.setDisplay(true);
- this._ldbmod.setDisplay(false);
- this._newb.setEnabled(true);
- this._modb.setEnabled(true);
- this._delb.setEnabled(true);
-};
-
-qx.Proto._switchToNewrecord = function()
-{
- this._table.setDisplay(false);
- this._ldbmod.setDisplay(true);
- this._newb.setEnabled(false);
- this._modb.setEnabled(false);
- this._delb.setEnabled(false);
- this._ldbmod.initNew(this._switchToNormal, this);
-};
-
-qx.Proto._switchToModrecord = function()
-{
- this._table.setDisplay(false);
- this._ldbmod.setDisplay(true);
- this._newb.setEnabled(false);
- this._modb.setEnabled(false);
- this._delb.setEnabled(false);
- this._ldbmod.initMod(this._table.getTableModel(), this._switchToNormal, this);
-};
-
-qx.Proto._confirmDeleteRecord = function()
-{
-
- this._ldbmod.showConfirmDelete();
-};
-
-qx.Proto._displayModifyResults = function(module, rpcRequest)
-{
- var tree = module.fsm.getObject("tree");
- tree.createDispatchDataEvent("changeSelection", tree.getSelectedNodes());
-
- alert("Object successfully modified!");
-
- this._switchToNormal();
- //this._ldbmod.postCleanUp();
-}
-
-qx.Proto._displayAddResults = function(module, rpcRequest)
-{
- var result = rpcRequest.getUserData("result");
-
- var tree = module.fsm.getObject("tree");
- var node = tree.getSelectedNodes()[0];
-
- tree.getDataModel().prune(node.nodeId, false);
- node.bOpened = false;
- tree.toggleOpened(node);
-
- alert("Object successfully added!");
-
- this._switchToNormal();
- //this._ldbmod.postCleanUp();
-};
-
-qx.Proto._displayDeleteResults = function(module, rpcRequest, type)
-{
- var result = rpcRequest.getUserData("result");
-
- var tree = module.fsm.getObject("tree");
- var dataModel = tree.getDataModel();
- var node = dataModel.getData()[tree.getSelectedNodes()[0].parentNodeId];
-
- dataModel.prune(node.nodeId, false);
- node.bOpened = false;
- tree.toggleOpened(node);
-
- alert("Object Successfully deleted!");
-
- this._ldbmod.setBase("");
-
- // just clear the attribute/value table.
- var tableModel = module.fsm.getObject("tableModel:browse");
- tableModel.setData([]);
-};
-
-qx.Proto._displaySearchResults = function(module, rpcRequest)
-{
- var fsm = module.fsm;
-
- // Obtain the ldif object
- var ldifview = fsm.getObject("LdifView");
-
- ldifview.reset();
-
- // Obtain the result object
- result = rpcRequest.getUserData("result").data;
-
- if (result && result["length"])
- {
- len = result["length"];
- for (var i = 0; i < result["length"]; i++)
- {
- var obj = result[i];
- if (typeof(obj) != "object")
- {
- alert("Found unexpected result, type " +
- typeof(obj) +
- ", " +
- obj +
- "\n");
- continue;
- }
- ldifview.appendObject(obj);
- }
- }
- else
- {
- alert("No results.");
- }
-};
-
-
-qx.Proto._displayTreeOpenResults = function(module, rpcRequest)
-{
- var t;
- var child;
- var fsm = module.fsm;
-
- // Get the tree object
- var tree = fsm.getObject("tree");
- var dataModel = tree.getDataModel();
-
- // Obtain the result object
- var result = rpcRequest.getUserData("result").data;
-
- // We also need some of the original parameters passed to the request
- var parentNode = rpcRequest.getUserData("parentNode");
- var attributes = rpcRequest.getUserData("attributes");
-
- // Remove any existing children, they will be replaced by the result of this call (refresh)
- dataModel.setData();
-
- // Any children?
- if (! result || result["length"] == 0)
- {
- // Nope. Remove parent's expand/contract button.
- dataModel.setState(parentNode.nodeId, { bHideOpenClose : true });
- return;
- }
-
- // base object, add naming contexts to the root
- if ((result.length == 1) &&
- ((result[0]["dn"] == "") ||
- (result[0]["dn"].toLowerCase() == "cn=rootdse")))
- {
- defnc = result[0]["defaultNamingContext"];
-
- // Build a tree row for the defaultNamingContext
- if (defnc)
- {
- dataModel.addBranch(parentNode.nodeId, defnc, false);
- }
-
- var ncs = result[0]["namingContexts"];
-
- // If it's multi-valued (type is an array) we have other naming contexts
- // to show
- if (typeof(ncs) == "object")
- {
- for (var i = 0; i < ncs.length; i++)
- {
- if (ncs[i] != defnc)
- {
- //skip default naming context
- dataModel.addBranch(parentNode.nodeId, ncs[i], false);
- }
- }
- }
- }
- else
- {
- for (var i = 0; i < result.length; i++)
- {
- var name;
-
- child = result[i];
-
- name = child["dn"].split(",")[0];
-
- // Build a standard tree row
- dataModel.addBranch(parentNode.nodeId, name, false);
- }
- }
-
- // Cause the tree changes to be rendered
- dataModel.setData();
-};
-
-qx.Proto._displayLdbmodBaseChanged = function(module, rpcRequest)
-{
- var fsm = module.fsm;
-
- // Obtain the result object
- var result = rpcRequest.getUserData("result").data;
-
- // If we received an empty list, ...
- if (result == null)
- {
- // ... then ??
- return;
- }
-
- this._ldbmod.setBase(result[0]["dn"]);
-};
-
-qx.Proto._displayTreeSelectionChangedResults = function(module, rpcRequest)
-{
- var fsm = module.fsm;
-
- // Obtain the result object
- var result = rpcRequest.getUserData("result").data;
-
- var tree = fsm.getObject("tree");
- var dataModel = tree.getDataModel();
-
- // If we received an empty list, ...
- if (result == null)
- {
- // ... then just clear the attribute/value table.
- dataModel.setData([ ]);
- return;
- }
-
- // Start with an empty table dataset
- var rowData = [ ];
-
- // The result contains a single object: attributes
- var attributes = result[0];
-
- // Track the maximum length of the attribute values
- var maxLen = 0;
-
- // For each attribute we received...
- for (var attr in attributes)
- {
- // If it's multi-valued (type is an array)...
- if (typeof(attributes[attr]) == "object")
- {
- // ... then add each value with same name
- var a = attributes[attr];
- for (var i = 0; i < a.length; i++)
- {
- if (a[i].length > maxLen)
- {
- maxLen = a[i].length;
- }
- rowData.push([ attr, a[i] ]);
- }
- }
- else // single-valued
- {
- // ... add its name and value to the table dataset
- if (attributes[attr].length > maxLen)
- {
- maxLen = attributes[attr].length;
- }
- rowData.push([ attr, attributes[attr] ]);
- }
- }
-
- // Obtain the table and tableModel objects
- var table = fsm.getObject("table:browse");
- var tableModel = fsm.getObject("tableModel:browse");
-
- // Adjust the width of the value column based on maxLen
- table.setColumnWidth(1, maxLen * 7);
-
- // Add the dataset to the table
- tableModel.setData(rowData);
-};
-
-
-qx.Proto._clearAllFields = function(module, rpcRequest)
-{
- // Obtain the result object
- var result = rpcRequest.getUserData("result").data;
-
- // Retrieve the database handle
- module.dbHandle = result;
-
- // In the future, when we support more than one database, we'll want to
- // clear all fields here. For now, there's no need.
-};
-
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/LdbBrowse.js b/webapps/swat/source/class/swat/module/ldbbrowse/LdbBrowse.js
deleted file mode 100644
index 7e3f96c8b5..0000000000
--- a/webapps/swat/source/class/swat/module/ldbbrowse/LdbBrowse.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * Swat LDB Browser class
- */
-qx.OO.defineClass("swat.module.ldbbrowse.LdbBrowse",
- swat.main.AbstractModule,
-function()
-{
- swat.main.AbstractModule.call(this);
-});
-
-
-/**
- * Create the module's finite state machine and graphical user interface.
- *
- * This function is called the first time a module is actually selected to
- * appear. Creation of the module's actual FSM and GUI have been deferred
- * until they were actually needed (now) so we need to create them.
- *
- * @param module {swat.main.Module}
- * The module descriptor for the module.
- */
-qx.Proto.initialAppear = function(module)
-{
- // Initial database to open
- module.dbFile = "sam.ldb";
-
- // Replace the existing (temporary) finite state machine with the real one
- swat.module.ldbbrowse.Fsm.getInstance().buildFsm(module);
-
- // Create the real gui
- swat.module.ldbbrowse.Gui.getInstance().buildGui(module);
-
- // Force the global database to be opened
- var dbName = module.fsm.getObject("dbName");
- dbName.setSelected(dbName.getList().getFirstChild());
-};
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js b/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js
deleted file mode 100644
index aff8ec0495..0000000000
--- a/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * Copyright::
- * (C) 2006 by Simo Sorce
- *
- * License:
- * GPL v2 or later
- */
-
-/**
- * Ldb Modifier Class
- */
-
-qx.OO.defineClass("swat.module.ldbbrowse.LdbModify", qx.ui.layout.VerticalBoxLayout,
-function(fsm)
-{
- qx.ui.layout.VerticalBoxLayout.call(this);
-
- this._fsm = fsm;
-
- this._mainArea = new qx.ui.layout.VerticalBoxLayout();
- this._mainArea.set({
- overflow: "auto",
- height: "1*",
- spacing: 5
- });
-
- // Add an horizonatl layout for the "New" and "Modify" buttons
- // We need a vertical box layout for the tree and the buttons
- this._hlayout = new qx.ui.layout.HorizontalBoxLayout();
- this._hlayout.set({
- height: "auto",
- spacing: 10
- });
-
- // add a spacer to align buttons to the right
- this._leftSpacer = new qx.ui.basic.HorizontalSpacer();
-
- // Add the "Cancel" button
- this._cancelbtn = new qx.ui.form.Button("Cancel");
- this._cancelbtn.addEventListener("execute", this._cancelOp, this);
-
- // Add the "OK" button
- this._okbtn = new qx.ui.form.Button("OK");
- this._okbtn.addEventListener("execute", this._fsm.eventListener, this._fsm);
-
- // We'll be receiving events on the object, so save its friendly name
- this._fsm.addObject("commit", this._okbtn, "swat.main.fsmUtils.disable_during_rpc");
-
- // Add the buttons to the hlayout
- this._hlayout.add(this._leftSpacer, this._cancelbtn, this._okbtn);
-
- // Add the hlayout to the vlayout.
- this.add(this._mainArea, this._hlayout);
-
- // By default this is a new record creator
- this._type = "add";
-
- // By default this is inactive
- this._active = false;
-
- this.basedn = "";
-
- this._dmw = null;
-});
-
-qx.OO.addProperty({ name : "basedn", type : "string" });
-
-/**
- * Set the type of operation
- *
- * @param type {String}
- * A string containing "new" or "modify"
- *
- * @param data {Object}
- * An LDB object with the current object parameters
- * Used only if type = "modify"
- *
- */
-
-qx.Proto.isActive = function() {
- if (this._active == true) {
- return true;
- }
-}
-
-/**
- * Set the base of the object to add
- *
- * @param type {String}
- * A string containing the base DN
- */
-
-qx.Proto.setBase = function(base) {
-
- this.basedn = base;
-
- if (this._active) {
- if (this._type == "add") {
-
- this._basedn.setHtml(this.basedn);
- }
- }
-}
-
-qx.Proto.getBase = function() {
-
- return this.basedn;
-
-}
-
-qx.Proto.initNew = function(callback, obj) {
-
- this._setExitCallback(callback, obj);
-
- if (this.basedn == "") {
- alert("Please select the parent node in the tree first!");
- this._callExitCallback();
- return;
- }
-
- this._active = true;
- this._type = "add";
-
- var hlayout = new qx.ui.layout.HorizontalBoxLayout();
- hlayout.set({ height: "auto", spacing: 10 });
-
- var dnlabel = new qx.ui.basic.Label("DN: ");
-
- // The name of the new/modified object
- // TODO: add validator
- this._rdn = new qx.ui.form.TextField("");
- this._rdn.setWidth(128);
-
- var dnsep = new qx.ui.basic.Label(",");
-
- // The basedn of the object
- // TODO: add validator
- this._basedn = new qx.ui.basic.Label(this.basedn);
-
- hlayout.add(dnlabel, this._rdn, dnsep, this._basedn);
-
- this._mainArea.add(hlayout);
-
- this._createAttributesArea();
-
- return;
-}
-
-qx.Proto.initMod = function(tablemodel, callback, obj) {
-
- this._setExitCallback(callback, obj);
-
- if (this.basedn == "") {
- this._callExitCallback();
- return;
- }
-
- this._active = true;
- this._type = "modify";
-
- this._dn = new qx.ui.basic.Label("DN: " + this.basedn);
-
- this._mainArea.add(this._dn);
-
- this._createAttributesArea();
-
- this._modBaseHash = new Array();
-
- // for each entry in the table, add new entries in the object
- var count = tablemodel.getRowCount();
- for (var i = 0; i < count; i++) {
- var row = tablemodel.getRowData(i);
- this._addNewAttribute(row[0], row[1]);
- if (this._modBaseHash[row[0]] == null) {
- this._modBaseHash[row[0]] = new Array();
- }
- this._modBaseHash[row[0]].push(row[1]);
- }
-}
-
-qx.Proto._setExitCallback = function(vFunction, vObject) {
-
- if(typeof vFunction !== "function") {
- throw new Error("swat.module.ldbbrowse.LdbModify: setExitCallback(" + vFunction + "' is not a function!");
- }
-
- this._exitCallback = {
- handler : vFunction,
- object : vObject
- }
-}
-
-qx.Proto._callExitCallback = function() {
-
- // Shortcuts for handler and object
- vFunction = this._exitCallback.handler;
- vObject = this._exitCallback.object;
-
- // Call object function
- try
- {
- if(typeof vFunction === "function") {
- vFunction.call(qx.util.Validation.isValid(vObject) ? vObject : this);
- }
- }
- catch(ex)
- {
- this.error("swat.module.ldbbrowse.LdbModify: Could not call exit callback: ", ex);
- }
-}
-
-qx.Proto._reset = function() {
-
- // Remove existing attributes
- this._mainArea.removeAll();
- this._active = false;
- this._type = "null";
-}
-
-qx.Proto.postCleanUp = function() {
- this._reset();
-}
-
-qx.Proto._cancelOp = function() {
-
- this._reset();
- this._callExitCallback();
-}
-
-qx.Proto._addNewAttribute = function(name, value, before) {
-
- var hlayout = new qx.ui.layout.HorizontalBoxLayout();
- hlayout.set({ width: "auto", height: "auto", spacing: 10 });
-
- var aButton = new qx.ui.form.Button("+");
- aButton.set({ width: 15, height: 15});
- aButton.addEventListener("execute", function() {
- this._addNewAttribute(name, null, hlayout);
- }, this);
-
- var aNameTextField = new qx.ui.form.TextField(name);
- aNameTextField.setWidth(150);
-
- var aValTextField = new qx.ui.form.TextField(value);
- aValTextField.setWidth(250);
-
- var rButton = new qx.ui.form.Button("-");
- rButton.set({ left: 5, width: 15, height: 15});
- rButton.addEventListener("execute", function() {
- hlayout.setParent(null);
- }, this);
-
- hlayout.add(aButton, aNameTextField, aValTextField, rButton);
- hlayout.setUserData("attrName", aNameTextField);
- hlayout.setUserData("attrVal", aValTextField);
-
- if (before) {
- this._attrArea.addAfter(hlayout, before);
- } else {
- //TODO: check the same attribute is not already present, if so just add a new value instead
- this._attrArea.addBefore(hlayout, this._attrAddButton);
- }
-}
-
-qx.Proto._createAttributesArea = function() {
-
- this._attrArea = new qx.ui.layout.VerticalBoxLayout();
-
- this._attrAddButton = new qx.ui.form.Button("+");
- this._attrAddButton.set({ width: 15, height: 15});
- this._attrAddButton.addEventListener("execute", this._addNewAttribute, this);
-
- this._attrArea.add(this._attrAddButton);
-
- this._mainArea.add(this._attrArea);
-}
-
-qx.Proto.getOpType = function() {
- return this._type;
-}
-
-qx.Proto.getLdif = function() {
-
- if (this._active != true) {
- return null;
- }
-
- c = this._attrArea.getChildren();
-
- switch (this._type) {
-
- case "add":
-
- var ldif = "dn: " + this._rdn.getValue() + "," + this.basedn + "\n";
-
- for (var i = 0; i < c.length; i++) {
- if (c[i] instanceof qx.ui.layout.HorizontalBoxLayout) {
- ldif = ldif + c[i].getUserData("attrName").getComputedValue() + ": " + c[i].getUserData("attrVal").getComputedValue() + "\n";
- }
- }
- break;
-
- case "modify":
-
- var ldif = "dn: " + this.basedn + "\n";
-
- ldif = ldif + "changetype: modify\n";
-
- var submAttrs = new Array();
-
- // Build an array of the submitted data
- for (var i = 0; i < c.length; i++) {
- if (c[i] instanceof qx.ui.layout.HorizontalBoxLayout) {
-
- var attrName = c[i].getUserData("attrName").getComputedValue();
- var attrVal = c[i].getUserData("attrVal").getComputedValue();
-
- if (submAttrs[attrName] == null) {
- submAttrs[attrName] = new Array();
- }
- submAttrs[attrName].push(attrVal);
- }
- }
-
- // compare arrays and find out what changed, built an hash of the modifications
- var modAttrs = new Array();
-
- for (var i in this._modBaseHash) {
- modAttrs[i] = new Array();
- modAttrs[i][0] = "skip";
-
- if (submAttrs[i] == null) {
- modAttrs[i][0] = "delete";
- } else {
- // check if the arrays are identical
- if (this._modBaseHash[i].length <= submAttrs[i].length) {
- for (var j = 0; j < this._modBaseHash[i].length; j++) {
- for (var k = 0; k < submAttrs[i].length; k++) {
- if (this._modBaseHash[i][j] == submAttrs[i][k]) {
- break;
- }
- }
- if (k >= submAttrs[i].length) {
- modAttrs[i][0] = "replace";
- break;
- }
- }
- // if all the attributes in base hash are contained in sumbAttr
- // it means only additions were done, sort out what was addedd
- if (modAttrs[i][0] != "replace") {
- for (var j = 0; j < submAttrs[i].length; j++) {
- for (var k = 0; k < this._modBaseHash[i].length; k++) {
- if (submAttrs[i][j] == this._modBaseHash[i][k]) break;
- }
- // this element was not found in original array
- if (k >= this._modBaseHash[i].length) {
- if (modAttrs[i][0] != "add") {
- modAttrs[i][0] = "add";
- }
- modAttrs[i].push(submAttrs[i][j]);
- }
- }
- }
- } else {
- modAttrs[i] = [ "replace" ];
- }
- }
- // if they differ replace the whole content
- if (modAttrs[i][0] == "replace") {
- for (var j = 0; j < submAttrs[i].length; j++) {
- modAttrs[i].push(submAttrs[i][j]);
- }
- }
-
- // wipe out attr from sumbAttr, so that we can later found truly new attrs addedd to the array
- submAttrs[i] = null;
- }
-
- for (var i in submAttrs) {
- if (submAttrs[i] != null) {
- modAttrs[i] = new Array();
- modAttrs[i][0] = "add";
-
- for (var j = 0; j < submAttrs[i].length; j++) {
- modAttrs[i].push(submAttrs[i][j]);
- }
- }
- }
-
- //track if we did any mod at all
- var nmods = 0;
-
- for (var i in modAttrs) {
- switch (modAttrs[i][0]) {
-
- case "delete":
- nmods++;
- ldif = ldif + "delete: " + i + "\n";
- break;
-
- case "add":
- nmods++;
- ldif = ldif + "add: " + i + "\n";
- for (var j = 1; j < modAttrs[i].length; j++) {
- ldif = ldif + i + ": " + modAttrs[i][j] + "\n";
- }
- break;
-
- case "replace":
- nmods++;
- ldif = ldif + "replace: " + i + "\n";
- for (var j = 1; j < modAttrs[i].length; j++) {
- ldif = ldif + i + ": " + modAttrs[i][j] + "\n";
- }
- break;
-
- default:
- //skip
- break;
- }
- }
-
- if (nmods == 0) {
- alert("No modifications?");
- }
-
- break;
-
- default:
-
- return null;
-
- }
-
- // terminate ldif record
- ldif = ldif + "\n";
-
- return ldif;
-};
-
-qx.Proto.showConfirmDelete = function() {
-
- var main = qx.ui.core.ClientDocument.getInstance();
-
- if (this._dmw == null) {
- this._dmw = new qx.ui.window.Window("-- DELETE Object --");
- this._dmw.set({
- width: 300,
- height: 125,
- modal: true,
- centered: true,
- restrictToPageOnOpen: true,
- showMinimize: false,
- showMaximize: false,
- showClose: false,
- resizeable: false
- });
-
- var warningLabel = new qx.ui.basic.Label("Error Dialog not initialized!");
- this._dmw.add(warningLabel);
- this._dmw.setUserData("label", warningLabel);
-
- var cancelButton = new qx.ui.form.Button("Cancel");
- cancelButton.addEventListener("execute", function() {
- this._dmw.close();
- }, this);
- cancelButton.set({ top: 45, left: 32 });
- this._dmw.add(cancelButton);
-
- this._dmw.addEventListener("appear",function() {
- cancelButton.focus();
- }, this._dmw);
-
- main.add(this._dmw);
- var okButton = new qx.ui.form.Button("OK");
- okButton.addEventListener("execute", function() {
- this._dmw.close();
- }, this);
- // We'll be receiving events on the object, so save its friendly name
- this._fsm.addObject("delete", okButton, "swat.main.fsmUtils.disable_during_rpc");
- okButton.addEventListener("execute", this._fsm.eventListener, this._fsm);
-
- okButton.set({ top: 45, right: 32 });
- this._dmw.add(okButton);
-
- main.add(this._dmw);
- }
-
- var label = this._dmw.getUserData("label");
-
- label.setHtml("<pre>Do you really want to delete\n" + this.basedn + " ?</pre>");
-
- this._dmw.open();
-};
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/LdifViewer.js b/webapps/swat/source/class/swat/module/ldbbrowse/LdifViewer.js
deleted file mode 100644
index 5732b9427f..0000000000
--- a/webapps/swat/source/class/swat/module/ldbbrowse/LdifViewer.js
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright::
- * (C) 2006 by Simo Sorce
- *
- * License:
- * GPL v2 or later
- */
-
-/**
- * Ldif Viewer Class
- */
-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.addProperty({ name : "innerText", type : "string" });
-
-qx.Proto._update = function() {
- this.setHtml("<pre>" + this.innerText + "</pre>");
-}
-
-/**
- * Reset the ldif contents and return to an empty page
- */
-qx.Proto.reset = function() {
- this.innerText = "";
- this.setHtml("");
-}
-
-/**
- * Add a comment to the ldif output
- *
- * @param aText {String}
- * A string to show up as an ldif Comment
- */
-qx.Proto.appendComment = function(aText) {
- this.innerText = this.innerText + "# " + a Text + "\n\n";
- this._update();
-}
-
-/**
- * Append an object to be shown
- *
- * @param o {Object}
- * An Object returned by an ldb search
- */
-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();
-}
diff --git a/webapps/swat/source/class/swat/module/netmgr/Fsm.js b/webapps/swat/source/class/swat/module/netmgr/Fsm.js
deleted file mode 100644
index c2e499a18f..0000000000
--- a/webapps/swat/source/class/swat/module/netmgr/Fsm.js
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) Rafal Szczesniak 2007
- */
-
-/**
- * Swat Net Manager class finite state machine
- */
-qx.OO.defineClass("swat.module.netmgr.Fsm", swat.main.AbstractModuleFsm,
-function()
-{
- swat.main.AbstractModuleFsm.call(this);
-});
-
-
-qx.Proto.buildFsm = function(module)
-{
- var fsm = module.fsm;
- var _this = this;
-
- /*
- * State: Idle
- *
- * Actions upon entry
- * - if returning from RPC, display the result
- *
- * Transition on:
- * "changeselection" on tree
- */
- var state = new qx.util.fsm.State(
- "State_Idle",
- {
- "onentry" :
- function(fsm, event)
- {
- if (fsm.getPreviousState() == "State_AwaitRpcResult")
- {
- var rpcRequest = _this.popRpcRequest();
- var result = rpcRequest.getUserData("result");
- var origins = swat.main.AbstractModuleFsm.JsonRpc_Origin;
- var serverErrors = swat.main.AbstractModuleFsm.JsonRpc_ServerError;
-
- if (result.type == "failed" &&
- result.data.origin == origins.Server &&
- result.data.code == serverErrors.ResourceError)
- {
- alert("Error when receiving rpc: '" + result.id + "'" + " exception: " + result.data);
- }
- else
- {
- // get the result of the call and apply it
- var gui = swat.module.netmgr.Gui.getInstance();
- gui.displayData(module, rpcRequest);
- }
-
- rpcRequest.request.dispose();
- rpcRequest.request = null;
- }
- },
-
- "events" :
- {
- "appear" :
- {
- "swat.main.canvas" :
- "Transition_Idle_to_AwaitRpcResult_via_canvas_appear",
- "vlayout":
- "Transition_Idle_to_AwaitRpcResult_via_vlayout_appear"
- },
-
- "changeSelection" :
- {
- "tree" :
- "Transition_Idle_to_Idle_via_tree_selection_changed"
- },
-
- "changeSelected":
- {
- // this one is dispatched from UsersView widget
- "domainName":
- "Transition_Idle_to_AwaitRpcResult_via_domainName_changed"
- },
-
- "changeNetCtx" :
- {
- "swat.module.netmgr.Gui" :
- "Transition_Idle_to_AwaitRpcResult_via_netCtx_changed"
- }
- }
- });
-
- // Replace the initial Idle state with this one
- fsm.replaceState(state, true);
-
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_canvas_appear",
- {
- "nextState" : "State_AwaitRpcResult",
-
- "ontransition" : function(fsm, event)
- {
- // Create default NetContext
- var request = _this.callRpc(fsm, "samba.ejsnet", "NetContext", []);
- request.setUserData("requestType", "NetContext");
- }
- });
-
- // Add the new transition
- state.addTransition(trans);
-
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_vlayout_appear",
- {
- "nextState" : "State_AwaitRpcResult",
-
- "ontransition" :
- function(fsm, event)
- {
- // Request our netbios name to add proper node to the tree
- var request = _this.callRpc(fsm, "samba.config", "lp_get", [ "netbios name" ]);
- request.setUserData("requestType", "hostname");
- }
- });
-
- // Add the new transition
- state.addTransition(trans);
-
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_Idle_via_tree_selection_changed",
- {
- "nextState" : "State_Idle",
-
- "ontransition" : function(fsm, event)
- {
- var nodes = event.getData();
- var selectedNode = nodes[0];
-
- var gui = swat.module.netmgr.Gui.getInstance();
- var parentNode = gui.getParentNode(module, selectedNode);
-
- // Change current NetContext if necessary for this host
- if (parentNode.netCtx != undefined)
- {
- module.setNetCtx(parentNode.netCtx);
- }
-
- var domainName = parentNode.label;
- var nodeName = selectedNode.label;
-
- switch (nodeName)
- {
- case "Users":
- gui.openUserManager(module, domainName);
- break;
-
- case "Groups":
- case "Domain":
- case "Services":
- alert("View not implemented yet");
- break;
-
- default:
- alert("Undefined call selected for node=['" + nodeName + "']");
- }
- }
-
- });
-
- // Add the new transition
- state.addTransition(trans);
-
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_domainName_changed",
- {
- "nextState" : "State_AwaitRpcResult",
-
- "ontransition" : function(fsm, event)
- {
- var domainName = fsm.getObject("domainName").getValue();
- var netCtxId = swat.module.netmgr.Gui.getInstance().getNetCtx();
-
- var req = _this.callRpc(fsm, "samba.ejsnet", "UserMgr", [ netCtxId, domainName ]);
- req.setUserData("requestType", "UserMgr");
- }
- });
-
- // Add the new transition
- state.addTransition(trans);
-
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_netCtx_changed",
- {
- "nextState" : "State_AwaitRpcResult",
-
- "ontransition" : function(fsm, event)
- {
- var netCtxId = swat.module.netmgr.Gui.getInstance().getNetCtx();
-
- var req = _this.callRpc(fsm, "samba.ejsnet", "NetContextCreds", [ netCtxId ]);
- req.setUserData("requestType", "NetContextCreds");
- }
- });
-
- state.addTransition(trans);
-
- blockedEvents =
- {
- "appear":
- {
- "tree" : qx.util.fsm.FiniteStateMachine.EventHandling.BLOCKED,
- "vlayout" : qx.util.fsm.FiniteStateMachine.EventHandling.BLOCKED
- }
- }
-
- // Add blocked events
- this.addAwaitRpcResultState(module, blockedEvents);
-
-};
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/module/netmgr/Gui.js b/webapps/swat/source/class/swat/module/netmgr/Gui.js
deleted file mode 100644
index ee366e69a5..0000000000
--- a/webapps/swat/source/class/swat/module/netmgr/Gui.js
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright (C) Rafal Szczesniak 2007
- */
-
-
-/**
- * Swat Net Manager class graphical user interface
- */
-qx.OO.defineClass("swat.module.netmgr.Gui", qx.core.Target,
-function()
-{
- qx.core.Target.call(this);
-});
-
-
-//qx.OO.addProperty({ name : "_tree", type : "object" });
-//qx.OO.addProperty({ name : "_panel", type : "object" });
-//qx.OO.addProperty({ name : "_txtDomain", type : "object" });
-//qx.OO.addProperty({ name : "_txtUsername", type : "object" });
-
-/* NetContex resource number assigned on the server side.
- Necessary for every ejsnet call */
-qx.OO.addProperty({ name : "netCtx", type : "number" });
-
-
-qx.Proto.buildGui = function(module)
-{
- var fsm = module.fsm;
-
- // Main layout composing the whole form
- var vlayout = new qx.ui.layout.VerticalBoxLayout();
- vlayout.set({
- top: 10,
- left: 10,
- right: 10,
- bottom: 20
- });
-
- // Horizontal layout holding TreeView and a "panel" for ListView
- var hlayout = new qx.ui.layout.HorizontalBoxLayout();
- hlayout.set({
- top: 0,
- left: 0,
- right: 0,
- height: "80%"
- });
-
- // Create a hosts tree
- this._tree = new qx.ui.treevirtual.TreeVirtual(["Hosts"]);
- var tree = this._tree;
-
- // Set the tree's properties
- tree.set({
- backgroundColor: 255,
- border: qx.renderer.border.BorderPresets.getInstance().thinInset,
- overflow: "hidden",
- width: "20%",
- height: "100%",
- alwaysShowOpenCloseSymbol: true
- });
-
- tree.setCellFocusAttributes({ backgroundColor : "transparent" });
-
- // Create event listener
- tree.addEventListener("appear", fsm.eventListener, fsm);
-
- // Give a tree widget nicer name to handle
- fsm.addObject("tree", tree, "swat.main.fsmUtils.disable_during_rpc");
-
- // "Panel" for list view
- this._panel = new qx.ui.layout.VerticalBoxLayout();
- var panel = this._panel;
-
- // TODO: Find out what's causing this bug - specifying 'width' works fine,
- // but setting 'right' instead does not which makes impossible to position
- // the panel against right boundary of a box
- panel.set({
- top: 0,
- left: 10,
- width:"80%",
- height: "100%"
- });
-
- // Add the tree view and panel for list view to the layout
- hlayout.add(tree);
- hlayout.add(panel);
-
- // Status layout containing informative labels and status information
- var statusLayout = new qx.ui.layout.HorizontalBoxLayout();
- statusLayout.set({
- top: 10,
- left: 0,
- width: "100%",
- height: "20%"
- });
-
- // First "column" of status fields
- var colALayout = new qx.ui.layout.VerticalBoxLayout();
- colALayout.set({
- top: 0,
- left: 0,
- width: "25%",
- height: "100%"
- });
-
- // Domain name (credentials) - label and text box
- var statusDomain = new qx.ui.layout.HorizontalBoxLayout();
- statusDomain.set({ top: 0, left: 0, width: "100%", height: "auto",
- verticalChildrenAlign: "middle" });
-
- var lblDomain = new qx.ui.basic.Atom();
- lblDomain.setLabel("Domain:");
- lblDomain.set({ width: 70, right: 5, horizontalChildrenAlign: "right" });
-
- var txtDomain = new qx.ui.form.TextField();
- txtDomain.set({ width: 80, readOnly: true });
- this._txtDomain = txtDomain;
-
- statusDomain.add(lblDomain);
- statusDomain.add(txtDomain);
-
- // Username (credentials) - label and text box
- var statusUsername = new qx.ui.layout.HorizontalBoxLayout();
- statusUsername.set({ top: 0, left: 0, width: "100%", height: "auto",
- verticalChildrenAlign: "middle" });
-
- var lblUsername = new qx.ui.basic.Atom();
- lblUsername.setLabel("Username:");
- lblUsername.set({ width: 70, right: 5, horizontalChildrenAlign: "right" });
-
- var txtUsername = new qx.ui.form.TextField();
- txtUsername.set({ width: 80, readOnly: true });
- this._txtUsername = txtUsername;
-
- statusUsername.add(lblUsername);
- statusUsername.add(txtUsername);
-
- colALayout.add(statusDomain);
- colALayout.add(statusUsername);
-
- statusLayout.add(colALayout);
-
- vlayout.add(hlayout);
- vlayout.add(statusLayout);
-
- vlayout.addEventListener("appear", fsm.eventListener, fsm);
- fsm.addObject("vlayout", vlayout);
-
- // place everything on canvas
- module.canvas.add(vlayout);
-
- // Add event handler to netCtx property change
- this.addEventListener("changeNetCtx", fsm.eventListener, fsm);
- fsm.addObject("swat.module.netmgr.Gui", this);
-};
-
-
-qx.Proto.displayData = function(module, rpcRequest)
-{
- var gui = module.gui;
- var fsm = module.fsm;
- var result = rpcRequest.getUserData("result");
- var requestType = rpcRequest.getUserData("requestType");
-
- // Something went wrong
- if (result.type == "failed")
- {
- alert("Async(" + result.id + ") exception: " + result.data);
- return;
- }
-
- switch (requestType)
- {
- case "hostname":
- // Add local host node
- this._addHostNode(module, rpcRequest, true);
- break;
-
- case "NetContext":
- this._initNetContext(module, rpcRequest);
- break;
-
- case "NetContextCreds":
- this._updateNetContextCreds(module, rpcRequest);
- break;
-
- case "UserMgr":
- this._initUserManager(module, rpcRequest);
- break;
- }
-
- qx.ui.core.Widget.flushGlobalQueues();
-};
-
-
-qx.Proto.getParentNode = function(module, node)
-{
- var tree = this._tree;
- var nodes = tree.getTableModel().getData();
- if (nodes == undefined)
- {
- return undefined;
- }
-
- if (node.parentNodeId == 0)
- {
- // there is no parent node
- return node;
- }
-
- var parentNode = nodes[node.parentNodeId];
- return parentNode;
-};
-
-
-qx.Proto.openUserManager = function(module, domainName)
-{
- // Remove existing panel if there is any - there can be only one at the time
- if (this._panel.hasChildren())
- {
- this._panel.removeAll();
- }
-
- // Create user view, pass the context and the view to the panel
- var view = new swat.module.netmgr.UsersView(module.fsm, domainName);
- this._panel.add(view);
-};
-
-
-qx.Proto._addHostNode = function(module, rpcRequest, local)
-{
- var fsm = module.fsm;
- var hostname = rpcRequest.getUserData("result").data;
-
- // Get the tree widget
- var tree = this._tree;
- var dataModel = tree.getDataModel();
-
- // Add new host and its service leaves
- var hostNodeId = dataModel.addBranch(null, hostname, false);
-
- var domainNodeId = dataModel.addLeaf(hostNodeId, "Domain", false);
- var usersNodeId = dataModel.addLeaf(hostNodeId, "Users", false);
- var groupsNodeId = dataModel.addLeaf(hostNodeId, "Groups", false);
- var srvcsNodeId = dataModel.addLeaf(hostNodeId, "Services", false);
-
- dataModel.setData();
- tree.addEventListener("changeSelection", fsm.eventListener, fsm);
-
- var hostNode = dataModel.getData()[hostNodeId];
-
- // Set host-specific properties
- hostNode.netCtx = undefined;
- hostNode.local = local;
-};
-
-
-qx.Proto._initNetContext = function(module, rpcRequest)
-{
- // Gather obtained NetContext handle
- var result = rpcRequest.getUserData("result").data;
- this.setNetCtx(result);
-};
-
-
-qx.Proto._updateNetContextCreds = function(module, rpcRequest)
-{
- // Get requested credentials from the current NetContext
- var result = rpcRequest.getUserData("result").data;
- this._txtUsername.setValue(result.username);
- this._txtDomain.setValue(result.domain);
-};
-
-
-qx.Proto._initUserManager = function(module, rpcRequest)
-{
- // Get obtained usrCtx handle
- var usrCtx = rpcRequest.getUserData("result").data;
-};
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/module/netmgr/NetManager.js b/webapps/swat/source/class/swat/module/netmgr/NetManager.js
deleted file mode 100644
index cdb9ba4515..0000000000
--- a/webapps/swat/source/class/swat/module/netmgr/NetManager.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) Rafal Szczesniak 2007
- */
-
-/**
- * Swat Net Manager class
- */
-qx.OO.defineClass("swat.module.netmgr.NetManager",
- swat.main.AbstractModule,
-function()
-{
- swat.main.AbstractModule.call(this);
-});
-
-
-qx.Proto.initialAppear = function(module)
-{
- // Replace the existing (temporary) finite state machine with the real one
- swat.module.netmgr.Fsm.getInstance().buildFsm(module);
-
- // Create the real gui
- swat.module.netmgr.Gui.getInstance().buildGui(module);
-};
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/module/netmgr/UsersView.js b/webapps/swat/source/class/swat/module/netmgr/UsersView.js
deleted file mode 100644
index a54bbf570f..0000000000
--- a/webapps/swat/source/class/swat/module/netmgr/UsersView.js
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) Rafal Szczesniak 2007
- */
-
-//qx.OO.addProperty({ name: "_fsm", type: "object"});
-//qx.OO.addProperty({ name: "_columns", type: "object"});
-//qx.OO.addProperty({ name: "_items", type: "object"});
-//qx.OO.addProperty({ name: "_view", type: "object" });
-
-/**
- * Users View
- */
-qx.OO.defineClass("swat.module.netmgr.UsersView", qx.ui.layout.HorizontalBoxLayout,
-function(fsm, domainName)
-{
- qx.ui.layout.HorizontalBoxLayout.call(this);
-
- this._fsm = fsm;
-
- // Set the whole view panel size and spacing between boxes
- this.set({ top: 0, left: 0, width: "100%", height: "100%" });
- this.setSpacing(5);
-
- // Provide vertical positioning of combo box and list view
- var innerBox = new qx.ui.layout.VerticalBoxLayout();
- innerBox.set({ top: 0, left: 0, width: "100%", height: "100%"});
-
- // horizontal box for domain selection label and combo box
- var selectDomainBox = new qx.ui.layout.HorizontalBoxLayout();
- selectDomainBox.set({ top: 0, left: 0, width: "auto", height: "10%" });
- selectDomainBox.setVerticalChildrenAlign("middle");
- selectDomainBox.setSpacing(5);
-
- // Setup domain selection combo box
- var lblDomain = new qx.ui.basic.Atom("Domain:");
- lblDomain.setHorizontalChildrenAlign("right");
-
- var cmbDomain = new qx.ui.form.ComboBox();
- cmbDomain.setEditable(false);
-
- // there's always BUILTIN domain so add it to the list
- var item = new qx.ui.form.ListItem("BUILTIN");
- cmbDomain.add(item);
-
- var selectedItem = undefined;
-
- // Simply add the domain name if it is passed as a string
- if (typeof(domainName) == "string")
- {
- item = new qx.ui.form.ListItem(domainName);
- cmbDomain.add(item);
-
- selectedItem = item;
- }
- else // if it's not a string we assume it is a list of strings
- {
- for (var s in domainName)
- {
- item = new qx.ui.form.ListItem(s);
- cmbDomain.add(s);
- }
-
- selectedItem = new qx.ui.form.ListItem(domainName[0]);
- }
-
- // Add event handling
- cmbDomain.addEventListener("changeSelected", fsm.eventListener, fsm);
- fsm.addObject("domainName", cmbDomain);
-
- // Set default selection and dispatch the respective event to initialise the view
- cmbDomain.setSelected(selectedItem);
-
- // Create an empty list view with sample column
- this._columns = { username : { label: "Username", width: 150, type: "text" }};
- this._items = [];
- this._view = new qx.ui.listview.ListView(this._items, this._columns);
- var view = this._view;
- view.set({ top: 0, left: 0, width: "90%", height: "90%" });
- view.setBorder(qx.renderer.border.BorderPresets.getInstance().shadow);
-
- // Arrange widgets and boxes
- selectDomainBox.add(lblDomain);
- selectDomainBox.add(cmbDomain);
-
- innerBox.add(selectDomainBox);
- innerBox.add(view);
-
- // place the inner box in the UsersView box
- this.add(innerBox);
-});
-
-
-// UsrMgr context is required for any operation on user accounts
-qx.OO.addProperty({ name : "usrCtx", type : "number" });
-
-
-qx.Proto.refreshView = function()
-{
-}
-
-
-qx.Proto._initUserManager = function(module, rpcRequest)
-{
- // Get obtained UsrCtx handle
- var usrCtx = rpcRequest.getUserData("result").data;
-};
diff --git a/webapps/swat/source/class/swat/module/statistics/Fsm.js b/webapps/swat/source/class/swat/module/statistics/Fsm.js
deleted file mode 100644
index c23cfb0feb..0000000000
--- a/webapps/swat/source/class/swat/module/statistics/Fsm.js
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * Swat statistics class finite state machine
- */
-qx.OO.defineClass("swat.module.statistics.Fsm", swat.main.AbstractModuleFsm,
-function()
-{
- swat.main.AbstractModuleFsm.call(this);
-});
-
-
-/**
- * Start the redisplay timer.
- *
- * @param fsm {qx.util.fsm.FiniteStateMachine}
- * The finite state machine in use by this module
- *
- * @param msInterval {Integer}
- * The number of milliseconds before the timer should expire
- */
-qx.Class._startTimer = function(fsm, msInterval)
-{
-
- // First, for good house keeping, ensure no timer exists
- swat.module.statistics.Fsm._stopTimer(fsm);
-
- // Create a timer instance to expire in the specified amount of time
- var timer = new qx.client.Timer(msInterval);
- timer.addEventListener("interval", fsm.eventListener, fsm);
- fsm.addObject("timer", timer);
- timer.start();
-};
-
-
-/**
- * Stop the redisplay timer.
- *
- * @param fsm {qx.util.fsm.FiniteStateMachine}
- * The finite state machine in use by this module
- */
-qx.Class._stopTimer = function(fsm)
-{
- // ... then stop the timer. Get the timer object.
- var timer = fsm.getObject("timer");
-
- // If it still exists...
- if (timer)
- {
- // ... then dispose of it.
- timer.dispose();
- fsm.removeObject("timer");
- }
-};
-
-
-qx.Proto.buildFsm = function(module)
-{
- var fsm = module.fsm;
- var _this = this;
- var _module = module;
-
- /*
- * State: Idle
- *
- * Actions upon entry
- * - if returning from RPC, display the result
- * - start an interval timer to request statistics again in a while
- *
- * Transition on:
- * "interval" on interval_timer
- */
- var state = new qx.util.fsm.State(
- "State_Idle",
- {
- "onentry" :
- function(fsm, event)
- {
- // Did we just return from an RPC request?
- if (fsm.getPreviousState() == "State_AwaitRpcResult")
- {
- // Yup. Display the result. We need to get the request object
- var rpcRequest = _this.popRpcRequest();
-
- // Display the result
- var gui = swat.module.statistics.Gui.getInstance();
- gui.displayData(module, rpcRequest.getUserData("result"));
-
- // Dispose of the request
- rpcRequest.request.dispose();
- rpcRequest.request = null;
-
- // Restart the timer.
- if (_module.visible)
- {
- // Give it a reasonable interval before we redisplay
- swat.module.statistics.Fsm._startTimer(fsm, 5000);
- }
- }
- },
-
- "onexit" :
- function(fsm, event)
- {
- // If we're not coming right back into this state...
- if (fsm.getNextState() != "State_Idle")
- {
- // ... then stop the timer.
- swat.module.statistics.Fsm._stopTimer(fsm);
- }
- },
-
- "events" :
- {
- // If the timer expires, send a new statistics request
- "interval" :
- {
- "timer" :
- "Transition_Idle_to_AwaitRpcResult_via_request_statistics"
- },
-
- // When we get an appear event, start our timer
- "appear" :
- {
- "swat.main.canvas" :
- "Transition_Idle_to_Idle_via_appear"
- },
-
- // When we get a disappear event, stop our timer
- "disappear" :
- {
- "swat.main.canvas" :
- "Transition_Idle_to_Idle_via_disappear"
- }
- }
- });
-
- // Replace the initial Idle state with this one
- fsm.replaceState(state, true);
-
- /*
- * Transition: Idle to AwaitRpcResult
- *
- * Cause: "interval" on timer
- *
- * Action:
- * Issue a Get Statistics request
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_AwaitRpcResult_via_request_statistics",
- {
- "nextState" :
- "State_AwaitRpcResult",
-
- "ontransition" :
- function(fsm, event)
- {
- // Issue a Get Statistics call
- _this.callRpc(fsm,
- "samba.management",
- "get_statistics",
- [ true, true ]);
- }
- });
- state.addTransition(trans);
-
- /*
- * Transition: Idle to Idle
- *
- * Cause: "appear" on canvas
- *
- * Action:
- * Start our timer
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_Idle_via_appear",
- {
- "nextState" :
- "State_Idle",
-
- "ontransition" :
- function(fsm, event)
- {
- _module.visible = true;
-
- // Redisplay immediately
- swat.module.statistics.Fsm._startTimer(fsm, 0);
- }
- });
- state.addTransition(trans);
-
- /*
- * Transition: Idle to Idle
- *
- * Cause: "disappear" on canvas
- *
- * Action:
- * Stop our timer
- */
- var trans = new qx.util.fsm.Transition(
- "Transition_Idle_to_Idle_via_disappear",
- {
- "nextState" :
- "State_Idle",
-
- "ontransition" :
- function(fsm, event)
- {
- _module.visible = false;
- swat.module.statistics.Fsm._stopTimer(fsm);
- }
- });
- state.addTransition(trans);
-
- // Add the AwaitRpcResult state and all of its transitions
- this.addAwaitRpcResultState(module);
-};
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/module/statistics/Gui.js b/webapps/swat/source/class/swat/module/statistics/Gui.js
deleted file mode 100644
index bad55b71c0..0000000000
--- a/webapps/swat/source/class/swat/module/statistics/Gui.js
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * Swat statistics class graphical user interface
- */
-qx.OO.defineClass("swat.module.statistics.Gui", qx.core.Object,
-function()
-{
- qx.core.Object.call(this);
-});
-
-
-/*
- * The result of our request for statistics is in this form:
- *
- * rpc: Object
- * status: INACTIVE
- * smb: Object
- * tcons: Array
- * 0: Object
- * share_name: tmp
- * last_use_time: 1167186771
- * client_ip: 127.0.0.1
- * tid: 10928
- * connect_time: 1167186757
- * connections: 1
- * sessions: Array
- * 0: Object
- * auth_time: 1167186757
- * vuid: 24588
- * last_use_time: 1167186771
- * client_ip: 127.0.0.1
- * connect_time: 1167186757
- * account_name: Administrator
- * domain_name: WORKGROUP
- * status: RUNNING
- * ldap: Object
- * status: INACTIVE
- * wins: Object
- * status: DISABLED
- * nbt: Object
- * status: RUNNING
- * statistics: Object
- * total_received: 32
- * total_sent: 4
- * query_count: 0
- * release_count: 0
- * register_count: 0
- * kdc: Object
- * status: INACTIVE
- * cldap: Object
- * status: RUNNING
- */
-
-/**
- * Build the raw graphical user interface.
- */
-qx.Proto.buildGui = function(module)
-{
- var o;
- var fsm = module.fsm;
- var canvas = module.canvas;
-
- canvas.setOverflow("auto");
-
- // Create a gui object where we'll put each widget handle that has varying
- // data to be displayed.
- module.gui = { };
-
- var addCaptionedText = function(caption, dest)
- {
- // Add a row to the destination grid
- dest.addRow();
- var row = dest.getRowCount() - 1;
- dest.setRowHeight(row, 16);
-
- // Add the caption
- var o = new qx.ui.basic.Label(caption);
- dest.add(o, 0, row);
-
- // Add the text field that will contain varying data
- o = new qx.ui.basic.Label("");
- dest.add(o, 1, row);
-
- // Give 'em the varying data label
- return o;
- };
-
- var addGroup = function(legend, top, height, width, left, right, dest)
- {
- // Add a groupbox
- var group = new qx.ui.groupbox.GroupBox(legend);
- group.setTop(top);
- if (left >= 0)
- {
- group.setLeft(left);
- }
- if (right >= 0)
- {
- group.setRight(right);
- }
- if (height >= 0)
- {
- group.setHeight(height);
- }
- if (typeof(width) == "string" || width >= 0)
- {
- group.setWidth(width);
- }
- group.setBackgroundColor("white");
- group.getLegendObject().setBackgroundColor("white");
-
- var grid = new qx.ui.layout.GridLayout();
- grid.setLocation(0, 0);
- grid.setDimension("100%", "100%");
- grid.setPadding(0, 0);
- grid.setRowCount(0);
- grid.setColumnCount(2);
- grid.setColumnWidth(0, 100);
- grid.setColumnWidth(1, 200);
-
- group.add(grid);
- dest.add(group);
-
- return grid;
- };
-
- // Add the RPC Service group box and its status
- var group = addGroup("RPC Service", 40, 60, "46%", 20, -1, canvas);
- module.gui.rpc =
- {
- status : addCaptionedText("Status:", group)
- };
-
- // Add the KDC Service group box and its status
- var group = addGroup("KDC Service", 40, 60, "46%", -1, 20, canvas);
- module.gui.kdc =
- {
- status : addCaptionedText("Status:", group)
- };
-
- // Add the LDAP Service group box and its status
- var group = addGroup("LDAP Service", 120, 60, "46%", 20, -1, canvas);
- module.gui.ldap =
- {
- status : addCaptionedText("Status:", group)
- };
-
- // Add the CLDAP Service group box and its status
- var group = addGroup("CLDAP Service", 120, 60, "46%", -1, 20, canvas);
- module.gui.cldap =
- {
- status : addCaptionedText("Status:", group)
- };
-
- // Add the WINS Service group box and its status
- var group = addGroup("WINS Service", 200, 60, "46%", 20, -1, canvas);
- module.gui.wins =
- {
- status : addCaptionedText("Status:", group)
- };
-
- // Add the NBT Service group box and its status, and the statistics
- var group = addGroup("NBT Service", 200, 140, "46%", -1, 20, canvas);
- module.gui.nbt =
- {
- status : addCaptionedText("Status:", group),
- total_received : addCaptionedText("Total received:", group),
- total_sent : addCaptionedText("Total sent:", group),
- query_count : addCaptionedText("Query count:", group),
- release_count : addCaptionedText("Release count:", group),
- register_count : addCaptionedText("Register count:", group)
- };
-
- // Add the SMB Service group box (sans grid) and its status
- var group = new qx.ui.groupbox.GroupBox("SMB Service");
- group.set({
- top: 360,
- height: 400,
- left: 20,
- right: 20
- });
- group.setBackgroundColor("white");
- group.getLegendObject().setBackgroundColor("white");
-
- // Create the Status block
- o = new qx.ui.basic.Label("Status:");
- o.set({
- top : 0,
- left : 0,
- width : 100
- });
- group.add(o);
-
- o = new qx.ui.basic.Label("");
- o.set({
- top : 0,
- left : 100,
- width : 200
- });
- group.add(o);
-
- // Add the status and create the table models for sessions and connections
- module.gui.smb =
- {
- status : o,
- sessions : new qx.ui.table.SimpleTableModel(),
- tcons : new qx.ui.table.SimpleTableModel()
- };
-
- // Begin the Sessions section
- o = new qx.ui.basic.Label("Sessions");
- o.set({
- top : 20,
- left : 20
- });
- group.add(o);
-
- // Set column labels
- var tableModel = module.gui.smb.sessions;
- tableModel.setColumns([
- "User",
- "Client",
- "Connected at",
- "Authenticated at",
- "Last used at",
- "VUID"
- ]);
- tableModel.setData([ ]);
-
- // Create the table for sessions
- var table = new qx.ui.table.Table(tableModel);
- table.set({
- top : 40,
- left : 20,
- right : 20,
- height : 160
- });
- table.setMetaColumnCounts([1, -1]);
- table.setStatusBarVisible(false);
- table.setColumnVisibilityButtonVisible(false);
- table.setColumnWidth(0, 260);
- table.setColumnWidth(1, 80);
- table.setColumnWidth(2, 120);
- table.setColumnWidth(3, 120);
- table.setColumnWidth(4, 120);
- table.setColumnWidth(5, 60);
-
- // Add the table to the groupbox
- group.add(table);
- canvas.add(group);
-
- // Begin the Connections section
- o = new qx.ui.basic.Label("Connections");
- o.set({
- top : 220,
- left : 20
- });
- group.add(o);
-
- // Create the table model for tcons
- var tableModel = module.gui.smb.tcons;
- tableModel.setColumns([
- "Share",
- "Client",
- "Connected at",
- "Last used at",
- "TID"
- ]);
- tableModel.setData([ ]);
-
- // Create the table for sessions
- var table = new qx.ui.table.Table(tableModel);
- table.set({
- top : 240,
- left : 20,
- right : 20,
- bottom : 20
- });
- table.setMetaColumnCounts([1, -1]);
- table.setStatusBarVisible(false);
- table.setColumnVisibilityButtonVisible(false);
- table.setColumnWidth(0, 260);
- table.setColumnWidth(1, 80);
- table.setColumnWidth(2, 120);
- table.setColumnWidth(3, 120);
- table.setColumnWidth(4, 60);
-
- // Add the table to the groupbox
- group.add(table);
- canvas.add(group);
-
-};
-
-
-/**
- * Populate the graphical user interface with the specified data
- *
- * @param module {swat.main.Module}
- * The module descriptor for the module.
- *
- * @result {Object}
- * The result returned by SAMBA to our request for statistics. We display
- * the data provided by this result.
- */
-qx.Proto.displayData = function(module, result)
-{
- var gui = module.gui;
-
- if (result.type == "failed")
- {
- // Have we already put up the FAILED message?
- if (gui.failed)
- {
- // Yup.
- gui.failed.setDisplay(true);
- return;
- }
-
- // Create a semi-transparent layover o which to display a failure message
- gui.failed = new qx.ui.layout.CanvasLayout();
- gui.failed.set({
- top: 0,
- bottom: 0,
- left: 0,
- right: 0
- });
- gui.failed.setBackgroundColor("white");
- gui.failed.setDisplay(true); // initially displayed
- gui.failed.setOpacity(0.7); // semi-transparent
-
- // Add the failure message
- var style =
- "color: red;" +
- "font-size: large;" +
- "font-weight: bold;";
- var o = new qx.ui.basic.Label("<span style='" + style + "'>" +
- "Communication with SAMBA failed!",
- "</span>");
- o.set({
- top : 0,
- left : 20
- });
- gui.failed.add(o);
-
- // Add the failed layover to the canvas
- module.canvas.add(gui.failed);
-
- return;
- }
-
- // Successful RPC request.
- // If the failure message was displayed, we no longer need it.
- if (gui.failed)
- {
- gui.failed.setDisplay(false);
- }
-
- // Create a function for formatting dates
- var dateFormat = function(unixepoch)
- {
- if (unixepoch == 0)
- {
- return "";
- }
-
- var d = new Date(unixepoch * 1000);
- return (d.getFullYear() + "-" +
- ("0" + (d.getMonth() + 1)).substr(-2) + "-" +
- ("0" + d.getDate()).substr(-2) + " " +
- ("0" + d.getHours()).substr(-2) + ":" +
- ("0" + d.getMinutes()).substr(-2));
- }
-
- // Set the status values
- gui.rpc.status.setHtml(result.data.rpc.status);
- gui.kdc.status.setHtml(result.data.kdc.status);
- gui.ldap.status.setHtml(result.data.ldap.status);
- gui.cldap.status.setHtml(result.data.cldap.status);
- gui.wins.status.setHtml(result.data.wins.status);
- gui.nbt.status.setHtml(result.data.nbt.status);
- gui.smb.status.setHtml(result.data.smb.status);
-
- // If the NBT service is running...
- if (result.data.nbt.status == "RUNNING")
- {
- // ... then output the statistics
- gui.nbt.total_received.setHtml(
- result.data.nbt.statistics.total_received.toString());
- gui.nbt.total_sent.setHtml(
- result.data.nbt.statistics.total_sent.toString());
- gui.nbt.query_count.setHtml(
- result.data.nbt.statistics.query_count.toString());
- gui.nbt.release_count.setHtml(
- result.data.nbt.statistics.release_count.toString());
- gui.nbt.register_count.setHtml(
- result.data.nbt.statistics.register_count.toString());
- }
- else
- {
- // otherwise, clear the statistics fields
- gui.nbt.total_received.setHtml("");
- gui.nbt.total_sent.setHtml("");
- gui.nbt.query_count.setHtml("");
- gui.nbt.release_count.setHtml("");
- gui.nbt.register_count.setHtml("");
- }
-
- // Initialize data for sessions list
- var rowData = [];
-
- // If there are any sessions...
- if (result.data.smb.sessions instanceof Array)
- {
- // ... then for each session...
- for (var i = 0; i < result.data.smb.sessions.length; i++)
- {
- // ... add its info to the table data
- var sess = result.data.smb.sessions[i];
- rowData.push([
- sess.account_name + "/" + sess.domain_name,
- sess.client_ip,
- dateFormat(sess.connect_time),
- dateFormat(sess.auth_time),
- dateFormat(sess.last_use_time),
- sess.vuid.toString()
- ]);
- }
- }
-
- // Whether there were sessions or not, reset the session table data
- gui.smb.sessions.setData(rowData);
-
- // Initialize data for tcons list
- var rowData = [];
-
- // If there are any tcons...
- if (result.data.smb.tcons instanceof Array)
- {
- // ... then for each tcon...
- for (var i = 0; i < result.data.smb.tcons.length; i++)
- {
- // ... add its info to the table data
- var conn = result.data.smb.tcons[i];
- rowData.push([
- conn.share_name,
- conn.client_ip,
- dateFormat(conn.connect_time),
- dateFormat(conn.last_use_time),
- conn.tid.toString()
- ]);
- }
- }
-
- // Whether there were tcons or not, reset the tcon table data
- gui.smb.tcons.setData(rowData);
-};
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/class/swat/module/statistics/Statistics.js b/webapps/swat/source/class/swat/module/statistics/Statistics.js
deleted file mode 100644
index 99528605a1..0000000000
--- a/webapps/swat/source/class/swat/module/statistics/Statistics.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright:
- * (C) 2006 by Derrell Lipman
- * All rights reserved
- *
- * License:
- * LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
- */
-
-/**
- * Swat statistics class
- */
-qx.OO.defineClass("swat.module.statistics.Statistics",
- swat.main.AbstractModule,
-function()
-{
- swat.main.AbstractModule.call(this);
-});
-
-
-/**
- * Create the module's finite state machine and graphical user interface.
- *
- * This function is called the first time a module is actually selected to
- * appear. Creation of the module's actual FSM and GUI have been deferred
- * until they were actually needed (now) so we need to create them.
- *
- * @param module {swat.main.Module}
- * The module descriptor for the module.
- */
-qx.Proto.initialAppear = function(module)
-{
- // Replace the existing (temporary) finite state machine with the real one
- swat.module.statistics.Fsm.getInstance().buildFsm(module);
-
- // Create the real gui
- swat.module.statistics.Gui.getInstance().buildGui(module);
-};
-
-
-/**
- * Singleton Instance Getter
- */
-qx.Class.getInstance = qx.lang.Function.returnInstance;
diff --git a/webapps/swat/source/index.html b/webapps/swat/source/index.html
deleted file mode 100644
index ea7bcfe871..0000000000
--- a/webapps/swat/source/index.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Swat</title>
- <script type="text/javascript" src="script/swat.js"></script>
- </head>
- <body>
- <script type="text/javascript">
-
- qx.core.Init.getInstance().setApplication(swat.main.Main);
-
- </script>
- </body>
-</html>