private void unassignSelectedRoles() { List<ProxyPentahoUser> selectedUsers = usersList.getSelectedObjects(); if (selectedUsers.size() == 1) { ArrayList<ProxyPentahoRole> assignedRoles = new ArrayList<ProxyPentahoRole>(); assignedRoles.addAll( Arrays.asList(UserAndRoleMgmtService.instance().getRoles(selectedUsers.get(0)))); final List<ProxyPentahoRole> rolesToUnassign = assignedRolesList.getSelectedObjects(); assignedRoles.removeAll(rolesToUnassign); AsyncCallback<Object> callback = new AsyncCallback<Object>() { public void onSuccess(Object result) { assignedRolesList.removeObjects(rolesToUnassign); } public void onFailure(Throwable caught) { MessageDialogBox messageDialog = new MessageDialogBox( ExceptionParser.getErrorHeader(caught.getMessage()), ExceptionParser.getErrorMessage( caught.getMessage(), Messages.getString("errorUnassigningRoles")), false, false, true); //$NON-NLS-1$ messageDialog.center(); } }; UserAndRoleMgmtService.instance() .setRoles( selectedUsers.get(0), (ProxyPentahoRole[]) assignedRoles.toArray(new ProxyPentahoRole[0]), callback); } }
private boolean createRole() { if (getRoleName().trim().length() == 0) { messageDialog.setMessage(Messages.getString("invalidRoleName")); // $NON-NLS-1$ messageDialog.center(); } else { ProxyPentahoRole role = getRole(); if (role != null) { AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() { public void onSuccess(Boolean result) { okBtn.setEnabled(true); cancelBtn.setEnabled(true); roleCreated = true; hide(); } public void onFailure(Throwable caught) { messageDialog.setText(ExceptionParser.getErrorHeader(caught.getMessage())); messageDialog.setMessage( ExceptionParser.getErrorMessage( caught.getMessage(), Messages.getString("errorCreatingRole"))); // $NON-NLS-1$ messageDialog.center(); okBtn.setEnabled(true); cancelBtn.setEnabled(true); } }; okBtn.setEnabled(false); cancelBtn.setEnabled(false); UserAndRoleMgmtService.instance().createRole(role, callback); } } return roleCreated; }
private void assignSelectedUsers() { AsyncCallback<Object> callback = new AsyncCallback<Object>() { public void onSuccess(Object result) { userAssignmentsModified = true; hide(); } public void onFailure(Throwable caught) { MessageDialogBox messageDialog = new MessageDialogBox( ExceptionParser.getErrorHeader(caught.getMessage()), ExceptionParser.getErrorMessage( caught.getMessage(), Messages.getString("errorAssigningSelectedUsers")), false, false, true); //$NON-NLS-1$ messageDialog.center(); } }; UserAndRoleMgmtService.instance() .setUsers( role, accumulatedUsersList.getObjects().toArray(new ProxyPentahoUser[0]), callback); }
private void userSelectionChanged() { List<ProxyPentahoUser> selectedUsers = usersList.getSelectedObjects(); if (selectedUsers.size() == 1) { userDetailsPanel.setUser(selectedUsers.get(0)); List<ProxyPentahoRole> roleList = Arrays.asList(UserAndRoleMgmtService.instance().getRoles(selectedUsers.get(0))); assignedRolesList.setObjects(roleList); } else { userDetailsPanel.setUser(null); List<ProxyPentahoRole> emptyRoleList = Collections.emptyList(); assignedRolesList.setObjects(emptyRoleList); } userDetailsPanel.setEnabled(selectedUsers.size() == 1); updateUserBtn.setEnabled(selectedUsers.size() == 1); if (selectedUsers.size() > 0) { deleteUserBtn.setEnabled(true); } else { deleteUserBtn.setEnabled(false); } if (selectedUsers.size() == 1) { addRoleAssignmentBtn.setEnabled(true); } else { addRoleAssignmentBtn.setEnabled(false); } userDetailsPanel.getUserNameTextBox().setEnabled(false); assignedRoleSelectionChanged(); }
private void deleteSelectedUsers() { final List<ProxyPentahoUser> selectedUsers = usersList.getSelectedObjects(); if (selectedUsers.size() > 0) { AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() { public void onSuccess(Boolean result) { usersList.removeObjects(selectedUsers); userSelectionChanged(); } public void onFailure(Throwable caught) { MessageDialogBox messageDialog = new MessageDialogBox( ExceptionParser.getErrorHeader(caught.getMessage()), ExceptionParser.getErrorMessage( caught.getMessage(), Messages.getString("errorDeletingUsers")), false, false, true); //$NON-NLS-1$ messageDialog.center(); } }; UserAndRoleMgmtService.instance() .deleteUsers(selectedUsers.toArray(new ProxyPentahoUser[0]), callback); } }
public void setRole(ProxyPentahoRole role) { userAssignmentsModified = false; this.role = role; if (role != null) { ArrayList<ProxyPentahoUser> unassignedUsers = new ArrayList<ProxyPentahoUser>(); unassignedUsers.addAll(Arrays.asList(UserAndRoleMgmtService.instance().getUsers())); ArrayList<ProxyPentahoUser> assignedUsers = new ArrayList<ProxyPentahoUser>(); assignedUsers.addAll(Arrays.asList(UserAndRoleMgmtService.instance().getUsers(role))); unassignedUsers.removeAll(assignedUsers); availableUsersList.setObjects(unassignedUsers); accumulatedUsersList.setObjects(assignedUsers); } else { List<ProxyPentahoUser> emptyList = Collections.emptyList(); availableUsersList.setObjects(emptyList); accumulatedUsersList.setObjects(emptyList); } }
public void onPopupClosed(PopupPanel sender, boolean autoClosed) { if (roleAssignmentsDialog.getRoleAssignmentsModified()) { List<ProxyPentahoRole> roleList = Arrays.asList( UserAndRoleMgmtService.instance().getRoles(roleAssignmentsDialog.getUser())); assignedRolesList.setObjects(roleList); assignedRoleSelectionChanged(); } }
@SuppressWarnings("unchecked") private void updateUserDetails(final Widget sender) { if (!userDetailsPanel.getPassword().equals(userDetailsPanel.getPasswordConfirmation())) { MessageDialogBox errorDialog = new MessageDialogBox( Messages.getString("updateUser"), Messages.getString("passwordConfirmationFailed"), false, false, true); //$NON-NLS-1$//$NON-NLS-2$ errorDialog.center(); } else { ((Button) sender).setEnabled(false); final ProxyPentahoUser user = userDetailsPanel.getUser(); AsyncCallback callback = new AsyncCallback() { public void onSuccess(Object result) { // Since users are compared by name, removeObject() will remove the old user from the // list // and addObject() will add the new user to the list. usersList.removeObject(user); usersList.addObject(user); usersList.setSelectedObject(user); ((Button) sender).setEnabled(true); } public void onFailure(Throwable caught) { MessageDialogBox messageDialog = new MessageDialogBox( ExceptionParser.getErrorHeader(caught.getMessage()), ExceptionParser.getErrorMessage( caught.getMessage(), Messages.getString("errorUpdatingUser")), false, false, true); //$NON-NLS-1$ messageDialog.center(); ((Button) sender).setEnabled(true); } }; // end AsyncCallback UserAndRoleMgmtService.instance().updateUser(user, callback); } }
public void refresh() { List<ProxyPentahoUser> userList = Arrays.asList(UserAndRoleMgmtService.instance().getUsers()); usersList.setObjects(userList); userSelectionChanged(); }