List of usage examples for org.eclipse.jdt.core ClasspathContainerInitializer canUpdateClasspathContainer
public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project)
true
if this container initializer can be requested to perform updates on its own container values. From source file:at.bestsolution.fxide.jdt.corext.util.JavaModelUtil.java
License:Open Source License
/** * Helper method that tests if an classpath entry can be found in a * container. <code>null</code> is returned if the entry can not be found * or if the container does not allows the configuration of source * attachments/*w w w .j a v a 2 s .c o m*/ * @param jproject The container's parent project * @param containerPath The path of the container * @param libPath The path of the library to be found * @return IClasspathEntry A classpath entry from the container of * <code>null</code> if the container can not be modified. * @throws JavaModelException thrown if accessing the container failed */ public static IClasspathEntry getClasspathEntryToEdit(IJavaProject jproject, IPath containerPath, IPath libPath) throws JavaModelException { IClasspathContainer container = JavaCore.getClasspathContainer(containerPath, jproject); ClasspathContainerInitializer initializer = JavaCore .getClasspathContainerInitializer(containerPath.segment(0)); if (container != null && initializer != null && initializer.canUpdateClasspathContainer(containerPath, jproject)) { return findEntryInContainer(container, libPath); } return null; // attachment not possible }
From source file:at.bestsolution.javafx.ide.jdt.internal.jdt.CPListElement.java
License:Open Source License
private IStatus evaluateContainerChildStatus(CPListElementAttribute attrib) { if (fProject != null) { ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(fPath.segment(0)); if (initializer != null && initializer.canUpdateClasspathContainer(fPath, fProject)) { if (attrib.isBuiltIn()) { if (CPListElement.SOURCEATTACHMENT.equals(attrib.getKey())) { return initializer.getSourceAttachmentStatus(fPath, fProject); } else if (CPListElement.ACCESSRULES.equals(attrib.getKey())) { return initializer.getAccessRulesStatus(fPath, fProject); }//ww w. java 2s .c o m } else { return initializer.getAttributeStatus(fPath, fProject, attrib.getKey()); } } return new Status(IStatus.ERROR, "at.bestsolution.javafx.ide.jdt", //$NON-NLS-1$ ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY, "", null); } return null; }
From source file:com.google.appengine.eclipse.core.sdk.GaeSdkContainerInitializerTest.java
License:Open Source License
public void testCanUpdateClasspathContainerIPathIJavaProject() { ClasspathContainerInitializer intializer = JavaCore .getClasspathContainerInitializer(GaeSdkContainer.CONTAINER_ID); assertNotNull(intializer);// w w w. j a va 2 s .co m assertTrue(intializer.canUpdateClasspathContainer(GaeSdkContainer.CONTAINER_PATH, gaeProject.getJavaProject())); assertFalse(intializer.canUpdateClasspathContainer(new Path("Nonexistent"), gaeProject.getJavaProject())); }
From source file:org.ebayopensource.turmeric.eclipse.maven.core.utils.MavenCoreUtils.java
License:Open Source License
/** * Update maven classpath container./*from www . ja v a2 s .c om*/ * * @param project the project * @param dependentName the dependent name * @param type the type * @throws CoreException the core exception * @throws InterruptedException the interrupted exception */ public static void updateMavenClasspathContainer(final IProject project, final String dependentName, final String type) throws CoreException, InterruptedException { final IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID); final IPath containerPath = new Path(SOAMavenConstants.MAVEN_CLASSPATH_CONTAINER_ID); final ClasspathContainerInitializer containerInitializer = JavaCore .getClasspathContainerInitializer(SOAMavenConstants.MAVEN_CLASSPATH_CONTAINER_ID); if (containerInitializer.canUpdateClasspathContainer(containerPath, javaProject)) { final IClasspathContainer mavenContainer = getMaven2ClasspathContainer(javaProject); containerInitializer.requestClasspathContainerUpdate(containerPath, javaProject, mavenContainer); containerInitializer.initialize(containerPath, javaProject); /* * project.build(IncrementalProjectBuilder.FULL_BUILD, * ProgressUtil.getDefaultMonitor(null)); */ // TODO this is a hot fix for the Maven class path issue // it will continuously wait until the newly added service is // available in the classpath String tlGroupId = getMavenOrgProviderInstance().getProjectGroupId(SupportedProjectType.TYPE_LIBRARY); if (IAssetInfo.TYPE_SERVICE_LIBRARY.equals(type)) { waitForClasspathContainerToUpdate( getMavenOrgProviderInstance().getProjectGroupId(SupportedProjectType.INTERFACE), javaProject, dependentName); } else if (tlGroupId.equals(type)) { waitForClasspathContainerToUpdate(tlGroupId, javaProject, dependentName); } } }
From source file:org.eclipse.jst.j2ee.internal.common.operations.JavaModelUtil.java
License:Open Source License
/** * Helper method that tests if an classpath entry can be found in a * container. <code>null</code> is returned if the entry can not be found * or if the container does not allows the configuration of source * attachments// ww w . j av a 2 s.com * @param jproject The container's parent project * @param containerPath The path of the container * @param libPath The path of the library to be found * @return IClasspathEntry A classpath entry from the container of * <code>null</code> if the container can not be modified. */ public static IClasspathEntry getClasspathEntryToEdit(IJavaProject jproject, IPath containerPath, IPath libPath) throws JavaModelException { IClasspathContainer container = JavaCore.getClasspathContainer(containerPath, jproject); ClasspathContainerInitializer initializer = JavaCore .getClasspathContainerInitializer(containerPath.segment(0)); if (container != null && initializer != null && initializer.canUpdateClasspathContainer(containerPath, jproject)) { IClasspathEntry[] entries = container.getClasspathEntries(); for (int i = 0; i < entries.length; i++) { IClasspathEntry curr = entries[i]; IClasspathEntry resolved = JavaCore.getResolvedClasspathEntry(curr); if (resolved != null && libPath.equals(resolved.getPath())) { return curr; // return the real entry } } } return null; // attachment not possible }
From source file:org.maven.ide.eclipse.scala.ScalaProjectConfigurator.java
License:Open Source License
private static void addDeployableAttribute(IJavaProject javaProject, IClasspathAttribute deployableAttribute, IProgressMonitor monitor) throws JavaModelException, CoreException { if (javaProject == null) return;//from ww w. j ava 2s . c om ClasspathContainerInitializer scalaInitializer = JavaCore .getClasspathContainerInitializer(SCALA_CONTAINER_PATH); if (scalaInitializer == null) return; IPath scalaContainerPath = Path.fromPortableString(SCALA_CONTAINER_PATH); Boolean updateAble = scalaInitializer.canUpdateClasspathContainer(scalaContainerPath, javaProject); final IClasspathContainer scalaLibrary = JavaCore.getClasspathContainer(scalaContainerPath, javaProject); final IClasspathEntry[] cpEntries = scalaLibrary.getClasspathEntries(); for (int i = 0; i < cpEntries.length; i++) { IClasspathEntry cpe = cpEntries[i]; LinkedHashMap<String, IClasspathAttribute> attrs = new LinkedHashMap<String, IClasspathAttribute>(); for (IClasspathAttribute attr : cpe.getExtraAttributes()) { //Keep all existing attributes except the non_deployable key if (!attr.getName().equals(NON_DEPLOYABLE_KEY)) { attrs.put(attr.getName(), attr); } } attrs.put(deployableAttribute.getName(), deployableAttribute); IClasspathAttribute[] newAttrs = attrs.values().toArray(new IClasspathAttribute[attrs.size()]); cpEntries[i] = JavaCore.newLibraryEntry(cpe.getPath(), cpe.getSourceAttachmentPath(), cpe.getSourceAttachmentRootPath(), cpe.getAccessRules(), newAttrs, cpe.isExported()); } IClasspathContainer candidateScalaContainer = new IClasspathContainer() { public IPath getPath() { return scalaLibrary.getPath(); } public IClasspathEntry[] getClasspathEntries() { return cpEntries; } public String getDescription() { return scalaLibrary.getDescription(); } public int getKind() { return scalaLibrary.getKind(); } }; if (updateAble) { scalaInitializer.requestClasspathContainerUpdate(scalaContainerPath, javaProject, candidateScalaContainer); } else { IJavaProject[] jPArray = { javaProject }; IClasspathContainer[] cpArray = { candidateScalaContainer }; JavaCore.setClasspathContainer(scalaContainerPath, jPArray, cpArray, null); } }