Search in sources :

Example 71 with PromiseError

use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.

the class PushToRemotePresenter method getUpstreamBranch.

/**
     * Get upstream branch for selected local branch. Can invoke {@code onSuccess(null)} if upstream branch isn't set
     */
private void getUpstreamBranch(final AsyncCallback<Branch> result) {
    final String configBranchRemote = "branch." + view.getLocalBranch() + ".remote";
    final String configUpstreamBranch = "branch." + view.getLocalBranch() + ".merge";
    service.config(appContext.getDevMachine(), project.getLocation(), Arrays.asList(configUpstreamBranch, configBranchRemote)).then(new Operation<Map<String, String>>() {

        @Override
        public void apply(Map<String, String> configs) throws OperationException {
            if (configs.containsKey(configBranchRemote) && configs.containsKey(configUpstreamBranch)) {
                String displayName = configs.get(configBranchRemote) + "/" + configs.get(configUpstreamBranch);
                Branch upstream = dtoFactory.createDto(Branch.class).withActive(false).withRemote(true).withDisplayName(displayName).withName("refs/remotes/" + displayName);
                result.onSuccess(upstream);
            } else {
                result.onSuccess(null);
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            result.onFailure(error.getCause());
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) Branch(org.eclipse.che.api.git.shared.Branch) Operation(org.eclipse.che.api.promises.client.Operation) Map(java.util.Map) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 72 with PromiseError

use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.

the class HistoryPresenterTest method shouldShowDialogOnInitCommitError.

@Test
public void shouldShowDialogOnInitCommitError() throws Exception {
    PromiseError error = mock(PromiseError.class);
    ServerException exception = mock(ServerException.class);
    when(exception.getErrorCode()).thenReturn(ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED);
    when(error.getCause()).thenReturn(exception);
    when(constant.initCommitWasNotPerformed()).thenReturn("error message");
    MessageDialog dialog = mock(MessageDialog.class);
    when(dialogFactory.createMessageDialog(eq("title"), eq("error message"), any(ConfirmCallback.class))).thenReturn(dialog);
    presenter.show();
    verify(logPromise).catchError(promiseErrorCaptor.capture());
    promiseErrorCaptor.getValue().apply(error);
    verify(dialog).show();
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) ServerException(org.eclipse.che.ide.commons.exception.ServerException) PromiseError(org.eclipse.che.api.promises.client.PromiseError) MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) BaseTest(org.eclipse.che.ide.ext.git.client.BaseTest) Test(org.junit.Test)

Example 73 with PromiseError

use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.

the class CreateWorkspacePresenterTest method errorShouldBeCaughtWhenCreatesWorkSpace.

@Test
public void errorShouldBeCaughtWhenCreatesWorkSpace() throws Exception {
    final PromiseError promiseError = mock(PromiseError.class);
    clickOnCreateButton();
    verify(userWsPromise).catchError(errorOperation.capture());
    errorOperation.getValue().apply(promiseError);
    //noinspection ThrowableResultOfMethodCallIgnored
    verify(promiseError).getCause();
    verify(componentCallback).onFailure(Matchers.<Exception>anyObject());
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) Test(org.junit.Test)

Example 74 with PromiseError

use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.

the class LanguageServerCodeAssistProcessor method computeCompletionProposals.

@Override
public void computeCompletionProposals(TextEditor editor, final int offset, final boolean triggered, final CodeAssistCallback callback) {
    this.lastErrorMessage = null;
    TextDocumentPositionParamsDTO documentPosition = dtoBuildHelper.createTDPP(editor.getDocument(), offset);
    final TextDocumentIdentifierDTO documentId = documentPosition.getTextDocument();
    String currentLine = editor.getDocument().getLineContent(documentPosition.getPosition().getLine());
    final String currentWord = getCurrentWord(currentLine, documentPosition.getPosition().getCharacter());
    if (!triggered && latestCompletionResult.isGoodFor(documentId, offset, currentWord)) {
        // no need to send new completion request
        computeProposals(currentWord, offset - latestCompletionResult.getOffset(), callback);
    } else {
        documentServiceClient.completion(documentPosition).then(new Operation<CompletionListDTO>() {

            @Override
            public void apply(CompletionListDTO list) throws OperationException {
                latestCompletionResult.update(documentId, offset, currentWord, list);
                computeProposals(currentWord, 0, callback);
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError error) throws OperationException {
                lastErrorMessage = error.getMessage();
            }
        });
    }
}
Also used : TextDocumentPositionParamsDTO(org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO) CompletionListDTO(org.eclipse.che.api.languageserver.shared.lsapi.CompletionListDTO) PromiseError(org.eclipse.che.api.promises.client.PromiseError) TextDocumentIdentifierDTO(org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 75 with PromiseError

use of org.eclipse.che.api.promises.client.PromiseError in project che by eclipse.

the class LanguageServerSignatureHelp method signatureHelp.

@Override
public Promise<Optional<SignatureHelp>> signatureHelp(Document document, int offset) {
    TextDocumentPositionParamsDTO paramsDTO = helper.createTDPP(document, offset);
    Promise<SignatureHelpDTO> promise = client.signatureHelp(paramsDTO);
    return promise.then(new Function<SignatureHelpDTO, Optional<SignatureHelp>>() {

        @Override
        public Optional<SignatureHelp> apply(SignatureHelpDTO arg) throws FunctionException {
            if (arg == null) {
                return Optional.absent();
            }
            return Optional.<SignatureHelp>of(new SignatureHelpImpl(arg));
        }
    }).catchError(new Function<PromiseError, Optional<SignatureHelp>>() {

        @Override
        public Optional<SignatureHelp> apply(PromiseError arg) throws FunctionException {
            notificationManager.notify(arg.getMessage(), StatusNotification.Status.FAIL, StatusNotification.DisplayMode.EMERGE_MODE);
            return Optional.absent();
        }
    });
}
Also used : TextDocumentPositionParamsDTO(org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO) Function(org.eclipse.che.api.promises.client.Function) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Optional(com.google.common.base.Optional) SignatureHelpDTO(org.eclipse.che.api.languageserver.shared.lsapi.SignatureHelpDTO) FunctionException(org.eclipse.che.api.promises.client.FunctionException) SignatureHelp(org.eclipse.che.ide.api.editor.signature.SignatureHelp)

Aggregations

PromiseError (org.eclipse.che.api.promises.client.PromiseError)137 OperationException (org.eclipse.che.api.promises.client.OperationException)123 Operation (org.eclipse.che.api.promises.client.Operation)109 Project (org.eclipse.che.ide.api.resources.Project)48 Resource (org.eclipse.che.ide.api.resources.Resource)40 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)21 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)20 Promise (org.eclipse.che.api.promises.client.Promise)19 List (java.util.List)15 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)13 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)13 Path (org.eclipse.che.ide.resource.Path)13 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)11 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)11 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10 HashMap (java.util.HashMap)9 Function (org.eclipse.che.api.promises.client.Function)8 FunctionException (org.eclipse.che.api.promises.client.FunctionException)8