private void setFields() { nameTextBox.setValue(group.getName()); for (User user : group.getUsers()) { toUserStore.add(new UserData(user)); } loadAvailableUsers(); }
private void setFields() { usernameTextBox.setValue(user.getUsername()); fullnameTextBox.setValue(user.getFullname()); emailTextBox.setValue(user.getEmail()); enabledCheckBox.setValue(user.isActiveFlag()); for (Group group : user.getGroups()) { if (!group.getName().equals(Constants.EVERYONE_GROUP_NAME)) { toGroupStore.add(new GroupData(group)); } } loadAvailableGroups(); }
private void refreshAvailableUsers(List<User> users) { for (User user : users) { if (!group.getUsers().contains(user)) { fromUserStore.add(new UserData(user)); } } }
private void doSave() { if (validateFields()) { group.setName(Utils.safeString(nameTextBox.getValue())); group.removeUsers(); for (UserData userData : toUserStore.getModels()) { group.addUser((User) userData.get(Constants.USER)); } final AsyncCallback<Boolean> callbackCheck = new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { WebPasswordSafe.handleServerFailure(caught); } @Override public void onSuccess(Boolean result) { // true => group name already taken, else go ahead and save if (result) { MessageBox.alert(textMessages.error(), textMessages.groupNameAlreadyExists(), null); } else { AsyncCallback<Void> callback = new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { WebPasswordSafe.handleServerFailure(caught); } @Override public void onSuccess(Void result) { Info.display(textMessages.status(), textMessages.groupSaved()); hide(); } }; if (group.getId() == 0) { UserService.Util.getInstance().addGroup(group, callback); } else { UserService.Util.getInstance().updateGroup(group, callback); } } } }; UserService.Util.getInstance().isGroupTaken(group.getName(), group.getId(), callbackCheck); } }
public GroupData(Group group) { set(Constants.ID, group.getId()); set(Constants.NAME, Format.htmlEncode(group.getName())); set(Constants.GROUP, group); }