use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class ImportOperation method getDestinationContainerFor.
/**
* Returns the container resource that the passed file system object should be
* imported into.
*
* @param fileSystemObject the file system object being imported
* @return the container resource that the passed file system object should be
* imported into
* @exception CoreException if this method failed
*/
IContainer getDestinationContainerFor(Object fileSystemObject) throws CoreException {
IPath pathname = new Path(provider.getFullPath(fileSystemObject));
if (createContainerStructure) {
return createContainersFor(pathname.removeLastSegments(1));
}
if (source == fileSystemObject) {
return null;
}
IPath sourcePath = new Path(provider.getFullPath(source));
IPath destContainerPath = pathname.removeLastSegments(1);
IPath relativePath = destContainerPath.removeFirstSegments(sourcePath.segmentCount()).setDevice(null);
return createContainersFor(relativePath);
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class ImportOperation method importFileSystemObjects.
/**
* Imports the specified file system objects into the workspace.
* If the import fails, adds a status object to the list to be returned by
* <code>getStatus</code>.
*
* @param filesToImport the list of file system objects to import
* (element type: <code>Object</code>)
* @throws CoreException
* @exception OperationCanceledException if canceled
*/
void importFileSystemObjects(List filesToImport) throws CoreException {
Iterator filesEnum = filesToImport.iterator();
while (filesEnum.hasNext()) {
Object fileSystemObject = filesEnum.next();
if (source == null) {
// We just import what we are given into the destination
IPath sourcePath = new Path(provider.getFullPath(fileSystemObject)).removeLastSegments(1);
if (provider.isFolder(fileSystemObject) && sourcePath.isEmpty()) {
// If we don't have a parent then we have selected the
// file systems root. Roots can't copied (at least not
// under windows).
errorTable.add(new Status(IStatus.INFO, PlatformUI.PLUGIN_ID, 0, "DataTransferMessages.ImportOperation_cannotCopy", null));
continue;
}
source = sourcePath.toFile();
}
importRecursivelyFrom(fileSystemObject, POLICY_DEFAULT);
}
}
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]);
}
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()]);
}
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());
}
}
}
Aggregations