}
private final void doAdd(int eventType) {
try {
Object input = null;
IEditor editor = null;
switch(eventType) {
case ADD_GROUP_ITEM:
input = new TreeNode(null, new XGroup());
editor = grpEditor;
break;
case ADD_ROLE_ITEM:
input = new TreeNode(null, new XRole());
editor = roleEditor;
break;
case ADD_USER_ITEM:
XUser user = ((Workbench) Registry.get(Workbench.ID)).getUser();
String sessionId = user.getSessionId();
WPaloAdminServiceProvider.getInstance().getRoles(sessionId, user,
new Callback<XRole[]>(constants.loadingAllRolesFailed()) {
public void onSuccess(XRole[] result) {
XUser newXUser = new XUser();
final Object input = new TreeNode(null, newXUser);
for (XRole r: result) {
if (r.getName().equalsIgnoreCase("editor")) {
newXUser.addRoleID(r.getId());
newXUser.addRoleName(r.getId(), r.getName());
}
if (r.getName().equalsIgnoreCase("viewer")) {
newXUser.addRoleID(r.getId());
newXUser.addRoleName(r.getId(), r.getName());
}
}
final Workbench wb = (Workbench)Registry.get(Workbench.ID);
wb.checkOpen(usrEditor, new Callback<Boolean>() {
public void onSuccess(Boolean result) {
if (result) {
IEditor editor = usrEditor;
editor.setInput(input);
wb.open(editor);
editor.selectFirstTab();
editor.setTextCursor();
}
}
});
}
});
break;
}
if (input != null && editor != null) {
final Workbench wb = (Workbench)Registry.get(Workbench.ID);
final IEditor edi = editor;
final Object inp = input;
wb.checkOpen(edi, new Callback<Boolean>() {
public void onSuccess(Boolean result) {
if (result) {
edi.setInput(inp);
wb.open(edi);
edi.selectFirstTab();
edi.setTextCursor();
}
}
});
}
} catch (Throwable t) {