Search in sources :

Example 1 with DispatchServiceCallback

use of edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback in project webprotege by protegeproject.

the class ChangeListViewPresenter method revertChanges.

private void revertChanges(ProjectChange projectChange) {
    GWT.log("Reverting revision " + projectChange.getRevisionNumber().getValue());
    projectId.ifPresent(theProjectId -> {
        final RevisionNumber revisionNumber = projectChange.getRevisionNumber();
        dispatchServiceManager.execute(new RevertRevisionAction(theProjectId, revisionNumber), new DispatchServiceCallback<RevertRevisionResult>() {

            @Override
            public void handleSuccess(RevertRevisionResult revertRevisionResult) {
                MessageBox.showMessage("Changes in revision " + revisionNumber.getValue() + " have been reverted");
                lastAction.ifPresent(action -> setChangesForProject(action.getProjectId()));
            }
        });
    });
}
Also used : java.util(java.util) DownloadFormatExtension(edu.stanford.bmir.protege.web.shared.download.DownloadFormatExtension) ProjectRevisionDownloader(edu.stanford.bmir.protege.web.client.download.ProjectRevisionDownloader) edu.stanford.bmir.protege.web.shared.change(edu.stanford.bmir.protege.web.shared.change) GWT(com.google.gwt.core.client.GWT) DispatchServiceCallback(edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback) Inject(javax.inject.Inject) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ImmutableList(com.google.common.collect.ImmutableList) CANCEL(edu.stanford.bmir.protege.web.client.library.dlg.DialogButton.CANCEL) DispatchServiceManager(edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager) MessageBox(edu.stanford.bmir.protege.web.client.library.msgbox.MessageBox) VIEW_CHANGES(edu.stanford.bmir.protege.web.shared.access.BuiltInAction.VIEW_CHANGES) Nonnull(javax.annotation.Nonnull) TimeUtil(edu.stanford.bmir.protege.web.shared.TimeUtil) Page(edu.stanford.bmir.protege.web.shared.pagination.Page) DiffElement(edu.stanford.bmir.protege.web.shared.diff.DiffElement) REVERT_CHANGES(edu.stanford.bmir.protege.web.shared.access.BuiltInAction.REVERT_CHANGES) RevisionNumber(edu.stanford.bmir.protege.web.shared.revision.RevisionNumber) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Messages(edu.stanford.bmir.protege.web.client.Messages) DialogButton(edu.stanford.bmir.protege.web.client.library.dlg.DialogButton) LoggedInUserProjectPermissionChecker(edu.stanford.bmir.protege.web.client.permissions.LoggedInUserProjectPermissionChecker) Ordering(com.google.common.collect.Ordering) DateTimeFormat(com.google.gwt.i18n.shared.DateTimeFormat) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) HasBusy(edu.stanford.bmir.protege.web.client.progress.HasBusy) RevisionNumber(edu.stanford.bmir.protege.web.shared.revision.RevisionNumber)

Example 2 with DispatchServiceCallback

use of edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback in project webprotege by protegeproject.

the class PerspectiveLinkManagerImpl method addLinkedPerspective.

public void addLinkedPerspective(final PerspectiveId perspectiveId, final Callback callback) {
    final UserId userId = loggedInUserProvider.getCurrentUserId();
    dispatchServiceManager.execute(new GetPerspectivesAction(projectId, userId), new DispatchServiceCallback<GetPerspectivesResult>() {

        @Override
        public void handleSuccess(GetPerspectivesResult result) {
            List<PerspectiveId> ids = new ArrayList<>(result.getPerspectives());
            ids.add(perspectiveId);
            final ImmutableList<PerspectiveId> perspectiveIds = ImmutableList.copyOf(ids);
            dispatchServiceManager.execute(new SetPerspectivesAction(projectId, userId, perspectiveIds), new DispatchServiceCallback<SetPerspectivesResult>() {

                @Override
                public void handleSuccess(SetPerspectivesResult setPerspectivesResult) {
                    callback.handlePerspectives(perspectiveIds);
                }
            });
        }
    });
}
Also used : DispatchServiceCallback(edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ArrayList(java.util.ArrayList)

Example 3 with DispatchServiceCallback

use of edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback in project webprotege by protegeproject.

the class WatchPresenter method start.

public void start(final OWLEntity forEntity) {
    final UserId userId = loggedInUserProvider.getCurrentUserId();
    dispatchServiceManager.execute(new GetWatchesAction(projectId, userId, forEntity), new DispatchServiceCallback<GetWatchesResult>() {

        @Override
        public void handleSuccess(GetWatchesResult result) {
            Set<Watch> watches = result.getWatches();
            updateDialog(watches);
            WebProtegeDialog<WatchTypeSelection> dlg = new WebProtegeDialog<>(controller);
            dlg.show();
            controller.setDialogButtonHandler(DialogButton.OK, (data, closer) -> {
                closer.hide();
                handleWatchTypeForEntity(data, forEntity);
            });
        }
    });
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) GWT(com.google.gwt.core.client.GWT) DispatchServiceCallback(edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback) DialogButton(edu.stanford.bmir.protege.web.client.library.dlg.DialogButton) Inject(javax.inject.Inject) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) edu.stanford.bmir.protege.web.shared.watches(edu.stanford.bmir.protege.web.shared.watches) LoggedInUserProvider(edu.stanford.bmir.protege.web.client.user.LoggedInUserProvider) DispatchServiceManager(edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) Optional(java.util.Optional) WebProtegeDialog(edu.stanford.bmir.protege.web.client.library.dlg.WebProtegeDialog) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) Collections(java.util.Collections) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) WebProtegeDialog(edu.stanford.bmir.protege.web.client.library.dlg.WebProtegeDialog)

