Search in sources :

Example 91 with OperationException

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

the class RenamePresenter method validateName.

/** {@inheritDoc} */
@Override
public void validateName() {
    ValidateNewName validateNewName = dtoFactory.createDto(ValidateNewName.class);
    validateNewName.setSessionId(renameRefactoringSession.getSessionId());
    validateNewName.setNewName(view.getNewName());
    refactorService.validateNewName(validateNewName).then(new Operation<RefactoringStatus>() {

        @Override
        public void apply(RefactoringStatus arg) throws OperationException {
            switch(arg.getSeverity()) {
                case OK:
                    view.setEnableAcceptButton(true);
                    view.setEnablePreviewButton(true);
                    view.clearErrorLabel();
                    break;
                case INFO:
                    view.setEnableAcceptButton(true);
                    view.setEnablePreviewButton(true);
                    view.showStatusMessage(arg);
                    break;
                default:
                    view.setEnableAcceptButton(false);
                    view.setEnablePreviewButton(false);
                    view.showErrorMessage(arg);
                    break;
            }
        }
    }).catchError(new Operation<PromiseError>() {

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

Example 92 with OperationException

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

the class RenamePresenter method show.

/**
     * Show Rename window with the special information.
     *
     * @param refactorInfo
     *         information about the rename operation
     */
public void show(RefactorInfo refactorInfo) {
    this.refactorInfo = refactorInfo;
    final CreateRenameRefactoring createRenameRefactoring = createRenameRefactoringDto(refactorInfo);
    Promise<RenameRefactoringSession> createRenamePromise = refactorService.createRenameRefactoring(createRenameRefactoring);
    createRenamePromise.then(new Operation<RenameRefactoringSession>() {

        @Override
        public void apply(RenameRefactoringSession session) throws OperationException {
            show(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) 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 93 with OperationException

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

the class MatchNode method actionPerformed.

@Override
public void actionPerformed() {
    if (compilationUnit != null) {
        final EditorPartPresenter editorPartPresenter = editorAgent.getOpenedEditor(Path.valueOf(compilationUnit.getPath()));
        if (editorPartPresenter != null) {
            selectRange(editorPartPresenter);
            Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

                @Override
                public void execute() {
                    editorAgent.activateEditor(editorPartPresenter);
                }
            });
            return;
        }
        appContext.getWorkspaceRoot().getFile(compilationUnit.getPath()).then(new Operation<Optional<File>>() {

            @Override
            public void apply(Optional<File> file) throws OperationException {
                if (file.isPresent()) {
                    editorAgent.openEditor(file.get(), new OpenEditorCallbackImpl() {

                        @Override
                        public void onEditorOpened(EditorPartPresenter editor) {
                            selectRange(editor);
                        }
                    });
                }
            }
        });
    } else if (classFile != null) {
        final String className = classFile.getElementName();
        final Resource resource = appContext.getResource();
        if (resource == null) {
            return;
        }
        final Project project = resource.getRelatedProject().get();
        service.getContent(project.getLocation(), className).then(new Operation<ClassContent>() {

            @Override
            public void apply(ClassContent content) throws OperationException {
                final VirtualFile file = new SyntheticFile(Path.valueOf(className.replace('.', '/')).lastSegment(), content.getContent());
                editorAgent.openEditor(file, new OpenEditorCallbackImpl() {

                    @Override
                    public void onEditorOpened(EditorPartPresenter editor) {
                        selectRange(editor);
                    }
                });
            }
        });
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) ClassContent(org.eclipse.che.ide.ext.java.shared.dto.ClassContent) Optional(com.google.common.base.Optional) Scheduler(com.google.gwt.core.client.Scheduler) Resource(org.eclipse.che.ide.api.resources.Resource) OpenEditorCallbackImpl(org.eclipse.che.ide.api.editor.OpenEditorCallbackImpl) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) SyntheticFile(org.eclipse.che.ide.api.resources.SyntheticFile) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) File(org.eclipse.che.ide.api.resources.File) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) SyntheticFile(org.eclipse.che.ide.api.resources.SyntheticFile) ClassFile(org.eclipse.che.ide.ext.java.shared.dto.model.ClassFile) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 94 with OperationException

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

the class OrganizeImportsPresenter method onFinishButtonClicked.

/** {@inheritDoc} */
@Override
public void onFinishButtonClicked() {
    selected.put(page, view.getSelectedImport());
    ConflictImportDTO result = dtoFactory.createDto(ConflictImportDTO.class).withTypeMatches(new ArrayList<>(selected.values()));
    if (file instanceof Resource) {
        final Optional<Project> project = ((Resource) file).getRelatedProject();
        javaCodeAssistClient.applyChosenImports(project.get().getLocation().toString(), JavaUtil.resolveFQN(file), result).then(new Operation<List<Change>>() {

            @Override
            public void apply(List<Change> result) throws OperationException {
                applyChanges(((TextEditor) editor).getDocument(), result);
                view.hide();
                ((TextEditor) editor).setFocus();
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                String title = locale.failedToProcessOrganizeImports();
                String message = arg.getMessage();
                notificationManager.notify(title, message, FAIL, FLOAT_MODE);
            }
        });
    }
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) Change(org.eclipse.che.ide.ext.java.shared.dto.Change) Project(org.eclipse.che.ide.api.resources.Project) ConflictImportDTO(org.eclipse.che.ide.ext.java.shared.dto.ConflictImportDTO) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) PromiseError(org.eclipse.che.api.promises.client.PromiseError) ArrayList(java.util.ArrayList) List(java.util.List) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 95 with OperationException

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

the class ClasspathResolver method updateClasspath.

/** Concatenates classpath entries and update classpath file. */
public Promise<Void> updateClasspath() {
    final Resource resource = appContext.getResource();
    checkState(resource != null);
    final Optional<Project> optProject = resource.getRelatedProject();
    checkState(optProject.isPresent());
    final List<ClasspathEntryDto> entries = new ArrayList<>();
    for (String path : libs) {
        entries.add(dtoFactory.createDto(ClasspathEntryDto.class).withPath(path).withEntryKind(LIBRARY));
    }
    for (ClasspathEntryDto container : containers) {
        entries.add(container);
    }
    for (String path : sources) {
        entries.add(dtoFactory.createDto(ClasspathEntryDto.class).withPath(path).withEntryKind(SOURCE));
    }
    for (String path : projects) {
        entries.add(dtoFactory.createDto(ClasspathEntryDto.class).withPath(path).withEntryKind(PROJECT));
    }
    final Project project = optProject.get();
    Promise<Void> promise = classpathUpdater.setRawClasspath(project.getLocation().toString(), entries);
    promise.then(new Operation<Void>() {

        @Override
        public void apply(Void arg) throws OperationException {
            project.synchronize().then(new Operation<Resource[]>() {

                @Override
                public void apply(Resource[] arg) throws OperationException {
                    eventBus.fireEvent(new ClasspathChangedEvent(project.getLocation().toString(), entries));
                }
            });
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            notificationManager.notify("Problems with updating classpath", arg.getMessage(), FAIL, EMERGE_MODE);
        }
    });
    return promise;
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) ArrayList(java.util.ArrayList) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) 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