Search in sources :

Example 31 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project che by eclipse.

the class PushToRemotePresenter method updateRemoteBranches.

/**
     * Update list of remote branches on view.
     */
void updateRemoteBranches() {
    getBranchesForCurrentProject(LIST_REMOTE, new AsyncCallback<List<Branch>>() {

        @Override
        public void onSuccess(final List<Branch> result) {
            // Need to add the upstream of local branch in the list of remote branches
            // to be able to push changes to the remote upstream branch
            getUpstreamBranch(new AsyncCallback<Branch>() {

                @Override
                public void onSuccess(Branch upstream) {
                    BranchFilterByRemote remoteRefsHandler = new BranchFilterByRemote(view.getRepository());
                    final List<String> remoteBranches = branchSearcher.getRemoteBranchesToDisplay(remoteRefsHandler, result);
                    String selectedRemoteBranch = null;
                    if (upstream != null && upstream.isRemote() && remoteRefsHandler.isLinkedTo(upstream)) {
                        String simpleUpstreamName = remoteRefsHandler.getBranchNameWithoutRefs(upstream);
                        if (!remoteBranches.contains(simpleUpstreamName)) {
                            remoteBranches.add(simpleUpstreamName);
                        }
                        selectedRemoteBranch = simpleUpstreamName;
                    }
                    // Need to add the current local branch in the list of remote branches
                    // to be able to push changes to the remote branch  with same name
                    final String currentBranch = view.getLocalBranch();
                    if (!remoteBranches.contains(currentBranch)) {
                        remoteBranches.add(currentBranch);
                    }
                    if (selectedRemoteBranch == null) {
                        selectedRemoteBranch = currentBranch;
                    }
                    view.setRemoteBranches(remoteBranches);
                    view.selectRemoteBranch(selectedRemoteBranch);
                }

                @Override
                public void onFailure(Throwable caught) {
                    GitOutputConsole console = gitOutputConsoleFactory.create(CONFIG_COMMAND_NAME);
                    console.printError(constant.failedGettingConfig());
                    processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
                    notificationManager.notify(constant.failedGettingConfig(), FAIL, FLOAT_MODE);
                }
            });
        }

        @Override
        public void onFailure(Throwable exception) {
            String errorMessage = exception.getMessage() != null ? exception.getMessage() : constant.remoteBranchesListFailed();
            GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_LIST_COMMAND_NAME);
            console.printError(errorMessage);
            processesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console);
            notificationManager.notify(constant.remoteBranchesListFailed(), FAIL, FLOAT_MODE);
            view.setEnablePushButton(false);
        }
    });
}
Also used : Branch(org.eclipse.che.api.git.shared.Branch) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) BranchFilterByRemote(org.eclipse.che.ide.ext.git.client.BranchFilterByRemote) GitOutputConsole(org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List)

Example 32 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project gwt-test-utils by gwt-test-utils.

the class SchedulerTest method scheduledCommandOrderWithRpcCall.