Example 4 with DispatchServiceCallback

use of edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback in project webprotege by protegeproject.

the class MetricsPresenterTestCase method setUp.

// @Before
public void setUp() {
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            DispatchServiceCallback<GetMetricsResult> action = (DispatchServiceCallback<GetMetricsResult>) invocationOnMock.getArguments()[1];
            action.onSuccess(result);
            return null;
        }
    }).when(dispatchServiceManager).execute(any(GetMetricsAction.class), any(DispatchServiceCallback.class));
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            handler = (RequestRefreshEventHandler) invocationOnMock.getArguments()[0];
            return null;
        }
    }).when(view).setRequestRefreshEventHandler(any(RequestRefreshEventHandler.class));
    when(result.getMetricValues()).thenReturn(metricValues);
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            metricsChangedHandler = (MetricsChangedHandler) invocationOnMock.getArguments()[0];
            return null;
        }
    }).when(eventManager).addProjectEventHandler(eq(projectId), any(MetricsChangedEvent.getType().getClass()), any(MetricsChangedHandler.class));
    presenter = new MetricsPresenter(projectId, view, dispatchServiceManager);
    presenter.start();
}
Also used : DispatchServiceCallback(edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback) RequestRefreshEventHandler(edu.stanford.bmir.protege.web.client.events.RequestRefreshEventHandler) InvocationOnMock(org.mockito.invocation.InvocationOnMock) MetricsPresenter(edu.stanford.bmir.protege.web.client.metrics.MetricsPresenter)

Example 5 with DispatchServiceCallback

use of edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback in project webprotege by protegeproject.

the class PerspectiveLinkManagerImpl method removeLinkedPerspective.

public void removeLinkedPerspective(final PerspectiveId perspectiveId, final Callback callback) {
    final UserId userId = loggedInUserProvider.getCurrentUserId();
    dispatchServiceManager.execute(new GetPerspectivesAction(projectId, userId), new DispatchServiceCallback<GetPerspectivesResult>() {

        @Override
        public void handleSuccess(GetPerspectivesResult result) {
            final List<PerspectiveId> ids = new ArrayList<>(result.getPerspectives());
            ids.remove(perspectiveId);
            dispatchServiceManager.execute(new SetPerspectivesAction(projectId, userId, ImmutableList.copyOf(ids)), new DispatchServiceCallback<SetPerspectivesResult>() {

                @Override
                public void handleSuccess(SetPerspectivesResult setPerspectivesResult) {
                    callback.handlePerspectives(ids);
                }
            });
        }
    });
}
Also used : DispatchServiceCallback(edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ArrayList(java.util.ArrayList)

Aggregations

DispatchServiceCallback (edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback)5 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)4 ImmutableList (com.google.common.collect.ImmutableList)3 GWT (com.google.gwt.core.client.GWT)2 DispatchServiceManager (edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceManager)2 DialogButton (edu.stanford.bmir.protege.web.client.library.dlg.DialogButton)2 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Inject (javax.inject.Inject)2 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Ordering (com.google.common.collect.Ordering)1 DateTimeFormat (com.google.gwt.i18n.shared.DateTimeFormat)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 Messages (edu.stanford.bmir.protege.web.client.Messages)1 ProjectRevisionDownloader (edu.stanford.bmir.protege.web.client.download.ProjectRevisionDownloader)1 RequestRefreshEventHandler (edu.stanford.bmir.protege.web.client.events.RequestRefreshEventHandler)1 CANCEL (edu.stanford.bmir.protege.web.client.library.dlg.DialogButton.CANCEL)1