use of org.activityinfo.ui.client.dispatch.callback.SuccessCallback in project activityinfo by bedatadriven.
the class FormSavedGuard method navigate.
@Override
public void navigate(final NavigationCallback callback) {
if (!saved) {
final SavePromptMessageBox box = new SavePromptMessageBox();
box.show(new SaveChangesCallback() {
@Override
public void save(final AsyncMonitor monitor) {
formDesigner.getFormDesignerActions().save().then(new SuccessCallback<Void>() {
@Override
public void onSuccess(Void result) {
box.hide();
callback.onDecided(true);
}
});
}
@Override
public void discard() {
box.hide();
callback.onDecided(true);
}
@Override
public void cancel() {
box.hide();
callback.onDecided(false);
}
});
} else {
callback.onDecided(true);
}
}
use of org.activityinfo.ui.client.dispatch.callback.SuccessCallback in project activityinfo by bedatadriven.
the class AbstractEditorGridPresenter method requestToNavigateAway.
/*
* The user has chosen to navigate away from this page We will automatically
* try to save any unsaved changes, but if it fails, we give the user a
* choice between retrying and and discarding changes
*/
@Override
public void requestToNavigateAway(PageState place, final NavigationCallback callback) {
if (getModifiedRecords().size() == 0) {
callback.onDecided(true);
} else {
final SavePromptMessageBox box = new SavePromptMessageBox();
box.show(new SaveChangesCallback() {
@Override
public void save(AsyncMonitor monitor) {
service.execute(createSaveCommand(), view.getSavingMonitor(), new SuccessCallback<BatchResult>() {
@Override
public void onSuccess(BatchResult result) {
box.hide();
getStore().commitChanges();
callback.onDecided(true);
}
});
}
@Override
public void cancel() {
box.hide();
callback.onDecided(false);
}
@Override
public void discard() {
box.hide();
callback.onDecided(true);
}
});
}
}
Aggregations