Search in sources :

Example 91 with Project

use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.

the class GetEffectivePomAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    final Resource[] resources = appContext.getResources();
    checkState(resources != null && resources.length == 1);
    final Project project = resources[0].getRelatedProject().get();
    checkState(MAVEN_ID.equals(project.getType()));
    mavenServerServiceClient.getEffectivePom(project.getLocation().toString()).then(new Operation<String>() {

        @Override
        public void apply(String content) throws OperationException {
            editorAgent.openEditor(new SyntheticFile("pom.xml", project.getAttributes().get(MavenAttributes.ARTIFACT_ID).get(0) + " [effective pom]", content));
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            notificationManager.notify("Problem with generating effective pom file", arg.getMessage(), FAIL, EMERGE_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) SyntheticFile(org.eclipse.che.ide.api.resources.SyntheticFile) Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 92 with Project

use of org.eclipse.che.ide.api.resources.Project in project che by eclipse.

the class ReimportMavenDependenciesAction method getPathsToSelectedMavenProject.

private List<String> getPathsToSelectedMavenProject() {
    final Resource[] resources = appContext.getResources();
    if (resources == null) {
        return Collections.emptyList();
    }
    Set<String> paths = new HashSet<>();
    for (Resource resource : resources) {
        final Optional<Project> project = resource.getRelatedProject();
        if (project.isPresent() && project.get().isTypeOf(MAVEN_ID)) {
            paths.add(project.get().getLocation().toString());
        }
    }
    return new ArrayList<>(paths);
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Resource(org.eclipse.che.ide.api.resources.Resource) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 93 with Project

use of org.eclipse.che.ide.api.resources.Project 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 94 with Project

use of org.eclipse.che.ide.api.resources.Project 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 95 with Project

use of org.eclipse.che.ide.api.resources.Project 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)

Aggregations

Project (org.eclipse.che.ide.api.resources.Project)127 Resource (org.eclipse.che.ide.api.resources.Resource)74 OperationException (org.eclipse.che.api.promises.client.OperationException)53 Operation (org.eclipse.che.api.promises.client.Operation)51 PromiseError (org.eclipse.che.api.promises.client.PromiseError)48 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)24 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)18 Promise (org.eclipse.che.api.promises.client.Promise)16 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)14 Container (org.eclipse.che.ide.api.resources.Container)14 List (java.util.List)12 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)12 Path (org.eclipse.che.ide.resource.Path)12 Optional (com.google.common.base.Optional)11 ArrayList (java.util.ArrayList)10 File (org.eclipse.che.ide.api.resources.File)10 Credentials (org.eclipse.che.ide.api.subversion.Credentials)10 FunctionException (org.eclipse.che.api.promises.client.FunctionException)9 JavaUtil.isJavaProject (org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject)9 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)8