Search in sources :

Example 96 with OperationException

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

the class ProjectClasspathPresenter method show.

/** Show dialog. */
public void show() {
    final Resource[] resources = appContext.getResources();
    Preconditions.checkState(resources != null && resources.length == 1);
    final Optional<Project> project = resources[0].getRelatedProject();
    Preconditions.checkState(isJavaProject(project.get()));
    classpathContainer.getClasspathEntries(project.get().getLocation().toString()).then(new Operation<List<ClasspathEntryDto>>() {

        @Override
        public void apply(List<ClasspathEntryDto> arg) throws OperationException {
            classpathResolver.resolveClasspathEntries(arg);
            if (propertiesMap == null) {
                propertiesMap = new HashMap<>();
                for (ClasspathPagePresenter page : classpathPages) {
                    Set<ClasspathPagePresenter> pages = propertiesMap.get(page.getCategory());
                    if (pages == null) {
                        pages = new HashSet<>();
                        propertiesMap.put(page.getCategory(), pages);
                    }
                    pages.add(page);
                }
                view.setPages(propertiesMap);
            }
            view.show();
            view.selectPage(propertiesMap.entrySet().iterator().next().getValue().iterator().next());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            notificationManager.notify("Problems with getting classpath", arg.getMessage(), FAIL, EMERGE_MODE);
        }
    });
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) 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) JavaUtil.isJavaProject(org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject) PromiseError(org.eclipse.che.api.promises.client.PromiseError) List(java.util.List) ClasspathPagePresenter(org.eclipse.che.ide.ext.java.client.project.classpath.valueproviders.pages.ClasspathPagePresenter) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 97 with OperationException

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

the class FileStructurePresenter method show.

/**
     * Shows the structure of the opened class.
     *
     * @param editorPartPresenter
     *         the active editor
     */
public void show(EditorPartPresenter editorPartPresenter) {
    loader.show();
    view.setTitle(editorPartPresenter.getEditorInput().getFile().getName());
    if (!(editorPartPresenter instanceof TextEditor)) {
        Log.error(getClass(), "Open Declaration support only TextEditor as editor");
        return;
    }
    activeEditor = ((TextEditor) editorPartPresenter);
    cursorOffset = activeEditor.getCursorOffset();
    VirtualFile file = activeEditor.getEditorInput().getFile();
    if (file instanceof Resource) {
        final Optional<Project> project = ((Resource) file).getRelatedProject();
        final Optional<Resource> srcFolder = ((Resource) file).getParentWithMarker(SourceFolderMarker.ID);
        if (!srcFolder.isPresent()) {
            return;
        }
        final String fqn = JavaUtil.resolveFQN((Container) srcFolder.get(), (Resource) file);
        javaNavigationService.getCompilationUnit(project.get().getLocation(), fqn, showInheritedMembers).then(new Operation<CompilationUnit>() {

            @Override
            public void apply(CompilationUnit unit) throws OperationException {
                view.setStructure(unit, showInheritedMembers);
                showInheritedMembers = !showInheritedMembers;
                loader.hide();
                view.show();
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                Log.error(FileStructurePresenter.class, arg.getMessage());
                loader.hide();
            }
        });
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) CompilationUnit(org.eclipse.che.ide.ext.java.shared.dto.model.CompilationUnit) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) PromiseError(org.eclipse.che.api.promises.client.PromiseError) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 98 with OperationException

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

the class FileStructurePresenter method actionPerformed.

/** {@inheritDoc} */
@Override
public void actionPerformed(final Member member) {
    if (member.isBinary()) {
        final Resource resource = context.getResource();
        if (resource == null) {
            return;
        }
        final Optional<Project> project = resource.getRelatedProject();
        javaNavigationService.getEntry(project.get().getLocation(), member.getLibId(), member.getRootPath()).then(new Operation<JarEntry>() {

            @Override
            public void apply(final JarEntry entry) throws OperationException {
                javaNavigationService.getContent(project.get().getLocation(), member.getLibId(), Path.valueOf(entry.getPath())).then(new Operation<ClassContent>() {

                    @Override
                    public void apply(ClassContent content) throws OperationException {
                        final String clazz = entry.getName().substring(0, entry.getName().indexOf('.'));
                        final VirtualFile file = new SyntheticFile(entry.getName(), clazz, content.getContent());
                        editorAgent.openEditor(file, new OpenEditorCallbackImpl() {

                            @Override
                            public void onEditorOpened(EditorPartPresenter editor) {
                                setCursor(editor, member.getFileRegion().getOffset());
                            }
                        });
                    }
                });
            }
        });
    } else {
        context.getWorkspaceRoot().getFile(member.getRootPath()).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) {
                            setCursor(editor, member.getFileRegion().getOffset());
                        }
                    });
                }
            }
        });
    }
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

        @Override
        public void execute() {
            setCursorPosition(member.getFileRegion());
        }
    });
    showInheritedMembers = false;
}
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) JarEntry(org.eclipse.che.ide.ext.java.shared.JarEntry) 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) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 99 with OperationException

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

