📄 vminstallclasspath.java
字号:
/**
* Copyright (c) 2003-2007 Craig Setera
* All Rights Reserved.
* Licensed under the Eclipse Public License - v 1.0
* For more information see http://www.eclipse.org/legal/epl-v10.html
*/
package eclipseme.core.model.impl;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.LibraryLocation;
import eclipseme.core.importer.LibraryImporter;
import eclipseme.core.model.Classpath;
import eclipseme.core.model.ILibrary;
import eclipseme.core.persistence.IPersistenceProvider;
import eclipseme.core.persistence.PersistenceException;
/**
* A special version of the Classpath class that is capable
* of appending or prepending the primary {@link IVMInstall} classpath
* libraries to this classpath dynamically.
* <p />
* Copyright (c) 2003-2007 Craig Setera<br>
* All Rights Reserved.<br>
* Licensed under the Eclipse Public License - v 1.0<p/>
* <br>
* $Revision$
* <br>
* $Date$
* <br>
* @author Craig Setera
*/
public class VMInstallClasspath extends Classpath {
private boolean prependVMLibraries;
private ILibrary[] entriesCache;
/**
* Construct a new classpath with the libraries prepended
* or appended according to the provided boolean.
*
* @param prependVMLibraries
*/
public VMInstallClasspath() {
super();
}
/**
* @see eclipseme.core.model.Classpath#getEntries()
*/
public ILibrary[] getEntries() {
if (entriesCache == null) {
entriesCache = calculateEntries();
}
return entriesCache;
}
public boolean isPrependVMLibraries() {
return prependVMLibraries;
}
/**
* @see eclipseme.core.model.Classpath#loadUsing(eclipseme.core.persistence.IPersistenceProvider)
*/
public void loadUsing(IPersistenceProvider persistenceProvider)
throws PersistenceException
{
super.loadUsing(persistenceProvider);
persistenceProvider.loadBoolean("prependVMLibraries");
}
public void setPrependVMLibraries(boolean prependVMLibraries) {
this.prependVMLibraries = prependVMLibraries;
}
/**
* @see eclipseme.core.model.Classpath#storeUsing(eclipseme.core.persistence.IPersistenceProvider)
*/
public void storeUsing(IPersistenceProvider persistenceProvider)
throws PersistenceException
{
super.storeUsing(persistenceProvider);
persistenceProvider.storeBoolean("prependVMLibraries", prependVMLibraries);
}
/**
* Calculate the entries for this classpath based on the current
* default VM installation.
*
* @return
*/
private ILibrary[] calculateEntries() {
ILibrary[] userLibs = super.getEntries();
// Retrieve the libraries from the default VM Install
LibraryLocation[] libraryLocations =
JavaRuntime.getLibraryLocations(JavaRuntime.getDefaultVMInstall());
// Build our complete list of entries
int vmLibIndex = prependVMLibraries ? 0 : userLibs.length;
int userLibIndex = prependVMLibraries ? userLibs.length : 0;
ILibrary[] allLibraries = new ILibrary[userLibs.length + libraryLocations.length];
System.arraycopy(userLibs, 0, allLibraries, userLibIndex, userLibs.length);
LibraryImporter importer = new LibraryImporter();
for (int i = 0; i < libraryLocations.length; i++) {
allLibraries[vmLibIndex++] =
importer.createLibraryFor(libraryLocations[i].getSystemLibraryPath().toFile());
}
return allLibraries;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -