Search in sources :

Example 1 with SaveChangesCallback

use of org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback 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 SaveChangesCallback

use of org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback 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)

Example 3 with SaveChangesCallback

use of org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback in project activityinfo by bedatadriven.

the class ReportDesignPage method requestToNavigateAway.

@Override
public void requestToNavigateAway(final PageState place, final NavigationCallback callback) {
    if (!dirty) {
        callback.onDecided(true);
    } else {
        SavePromptMessageBox box = new SavePromptMessageBox();
        box.show(new SaveChangesCallback() {

            @Override
            public void save(final AsyncMonitor monitor) {
                saveTitled(monitor, new SaveCallback() {

                    @Override
                    public void onSaved() {
                        callback.onDecided(true);
                    }
                });
            }

            @Override
            public void discard() {
                callback.onDecided(true);
            }

            @Override
            public void cancel() {
                callback.onDecided(false);
            }
        });
    }
}
Also used : SavePromptMessageBox(org.activityinfo.ui.client.page.common.dialog.SavePromptMessageBox) SaveChangesCallback(org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback) MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) AsyncMonitor(org.activityinfo.ui.client.dispatch.AsyncMonitor)

Example 4 with SaveChangesCallback

use of org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback in project activityinfo by bedatadriven.

the class DbUserEditor method requestToNavigateAway.

@Override
public void requestToNavigateAway(PageState place, final NavigationCallback callback) {
    if (modified) {
        final SavePromptMessageBox savePrompt = new SavePromptMessageBox();
        savePrompt.show(new SaveChangesCallback() {

            @Override
            public void save(AsyncMonitor monitor) {
                savePrompt.hide();
                actions.save(callback);
            }

            @Override
            public void cancel() {
                savePrompt.hide();
                callback.onDecided(false);
            }

            @Override
            public void discard() {
                savePrompt.hide();
                callback.onDecided(true);
            }
        });
    } else {
        callback.onDecided(true);
    }
}
Also used : 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 5 with SaveChangesCallback

use of org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback in project activityinfo by bedatadriven.

the class DataEntryPage method requestToNavigateAway.

@Override
public void requestToNavigateAway(PageState place, final NavigationCallback callback) {
    if (monthlyPanel.isModified()) {
        final SavePromptMessageBox box = new SavePromptMessageBox();
        box.show(new SaveChangesCallback() {

            @Override
            public void save(AsyncMonitor monitor) {
                monthlyPanel.save().then(new AsyncCallback<Void>() {

                    @Override
                    public void onFailure(Throwable caught) {
                    // handled by monitor
                    }

                    @Override
                    public void onSuccess(Void result) {
                        box.hide();
                        callback.onDecided(true);
                    }
                });
            }

            @Override
            public void cancel() {
                box.hide();
                callback.onDecided(false);
            }

            @Override
            public void discard() {
                box.hide();
                callback.onDecided(true);
            }
        });
    } else {
        callback.onDecided(true);
    }
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) SavePromptMessageBox(org.activityinfo.ui.client.page.common.dialog.SavePromptMessageBox) SaveChangesCallback(org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback) MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) AsyncMonitor(org.activityinfo.ui.client.dispatch.AsyncMonitor)

Aggregations

AsyncMonitor (org.activityinfo.ui.client.dispatch.AsyncMonitor)6 SaveChangesCallback (org.activityinfo.ui.client.page.common.dialog.SaveChangesCallback)6 SavePromptMessageBox (org.activityinfo.ui.client.page.common.dialog.SavePromptMessageBox)6 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 SuccessCallback (org.activityinfo.ui.client.dispatch.callback.SuccessCallback)2 BatchResult (org.activityinfo.legacy.shared.command.result.BatchResult)1