the class OpenImplementationPresenter method show.

/**
     * Shows the implementations of the selected element.
     *
     * @param editorPartPresenter
     *         the active editor
     */
public void show(final EditorPartPresenter editorPartPresenter) {
    if (!(editorPartPresenter instanceof TextEditor)) {
        Log.error(getClass(), "Open Declaration support only TextEditor as editor");
        return;
    }
    activeEditor = ((TextEditor) editorPartPresenter);
    final VirtualFile file = activeEditor.getEditorInput().getFile();
    if (file instanceof Resource) {
        final Optional<Project> project = ((Resource) file).getRelatedProject();
        final Optional<Resource> srcFolder = ((Resource) file).getParentWithMarker(SourceFolderMarker.ID);
        if (!srcFolder.isPresent()) {
            return;
        }
        final String fqn = JavaUtil.resolveFQN((Container) srcFolder.get(), (Resource) file);
        service.getImplementations(project.get().getLocation(), fqn, activeEditor.getCursorOffset()).then(new Operation<ImplementationsDescriptorDTO>() {

            @Override
            public void apply(ImplementationsDescriptorDTO impls) throws OperationException {
                int overridingSize = impls.getImplementations().size();
                String title = locale.openImplementationWindowTitle(impls.getMemberName(), overridingSize);
                NoImplementationWidget noImplementationWidget = new NoImplementationWidget(popupResources, javaResources, locale, OpenImplementationPresenter.this, title);
                if (overridingSize == 1) {
                    actionPerformed(impls.getImplementations().get(0));
                } else if (overridingSize > 1) {
                    openOneImplementation(impls, noImplementationWidget, (TextEditor) editorPartPresenter);
                } else if (!isNullOrEmpty(impls.getMemberName()) && overridingSize == 0) {
                    showNoImplementations(noImplementationWidget, (TextEditor) editorPartPresenter);
                }
            }
        });
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) Project(org.eclipse.che.ide.api.resources.Project) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) Resource(org.eclipse.che.ide.api.resources.Resource) ImplementationsDescriptorDTO(org.eclipse.che.ide.ext.java.shared.dto.ImplementationsDescriptorDTO) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 100 with OperationException

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

the class MovePresenter method onAcceptButtonClicked.

/** {@inheritDoc} */
@Override
public void onAcceptButtonClicked() {
    final RefactoringSession session = dtoFactory.createDto(RefactoringSession.class);
    session.setSessionId(refactoringSessionId);
    prepareMovingChanges(session).then(new Operation<ChangeCreationResult>() {

        @Override
        public void apply(ChangeCreationResult arg) throws OperationException {
            if (arg.isCanShowPreviewPage()) {
                eventBus.fireEvent(newFileTrackingSuspendEvent());
                refactorService.applyRefactoring(session).then(new Operation<RefactoringResult>() {

                    @Override
                    public void apply(RefactoringResult arg) throws OperationException {
                        if (arg.getSeverity() == OK) {
                            view.hide();
                            refactoringUpdater.updateAfterRefactoring(arg.getChanges());
                            final Resource[] resources = refactorInfo.getResources();
                            if (resources != null && resources.length == 1) {
                                refactorService.reindexProject(resources[0].getRelatedProject().get().getLocation().toString());
                            }
                        } else {
                            view.showErrorMessage(arg);
                        }
                        for (ChangeInfo change : arg.getChanges()) {
                            final String path = change.getPath();
                            final String oldPath = change.getOldPath();
                            eventBus.fireEvent(newFileTrackingMoveEvent(path, oldPath));
                        }
                        eventBus.fireEvent(newFileTrackingResumeEvent());
                    }
                });
            } else {
                view.showErrorMessage(arg.getStatus());
            }
        }
    }).catchError(new Operation<PromiseError>() {

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