List of usage examples for org.eclipse.jdt.core IClasspathEntry getExtraAttributes
IClasspathAttribute[] getExtraAttributes();
From source file:org.eclipse.jst.j2ee.internal.common.classpath.WtpOsgiBundlesLibraryProviderInstallOperationConfig.java
License:Open Source License
@Override public synchronized void init(final IFacetedProjectBase fproj, final IProjectFacetVersion fv, final ILibraryProvider provider) { super.init(fproj, fv, provider); this.includeWithApplicationEnabled = hasModuleFacet(fproj); final IProject project = fproj.getProject(); if (project != null) { final IProjectFacet f = fv.getProjectFacet(); final ILibraryProvider currentProvider = LibraryProviderFramework.getCurrentProvider(project, f); if (currentProvider == provider) { this.includeWithApplicationEnabled = false; final IPath path = OsgiBundlesContainer.CONTAINER_PATH.append(f.getId()); final IJavaProject jproj = JavaCore.create(project); try { for (IClasspathEntry cpe : jproj.getRawClasspath()) { if (path.equals(cpe.getPath())) { for (IClasspathAttribute attr : cpe.getExtraAttributes()) { if (attr.getName() .equals(IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY)) { this.includeWithApplicationEnabled = true; break; }/*from w w w. ja v a 2s .c om*/ } } if (this.includeWithApplicationEnabled) { break; } } } catch (CoreException e) { throw new RuntimeException(e); } } } this.includeWithApplicationSettingEnabled = (this.includeWithApplicationEnabled ? true : hasModuleFacet(fproj)); this.facetedProjectListener = new IFacetedProjectListener() { public void handleEvent(final IFacetedProjectEvent event) { final boolean moduleFaceted = hasModuleFacet(event.getWorkingCopy()); setIncludeWithApplicationEnabled(moduleFaceted); setIncludeWithApplicationSettingEnabled(moduleFaceted); } }; fproj.addListener(this.facetedProjectListener, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED); }
From source file:org.eclipse.jst.j2ee.internal.common.classpath.WtpUserLibraryProviderInstallOperationConfig.java
License:Open Source License
@Override public synchronized void init(final IFacetedProjectBase fproj, final IProjectFacetVersion fv, final ILibraryProvider provider) { super.init(fproj, fv, provider); this.includeWithApplicationEnabled = hasModuleFacet(fproj); final IProject project = fproj.getProject(); if (project != null) { final IProjectFacet f = fv.getProjectFacet(); final ILibraryProvider currentProvider = LibraryProviderFramework.getCurrentProvider(project, f); if (currentProvider == provider) { this.includeWithApplicationEnabled = false; final IJavaProject jproj = JavaCore.create(project); try { for (IClasspathEntry cpe : jproj.getRawClasspath()) { if (cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { final IPath path = cpe.getPath(); if (path.segmentCount() >= 2 && path.segment(0).equals(JavaCore.USER_LIBRARY_CONTAINER_ID)) { for (IClasspathAttribute attr : cpe.getExtraAttributes()) { if (attr.getName() .equals(IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY)) { this.includeWithApplicationEnabled = true; break; }// ww w .j a v a2 s. co m } } } if (this.includeWithApplicationEnabled) { break; } } } catch (CoreException e) { throw new RuntimeException(e); } } } this.includeWithApplicationSettingEnabled = (this.includeWithApplicationEnabled) ? true : hasModuleFacet(fproj); this.facetedProjectListener = new IFacetedProjectListener() { public void handleEvent(final IFacetedProjectEvent event) { final boolean moduleFaceted = hasModuleFacet(event.getWorkingCopy()); setIncludeWithApplicationEnabled(moduleFaceted); setIncludeWithApplicationSettingEnabled(moduleFaceted); } }; fproj.addListener(this.facetedProjectListener, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED); }
From source file:org.eclipse.jst.j2ee.project.facet.J2EEFacetRuntimeChangedDelegate.java
License:Open Source License
private boolean hasOwnerAttribute(IClasspathEntry cpe) { if (cpe != null) { for (IClasspathAttribute attr : cpe.getExtraAttributes()) { if (attr.getName().equals(OWNER_PROJECT_FACETS_ATTR)) return true; }// w w w .j a v a 2s . com } return false; }
From source file:org.eclipse.jst.jsf.core.jsflibraryconfiguration.internal.JSFLibraryReferenceFacadeFactory.java
License:Open Source License
private static boolean getJ2EEModuleDependency(IClasspathEntry classpathEntry) { IClasspathAttribute[] attrs = classpathEntry.getExtraAttributes(); for (int i = 0; i < attrs.length; i++) { IClasspathAttribute attr = attrs[i]; if (attr.getName().equals(IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY)) { return true; }//from w ww. java 2s . c o m } return false; }
From source file:org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate.java
License:Open Source License
/** * Request that the classpath container for the given runtime and id be updated * with the given classpath container entries. * /* ww w. jav a2 s. c om*/ * @param runtime a runtime * @param entries an array of classpath entries */ public void requestClasspathContainerUpdate(IRuntime runtime, IClasspathEntry[] entries) { // default behaviour is to save the source path entries if (runtime == null || entries == null) return; // find the source attachments List<SourceAttachmentUpdate> srcAttachments = new ArrayList<SourceAttachmentUpdate>(); for (IClasspathEntry entry : entries) { if (entry.getSourceAttachmentPath() != null || (entry.getExtraAttributes() != null && entry.getExtraAttributes().length > 0)) { SourceAttachmentUpdate sau = new SourceAttachmentUpdate(); sau.runtimeId = runtime.getId(); sau.entry = entry.getPath(); sau.sourceAttachmentPath = entry.getSourceAttachmentPath(); sau.sourceAttachmentRootPath = entry.getSourceAttachmentRootPath(); sau.attributes = entry.getExtraAttributes(); srcAttachments.add(sau); } } sourceAttachments = srcAttachments; save(); }
From source file:org.eclipse.m2e.jdt.internal.BuildPathManager.java
License:Open Source License
private ArtifactKey findArtifactByArtifactKey(IClasspathEntry entry) { IClasspathAttribute[] attributes = entry.getExtraAttributes(); String groupId = null;//from w w w.j ava 2 s . co m String artifactId = null; String version = null; String classifier = null; for (int j = 0; j < attributes.length; j++) { if (GROUP_ID_ATTRIBUTE.equals(attributes[j].getName())) { groupId = attributes[j].getValue(); } else if (ARTIFACT_ID_ATTRIBUTE.equals(attributes[j].getName())) { artifactId = attributes[j].getValue(); } else if (VERSION_ATTRIBUTE.equals(attributes[j].getName())) { version = attributes[j].getValue(); } else if (CLASSIFIER_ATTRIBUTE.equals(attributes[j].getName())) { classifier = attributes[j].getValue(); } } if (groupId != null && artifactId != null && version != null) { return new ArtifactKey(groupId, artifactId, version, classifier); } return null; }
From source file:org.eclipse.m2e.jdt.internal.BuildPathManager.java
License:Open Source License
/** public for unit tests only */ public String getJavadocLocation(IClasspathEntry entry) { IClasspathAttribute[] attributes = entry.getExtraAttributes(); for (int j = 0; j < attributes.length; j++) { IClasspathAttribute attribute = attributes[j]; if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attribute.getName())) { return attribute.getValue(); }//from ww w . j a va 2 s. c om } return null; }
From source file:org.eclipse.m2e.jdt.internal.BuildPathManager.java
License:Open Source License
void attachSourcesAndJavadoc(IPackageFragmentRoot fragment, File sources, File javadoc, IProgressMonitor monitor) {/*from w w w.j a va2 s . c o m*/ IJavaProject javaProject = fragment.getJavaProject(); IPath srcPath = sources != null ? Path.fromOSString(sources.getAbsolutePath()) : null; String javaDocUrl = getJavaDocUrl(javadoc); try { IClasspathEntry[] cp = javaProject.getRawClasspath(); for (int i = 0; i < cp.length; i++) { IClasspathEntry entry = cp[i]; if (IClasspathEntry.CPE_LIBRARY == entry.getEntryKind() && entry.equals(fragment.getRawClasspathEntry())) { List<IClasspathAttribute> attributes = new ArrayList<IClasspathAttribute>( Arrays.asList(entry.getExtraAttributes())); if (srcPath == null) { // configure javadocs if available if (javaDocUrl != null) { attributes.add(JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, javaDocUrl)); } } cp[i] = JavaCore.newLibraryEntry(entry.getPath(), srcPath, null, entry.getAccessRules(), // attributes.toArray(new IClasspathAttribute[attributes.size()]), // entry.isExported()); break; } } javaProject.setRawClasspath(cp, monitor); } catch (CoreException e) { log.error(e.getMessage(), e); } }
From source file:org.eclipse.m2e.jdt.internal.ClasspathEntryDescriptor.java
License:Open Source License
private void setClasspathEntry(IClasspathEntry entry) { this.entryKind = entry.getEntryKind(); this.path = entry.getPath(); this.exported = entry.isExported(); this.outputLocation = entry.getOutputLocation(); this.accessRules = new ArrayList<IAccessRule>(); for (IAccessRule rule : entry.getAccessRules()) { this.accessRules.add(rule); }// ww w . j a v a2s. co m this.attributes = new LinkedHashMap<String, String>(); for (IClasspathAttribute attribute : entry.getExtraAttributes()) { attributes.put(attribute.getName(), attribute.getValue()); } this.sourceAttachmentPath = entry.getSourceAttachmentPath(); this.sourceAttachmentRootPath = entry.getSourceAttachmentRootPath(); setInclusionPatterns(entry.getInclusionPatterns()); setExclusionPatterns(entry.getExclusionPatterns()); this.combineAccessRules = entry.combineAccessRules(); }
From source file:org.eclipse.m2e.jdt.internal.launch.MavenRuntimeClasspathProvider.java
License:Open Source License
private static String getArtifactClassifier(IClasspathEntry entry) { IClasspathAttribute[] attributes = entry.getExtraAttributes(); for (IClasspathAttribute attribute : attributes) { if (IClasspathManager.CLASSIFIER_ATTRIBUTE.equals(attribute.getName())) { return attribute.getValue(); }/* w ww . ja v a 2 s .c o m*/ } return null; }