Search in sources :

Example 36 with OperationException

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

the class ShowLogPresenter method showLog.

/**
     * Fetches the count of revisions and opens the popup.
     */
public void showLog() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    checkState(resources.length == 1);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {

        @Override
        public Promise<InfoResponse> perform(Credentials credentials) {
            return service.info(project.getLocation(), toRelative(project, resources[0]).toString(), "HEAD", false, credentials);
        }
    }, null).then(new Operation<InfoResponse>() {

        @Override
        public void apply(InfoResponse response) throws OperationException {
            if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) {
                printErrors(response.getErrorOutput(), constants.commandInfo());
                notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
                return;
            }
            SubversionItem subversionItem = response.getItems().get(0);
            view.setRevisionCount(subversionItem.getRevision());
            view.rangeField().setValue("1:" + subversionItem.getRevision());
            view.show();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : InfoResponse(org.eclipse.che.plugin.svn.shared.InfoResponse) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) SubversionItem(org.eclipse.che.plugin.svn.shared.SubversionItem) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 37 with OperationException

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

the class PropertyEditorPresenter method onPropertyNameChanged.

@Override
public void onPropertyNameChanged(String propertyName) {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    checkState(resources.length == 1);
    service.propertyGet(project.getLocation(), propertyName, toRelative(project, resources[0])).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            view.setPropertyCurrentValue(response.getOutput());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 38 with OperationException

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

the class PropertyEditorPresenter method deleteProperty.

private void deleteProperty(Project project) {
    final String propertyName = view.getSelectedProperty();
    final Depth depth = view.getDepth();
    final boolean force = view.isForceSelected();
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    checkState(resources.length == 1);
    final StatusNotification notification = new StatusNotification(constants.propertyRemoveStart(), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    service.propertyDelete(project.getLocation(), propertyName, depth, force, toRelative(project, resources[0])).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandProperty());
            notification.setTitle(constants.propertyRemoveFinished());
            notification.setStatus(SUCCESS);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notification.setTitle(constants.propertyRemoveFailed());
            notification.setStatus(FAIL);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Depth(org.eclipse.che.plugin.svn.shared.Depth) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 39 with OperationException

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

the class PropertyEditorPresenter method editProperty.

private void editProperty(Project project) {
    final String propertyName = view.getSelectedProperty();
    final Depth depth = view.getDepth();
    final String propertyValue = view.getPropertyValue();
    final boolean force = view.isForceSelected();
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    checkState(resources.length == 1);
    final StatusNotification notification = new StatusNotification(constants.propertyModifyStart(), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    service.propertySet(project.getLocation(), propertyName, propertyValue, depth, force, toRelative(project, resources[0])).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandProperty());
            notification.setTitle(constants.propertyModifyFinished());
            notification.setStatus(SUCCESS);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notification.setTitle(constants.propertyModifyFailed());
            notification.setStatus(FAIL);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Depth(org.eclipse.che.plugin.svn.shared.Depth) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 40 with OperationException

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

the class TestServiceClientTest method cancelledTestsBecauseCompilationNotStarted.

@Test
public void cancelledTestsBecauseCompilationNotStarted() {
    Promise<CommandImpl> compileCommandPromise = createCommandPromise(new CommandImpl("test-compile", "mvn test-compile -f ${current.project.path}", "mvn"));
    when(devMachine.getDescriptor()).thenReturn(machine);
    Promise<TestResult> result = testServiceClient.runTestsAfterCompilation(projectPath, testFramework, parameters, statusNotification, compileCommandPromise);
    triggerProcessEvents(processStartResponse(false));
    verify(testServiceClient, never()).sendTests(anyString(), anyString(), anyMapOf(String.class, String.class));
    verify(statusNotification).setContent("Compiling the project before starting the test session.");
    result.catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError promiseError) throws OperationException {
            Throwable cause = promiseError.getCause();
            Assert.assertNotNull(cause);
            Assert.assertEquals(TestServiceClient.PROJECT_BUILD_NOT_STARTED_MESSAGE, cause.getMessage());
        }
    });
}
Also used : CommandImpl(org.eclipse.che.ide.api.command.CommandImpl) PromiseError(org.eclipse.che.api.promises.client.PromiseError) TestResult(org.eclipse.che.api.testing.shared.TestResult) Matchers.anyString(org.mockito.Matchers.anyString) OperationException(org.eclipse.che.api.promises.client.OperationException) Test(org.junit.Test)

Aggregations

OperationException (org.eclipse.che.api.promises.client.OperationException)158 PromiseError (org.eclipse.che.api.promises.client.PromiseError)123 Operation (org.eclipse.che.api.promises.client.Operation)115 Project (org.eclipse.che.ide.api.resources.Project)53 Resource (org.eclipse.che.ide.api.resources.Resource)48 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)21 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)21 List (java.util.List)19 Promise (org.eclipse.che.api.promises.client.Promise)17 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)15 Path (org.eclipse.che.ide.resource.Path)15 JsPromiseError (org.eclipse.che.api.promises.client.js.JsPromiseError)14 ArrayList (java.util.ArrayList)13 GitOutputConsole (org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsole)13 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)12 DebuggerObserver (org.eclipse.che.ide.debug.DebuggerObserver)11 Optional (com.google.common.base.Optional)10 HashMap (java.util.HashMap)10 File (org.eclipse.che.ide.api.resources.File)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10