+ var commands = this.getCommands();
+ this.toolBarPart.add(commands["new_user"].command.getToolbarButton());
+ this.toolBarPart.add(commands["delete_user"].command.getToolbarButton());
+ this.toolBarPart.add(commands["edit_user"].command.getToolbarButton());
+ this.toolBar.setShow("icon");
+ this.loadUsersList();
+
+ var rolesApplet = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("roles").getContent();
+ rolesApplet.addListener("changeRolesList", function(e){
+ this.setRolesList(e.getData());
+ this.loadUsersList();
+ }, this);
+
+ },
+
+ loadUsersList : function(){
+ var selectionModel = this.table.getSelectionModel();
+ selectionModel.clearSelection();
+ var request = org.argeo.security.ria.SecurityAPI.getListUsersService();
+ request.addListener("completed", function(response){
+ var jSon = response.getContent();
+ var usMap = {};
+ for(var i=0;i<jSon.length;i++){
+ var user = new org.argeo.security.ria.model.User();
+ user.load(jSon[i], "json");
+ usMap[user.getName()] = user;
+ }
+ this.setUsersList(usMap);
+ }, this);
+ request.send();
+ },
+
+ /**
+ *
+ * @param {org.argeo.security.ria.model.User} userObject
+ */
+ refreshUserEntry : function(userObject){
+ var userName = userObject.getName();
+ var data = this.tableModel.getDataAsMapArray();
+ var index = 0;
+ var found = false;
+ for(index=0;index<data.length;index++){
+ if(data[index].username == userName){
+ found =true;
+ break;
+ }
+ }
+ var newRows = [{username:userName,roles:userObject.getRoles().join(",")}];
+ if(found){
+ this.tableModel.setRowsAsMapArray(newRows, index);
+ }else{
+ this.tableModel.setRowsAsMapArray(newRows, index);
+ }
+ },
+
+ _applyUsersList : function(usList){
+ var data = [];
+ qx.lang.Object.getValues(usList).forEach(function(usObject){
+ data.push([usObject.getName(), usObject.getRoles().join(",")]);
+ });
+ this.tableModel.setData(data);
+ },
+
+ applySelection : function(selectionValue, target, ignoreCase){
+ var selectionModel = this.table.getSelectionModel();
+ selectionModel.clearSelection();
+ if(!selectionValue){
+ return;
+ }
+ selectionModel.setBatchMode(true);
+ var data = this.tableModel.getData();
+ for(var i=0;i<this.tableModel.getRowCount();i++){
+ var value = this.tableModel.getRowDataAsMap(i)[target];
+ var pattern = new RegExp(selectionValue, "g"+(ignoreCase?"i":""));
+ if(pattern.test(value)){
+ selectionModel.addSelectionInterval(i, i);
+ }
+ }
+ selectionModel.setBatchMode(false);