Search in sources :

Example 1 with ClasspathEntryDto

use of org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto in project che by eclipse.

the class SourcepathMacroTest method defaultValueOfSourcepathShouldBeBuilt.

@Test
public void defaultValueOfSourcepathShouldBeBuilt() throws Exception {
    List<ClasspathEntryDto> entries = new ArrayList<>();
    Set<String> libs = new HashSet<>();
    Path projectsRoot = Path.valueOf("/projects");
    when(appContext.getProjectsRoot()).thenReturn(projectsRoot);
    when(classpathContainer.getClasspathEntries(anyString())).thenReturn(classpathEntriesPromise);
    when(classpathResolver.getLibs()).thenReturn(libs);
    sourcepathMacro.expand();
    verify(classpathEntriesPromise).then(classpathEntriesCapture.capture());
    String classpath = classpathEntriesCapture.getValue().apply(entries);
    verify(classpathResolver).resolveClasspathEntries(entries);
    assertEquals("/projects/name", classpath);
}
Also used : Path(org.eclipse.che.ide.resource.Path) ArrayList(java.util.ArrayList) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) Matchers.anyString(org.mockito.Matchers.anyString) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with ClasspathEntryDto

use of org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto in project che by eclipse.

the class ClasspathMacroTest method defaultValueOfClasspathShouldBeBuilt.

@Test
public void defaultValueOfClasspathShouldBeBuilt() throws Exception {
    List<ClasspathEntryDto> entries = new ArrayList<>();
    Set<String> libs = new HashSet<>();
    Path projectsRoot = Path.valueOf("/projects");
    when(appContext.getProjectsRoot()).thenReturn(projectsRoot);
    when(classpathContainer.getClasspathEntries(anyString())).thenReturn(classpathEntriesPromise);
    when(classpathResolver.getLibs()).thenReturn(libs);
    classpathMacro.expand();
    verify(classpathEntriesPromise).then(classpathEntriesCapture.capture());
    String classpath = classpathEntriesCapture.getValue().apply(entries);
    verify(classpathResolver).resolveClasspathEntries(entries);
    assertEquals("/projects/name:", classpath);
}
Also used : Path(org.eclipse.che.ide.resource.Path) ArrayList(java.util.ArrayList) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) Matchers.anyString(org.mockito.Matchers.anyString) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with ClasspathEntryDto

use of org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto in project che by eclipse.

the class ClasspathMacroTest method classpathShouldBeBuiltWith2Libraries.

@Test
public void classpathShouldBeBuiltWith2Libraries() throws Exception {
    String lib1 = "lib1.jar";
    String lib2 = "lib2.jar";
    List<ClasspathEntryDto> entries = new ArrayList<>();
    Set<String> libs = new HashSet<>();
    libs.add(lib1);
    libs.add(lib2);
    when(classpathContainer.getClasspathEntries(anyString())).thenReturn(classpathEntriesPromise);
    when(classpathResolver.getLibs()).thenReturn(libs);
    classpathMacro.expand();
    verify(classpathEntriesPromise).then(classpathEntriesCapture.capture());
    String classpath = classpathEntriesCapture.getValue().apply(entries);
    verify(classpathResolver).resolveClasspathEntries(entries);
    assertEquals("lib2.jar:lib1.jar:", classpath);
}
Also used : ArrayList(java.util.ArrayList) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) Matchers.anyString(org.mockito.Matchers.anyString) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with ClasspathEntryDto

use of org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto in project che by eclipse.

the class LibEntryPresenter method go.

@Override
public void go(final AcceptsOneWidget container) {
    final Resource resource = appContext.getResource();
    Preconditions.checkState(resource != null);
    final Optional<Project> project = resource.getRelatedProject();
    isPlainJava = JAVAC.equals(project.get().getType());
    setReadOnlyMod();
    container.setWidget(view);
    if (!categories.isEmpty()) {
        view.renderLibraries();
        return;
    }
    classpathContainer.getClasspathEntries(project.get().getPath()).then(new Operation<List<ClasspathEntryDto>>() {

        @Override
        public void apply(List<ClasspathEntryDto> arg) throws OperationException {
            categories.clear();
            for (ClasspathEntryDto entry : arg) {
                if (CONTAINER == entry.getEntryKind() || LIBRARY == entry.getEntryKind()) {
                    categories.put(entry.getPath(), entry);
                }
            }
            view.setData(categories);
            view.renderLibraries();
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Resource(org.eclipse.che.ide.api.resources.Resource) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto) List(java.util.List) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 5 with ClasspathEntryDto

use of org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto in project che by eclipse.

the class ClasspathUpdaterService method createModifiedEntry.

private IClasspathEntry[] createModifiedEntry(List<ClasspathEntryDto> entries) {
    List<IClasspathEntry> coreClasspathEntries = new ArrayList<>(entries.size());
    for (ClasspathEntryDto entry : entries) {
        IPath path = fromOSString(entry.getPath());
        int entryKind = entry.getEntryKind();
        if (IClasspathEntry.CPE_LIBRARY == entryKind) {
            coreClasspathEntries.add(newLibraryEntry(path, null, null));
        } else if (IClasspathEntry.CPE_SOURCE == entryKind) {
            coreClasspathEntries.add(newSourceEntry(path));
        } else if (IClasspathEntry.CPE_VARIABLE == entryKind) {
            coreClasspathEntries.add(newVariableEntry(path, null, null));
        } else if (IClasspathEntry.CPE_CONTAINER == entryKind) {
            coreClasspathEntries.add(newContainerEntry(path));
        } else if (IClasspathEntry.CPE_PROJECT == entryKind) {
            coreClasspathEntries.add(newProjectEntry(path));
        }
    }
    return coreClasspathEntries.toArray(new IClasspathEntry[coreClasspathEntries.size()]);
}
Also used : IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ArrayList(java.util.ArrayList) ClasspathEntryDto(org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto)

Aggregations

ClasspathEntryDto (org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto)16 ArrayList (java.util.ArrayList)8 Project (org.eclipse.che.ide.api.resources.Project)8 Resource (org.eclipse.che.ide.api.resources.Resource)8 List (java.util.List)7 OperationException (org.eclipse.che.api.promises.client.OperationException)6 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 Matchers.anyString (org.mockito.Matchers.anyString)5 Operation (org.eclipse.che.api.promises.client.Operation)4 PromiseError (org.eclipse.che.api.promises.client.PromiseError)4 JavaUtil.isJavaProject (org.eclipse.che.ide.ext.java.client.util.JavaUtil.isJavaProject)3 Collections.singletonList (java.util.Collections.singletonList)2 Set (java.util.Set)2 FunctionException (org.eclipse.che.api.promises.client.FunctionException)2 Container (org.eclipse.che.ide.api.resources.Container)2 Path (org.eclipse.che.ide.resource.Path)2 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)2 ClasspathPagePresenter (org.eclipse.che.ide.ext.java.client.project.classpath.valueproviders.pages.ClasspathPagePresenter)1 IPath (org.eclipse.core.runtime.IPath)1