Search in sources :

Example 96 with Project

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

the class ClasspathMacro method expand.

@Override
public Promise<String> expand() {
    final Resource[] resources = appContext.getResources();
    if (resources == null || resources.length != 1) {
        return promises.resolve("");
    }
    final Resource resource = resources[0];
    final Optional<Project> project = resource.getRelatedProject();
    if (!JavaUtil.isJavaProject(project.get())) {
        return promises.resolve("");
    }
    final String projectPath = project.get().getLocation().toString();
    return classpathContainer.getClasspathEntries(projectPath).then(new Function<List<ClasspathEntryDto>, String>() {

        @Override
        public String apply(List<ClasspathEntryDto> arg) throws FunctionException {
            classpathResolver.resolveClasspathEntries(arg);
            Set<String> libs = classpathResolver.getLibs();
            StringBuilder classpath = new StringBuilder();
            for (String lib : libs) {
                classpath.append(lib).append(':');
            }
            for (ClasspathEntryDto container : classpathResolver.getContainers()) {
                if (!JRE_CONTAINER.equals(container.getPath())) {
                    addLibsFromContainer(container, classpath);
                }
            }
            if (classpath.toString().isEmpty()) {
                classpath.append(appContext.getProjectsRoot().toString()).append(projectPath).append(':');
            }
            return classpath.toString();
        }
    });
}
Also used : Set(java.util.Set) Resource(org.eclipse.che.ide.api.resources.Resource) FunctionException(org.eclipse.che.api.promises.client.FunctionException) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) Project(org.eclipse.che.ide.api.resources.Project) List(java.util.List)

Example 97 with Project

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

the class SourcepathMacro method expand.

@Override
public Promise<String> expand() {
    final Resource[] resources = appContext.getResources();
    if (resources == null || resources.length != 1) {
        return promises.resolve("");
    }
    final Resource resource = resources[0];
    final Optional<Project> project = resource.getRelatedProject();
    if (!JavaUtil.isJavaProject(project.get())) {
        return promises.resolve("");
    }
    final String projectPath = project.get().getLocation().toString();
    return classpathContainer.getClasspathEntries(projectPath).then(new Function<List<ClasspathEntryDto>, String>() {

        @Override
        public String apply(List<ClasspathEntryDto> arg) throws FunctionException {
            classpathResolver.resolveClasspathEntries(arg);
            Set<String> sources = classpathResolver.getSources();
            StringBuilder classpath = new StringBuilder();
            for (String source : sources) {
                classpath.append(source.substring(projectPath.length() + 1)).append(':');
            }
            if (classpath.toString().isEmpty()) {
                classpath.append(appContext.getProjectsRoot().toString()).append(projectPath);
            }
            return classpath.toString();
        }
    });
}
Also used : Set(java.util.Set) Resource(org.eclipse.che.ide.api.resources.Resource) FunctionException(org.eclipse.che.api.promises.client.FunctionException) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) Project(org.eclipse.che.ide.api.resources.Project) List(java.util.List)

Example 98 with Project

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

the class QuickDocPresenter method showDocumentation.

@Override
public void showDocumentation() {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    if (activeEditor == null) {
        return;
    }
    if (!(activeEditor instanceof TextEditor)) {
        Log.error(getClass(), "Quick Document support only TextEditor as editor");
        return;
    }
    TextEditor editor = ((TextEditor) activeEditor);
    int offset = editor.getCursorOffset();
    final PositionConverter.PixelCoordinates coordinates = editor.getPositionConverter().offsetToPixel(offset);
    final Resource resource = appContext.getResource();
    if (resource != null) {
        final Optional<Project> project = resource.getRelatedProject();
        final Optional<Resource> srcFolder = resource.getParentWithMarker(SourceFolderMarker.ID);
        if (!srcFolder.isPresent()) {
            return;
        }
        final String fqn = JavaUtil.resolveFQN((Container) srcFolder.get(), resource);
        final String docUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/java/javadoc/find?fqn=" + fqn + "&projectpath=" + project.get().getLocation() + "&offset=" + offset;
        view.show(agentURLDecorator.modify(docUrl), coordinates.getX(), coordinates.getY());
    }
}
Also used : 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) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) PositionConverter(org.eclipse.che.ide.api.editor.position.PositionConverter)

Example 99 with Project

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

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

the class MovePresenter method createMoveDto.

private CreateMoveRefactoring createMoveDto() {
    List<ElementToMove> elements = new ArrayList<>();
    Project project = null;
    for (Resource resource : refactorInfo.getResources()) {
        ElementToMove element = dtoFactory.createDto(ElementToMove.class);
        if (resource instanceof Container) {
            element.setPath(resource.getLocation().toString());
            element.setPack(true);
        } else {
            element.setPath(JavaUtil.resolveFQN(resource));
            element.setPack(false);
        }
        elements.add(element);
        if (project == null) {
            project = resource.getRelatedProject().get();
        }
    }
    CreateMoveRefactoring moveRefactoring = dtoFactory.createDto(CreateMoveRefactoring.class);
    moveRefactoring.setElements(elements);
    if (project != null) {
        moveRefactoring.setProjectPath(project.getLocation().toString());
    }
    return moveRefactoring;
}
Also used : JavaProject(org.eclipse.che.ide.ext.java.shared.dto.model.JavaProject) Project(org.eclipse.che.ide.api.resources.Project) Container(org.eclipse.che.ide.api.resources.Container) CreateMoveRefactoring(org.eclipse.che.ide.ext.java.shared.dto.refactoring.CreateMoveRefactoring) ElementToMove(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ElementToMove) ArrayList(java.util.ArrayList) Resource(org.eclipse.che.ide.api.resources.Resource)

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