Search in sources :

Example 1 with SuccessCallback

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);
    }
}
Also used : SuccessCallback(org.activityinfo.ui.client.dispatch.callback.SuccessCallback) SavePromptMessageBox(org.activityinfo.ui.client.page.common.dialog.SavePromptMessageBox) SaveChangesCallback(org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback) AsyncMonitor(org.activityinfo.ui.client.dispatch.AsyncMonitor)

Example 2 with SuccessCallback

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);
            }
        });
    }
}
Also used : SuccessCallback(org.activityinfo.ui.client.dispatch.callback.SuccessCallback) SavePromptMessageBox(org.activityinfo.ui.client.page.common.dialog.SavePromptMessageBox) SaveChangesCallback(org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback) BatchResult(org.activityinfo.legacy.shared.command.result.BatchResult) AsyncMonitor(org.activityinfo.ui.client.dispatch.AsyncMonitor)

Aggregations

AsyncMonitor (org.activityinfo.ui.client.dispatch.AsyncMonitor)2 SuccessCallback (org.activityinfo.ui.client.dispatch.callback.SuccessCallback)2 SaveChangesCallback (org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback)2 SavePromptMessageBox (org.activityinfo.ui.client.page.common.dialog.SavePromptMessageBox)2 BatchResult (org.activityinfo.legacy.shared.command.result.BatchResult)1