use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class Launching method readInstallInfo.
/**
* Reads the file of saved time stamps and populates the {@link #fgInstallTimeMap}.
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=266651 for more information
*
* @since 3.7
*/
private static void readInstallInfo() {
fgInstallTimeMap = new HashMap<String, Long>();
IPath libPath = getDefault().getStateLocation();
//$NON-NLS-1$
libPath = libPath.append(".install.xml");
File file = libPath.toFile();
if (file.exists()) {
try {
InputStream stream = new BufferedInputStream(new FileInputStream(file));
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
parser.setErrorHandler(new DefaultHandler());
Element root = parser.parse(new InputSource(stream)).getDocumentElement();
if (root.getNodeName().equalsIgnoreCase("dirs")) {
//$NON-NLS-1$
NodeList nodes = root.getChildNodes();
Node node = null;
Element element = null;
for (int i = 0; i < nodes.getLength(); i++) {
node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
element = (Element) node;
if (element.getNodeName().equalsIgnoreCase("entry")) {
//$NON-NLS-1$
//$NON-NLS-1$
String loc = element.getAttribute("loc");
//$NON-NLS-1$
String stamp = element.getAttribute("stamp");
try {
Long l = new Long(stamp);
fgInstallTimeMap.put(loc, l);
} catch (NumberFormatException nfe) {
//do nothing
}
}
}
}
}
} catch (IOException e) {
log(e);
} catch (ParserConfigurationException e) {
log(e);
} catch (SAXException e) {
log(e);
}
}
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class StandardVMType method getDefaultSystemLibrarySource.
/**
* Returns a path to the source attachment for the given library, or
* an empty path if none.
*
* @param libLocation
* the {@link java.io.File} location of the library to find the source for
* @return a path to the source attachment for the given library, or
* an empty path if none
*/
protected IPath getDefaultSystemLibrarySource(File libLocation) {
File parent = libLocation.getParentFile();
while (parent != null) {
File parentsrc = new File(parent, SRC_JAR);
if (parentsrc.isFile()) {
setDefaultRootPath(SRC);
return new Path(parentsrc.getPath());
}
parentsrc = new File(parent, SRC_ZIP);
if (parentsrc.isFile()) {
//$NON-NLS-1$
setDefaultRootPath("");
return new Path(parentsrc.getPath());
}
parent = parent.getParentFile();
}
// if we didn't find any of the normal source files, look for J9 source
IPath result = checkForJ9LibrarySource(libLocation);
if (result != null) {
return result;
}
// check for <lib>-src.jar pattern
IPath libName = new Path(libLocation.getName());
String extension = libName.getFileExtension();
String prefix = libName.removeFileExtension().lastSegment();
if (extension != null) {
IPath srcPath = new Path(libLocation.getPath());
srcPath = srcPath.removeLastSegments(1);
StringBuffer buf = new StringBuffer();
buf.append(prefix);
//$NON-NLS-1$
buf.append("-src.");
buf.append(extension);
srcPath = srcPath.append(buf.toString());
if (srcPath.toFile().exists()) {
return srcPath;
}
}
//$NON-NLS-1$
setDefaultRootPath("");
return Path.EMPTY;
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class StandardVMType method gatherAllLibraries.
/**
* Returns a list of all zip's and jars contained in the given directories.
*
* @param dirPaths
* a list of absolute paths of directories to search
* @return List of all zip's and jars
*/
public static List<LibraryLocation> gatherAllLibraries(String[] dirPaths) {
List<LibraryLocation> libraries = new ArrayList<LibraryLocation>();
for (int i = 0; i < dirPaths.length; i++) {
File extDir = new File(dirPaths[i]);
if (extDir.isDirectory()) {
String[] names = extDir.list(fgArchiveFilter);
if (names != null) {
for (int j = 0; j < names.length; j++) {
File jar = new File(extDir, names[j]);
if (jar.isFile()) {
try {
IPath libPath = new Path(jar.getCanonicalPath());
IPath sourcePath = Path.EMPTY;
IPath packageRoot = Path.EMPTY;
URL javadocLocation = null;
URL indexLocation = null;
// for( ILibraryLocationResolver resolver : getLibraryLocationResolvers() ) {
// try {
// sourcePath = resolver.getSourcePath(libPath);
// packageRoot = resolver.getPackageRoot(libPath);
// javadocLocation = resolver.getJavadocLocation(libPath);
// indexLocation = resolver.getIndexLocation(libPath);
// break;
// } catch(Exception e) {
// Launching.log(e);
// }
// }
LibraryLocation library = new LibraryLocation(libPath, sourcePath, packageRoot, javadocLocation, indexLocation);
libraries.add(library);
} catch (IOException e) {
Launching.log(e);
}
}
}
}
}
}
return libraries;
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class StandardVMType method getDefaultLibraryLocations.
/* (non-Javadoc)
* @see org.eclipse.jdt.launching.IVMInstallType#getDefaultLibraryLocations(java.io.File)
*/
public LibraryLocation[] getDefaultLibraryLocations(File installLocation) {
//NOTE: We do not add libraries from the "endorsed" directory explicitly, as
//the bootpath contains these entries already (if they exist).
// Determine the java executable that corresponds to the specified install location
// and use this to generate library information. If no java executable was found,
// the 'standard' libraries will be returned.
List<LibraryLocation> allLibs = fgDefaultLibLocs.get(installLocation.getAbsolutePath());
if (allLibs == null) {
File javaExecutable = findJavaExecutable(installLocation);
LibraryInfo libInfo;
if (javaExecutable == null) {
libInfo = getDefaultLibraryInfo(installLocation);
} else {
libInfo = getLibraryInfo(installLocation, javaExecutable);
}
// Add all endorsed libraries - they are first, as they replace
allLibs = new ArrayList<LibraryLocation>(gatherAllLibraries(libInfo.getEndorsedDirs()));
// next is the boot path libraries
String[] bootpath = libInfo.getBootpath();
List<LibraryLocation> boot = new ArrayList<LibraryLocation>(bootpath.length);
URL url = getDefaultJavadocLocation(installLocation);
for (int i = 0; i < bootpath.length; i++) {
IPath path = new Path(bootpath[i]);
File lib = path.toFile();
if (lib.exists() && lib.isFile()) {
LibraryLocation libraryLocation = new LibraryLocation(path, getDefaultSystemLibrarySource(lib), getDefaultPackageRootPath(), url);
boot.add(libraryLocation);
}
}
allLibs.addAll(boot);
// Add all extension libraries
allLibs.addAll(gatherAllLibraries(libInfo.getExtensionDirs()));
//remove duplicates
HashSet<String> set = new HashSet<String>();
LibraryLocation lib = null;
for (ListIterator<LibraryLocation> liter = allLibs.listIterator(); liter.hasNext(); ) {
lib = liter.next();
IPath systemLibraryPath = lib.getSystemLibraryPath();
String device = systemLibraryPath.getDevice();
if (device != null) {
// @see Bug 197866 - Installed JRE Wizard creates duplicate system libraries when drive letter is lower case
systemLibraryPath = systemLibraryPath.setDevice(device.toUpperCase());
}
if (!set.add(systemLibraryPath.toOSString())) {
//did not add it, duplicate
liter.remove();
}
}
fgDefaultLibLocs.put(installLocation.getAbsolutePath(), allLibs);
}
return allLibs.toArray(new LibraryLocation[allLibs.size()]);
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class ChangeDescription method createSourceResource.
private IResource createSourceResource(IResourceDelta delta) {
IPath sourcePath = delta.getMovedFromPath();
IResource resource = delta.getResource();
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
switch(resource.getType()) {
case IResource.PROJECT:
return wsRoot.getProject(sourcePath.segment(0));
case IResource.FOLDER:
return wsRoot.getFolder(sourcePath);
case IResource.FILE:
return wsRoot.getFile(sourcePath);
}
return null;
}
Aggregations