final int index = membersListBox.getSelectedIndex();
final String username = membersListBox.getItemText(index);
final User user = userMap.get(username);
final AsyncCallback<Void> deleteUserCallback = new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
MessageDialogBox dialog = new MessageDialogBox("Error", caught.getMessage(), true, true, true);
dialog.center();
}
public void onSuccess(Void nothing) {
members.remove(user);
populateUI();
try {
if (index < membersListBox.getItemCount()) {
membersListBox.setSelectedIndex(index);
} else {
membersListBox.setSelectedIndex(index - 1);
}
} catch (Exception e) {
}
onChange(new com.google.gwt.event.dom.client.ChangeEvent() {
public Object getSource() {
return membersListBox;
}
});
};
};
BaseServiceCache.getService().deleteUser(user, group, deleteUserCallback);
}
});
removeButton.setText(" < ");
removeButton.setTitle("Remove Member");
addButton.setText(" > ");
addButton.setTitle("Add Member");
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final int index = allUsersListBox.getSelectedIndex();
final String username = allUsersListBox.getItemText(index);
final User user = userMap.get(username);
final AsyncCallback<GroupMembership> addUserCallback = new AsyncCallback<GroupMembership>() {
public void onFailure(Throwable caught) {
MessageDialogBox dialog = new MessageDialogBox("Error", caught.getMessage(), true, true, true);
dialog.center();
}
public void onSuccess(GroupMembership membership) {
members.add(user);
populateUI();