private final void setRoles(final List<String> roleIDs) { Workbench wb = (Workbench) Registry.get(Workbench.ID); XUser admin = wb.getUser(); if (admin != null) { WPaloAdminServiceProvider.getInstance() .getRoles( admin.getSessionId(), admin, new Callback<XRole[]>(constants.loadingAllRolesFailed()) { public void onSuccess(XRole[] roles) { for (XRole role : roles) { boolean check = roleIDs.contains(role.getId()); String rightName = constants.none(); String p = role.getPermission(); if (p.equals("R")) rightName = constants.read(); else if (p.equals("W")) rightName = constants.write(); else if (p.equals("D")) rightName = constants.delete(); else if (p.equals("C")) rightName = constants.create(); else if (p.equals("G")) rightName = constants.grant(); TableItem item = new TableItem( new Object[] { check, role.getName(), rightName, translateDescription(role.getDescription()) }); item.setData(ROLE_DATA, role); rolesTable.add(item); } } }); } }
private final boolean isSelected(XUser user) { for (TableItem item : membersTable.getItems()) { XUser xu = (XUser) item.getData(MEMBER_DATA); if (xu.equals(user)) { boolean selected = false; Object colVal = item.getValue(0); if (colVal instanceof CheckBox) selected = ((CheckBox) colVal).getValue(); else if (colVal instanceof Boolean) selected = ((Boolean) colVal).booleanValue(); return selected; } } return false; }
public final boolean save(XObject input) { if (input instanceof XGroup) { XGroup group = (XGroup) input; group.clearUsers(); if (group.getId() == null) { ((GroupEditor) editor).needsUpdate = true; return true; } for (XUser user : getAllUsers()) { if (isSelected(user)) { group.addUserID(user.getId()); user.addGroupID(group.getId()); } else { group.removeUserID(user.getId()); user.removeGroupID(group.getId()); } ((GroupEditor) editor).adminController.updateUser(user); } } return true; }