Search in sources :

Example 56 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback 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)

Example 57 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project activityinfo by bedatadriven.

the class MonthlyReportsPanel method confirmUnsavedData.

private void confirmUnsavedData(final Function function) {
    if (isModified()) {
        final SavePromptMessageBox box = new SavePromptMessageBox();
        box.show(new SaveChangesCallback() {

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

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

                    @Override
                    public void onSuccess(Void result) {
                        box.hide();
                        function.apply(null);
                    }
                });
            }

            @Override
            public void cancel() {
                box.hide();
                function.apply(null);
            }

            @Override
            public void discard() {
                box.hide();
                function.apply(null);
            }
        });
    }
}
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)

Example 58 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project webprotege by protegeproject.

the class PrimitiveDataParserImpl_LiteralParsing_TestCase method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() {
    primitiveTypes = Sets.newHashSet();
    primitiveTypes.add(PrimitiveType.LITERAL);
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            AsyncCallback<Optional<OWLEntityData>> callback = (AsyncCallback<Optional<OWLEntityData>>) invocationOnMock.getArguments()[2];
            callback.onSuccess(Optional.empty());
            return null;
        }
    }).when(lookupHandler).lookupEntity(any(String.class), any(Set.class), any(AsyncCallback.class));
    parser = new PrimitiveDataParserImpl(lookupHandler);
}
Also used : Set(java.util.Set) Optional(java.util.Optional) PrimitiveDataParserImpl(edu.stanford.bmir.protege.web.client.primitive.PrimitiveDataParserImpl) InvocationOnMock(org.mockito.invocation.InvocationOnMock) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) Before(org.junit.Before)

Example 59 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project webprotege by protegeproject.

the class PrimitiveDataParserImpl_EntityParsing_TestCase method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() {
    primitiveTypes = Sets.newHashSet();
    lookupMap = Maps.newHashMap();
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            AsyncCallback<Optional<OWLEntityData>> callback = (AsyncCallback<Optional<OWLEntityData>>) invocationOnMock.getArguments()[2];
            callback.onSuccess(Optional.of(lookupMap.get(invocationOnMock.getArguments()[0])));
            return null;
        }
    }).when(lookupHandler).lookupEntity(any(String.class), any(Set.class), any(AsyncCallback.class));
    parser = new PrimitiveDataParserImpl(lookupHandler);
}
Also used : Set(java.util.Set) Optional(java.util.Optional) PrimitiveDataParserImpl(edu.stanford.bmir.protege.web.client.primitive.PrimitiveDataParserImpl) InvocationOnMock(org.mockito.invocation.InvocationOnMock) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) Before(org.junit.Before)

Example 60 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project blogwt by billy1380.

the class PageController method getPage.

/**
 * @param page
 */
public void getPage(Page page, boolean includePosts) {
    final GetPageRequest input = ApiHelper.setAccessCode(new GetPageRequest());
    input.session = SessionController.get().sessionForApiCall();
    input.page = page;
    input.includePosts = Boolean.valueOf(includePosts);
    if (getPageRequest != null) {
        getPageRequest.cancel();
    }
    getPageRequest = ApiHelper.createPageClient().getPage(input, new AsyncCallback<GetPageResponse>() {

        @Override
        public void onSuccess(GetPageResponse output) {
            getPageRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
            }
            DefaultEventBus.get().fireEventFromSource(new GetPageSuccess(input, output), PageController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getPageRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPageFailure(input, caught), PageController.this);
        }
    });
}
Also used : GetPageSuccess(com.willshex.blogwt.client.api.page.event.GetPageEventHandler.GetPageSuccess) GetPageResponse(com.willshex.blogwt.shared.api.page.call.GetPageResponse) GetPageFailure(com.willshex.blogwt.client.api.page.event.GetPageEventHandler.GetPageFailure) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPageRequest(com.willshex.blogwt.shared.api.page.call.GetPageRequest)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)85 Test (org.junit.Test)13 GetSchema (org.activityinfo.shared.command.GetSchema)9 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)8 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)8 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)7 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)6 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)6 CallbackGroup (com.google.gerrit.client.rpc.CallbackGroup)4 FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)4 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)4 VoidResult (org.activityinfo.shared.command.result.VoidResult)4 FormDialogTether (org.activityinfo.ui.client.page.common.dialog.FormDialogTether)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 Set (java.util.Set)3 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)3 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)3 CreateResult (org.activityinfo.shared.command.result.CreateResult)3 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)3