From 30d0df2528e69ed0a0f8fb873fd8d591db949697 Mon Sep 17 00:00:00 2001 From: Charles du Jeu Date: Tue, 15 Sep 2009 18:12:04 +0000 Subject: [PATCH] First pass on perspectives git-svn-id: https://svn.argeo.org/commons/trunk@2924 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../org/argeo/security/ria/Perspective.js | 65 +++++++++++ .../org/argeo/security/ria/RolesApplet.js | 83 ++++++++++++++ .../org/argeo/security/ria/UsersApplet.js | 102 ++++++++++++++++++ 3 files changed, 250 insertions(+) create mode 100644 security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/Perspective.js create mode 100644 security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/RolesApplet.js create mode 100644 security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UsersApplet.js diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/Perspective.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/Perspective.js new file mode 100644 index 000000000..6154dca55 --- /dev/null +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/Perspective.js @@ -0,0 +1,65 @@ +/** + * IPerspective Implementation : Horizontal split pane defining two panes, + * "list" and "applet". + */ +/* ************************************************************************ + +#asset(resource/org.argeo.security.ria/*) + +************************************************************************ */ + +qx.Class.define("org.argeo.security.ria.Perspective", { + extend : qx.core.Object, + implement : [org.argeo.ria.components.IPerspective], + + construct : function() { + this.base(arguments); + }, + + statics : { + LABEL : "RIA Security", + ICON : "org.argeo.security.ria/preferences-security.png" + }, + + + members : { + + initViewPanes : function(viewsManager) { + + this._firstSplit = new qx.ui.splitpane.Pane("horizontal"); + this._secondSplit = new qx.ui.splitpane.Pane("horizontal"); + this._secondSplit.setDecorator(null); + + var rolesPane = new org.argeo.ria.components.ViewPane("roles", "Roles"); + viewsManager.registerViewPane(rolesPane); + var usersPane = new org.argeo.ria.components.ViewPane("users", "Users"); + viewsManager.registerViewPane(usersPane); + var editorPane = new org.argeo.ria.components.ViewPane("editor", "Editor"); + viewsManager.registerViewPane(editorPane); + + this._firstSplit.add(rolesPane, 1); + this._firstSplit.add(this._secondSplit, 4); + + this._secondSplit.add(usersPane, 4); + this._secondSplit.add(editorPane, 3); + + viewsManager.getViewPanesContainer().add(this._firstSplit, {flex : 1}); + }, + + initViews : function(viewsManager) { + + var usersView = viewsManager.initIViewClass(org.argeo.security.ria.UsersApplet, "users"); + usersView.load(); + + var rolesView = viewsManager.initIViewClass(org.argeo.security.ria.RolesApplet, "roles"); + rolesView.load(); + }, + + remove : function(viewsManager) { + viewsManager.getViewPaneById("applet").empty(); + viewsManager.getViewPanesContainer().remove(this.splitPane); + } + + } + +}); \ No newline at end of file diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/RolesApplet.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/RolesApplet.js new file mode 100644 index 000000000..3d6ad869f --- /dev/null +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/RolesApplet.js @@ -0,0 +1,83 @@ +/** + * A simple Hello World applet for documentation purpose. + * The only associated command is the "Close" command. + */ +/* ************************************************* +#asset(resource/org.argeo.ria.sample/window-close.png) +****************************************************/ +qx.Class.define("org.argeo.security.ria.RolesApplet", +{ + extend : qx.ui.container.Composite, + implement : [org.argeo.ria.components.IView], + + construct : function(){ + this.base(arguments); + this.setLayout(new qx.ui.layout.VBox()); + }, + + properties : + { + /** + * The viewPane inside which this applet is added. + */ + view : { + init : null + }, + /** + * Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions} + */ + commands : { + init : {} + }, + viewSelection : { + nullable:false, + check:"org.argeo.ria.components.ViewSelection" + }, + instanceId : {init:""}, + instanceLabel : {init:""} + }, + + members : + { + /** + * Called at applet creation. Just registers viewPane. + * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane. + */ + init : function(viewPane){ + this.setView(viewPane); + this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId())); + this.tableModel = new qx.ui.table.model.Simple(); + this.tableModel.setColumns(["Role Name"]); + this.table = new qx.ui.table.Table(this.tableModel, { + tableColumnModel: function(obj){ + return new qx.ui.table.columnmodel.Resize(obj) + } + }); + this.table.setStatusBarVisible(false); + viewPane.add(this.table, {height:"100%"}); + + var selectionModel = this.table.getSelectionModel(); + selectionModel.addListener("changeSelection", function(){ + var ranges = selectionModel.getSelectedRanges(); + }); + }, + + /** + * Load a given row : the data passed must be a simple data array. + * @param data {Element} The text xml description. + */ + load : function(){ + var data = [["ROLE_ADMIN"],["ROLE_USER"]]; + this.tableModel.setData(data); + }, + + addScroll : function(){ + return false; + }, + + close : function(){ + return false; + } + + } +}); \ No newline at end of file diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UsersApplet.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UsersApplet.js new file mode 100644 index 000000000..72074cd15 --- /dev/null +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UsersApplet.js @@ -0,0 +1,102 @@ +/** + * A simple Hello World applet for documentation purpose. + * The only associated command is the "Close" command. + */ +/* ************************************************* +#asset(resource/org.argeo.ria.sample/window-close.png) +****************************************************/ +qx.Class.define("org.argeo.security.ria.UsersApplet", +{ + extend : qx.ui.container.Composite, + implement : [org.argeo.ria.components.IView], + + construct : function(){ + this.base(arguments); + this.setLayout(new qx.ui.layout.VBox()); + }, + + properties : + { + /** + * The viewPane inside which this applet is added. + */ + view : { + init : null + }, + /** + * Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions} + */ + commands : { + init : { + "close" : { + label : "Close", + icon : "ria/window-close.png", + shortcut : "Control+w", + enabled : true, + menu : "Applet", + toolbar : "result", + callback : function(e){ + // Call service to delete + this.getView().empty(); + }, + command : null + } + } + }, + viewSelection : { + nullable:false, + check:"org.argeo.ria.components.ViewSelection" + }, + instanceId : {init:""}, + instanceLabel : {init:""} + }, + + members : + { + /** + * Called at applet creation. Just registers viewPane. + * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane. + */ + init : function(viewPane){ + this.setView(viewPane); + this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId())); + this.tableModel = new qx.ui.table.model.Filtered(); + this.tableModel.setColumns(["username", "roles"]); + this.table = new qx.ui.table.Table(this.tableModel, { + tableColumnModel: function(obj){ + return new qx.ui.table.columnmodel.Resize(obj) + } + }); + this.table.setStatusBarVisible(false); + viewPane.add(this.table, {height:"100%"}); + }, + + /** + * Load a given row : the data passed must be a simple data array. + * @param data {Element} The text xml description. + */ + load : function(){ + var data = [["mbaudier", "ROLE_ADMIN,ROLE_USER"], ["cdujeu","ROLE_USER"]]; + this.tableModel.setData(data); + this.applyFilter("ROLE_ADMIN", "roles", true); + }, + + applyFilter : function(filterValue, target, ignoreCase){ + this.tableModel.addRegex("^((?!"+filterValue+").)*$", target, ignoreCase); + this.tableModel.applyFilters(); + }, + + resetHiddenRows : function(){ + this.tableModel.resetHiddenRows(); + }, + + addScroll : function(){ + return false; + }, + + close : function(){ + return false; + } + + } +}); \ No newline at end of file -- 2.30.2