Search in sources :

Example 31 with OperationException

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

the class RevertPresenter method createConfirmDialog.

private ConfirmDialog createConfirmDialog(final Project project, final Resource[] resources) {
    final ConfirmCallback okCallback = new ConfirmCallback() {

        @Override
        public void accepted() {
            final StatusNotification notification = new StatusNotification(constants.revertStarted(), PROGRESS, FLOAT_MODE);
            notificationManager.notify(notification);
            service.revert(project.getLocation(), toRelative(project, resources), "infinity").then(new Operation<CLIOutputResponse>() {

                @Override
                public void apply(CLIOutputResponse response) throws OperationException {
                    List<String> errOutput = response.getErrOutput();
                    printResponse(response.getCommand(), response.getOutput(), errOutput, "svn revert");
                    if (errOutput == null || errOutput.size() == 0) {
                        notification.setTitle(constants.revertSuccessful());
                        notification.setStatus(SUCCESS);
                    } else {
                        notification.setTitle(constants.revertWarning());
                        notification.setStatus(SUCCESS);
                    }
                }
            }).catchError(new Operation<PromiseError>() {

                @Override
                public void apply(PromiseError error) throws OperationException {
                    notification.setTitle(constants.revertFailed());
                    notification.setStatus(FAIL);
                }
            });
        }
    };
    final CancelCallback cancelCallback = new CancelCallback() {

        @Override
        public void cancelled() {
        }
    };
    String pathsString = null;
    for (Resource resource : resources) {
        if (pathsString == null) {
            pathsString = resource.getLocation().toString();
        } else {
            pathsString += ", " + resource.getLocation().toString();
        }
    }
    String confirmText = resources.length > 0 ? constants.revertConfirmText(" to " + pathsString) : constants.revertConfirmText("");
    return dialogFactory.createConfirmDialog(constants.revertTitle(), confirmText, okCallback, cancelCallback);
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) PromiseError(org.eclipse.che.api.promises.client.PromiseError) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Resource(org.eclipse.che.ide.api.resources.Resource) CancelCallback(org.eclipse.che.ide.api.dialogs.CancelCallback) 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 32 with OperationException

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

the class StatusPresenter method showStatus.

public void showStatus() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    service.status(project.getLocation(), toRelative(project, resources), null, false, false, false, true, false, null).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandStatus());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(constants.statusFailed(), 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 33 with OperationException

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

the class SwitchPresenter method showWindow.

public void showWindow() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    switchView.showWindow();
    switchView.setSwitchButtonEnabled(false);
    invalidateLoadedData();
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {

        @Override
        public Promise<InfoResponse> perform(Credentials credentials) {
            return service.info(appContext.getRootProject().getLocation(), ".", "HEAD", false, credentials);
        }
    }, null).then(new Operation<InfoResponse>() {

        @Override
        public void apply(InfoResponse response) throws OperationException {
            if (!response.getItems().isEmpty()) {
                SubversionItem subversionItem = response.getItems().get(0);
                projectUri = subversionItem.getProjectUri();
            }
            defaultViewInitialization();
            handleSwitchButton();
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            projectUri = "^";
            Path location = appContext.getRootProject().getLocation();
            notificationManager.notify(constants.infoRequestError(location.toString()), error.getMessage(), FAIL, EMERGE_MODE);
            defaultViewInitialization();
            handleSwitchButton();
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) InfoResponse(org.eclipse.che.plugin.svn.shared.InfoResponse) SubversionItem(org.eclipse.che.plugin.svn.shared.SubversionItem) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 34 with OperationException

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

the class UpdatePresenter method doUpdate.

protected void doUpdate(final String revision, final String depth, final boolean ignoreExternals, final UpdateToRevisionView view) {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    final StatusNotification notification = new StatusNotification(constants.updateToRevisionStarted(revision), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputWithRevisionResponse>() {

        @Override
        public Promise<CLIOutputWithRevisionResponse> perform(Credentials credentials) {
            notification.setStatus(PROGRESS);
            notification.setTitle(constants.updateToRevisionStarted(revision));
            return service.update(project.getLocation(), toRelative(project, resources), revision, depth, ignoreExternals, "postpone", credentials);
        }
    }, notification).then(new Operation<CLIOutputWithRevisionResponse>() {

        @Override
        public void apply(CLIOutputWithRevisionResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandUpdate());
            notification.setTitle(constants.updateSuccessful(Long.toString(response.getRevision())));
            notification.setStatus(SUCCESS);
            if (view != null) {
                view.close();
            }
        }
    }).catchError(new Operation<PromiseError>() {

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

Example 35 with OperationException

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

the class RunClassContextTestAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    final StatusNotification notification = new StatusNotification("Running Tests...", PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    final Selection<?> selection = selectionAgent.getSelection();
    final Object possibleNode = selection.getHeadElement();
    if (possibleNode instanceof FileNode) {
        VirtualFile file = ((FileNode) possibleNode).getData();
        final Project project = appContext.getRootProject();
        String fqn = JavaUtil.resolveFQN(file);
        Map<String, String> parameters = new HashMap<>();
        parameters.put("fqn", fqn);
        parameters.put("runClass", "true");
        parameters.put("updateClasspath", "true");
        Promise<TestResult> testResultPromise = service.getTestResult(project.getPath(), "testng", parameters);
        testResultPromise.then(new Operation<TestResult>() {

            @Override
            public void apply(TestResult result) throws OperationException {
                notification.setStatus(SUCCESS);
                if (result.isSuccess()) {
                    notification.setTitle("Test runner executed successfully");
                    notification.setContent("All tests are passed");
                } else {
                    notification.setTitle("Test runner executed successfully with test failures.");
                    notification.setContent(result.getFailureCount() + " test(s) failed.\n");
                }
                presenter.handleResponse(result);
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError exception) throws OperationException {
                final String errorMessage = (exception.getMessage() != null) ? exception.getMessage() : "Failed to run test cases";
                notification.setContent(errorMessage);
                notification.setStatus(FAIL);
            }
        });
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) HashMap(java.util.HashMap) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) TestResult(org.eclipse.che.api.testing.shared.TestResult) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) FileNode(org.eclipse.che.ide.resources.tree.FileNode) OperationException(org.eclipse.che.api.promises.client.OperationException)

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