Search in sources :

Example 6 with ClasspathContainerInitializer

use of org.eclipse.jdt.core.ClasspathContainerInitializer in project flux by eclipse.

the class JavaModelUtil method getClasspathEntryToEdit.

/**
	 * 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
	 * @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);
    }
    // attachment not possible
    return null;
}
Also used : IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer) ClasspathContainerInitializer(org.eclipse.jdt.core.ClasspathContainerInitializer)

Aggregations

ClasspathContainerInitializer (org.eclipse.jdt.core.ClasspathContainerInitializer)6 IClasspathContainer (org.eclipse.jdt.core.IClasspathContainer)4 JavaModelException (org.eclipse.jdt.core.JavaModelException)3 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1 IJavaElement (org.eclipse.jdt.core.IJavaElement)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)1 StyledString (org.eclipse.jface.viewers.StyledString)1