@Test
public void scheduledCommandOrderWithRpcCall() {
    // Given
    final StringBuilder sb = new StringBuilder();
    final MyRemoteServiceAsync service = GWT.create(MyRemoteService.class);
    Scheduler.get().scheduleEntry(new ScheduledCommand() {

        public void execute() {
            sb.append("scheduleEntry1 ");
        }
    });
    Scheduler.get().scheduleFinally(new ScheduledCommand() {

        public void execute() {
            sb.append("scheduleFinally1 ");
        }
    });
    service.myMethod("service1", new AsyncCallback<String>() {

        public void onFailure(Throwable caught) {
        }

        public void onSuccess(String result) {
            sb.append("onSuccess1 ");
        }
    });
    service.myMethod("service2", new AsyncCallback<String>() {

        public void onFailure(Throwable caught) {
        }

        public void onSuccess(String result) {
            sb.append("onSuccess2 ");
        }
    });
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        public void execute() {
            sb.append("scheduleDeferred1 ");
            service.myMethod("service3", new AsyncCallback<String>() {

                public void onFailure(Throwable caught) {
                }

                public void onSuccess(String result) {
                    sb.append("onSuccess3 ");
                }
            });
            Scheduler.get().scheduleEntry(new ScheduledCommand() {

                public void execute() {
                    sb.append("scheduleEntry2 ");
                    Scheduler.get().scheduleEntry(new ScheduledCommand() {

                        public void execute() {
                            sb.append("scheduleEntry3 ");
                        }
                    });
                }
            });
            Scheduler.get().scheduleFinally(new ScheduledCommand() {

                public void execute() {
                    sb.append("scheduleFinally2 ");
                    Scheduler.get().scheduleFinally(new ScheduledCommand() {

                        public void execute() {
                            sb.append("scheduleFinally3 ");
                        }
                    });
                }
            });
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                public void execute() {
                    sb.append("scheduleDeferred2 ");
                }
            });
        }
    });
    // When
    getBrowserSimulator().fireLoopEnd();
    // Then
    assertThat(sb.toString()).isEqualTo("scheduleFinally1 scheduleEntry1 scheduleDeferred1 onSuccess1 onSuccess2 scheduleFinally2 scheduleFinally3 scheduleEntry2 scheduleEntry3 scheduleDeferred2 onSuccess3 ");
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) Test(org.junit.Test)

Example 33 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project che by eclipse.

the class ProjectImporter method authUserAndRecallImport.

private Promise<Project> authUserAndRecallImport(final String providerName, final String authenticateUrl, final Path path, final SourceStorage sourceStorage, final ProjectNotificationSubscriber subscriber) {
    return createFromAsyncRequest(new RequestCall<Project>() {

        @Override
        public void makeCall(final AsyncCallback<Project> callback) {
            OAuth2Authenticator authenticator = oAuth2AuthenticatorRegistry.getAuthenticator(providerName);
            if (authenticator == null) {
                authenticator = oAuth2AuthenticatorRegistry.getAuthenticator("default");
            }
            authenticator.authenticate(OAuth2AuthenticatorUrlProvider.get(appContext.getMasterEndpoint(), authenticateUrl), new AsyncCallback<OAuthStatus>() {

                @Override
                public void onFailure(Throwable caught) {
                    callback.onFailure(new Exception(caught.getMessage()));
                }

                @Override
                public void onSuccess(OAuthStatus result) {
                    if (!result.equals(OAuthStatus.NOT_PERFORMED)) {
                        doImport(path, sourceStorage).then(new Operation<Project>() {

                            @Override
                            public void apply(Project project) throws OperationException {
                                callback.onSuccess(project);
                            }
                        }).catchError(new Operation<PromiseError>() {

                            @Override
                            public void apply(PromiseError error) throws OperationException {
                                callback.onFailure(error.getCause());
                            }
                        });
                    } else {
                        subscriber.onFailure("Authentication cancelled");
                        callback.onFailure(new IllegalStateException("Authentication cancelled"));
                    }
                }
            });
        }
    });
}
Also used : OAuth2Authenticator(org.eclipse.che.ide.api.oauth.OAuth2Authenticator) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) OAuthStatus(org.eclipse.che.security.oauth.OAuthStatus) Operation(org.eclipse.che.api.promises.client.Operation) FunctionException(org.eclipse.che.api.promises.client.FunctionException) OperationException(org.eclipse.che.api.promises.client.OperationException) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 34 with AsyncCallback

use of com.google.gwt.user.client.rpc.AsyncCallback in project gerrit by GerritCodeReview.

the class ChangeScreen method onLoad.

