public final void doSave(final AsyncCallback <Boolean> callback) {
final Workbench wb = (Workbench)Registry.get(Workbench.ID);
XUser admin = wb.getUser();
if(admin != null) {
final XObject xObj = input.getXObject();
for (EditorTab tab : tabs) {
if (!tab.save(xObj)) {
MessageBox.alert(constants.error(),
messages.failedToSave(getTitle()),
null);
return;
}
}
// if (getSaveType() == WPaloEvent.SAVED_USER_ITEM) {
// final TreeNode input = (TreeNode) getInput();
// final XUser user = (XUser) ((TreeNode) getInput()).getXObject();
// final XUser loggedInUser = ((Workbench)Registry.get(Workbench.ID)).getUser();
// String sessionId = loggedInUser.getSessionId();
// WPaloAdminServiceProvider.getInstance().getGroups(sessionId, user,
// new Callback<XGroup[]>("Failed to load groups!!") {
// public void onSuccess(XGroup[] groups) {
// user.clearGroups();
// for (XGroup group : groups) {
// user.addGroupID(group.getId());
// }
// WPaloAdminServiceProvider.getInstance().saveXObject(loggedInUser.getSessionId(), xObj,
// new Callback<XObject>() {
// public void onFailure(Throwable t) {
// MessageBox.alert("Error", "Failed to save '"
// + xObj.getName() + "'!\n" + t.getMessage(),
// null);
// saved(false);
// if (callback != null) {
// callback.onSuccess(true);
// }
// }
// public void onSuccess(XObject arg0) {
// input.setXObject(arg0);
// saved(true);
// setInput(arg0);
// if (callback != null) {
// callback.onSuccess(true);
// }
// }
// });
// }
// });
// } else {
WPaloAdminServiceProvider.getInstance().saveXObject(wb.getUser().getSessionId(), xObj,
new Callback<XObject>() {
public void onFailure(Throwable t) {
if (xObj != null && xObj.getName() != null) {
MessageBox.alert(constants.error(),
messages.failedToSave(ViewBrowserModel.modify(xObj.getName())) + t.getMessage(),
null);
} else {
String id = xObj == null ? "" : xObj.getId();
MessageBox.alert(constants.error(),
messages.failedToSave(id) + t.getMessage(),
null);
}
saved(false);