本文整理汇总了Java中org.eclipse.jdt.launching.LibraryLocation类的典型用法代码示例。如果您正苦于以下问题:Java LibraryLocation类的具体用法?Java LibraryLocation怎么用?Java LibraryLocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LibraryLocation类属于org.eclipse.jdt.launching包,在下文中一共展示了LibraryLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processVMInstallType
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
private void processVMInstallType(IVMInstallType installType, List locations, List labels) {
if (installType != null) {
IVMInstall[] installs= installType.getVMInstalls();
boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS());
final String HOME_SUFFIX= "/Home"; //$NON-NLS-1$
for (int i= 0; i < installs.length; i++) {
String label= getFormattedLabel(installs[i].getName());
LibraryLocation[] libLocations= installs[i].getLibraryLocations();
if (libLocations != null) {
processLibraryLocation(libLocations, label);
} else {
String filePath= installs[i].getInstallLocation().getAbsolutePath();
// on MacOS X install locations end in an additional "/Home" segment; remove it
if (isMac && filePath.endsWith(HOME_SUFFIX))
filePath= filePath.substring(0, filePath.length()- HOME_SUFFIX.length() + 1);
locations.add(filePath);
labels.add(label);
}
}
}
}
示例2: processVMInstallType
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
private void processVMInstallType(IVMInstallType installType, List<IPath> locations, List<String> labels) {
if (installType != null) {
IVMInstall[] installs= installType.getVMInstalls();
boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS());
for (int i= 0; i < installs.length; i++) {
String label= getFormattedLabel(installs[i].getName());
LibraryLocation[] libLocations= installs[i].getLibraryLocations();
if (libLocations != null) {
processLibraryLocation(libLocations, label);
} else {
IPath filePath= Path.fromOSString(installs[i].getInstallLocation().getAbsolutePath());
// On MacOS X, install locations end in an additional "/Home" segment; remove it.
if (isMac && "Home".equals(filePath.lastSegment())) //$NON-NLS-1$
filePath= filePath.removeLastSegments(1);
locations.add(filePath);
labels.add(label);
}
}
}
}
示例3: processVMInstallType
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
private void processVMInstallType(IVMInstallType installType, List<String> locations, List<String> labels) {
if (installType != null) {
IVMInstall[] installs= installType.getVMInstalls();
boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS());
final String HOME_SUFFIX= "/Home"; //$NON-NLS-1$
for (int i= 0; i < installs.length; i++) {
String label= getFormattedLabel(installs[i].getName());
LibraryLocation[] libLocations= installs[i].getLibraryLocations();
if (libLocations != null) {
processLibraryLocation(libLocations, label);
} else {
String filePath= installs[i].getInstallLocation().getAbsolutePath();
// on MacOS X install locations end in an additional
// "/Home" segment; remove it
if (isMac && filePath.endsWith(HOME_SUFFIX))
filePath= filePath.substring(0, filePath.length() - HOME_SUFFIX.length() + 1);
locations.add(filePath);
labels.add(label);
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:23,代码来源:FilteredTypesSelectionDialog.java
示例4: addClassPathEntries
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
public void addClassPathEntries() {
try {
final ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
final IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] _libraryLocations = JavaRuntime.getLibraryLocations(vmInstall);
final Consumer<LibraryLocation> _function = new Consumer<LibraryLocation>() {
@Override
public void accept(final LibraryLocation eachLocation) {
IPath _systemLibraryPath = eachLocation.getSystemLibraryPath();
IClasspathEntry _newLibraryEntry = JavaCore.newLibraryEntry(_systemLibraryPath, null, null);
entries.add(_newLibraryEntry);
}
};
((List<LibraryLocation>)Conversions.doWrapArray(_libraryLocations)).forEach(_function);
int _size = entries.size();
IClasspathEntry[] _newArrayOfSize = new IClasspathEntry[_size];
IClasspathEntry[] _array = entries.<IClasspathEntry>toArray(_newArrayOfSize);
this.javaProject.setRawClasspath(_array, null);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例5: call
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
@Override
public Object call(Object args) throws Exception {
try {
IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] libraryLocations = JavaRuntime.getLibraryLocations(defaultVMInstall);
ArrayList<File> jars = new ArrayList<File>();
for (LibraryLocation location : libraryLocations) {
jars.add(location.getSystemLibraryPath().toFile());
}
return jars;
} catch (Throwable e) {
JythonModulesManagerUtils.tryRethrowAsJDTNotAvailableException(e);
throw new RuntimeException("Should never get here", e);
}
}
示例6: getJavaVersion
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
/**
* Returns the version string for the Java implementation, or null if it is
* unknown.
*/
public String getJavaVersion() {
HyVMInstallType installType = (HyVMInstallType) getVMInstallType();
File installLocation = getInstallLocation();
if (installLocation == null) {
return null;
}
// Look for the luni library
LibraryLocation[] libraries = installType
.getDefaultLibraryLocations(installLocation);
for (LibraryLocation library : libraries) {
IPath libPath = library.getSystemLibraryPath();
if (libPath.lastSegment().equals("luni.jar")) {
return findSpecVersionFrom(libPath);
}
}
return null;
}
示例7: createProject
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
/**
* This method creates a new java project based on the user inputs, captured in WizardInput object.
* The new project is created in the current workspace.
* @param wizardInput
* @return IJavaProject
* @throws CoreException
* @throws IOException
**/
public IJavaProject createProject(WizardInput wizardInput) throws CoreException, IOException
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(wizardInput.getProjectName());
project.create(null);
project.open(null);
IProjectDescription description = project.getDescription();
description.setNatureIds(new String[] { JavaCore.NATURE_ID });
project.setDescription(description, null);
IJavaProject javaProject = JavaCore.create(project);
IFolder binFolder = project.getFolder("bin");
binFolder.create(false, true, null);
javaProject.setOutputLocation(binFolder.getFullPath(), null);
List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
for (LibraryLocation element : locations) {
entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
}
InputStream is = new BufferedInputStream(new FileInputStream(wizardInput.getSootPath().toOSString()));
IFile jarFile = project.getFile("soot-trunk.jar");
jarFile.create(is, false, null);
IPath path = jarFile.getFullPath();
entries.add(JavaCore.newLibraryEntry(path, null, null));
javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
IFolder sourceFolder = project.getFolder("src");
sourceFolder.create(false, true, null);
IPackageFragmentRoot root1 = javaProject.getPackageFragmentRoot(sourceFolder);
IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
newEntries[oldEntries.length] = JavaCore.newSourceEntry(root1.getPath());
javaProject.setRawClasspath(newEntries, null);
String filepath = sourceFolder.getLocation().toOSString();
File file = new File(filepath);
wizardInput.setFile(file);
try {
CodeGenerator.generateSource(wizardInput);
} catch (JClassAlreadyExistsException e) {
e.printStackTrace();
}
sourceFolder.refreshLocal(1, null);
javaProject.open(null);
return javaProject;
}
示例8: isRuntimeJar
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
public static boolean isRuntimeJar(File jar) throws IOException {
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
for (LibraryLocation library : locations) {
File runtime = JavaCore.newLibraryEntry(library.getSystemLibraryPath(), null, null).getPath().toFile().getCanonicalFile();
if(runtime.equals(jar.getCanonicalFile())){
return true;
}
}
return false;
}
示例9: getRuntimeJar
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
public static File getRuntimeJar(String jarName) throws IOException {
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
for (LibraryLocation library : locations) {
File runtime = JavaCore.newLibraryEntry(library.getSystemLibraryPath(), null, null).getPath().toFile().getCanonicalFile();
if(runtime.getName().equals(jarName)){
return runtime;
}
}
return null;
}
示例10: addJavaLibrariesTo
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
private void addJavaLibrariesTo(IJavaProject javaProject) throws JavaModelException {
List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
for (LibraryLocation element : locations) {
entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
}
entries.addAll(Arrays.asList(javaProject.getRawClasspath()));
javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
}
示例11: getAccessRules
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
/**
* Returns an array of access rules to be applied to the specified runtime
* libraries and execution environment in the context of the given project.
*
* An array of access rules is returned for each library specified by
* libraries.
*/
public IAccessRule[][] getAccessRules(IExecutionEnvironment environment,
IVMInstall vm, LibraryLocation[] libraries, IJavaProject project) {
// Read list of packages in our definition
if (packages == null) {
try {
packages = getPackages();
} catch (IOException e) {
Activator.getDefault().log("Unable to read package definition", e);
return new IAccessRule[0][];
}
}
// Set up rules for specific packages
IAccessRule[] packageRules = new IAccessRule[packages.length + 1];
// Allow named packages
for (int i = 0; i < packages.length; i++) {
Path path = new Path(packages[i].replace('.', IPath.SEPARATOR));
packageRules[i] = JavaCore.newAccessRule(path, IAccessRule.K_ACCESSIBLE);
}
// Disallow everything else
packageRules[packages.length] = JavaCore.newAccessRule(
new Path("**/*"), IAccessRule.K_NON_ACCESSIBLE); //$NON-NLS-1$
// These rules apply equally to all libraries
IAccessRule[][] allRules = new IAccessRule[libraries.length][];
for (int i = 0; i < allRules.length; i++) {
allRules[i] = packageRules;
}
return allRules;
}
示例12: kernelLocation
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
private LibraryLocation[] kernelLocation(String subdir, String vmname) {
List kernelLibraries = ((HyVMInstallType) getVMInstallType()).getKernelLibraries(
getInstallLocation(), subdir, vmname);
LibraryLocation[] kernelLibrariesLocation = new LibraryLocation[kernelLibraries
.size()];
for (int i = 0; i < kernelLibraries.size(); i++) {
kernelLibrariesLocation[i] = (LibraryLocation) kernelLibraries.get(i);
}
return kernelLibrariesLocation;
}
示例13: getDefaultLibraryLocations
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
@Override
public LibraryLocation[] getDefaultLibraryLocations(File installLocation) {
// for now use the same stub JAR for all
IPath path = Path.fromOSString(new File(installLocation, RTSTUBS_JAR).getAbsolutePath());
return new LibraryLocation[] { new LibraryLocation(path, Path.EMPTY, Path.EMPTY) };
}
示例14: processLibraryLocation
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
private void processLibraryLocation(LibraryLocation[] libLocations, String label) {
for (int l= 0; l < libLocations.length; l++) {
LibraryLocation location= libLocations[l];
fLib2Name.put(location.getSystemLibraryPath().toString(), label);
}
}
示例15: processLibraryLocation
import org.eclipse.jdt.launching.LibraryLocation; //导入依赖的package包/类
private void processLibraryLocation(LibraryLocation[] libLocations, String label) {
for (int l= 0; l < libLocations.length; l++) {
LibraryLocation location= libLocations[l];
fLib2Name.put(location.getSystemLibraryPath(), label);
}
}