@Override
protected void onLoad() {
    super.onLoad();
    CallbackGroup group = new CallbackGroup();
    if (Gerrit.isSignedIn()) {
        ChangeList.query("change:" + changeId.get() + " has:draft", Collections.<ListChangesOption>emptySet(), group.add(new AsyncCallback<ChangeList>() {

            @Override
            public void onSuccess(ChangeList result) {
                hasDraftComments = result.length() > 0;
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        }));
        ChangeApi.editWithFiles(changeId.get(), group.add(new AsyncCallback<EditInfo>() {

            @Override
            public void onSuccess(EditInfo result) {
                edit = result;
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        }));
    }
    loadChangeInfo(true, group.addFinal(new GerritCallback<ChangeInfo>() {

        @Override
        public void onSuccess(final ChangeInfo info) {
            info.init();
            initCurrentRevision(info);
            final RevisionInfo rev = info.revision(revision);
            CallbackGroup group = new CallbackGroup();
            loadCommit(rev, group);
            group.addListener(new GerritCallback<Void>() {

                @Override
                public void onSuccess(Void result) {
                    if (base.isBase() && rev.isMerge()) {
                        base = DiffObject.parse(info.legacyId(), Gerrit.getUserPreferences().defaultBaseForMerges().getBase());
                    }
                    loadConfigInfo(info, base);
                    JsArray<MessageInfo> mAr = info.messages();
                    for (int i = 0; i < mAr.length(); i++) {
                        if (mAr.get(i).tag() != null) {
                            hideTaggedComments.setVisible(true);
                            break;
                        }
                    }
                }
            });
            group.done();
        }
    }));
}
Also used : GerritCallback(com.google.gerrit.client.rpc.GerritCallback) JsArray(com.google.gwt.core.client.JsArray) ChangeInfo(com.google.gerrit.client.info.ChangeInfo) RevisionInfo(com.google.gerrit.client.info.ChangeInfo.RevisionInfo) ChangeList(com.google.gerrit.client.changes.ChangeList) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) CallbackGroup(com.google.gerrit.client.rpc.CallbackGroup) EditInfo(com.google.gerrit.client.info.ChangeInfo.EditInfo)

Example 35 with AsyncCallback

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

the class PageController method fetchPages.

private void fetchPages() {
    final GetPagesRequest input = ApiHelper.setAccessCode(new GetPagesRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    input.includePosts = Boolean.FALSE;
    if (getPagesRequest != null) {
        getPagesRequest.cancel();
    }
    getPagesRequest = ApiHelper.createPageClient().getPages(input, new AsyncCallback<GetPagesResponse>() {

        @Override
        public void onSuccess(GetPagesResponse output) {
            getPagesRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.pages != null && output.pages.size() > 0) {
                    pager = output.pager;
                    updateRowCount(input.pager.count == null ? 0 : input.pager.count.intValue(), input.pager.count == null || input.pager.count.intValue() == 0);
                    updateRowData(input.pager.start.intValue(), output.pages);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Page>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetPagesSuccess(input, output), PageController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getPagesRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPagesFailure(input, caught), PageController.this);
        }
    });
}
Also used : GetPagesRequest(com.willshex.blogwt.shared.api.page.call.GetPagesRequest) GetPagesFailure(com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesFailure) GetPagesSuccess(com.willshex.blogwt.client.api.page.event.GetPagesEventHandler.GetPagesSuccess) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPagesResponse(com.willshex.blogwt.shared.api.page.call.GetPagesResponse)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)64 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)8 Test (org.junit.Test)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)5 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)4 FormDialogTether (org.activityinfo.ui.client.page.common.dialog.FormDialogTether)4 ChangeInfo (com.google.gerrit.client.info.ChangeInfo)3 Date (java.util.Date)3 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)3 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)3 MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)3 FormDialogImpl (org.activityinfo.ui.client.page.common.dialog.FormDialogImpl)3 Operation (org.eclipse.che.api.promises.client.Operation)3 OperationException (org.eclipse.che.api.promises.client.OperationException)3 PromiseError (org.eclipse.che.api.promises.client.PromiseError)3 Path (org.eclipse.che.ide.resource.Path)3 EditInfo (com.google.gerrit.client.info.ChangeInfo.EditInfo)2 RevisionInfo (com.google.gerrit.client.info.ChangeInfo.RevisionInfo)2