Search in sources :

Example 91 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class JavaProjectHelper method addRTJar13.

public static IPackageFragmentRoot addRTJar13(IJavaProject jproject) throws CoreException {
    IPath[] rtJarPath = findRtJar(RT_STUBS_13);
    Map options = jproject.getOptions(false);
    JavaProjectHelper.set13CompilerOptions(options);
    jproject.setOptions(options);
    return addLibrary(jproject, rtJarPath[0], rtJarPath[1], rtJarPath[2]);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Map(java.util.Map)

Example 92 with IPath

use of org.eclipse.core.runtime.IPath 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)

Example 93 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class ClasspathBuilder method addJars.

private void addJars(IJavaProject project, List<String> library, final List<IClasspathEntry> classpathEntries) {
    if (library == null || library.isEmpty()) {
        return;
    }
    for (String libFolder : library) {
        if (libFolder.isEmpty()) {
            continue;
        }
        IFolder libraryFolder = project.getProject().getFolder(libFolder);
        if (!libraryFolder.exists()) {
            return;
        }
        try {
            libraryFolder.accept(proxy -> {
                if (IResource.FILE != proxy.getType()) {
                    return true;
                }
                IPath path = proxy.requestFullPath();
                if (!path.toString().endsWith(".jar")) {
                    return false;
                }
                IClasspathEntry libEntry = JavaCore.newLibraryEntry(proxy.requestResource().getLocation(), null, null);
                classpathEntries.add(libEntry);
                return false;
            }, IContainer.INCLUDE_PHANTOMS);
        } catch (CoreException e) {
            LOG.warn("Can't read folder structure: " + libraryFolder.getFullPath().toString());
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IFolder(org.eclipse.core.resources.IFolder)

Example 94 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class ZipFileStructureProvider method initialize.

/**
     * Initializes this object's children table based on the contents of
     * the specified source file.
     */
protected void initialize() {
    children = new HashMap(1000);
    Enumeration entries = zipFile.entries();
    while (entries.hasMoreElements()) {
        ZipEntry entry = (ZipEntry) entries.nextElement();
        if (!entry.isDirectory()) {
            IPath path = new Path(entry.getName()).addTrailingSeparator();
            int pathSegmentCount = path.segmentCount();
            for (int i = 1; i < pathSegmentCount; i++) {
                createContainer(path.uptoSegment(i));
            }
            createFile(entry);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Enumeration(java.util.Enumeration) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) ZipEntry(java.util.zip.ZipEntry)

Example 95 with IPath

use of org.eclipse.core.runtime.IPath in project che by eclipse.

the class JavaRefactoringDescriptorUtil method setResourcePathArray.

/**
	 * Inserts the resources into the map.
	 *
	 * @param arguments arguments the map with <code>&lt;String, String&gt;</code> mapping
	 * @param countAttribute the attribute where the number of resources will be stored. Can be <code>null</code> if no count attribute should be created
	 * @param arrayAttribute the attribute where the resources will be stored
	 * @param project the project of the resources or <code>null</code>
	 * @param resourcePaths the resource paths to store
	 * @param offset the offset to start at
	 *
	 * @throws IllegalArgumentException if the attribute name is invalid or any of the resources are null
	 */
public static void setResourcePathArray(Map arguments, String countAttribute, String arrayAttribute, String project, IPath[] resourcePaths, int offset) throws IllegalArgumentException {
    if (resourcePaths == null)
        //$NON-NLS-1$ //$NON-NLS-2$
        throw new IllegalArgumentException("The resources for arrayAttribute '" + arrayAttribute + "' may not be null");
    if (countAttribute != null)
        setInt(arguments, countAttribute, resourcePaths.length);
    for (int i = 0; i < resourcePaths.length; i++) {
        IPath resourcePath = resourcePaths[i];
        setResourcePath(arguments, getAttributeName(arrayAttribute, offset + i), project, resourcePath);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath)

Aggregations

IPath (org.eclipse.core.runtime.IPath)800 Path (org.eclipse.core.runtime.Path)219 File (java.io.File)161 IFile (org.eclipse.core.resources.IFile)150 CoreException (org.eclipse.core.runtime.CoreException)135 IResource (org.eclipse.core.resources.IResource)112 IOException (java.io.IOException)100 ArrayList (java.util.ArrayList)92 IProject (org.eclipse.core.resources.IProject)85 IFolder (org.eclipse.core.resources.IFolder)80 Test (org.junit.Test)72 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)58 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)55 IStatus (org.eclipse.core.runtime.IStatus)48 InputStream (java.io.InputStream)44 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)42 Status (org.eclipse.core.runtime.Status)36 IJavaProject (org.eclipse.jdt.core.IJavaProject)36 URL (java.net.URL)33 IContainer (org.eclipse.core.resources.IContainer)33