Search in sources :

Example 86 with OperationException

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

the class UploadFilePresenter method onSubmitComplete.

/** {@inheritDoc} */
@Override
public void onSubmitComplete(String result) {
    if (!isNullOrEmpty(result)) {
        view.closeDialog();
        notificationManager.notify(locale.failedToUploadFiles(), parseMessage(result), StatusNotification.Status.FAIL, FLOAT_MODE);
        return;
    }
    container.getFile(Path.valueOf(view.getFileName())).then(new Operation<Optional<File>>() {

        @Override
        public void apply(final Optional<File> file) throws OperationException {
            if (file.isPresent()) {
                eventBus.fireEvent(new RevealResourceEvent(file.get()));
                final NotificationListener notificationListener = new NotificationListener() {

                    boolean clicked = false;

                    @Override
                    public void onClick(Notification notification) {
                        if (!clicked) {
                            eventBus.fireEvent(FileEvent.createOpenFileEvent(file.get()));
                            clicked = true;
                            notification.setListener(null);
                            notification.setContent("");
                        }
                    }

                    @Override
                    public void onDoubleClick(Notification notification) {
                    //stub
                    }

                    @Override
                    public void onClose(Notification notification) {
                    //stub
                    }
                };
                notificationManager.notify("File '" + view.getFileName() + "' has uploaded successfully", "Click here to open it", StatusNotification.Status.SUCCESS, FLOAT_MODE, notificationListener);
                view.closeDialog();
            }
        }
    });
//TODO this should process editor agent
//        if (view.isOverwriteFileSelected()) {
//            String path = ((HasStorablePath)getResourceBasedNode()).getStorablePath() + "/" + view.getFileName();
//            eventBus.fireEvent(new FileContentUpdateEvent(path));
//        }
}
Also used : Optional(com.google.common.base.Optional) RevealResourceEvent(org.eclipse.che.ide.resources.reveal.RevealResourceEvent) File(org.eclipse.che.ide.api.resources.File) OperationException(org.eclipse.che.api.promises.client.OperationException) Notification(org.eclipse.che.ide.api.notification.Notification) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) NotificationListener(org.eclipse.che.ide.api.notification.NotificationListener)

Example 87 with OperationException

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

the class JavaRefactoringRename method createLinkedRenameSession.

private void createLinkedRenameSession() {
    final CreateRenameRefactoring refactoringSession = createRenameRefactoringDto(textEditor, true);
    Promise<RenameRefactoringSession> createRenamePromise = refactoringServiceClient.createRenameRefactoring(refactoringSession);
    createRenamePromise.then(new Operation<RenameRefactoringSession>() {

        @Override
        public void apply(RenameRefactoringSession session) throws OperationException {
            activateLinkedModeIntoEditor(session, textEditor.getDocument());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            isActiveLinkedEditor = false;
            showError();
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) CreateRenameRefactoring(org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateRenameRefactoring) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 88 with OperationException

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

the class JavaRefactoringRename method performRename.

private void performRename(RenameRefactoringSession session) {
    final LinkedRenameRefactoringApply dto = createLinkedRenameRefactoringApplyDto(newName, session.getSessionId());
    Promise<RefactoringResult> applyModelPromise = refactoringServiceClient.applyLinkedModeRename(dto);
    applyModelPromise.then(new Operation<RefactoringResult>() {

        @Override
        public void apply(RefactoringResult result) throws OperationException {
            switch(result.getSeverity()) {
                case OK:
                case INFO:
                    final VirtualFile file = textEditor.getDocument().getFile();
                    if (file instanceof Resource) {
                        final Optional<Project> project = ((Resource) file).getRelatedProject();
                        refactoringServiceClient.reindexProject(project.get().getLocation().toString());
                    }
                    refactoringUpdater.updateAfterRefactoring(result.getChanges());
                    break;
                case WARNING:
                case ERROR:
                    enableAutoSave();
                    undoChanges();
                    showWarningDialog();
                    break;
                case FATAL:
                    undoChanges();
                    notificationManager.notify(locale.failedToRename(), result.getEntries().get(0).getMessage(), FAIL, FLOAT_MODE);
                    break;
                default:
                    break;
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            enableAutoSave();
            undoChanges();
            notificationManager.notify(locale.failedToRename(), arg.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) RefactoringResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult) Resource(org.eclipse.che.ide.api.resources.Resource) LinkedRenameRefactoringApply(org.eclipse.che.ide.ext.java.shared.dto.refactoring.LinkedRenameRefactoringApply) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 89 with OperationException

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

the class JavaRefactoringRename method createRenameSession.

private void createRenameSession() {
    final CreateRenameRefactoring refactoringSession = createRenameRefactoringDto(textEditor, false);
    Promise<RenameRefactoringSession> createRenamePromise = refactoringServiceClient.createRenameRefactoring(refactoringSession);
    createRenamePromise.then(new Operation<RenameRefactoringSession>() {

        @Override
        public void apply(RenameRefactoringSession session) throws OperationException {
            renamePresenter.show(session);
            if (mode != null) {
                mode.exitLinkedMode(false);
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            showError();
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) CreateRenameRefactoring(org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateRenameRefactoring) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 90 with OperationException

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

the class RenamePresenter method applyChanges.

private void applyChanges() {
    final RefactoringSession session = dtoFactory.createDto(RefactoringSession.class);
    session.setSessionId(renameRefactoringSession.getSessionId());
    prepareRenameChanges(session).then(new Operation<ChangeCreationResult>() {

        @Override
        public void apply(ChangeCreationResult arg) throws OperationException {
            int severityCode = arg.getStatus().getSeverity();
            switch(severityCode) {
                case WARNING:
                case ERROR:
                    showWarningDialog(session, arg);
                    break;
                case FATAL:
                    if (!arg.isCanShowPreviewPage()) {
                        view.showErrorMessage(arg.getStatus());
                    }
                    break;
                default:
                    applyRefactoring(session);
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            notificationManager.notify(locale.failedToRename(), arg.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) RefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) 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)

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