Search in sources :

Example 41 with PromiseError

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

the class DebuggerTest method testGetValue.

@Test
public void testGetValue() throws Exception {
    final VariableDto variableDto = mock(VariableDto.class);
    final Variable variable = mock(Variable.class);
    final Promise<SimpleValueDto> promiseValue = mock(Promise.class);
    doReturn(variableDto).when(dtoFactory).createDto(VariableDto.class);
    doReturn(mock(VariablePathDto.class)).when(dtoFactory).createDto(VariablePathDto.class);
    doReturn(mock(VariablePathDto.class)).when(variable).getVariablePath();
    doReturn(Collections.emptyList()).when(variable).getVariables();
    doReturn(promiseValue).when(service).getValue(SESSION_ID, variableDto);
    doReturn(promiseValue).when(promiseValue).then((Function<SimpleValueDto, Object>) any());
    doReturn(promiseValue).when(promiseValue).catchError((Operation<PromiseError>) any());
    Promise<SimpleValue> result = debugger.getValue(variable);
    assertEquals(promiseValue, result);
}
Also used : Variable(org.eclipse.che.api.debug.shared.model.Variable) VariablePathDto(org.eclipse.che.api.debug.shared.dto.VariablePathDto) PromiseError(org.eclipse.che.api.promises.client.PromiseError) VariableDto(org.eclipse.che.api.debug.shared.dto.VariableDto) SimpleValueDto(org.eclipse.che.api.debug.shared.dto.SimpleValueDto) SimpleValue(org.eclipse.che.api.debug.shared.model.SimpleValue) BaseTest(org.eclipse.che.plugin.debugger.ide.BaseTest) Test(org.junit.Test)

Example 42 with PromiseError

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

the class EvaluateExpressionPresenter method onEvaluateClicked.

/** {@inheritDoc} */
@Override
public void onEvaluateClicked() {
    Debugger debugger = debuggerManager.getActiveDebugger();
    if (debugger != null) {
        view.setEnableEvaluateButton(false);
        debugger.evaluate(view.getExpression()).then(new Operation<String>() {

            @Override
            public void apply(String result) throws OperationException {
                view.setResult(result);
                view.setEnableEvaluateButton(true);
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError error) throws OperationException {
                view.setResult(constant.evaluateExpressionFailed(error.getMessage()));
                view.setEnableEvaluateButton(true);
            }
        });
    }
}
Also used : Debugger(org.eclipse.che.ide.debug.Debugger) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 43 with PromiseError

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

the class MovePresenter method show.

/**
     * Show Move panel with the special information.
     *
     * @param refactorInfo
     *         information about the move operation
     */
public void show(final RefactorInfo refactorInfo) {
    this.refactorInfo = refactorInfo;
    view.setEnablePreviewButton(false);
    view.setEnableAcceptButton(false);
    view.clearErrorLabel();
    CreateMoveRefactoring moveRefactoring = createMoveDto();
    Promise<String> sessionIdPromise = refactorService.createMoveRefactoring(moveRefactoring);
    sessionIdPromise.then(new Operation<String>() {

        @Override
        public void apply(String sessionId) throws OperationException {
            MovePresenter.this.refactoringSessionId = sessionId;
            showProjectsAndPackages();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), Status.FAIL, FLOAT_MODE);
        }
    });
}
Also used : CreateMoveRefactoring(org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateMoveRefactoring) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 44 with PromiseError

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

the class MovePresenter method onPreviewButtonClicked.

/** {@inheritDoc} */
@Override
public void onPreviewButtonClicked() {
    RefactoringSession session = dtoFactory.createDto(RefactoringSession.class);
    session.setSessionId(refactoringSessionId);
    prepareMovingChanges(session).then(new Operation<ChangeCreationResult>() {

        @Override
        public void apply(ChangeCreationResult arg) throws OperationException {
            if (arg.isCanShowPreviewPage()) {
                previewPresenter.show(refactoringSessionId, refactorInfo);
                view.hide();
            } else {
                view.showStatusMessage(arg.getStatus());
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(locale.showPreviewError(), error.getMessage(), Status.FAIL, FLOAT_MODE);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) RefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringSession) ChangeCreationResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangeCreationResult) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 45 with PromiseError

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

the class MovePresenter method showProjectsAndPackages.

private void showProjectsAndPackages() {
    Promise<List<JavaProject>> projectsPromise = navigationService.getProjectsAndPackages(true);
    projectsPromise.then(new Operation<List<JavaProject>>() {

        @Override
        public void apply(List<JavaProject> projects) throws OperationException {
            List<JavaProject> currentProject = new ArrayList<>();
            for (JavaProject project : projects) {
                currentProject.add(project);
            }
            view.setTreeOfDestinations(currentProject);
            view.show(refactorInfo);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(locale.showPackagesError(), error.getMessage(), Status.FAIL, FLOAT_MODE);
        }
    });
}
Also used : JavaProject(org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject) PromiseError(org.eclipse.che.api.promises.client.PromiseError) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

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