First pass on perspectives
authorCharles du Jeu <charles.dujeu@gmail.com>
Tue, 15 Sep 2009 18:12:04 +0000 (18:12 +0000)
committerCharles du Jeu <charles.dujeu@gmail.com>
Tue, 15 Sep 2009 18:12:04 +0000 (18:12 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@2924 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/Perspective.js [new file with mode: 0644]
security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/RolesApplet.js [new file with mode: 0644]
security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UsersApplet.js [new file with mode: 0644]

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 (file)
index 0000000..6154dca
--- /dev/null
@@ -0,0 +1,65 @@
+/**\r
+ * IPerspective Implementation : Horizontal split pane defining two panes,\r
+ * "list" and "applet".\r
+ */\r
+/* ************************************************************************\r
+\r
+#asset(resource/org.argeo.security.ria/*)\r
+\r
+************************************************************************ */\r
+\r
+qx.Class.define("org.argeo.security.ria.Perspective", {\r
+       extend : qx.core.Object,\r
+       implement : [org.argeo.ria.components.IPerspective],\r
+\r
+       construct : function() {\r
+               this.base(arguments);\r
+       },\r
+\r
+       statics : {\r
+               LABEL : "RIA Security",\r
+               ICON : "org.argeo.security.ria/preferences-security.png"\r
+       },\r
+       \r
+\r
+       members : {\r
+\r
+               initViewPanes : function(viewsManager) {\r
+\r
+                       this._firstSplit = new qx.ui.splitpane.Pane("horizontal");\r
+                       this._secondSplit = new qx.ui.splitpane.Pane("horizontal");\r
+                       this._secondSplit.setDecorator(null);\r
+                       \r
+                       var rolesPane = new org.argeo.ria.components.ViewPane("roles", "Roles");\r
+                       viewsManager.registerViewPane(rolesPane);\r
+                       var usersPane = new org.argeo.ria.components.ViewPane("users", "Users");\r
+                       viewsManager.registerViewPane(usersPane);\r
+                       var editorPane = new org.argeo.ria.components.ViewPane("editor", "Editor");\r
+                       viewsManager.registerViewPane(editorPane);\r
+                       \r
+                       this._firstSplit.add(rolesPane, 1);\r
+                       this._firstSplit.add(this._secondSplit, 4);\r
+                       \r
+                       this._secondSplit.add(usersPane, 4);\r
+                       this._secondSplit.add(editorPane, 3);\r
+                       \r
+                       viewsManager.getViewPanesContainer().add(this._firstSplit, {flex : 1});\r
+               },\r
+\r
+               initViews : function(viewsManager) {\r
+\r
+                       var usersView = viewsManager.initIViewClass(org.argeo.security.ria.UsersApplet, "users");\r
+                       usersView.load();\r
+                       \r
+                       var rolesView = viewsManager.initIViewClass(org.argeo.security.ria.RolesApplet, "roles");\r
+                       rolesView.load();\r
+               },\r
+\r
+               remove : function(viewsManager) {\r
+                       viewsManager.getViewPaneById("applet").empty();\r
+                       viewsManager.getViewPanesContainer().remove(this.splitPane);\r
+               }\r
+\r
+       }\r
+\r
+});
\ 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 (file)
index 0000000..3d6ad86
--- /dev/null
@@ -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 (file)
index 0000000..72074cd
--- /dev/null
@@ -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