Search in sources :

Example 86 with PromiseError

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

the class MergePresenter method mergeClicked.

/**
     * Performs actions when clicking Merge button.
     */
@Override
public void mergeClicked() {
    view.hide();
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(resources != null && resources.length == 1);
    service.merge(project.getLocation(), resources[0].getLocation(), Path.valueOf(sourceURL)).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), null, constants.commandMerge());
        }
    }).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 87 with PromiseError

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

the class MergePresenter method merge.

/**
     * Prepares to merging and opens Merge dialog.
     */
public void merge() {
    view.enableMergeButton(false);
    view.sourceCheckBox().setValue(false);
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(resources != null && 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;
            }
            mergeTarget = response.getItems().get(0);
            view.targetTextBox().setValue(mergeTarget.getRelativeURL());
            String repositoryRoot = mergeTarget.getRepositoryRoot();
            service.info(project.getLocation(), repositoryRoot, "HEAD", true).then(new Operation<InfoResponse>() {

                @Override
                public void apply(InfoResponse response) throws OperationException {
                    if (!response.getErrorOutput().isEmpty()) {
                        printErrors(response.getErrorOutput(), constants.commandInfo());
                        notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
                        return;
                    }
                    sourceURL = response.getItems().get(0).getURL();
                    SubversionItemNode subversionTreeNode = new SubversionItemNode(response.getItems().get(0));
                    List<Node> children = new ArrayList<>();
                    if (response.getItems().size() > 1) {
                        for (int i = 1; i < response.getItems().size(); i++) {
                            SubversionItem item = response.getItems().get(i);
                            if (!"file".equals(item.getNodeKind())) {
                                children.add(new SubversionItemNode(item));
                            }
                        }
                    }
                    subversionTreeNode.setChildren(children);
                    view.setRootNode(subversionTreeNode);
                    view.show();
                    validateSourceURL();
                }
            }).catchError(new Operation<PromiseError>() {

                @Override
                public void apply(PromiseError error) throws OperationException {
                    notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
                }
            });
        }
    }).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) Node(org.eclipse.che.ide.api.data.tree.Node) AbstractTreeNode(org.eclipse.che.ide.api.data.tree.AbstractTreeNode) Resource(org.eclipse.che.ide.api.resources.Resource) ArrayList(java.util.ArrayList) 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 88 with PromiseError

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

the class MovePresenter method onMoveClicked.

/** {@inheritDoc} */
@Override
public void onMoveClicked() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Path source = getSource();
    final String comment = view.isURLSelected() ? view.getComment() : null;
    final StatusNotification notification = new StatusNotification(locale.moveNotificationStarted(source.toString()), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {

        @Override
        public Promise<CLIOutputResponse> perform(Credentials credentials) {
            notification.setStatus(PROGRESS);
            notification.setTitle(locale.moveNotificationStarted(source.toString()));
            return service.move(project.getLocation(), source, getTarget(), comment, credentials);
        }
    }, notification).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            notification.setTitle(locale.moveNotificationSuccessful());
            notification.setStatus(SUCCESS);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            notification.setTitle(locale.moveNotificationFailed());
            notification.setStatus(FAIL);
        }
    });
    view.onClose();
}
Also used : Path(org.eclipse.che.ide.resource.Path) 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) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 89 with PromiseError

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

the class PropertyEditorPresenter method obtainExistingPropertiesForPath.

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

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            List<String> properties = new ArrayList<String>();
            for (String property : response.getOutput()) {
                properties.add(property.trim());
            }
            view.setExistingPropertiesForPath(properties);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(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) ArrayList(java.util.ArrayList) 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 90 with PromiseError

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

the class OrionEditorPresenter method initializeEditor.

@Override
protected void initializeEditor(final EditorAgent.OpenEditorCallback callback) {
    QuickAssistProcessor processor = configuration.getQuickAssistProcessor();
    if (quickAssistantFactory != null && processor != null) {
        quickAssistant = quickAssistantFactory.createQuickAssistant(this);
        quickAssistant.setQuickAssistProcessor(processor);
    }
    editorInit = new OrionEditorInit(configuration, this.codeAssistantFactory, this.quickAssistant, this);
    Promise<Void> initializerPromise = editorModule.getInitializerPromise();
    initializerPromise.catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            displayErrorPanel(constant.editorInitErrorMessage());
            callback.onInitializationFailed();
        }
    }).thenPromise(new Function<Void, Promise<String>>() {

        @Override
        public Promise<String> apply(Void arg) throws FunctionException {
            return documentStorage.getDocument(input.getFile());
        }
    }).then(new Operation<String>() {

        @Override
        public void apply(String content) throws OperationException {
            createEditor(content);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            displayErrorPanel(constant.editorFileErrorMessage());
            callback.onInitializationFailed();
        }
    });
}
Also used : FunctionException(org.eclipse.che.api.promises.client.FunctionException) QuickAssistProcessor(org.eclipse.che.ide.api.editor.quickfix.QuickAssistProcessor) Operation(org.eclipse.che.api.promises.client.Operation) Promise(org.eclipse.che.api.promises.client.Promise) PromiseError(org.eclipse.che.api.promises.client.PromiseError) 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