List of usage examples for org.eclipse.jdt.core IClasspathAttribute getValue
String getValue();
From source file:at.bestsolution.fxide.jdt.corext.javadoc.JavaDocLocations.java
License:Open Source License
public static URL getLibraryJavadocLocation(IClasspathEntry entry) { if (entry == null) { throw new IllegalArgumentException("Entry must not be null"); //$NON-NLS-1$ }//from w ww . j a v a 2 s . co m int kind = entry.getEntryKind(); if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) { throw new IllegalArgumentException("Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); //$NON-NLS-1$ } IClasspathAttribute[] extraAttributes = entry.getExtraAttributes(); for (int i = 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib = extraAttributes[i]; if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) { return parseURL(attrib.getValue()); } } return null; }
From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess2.java
License:Open Source License
private static String getSourceAttachmentEncoding(IPackageFragmentRoot root) throws JavaModelException { String encoding = ResourcesPlugin.getEncoding(); IClasspathEntry entry = root.getRawClasspathEntry(); if (entry != null) { int kind = entry.getEntryKind(); if (kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE) { IClasspathAttribute[] extraAttributes = entry.getExtraAttributes(); for (int i = 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib = extraAttributes[i]; if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) { return attrib.getValue(); }/*from w w w . ja v a2 s . c om*/ } } } return encoding; }
From source file:at.bestsolution.javafx.ide.jdt.internal.jdt.CPListElement.java
License:Open Source License
public static CPListElement create(Object parent, IClasspathEntry curr, boolean newElement, IJavaProject project) {/*from w w w .jav a2 s. c om*/ IPath path = curr.getPath(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); // get the resource IResource res = null; boolean isMissing = false; IPath linkTarget = null; switch (curr.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: try { isMissing = project != null && (JavaCore.getClasspathContainer(path, project) == null); } catch (JavaModelException e) { isMissing = true; } break; case IClasspathEntry.CPE_VARIABLE: IPath resolvedPath = JavaCore.getResolvedVariablePath(path); isMissing = root.findMember(resolvedPath) == null && !resolvedPath.toFile().exists(); break; case IClasspathEntry.CPE_LIBRARY: res = root.findMember(path); if (res == null) { if (!ArchiveFileFilter.isArchivePath(path, true)) { if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK() && root.getProject(path.segment(0)).exists()) { res = root.getFolder(path); } } IPath rawPath = path; if (project != null) { IPackageFragmentRoot[] roots = project.findPackageFragmentRoots(curr); if (roots.length == 1) rawPath = roots[0].getPath(); } isMissing = !rawPath.toFile().exists(); // look for external JARs and folders } else if (res.isLinked()) { linkTarget = res.getLocation(); } break; case IClasspathEntry.CPE_SOURCE: path = path.removeTrailingSeparator(); res = root.findMember(path); if (res == null) { if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) { res = root.getFolder(path); } isMissing = true; } else if (res.isLinked()) { linkTarget = res.getLocation(); } break; case IClasspathEntry.CPE_PROJECT: res = root.findMember(path); isMissing = (res == null); break; } CPListElement elem = new CPListElement(parent, project, curr.getEntryKind(), path, newElement, res, linkTarget); elem.setExported(curr.isExported()); elem.setAttribute(SOURCEATTACHMENT, curr.getSourceAttachmentPath()); elem.setAttribute(OUTPUT, curr.getOutputLocation()); elem.setAttribute(EXCLUSION, curr.getExclusionPatterns()); elem.setAttribute(INCLUSION, curr.getInclusionPatterns()); elem.setAttribute(ACCESSRULES, curr.getAccessRules()); elem.setAttribute(COMBINE_ACCESSRULES, new Boolean(curr.combineAccessRules())); IClasspathAttribute[] extraAttributes = curr.getExtraAttributes(); for (int i = 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib = extraAttributes[i]; CPListElementAttribute attribElem = elem.findAttributeElement(attrib.getName()); if (attribElem == null) { elem.createAttributeElement(attrib.getName(), attrib.getValue(), false); } else { attribElem.setValue(attrib.getValue()); } } elem.setIsMissing(isMissing); return elem; }
From source file:com.amazonaws.eclipse.android.sdk.classpath.AndroidSdkClasspathContainer.java
License:Open Source License
/** * Loads the JDT classpath entries for the AWS SDK for Android from the * specified SDK install and returns them as a list. * * @param sdkInstall// ww w . j ava2 s . c o m * The SDK install from which to load the classpath entries. * * @return A list of the JDT classpath entries for the AWS SDK for Android * at the specified install base. */ private List<IClasspathEntry> loadSdkClasspathEntries(AbstractSdkInstall sdkInstall) { List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>(); IPath sdkJarPath = null, sdkSourceJarPath = null; try { File sdkJar = sdkInstall.getSdkJar(); sdkJarPath = project.getLocation().append("libs").append(sdkJar.getName()); } catch (FileNotFoundException e) { // The SDK has been deleted, there's no classpath entries anymore. return new ArrayList<IClasspathEntry>(); } IClasspathAttribute externalJavadocPath = JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, sdkInstall.getJavadocURL()); if (externalJavadocPath.getValue() != null) { classpathEntries.add(JavaCore.newLibraryEntry(sdkJarPath, sdkSourceJarPath, null, new IAccessRule[0], new IClasspathAttribute[] { externalJavadocPath }, true)); } else { classpathEntries.add(JavaCore.newLibraryEntry(sdkJarPath, sdkSourceJarPath, null, new IAccessRule[0], new IClasspathAttribute[0], true)); } for (File jarFile : sdkInstall.getThirdPartyJars()) { IPath thirdPartyJarPath = new Path(jarFile.getAbsolutePath()); classpathEntries.add(JavaCore.newLibraryEntry(thirdPartyJarPath, thirdPartyJarPath, null, true)); } return classpathEntries; }
From source file:com.amazonaws.eclipse.sdk.ui.classpath.AwsClasspathContainer.java
License:Open Source License
/** * Loads the JDT classpath entries for the AWS SDK for Java from the specified * SDK install and returns them as a list. * * @param sdkInstall/* w ww .j av a 2s. c o m*/ * The SDK install from which to load the classpath entries. * * @return A list of the JDT classpath entries for the AWS SDK for Java at the * specified install base. */ private List<IClasspathEntry> loadSdkClasspathEntries(SdkInstall sdkInstall) { List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>(); IPath sdkJarPath, sdkSourceJarPath; try { sdkJarPath = new Path(sdkInstall.getSdkJar().getAbsolutePath()); sdkSourceJarPath = new Path(sdkInstall.getSdkSourceJar().getAbsolutePath()); } catch (FileNotFoundException e) { // The SDK has been deleted, there's no classpath entries anymore. return new ArrayList<IClasspathEntry>(); } IClasspathAttribute externalJavadocPath = JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, sdkInstall.getJavadocURL()); if (externalJavadocPath.getValue() != null) { classpathEntries.add(JavaCore.newLibraryEntry(sdkJarPath, sdkSourceJarPath, null, new IAccessRule[0], new IClasspathAttribute[] { externalJavadocPath }, true)); } else { classpathEntries.add(JavaCore.newLibraryEntry(sdkJarPath, sdkSourceJarPath, null, new IAccessRule[0], new IClasspathAttribute[0], true)); } for (File jarFile : sdkInstall.getThirdPartyJars()) { IPath thirdPartyJarPath = new Path(jarFile.getAbsolutePath()); classpathEntries.add(JavaCore.newLibraryEntry(thirdPartyJarPath, thirdPartyJarPath, null, true)); } return classpathEntries; }
From source file:com.android.ide.eclipse.adt.internal.project.AndroidClasspathContainerInitializer.java
License:Open Source License
@Override public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { AdtPlugin plugin = AdtPlugin.getDefault(); synchronized (Sdk.getLock()) { boolean sdkIsLoaded = plugin.getSdkLoadStatus() == LoadStatus.LOADED; // check if the project has a valid target. IAndroidTarget target = null;/* ww w . j av a 2 s . c o m*/ if (sdkIsLoaded) { target = Sdk.getCurrent().getTarget(project.getProject()); } if (sdkIsLoaded && target != null) { String[] paths = getTargetPaths(target); IPath android_lib = new Path(paths[CACHE_INDEX_JAR]); IClasspathEntry[] entries = containerSuggestion.getClasspathEntries(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IPath entryPath = entry.getPath(); if (entryPath != null) { if (entryPath.equals(android_lib)) { IPath entrySrcPath = entry.getSourceAttachmentPath(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); if (entrySrcPath != null) { ProjectHelper.saveStringProperty(root, getAndroidSourceProperty(target), entrySrcPath.toString()); } else { ProjectHelper.saveStringProperty(root, getAndroidSourceProperty(target), null); } IClasspathAttribute[] extraAttributtes = entry.getExtraAttributes(); if (extraAttributtes.length == 0) { ProjectHelper.saveStringProperty(root, PROPERTY_ANDROID_API, NULL_API_URL); } for (int j = 0; j < extraAttributtes.length; j++) { IClasspathAttribute extraAttribute = extraAttributtes[j]; String value = extraAttribute.getValue(); if ((value == null || value.trim().length() == 0) && IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME .equals(extraAttribute.getName())) { value = NULL_API_URL; } if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME .equals(extraAttribute.getName())) { ProjectHelper.saveStringProperty(root, PROPERTY_ANDROID_API, value); } } } } } } rebindClasspathEntries(project.getJavaModel(), containerPath); } } }
From source file:com.android.ide.eclipse.auidt.internal.project.AndroidClasspathContainerInitializer.java
License:Open Source License
@Override public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { AdtPlugin plugin = AdtPlugin.getDefault(); synchronized (Sdk.getLock()) { boolean sdkIsLoaded = plugin.getSdkLoadStatus() == LoadStatus.LOADED; // check if the project has a valid target. IAndroidTarget target = null;/*ww w .j av a2s .c om*/ if (sdkIsLoaded) { target = Sdk.getCurrent().getTarget(project.getProject()); } if (sdkIsLoaded && target != null) { String[] paths = getTargetPaths(target); IPath android_lib = new Path(paths[CACHE_INDEX_JAR]); IClasspathEntry[] entries = containerSuggestion.getClasspathEntries(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IPath entryPath = entry.getPath(); if (entryPath != null) { if (entryPath.equals(android_lib)) { IPath entrySrcPath = entry.getSourceAttachmentPath(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); if (entrySrcPath != null) { ProjectHelper.saveStringProperty(root, getAndroidSourceProperty(target), entrySrcPath.toString()); } else { ProjectHelper.saveStringProperty(root, getAndroidSourceProperty(target), null); } IClasspathAttribute[] extraAttributtes = entry.getExtraAttributes(); if (extraAttributtes.length == 0) { ProjectHelper.saveStringProperty(root, PROPERTY_ANDROID_API, NULL_API_URL); } for (int j = 0; j < extraAttributtes.length; j++) { IClasspathAttribute extraAttribute = extraAttributtes[j]; String value = extraAttribute.getValue(); if ((value == null || value.trim().length() == 0) && IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME .equals(extraAttribute.getName())) { value = NULL_API_URL; } if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME .equals(extraAttribute.getName())) { ProjectHelper.saveStringProperty(root, PROPERTY_ANDROID_API, value); } } } } } } rebindClasspathEntries(project.getJavaModel(), containerPath); } } }
From source file:com.codenvy.ide.ext.java.server.internal.core.ClasspathEntry.java
License:Open Source License
public boolean isOptional() { for (int i = 0, length = this.extraAttributes.length; i < length; i++) { IClasspathAttribute attribute = this.extraAttributes[i]; if (IClasspathAttribute.OPTIONAL.equals(attribute.getName()) && "true".equals(attribute.getValue())) //$NON-NLS-1$ return true; }/*from w w w . j a v a 2s . c o m*/ return false; }
From source file:com.codenvy.ide.ext.java.server.internal.core.ClasspathEntry.java
License:Open Source License
public String getSourceAttachmentEncoding() { for (int i = 0, length = this.extraAttributes.length; i < length; i++) { IClasspathAttribute attribute = this.extraAttributes[i]; if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attribute.getName())) return attribute.getValue(); }// w w w .j a va2 s . c o m return null; }
From source file:com.codenvy.ide.ext.java.server.internal.core.ClasspathEntry.java
License:Open Source License
/** * This function computes the URL of the index location for this classpath entry. It returns null if the URL is * invalid.// w w w . j a v a 2s . c o m */ public URL getLibraryIndexLocation() { switch (getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: case IClasspathEntry.CPE_VARIABLE: break; default: return null; } if (this.extraAttributes == null) return null; for (int i = 0; i < this.extraAttributes.length; i++) { IClasspathAttribute attrib = this.extraAttributes[i]; if (IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) { String value = attrib.getValue(); try { return new URL(value); } catch (MalformedURLException e) { return null; } } } return null; }