Class IzClasspathContainerInitializer


  • public class IzClasspathContainerInitializer
    extends org.eclipse.jdt.core.ClasspathContainerInitializer
    This extension point allows clients to contribute custom classpath container initializers, which are used to lazily bind classpath containers to instances of org.eclipse.jdt.core.IClasspathContainer.

    The iizi implementation of its classpath container initializer and a project's plug-ins. Classpath variable containers are used in conjunction with the "org.eclipse.jdt.core.classpathContainerInitializer" extension point.

    Author:
    Christopher Mindus
    See Also:
    IClasspathEntry, IClasspathContainer
    • Field Summary

      • Fields inherited from class org.eclipse.jdt.core.ClasspathContainerInitializer

        ATTRIBUTE_NOT_SUPPORTED, ATTRIBUTE_READ_ONLY
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static booleanaddContainer​(IzClasspathContainer.Type type, org.eclipse.jdt.core.IJavaProject project, org.eclipse.core.runtime.IProgressMonitor monitor)
      Adds an iizi libraries container to classpath if not already present.
      java.lang.StringgetDescription​(org.eclipse.core.runtime.IPath containerPath, org.eclipse.jdt.core.IJavaProject project)
      Returns a readable description for a container path.
      voidinitialize​(org.eclipse.core.runtime.IPath containerPath, org.eclipse.jdt.core.IJavaProject project)
      Binds a classpath container to a IClasspathContainer for a given project, or silently fails if unable to do so.
      static booleanremoveContainers​(org.eclipse.jdt.core.IJavaProject project, org.eclipse.core.runtime.IProgressMonitor monitor)
      Removes all iizi libraries containers from classpath.
      • Methods inherited from class org.eclipse.jdt.core.ClasspathContainerInitializer

        canUpdateClasspathContainer, getAccessRulesStatus, getAttributeStatus, getComparisonID, getFailureContainer, getSourceAttachmentStatus, requestClasspathContainerUpdate
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IzClasspathContainerInitializer

        public IzClasspathContainerInitializer()
        Public constructor.
    • Method Detail

      • initialize

        public void initialize​(org.eclipse.core.runtime.IPath containerPath,
                               org.eclipse.jdt.core.IJavaProject project)
                        throws org.eclipse.core.runtime.CoreException
        Binds a classpath container to a IClasspathContainer for a given project, or silently fails if unable to do so.

        A container is identified by a container path, which must be formed of two segments. The first segment is used as a unique identifier (which this initializer did register onto), and the second segment can be used as an additional hint when performing the resolution.

        The initializer is invoked if a container path needs to be resolved for a given project, and no value for it was recorded so far. The implementation of the initializer would typically set the corresponding container using JavaCore#setClasspathContainer.

        A container initialization can be indirectly performed while attempting to resolve a project classpath using IJavaProject#getResolvedClasspath(; or directly when using JavaCore#getClasspathContainer. During the initialization process, any attempt to further obtain the same container will simply return null so as to avoid an infinite regression of initializations.

        A container initialization may also occur indirectly when setting a project classpath, as the operation needs to resolve the classpath for validation purpose. While the operation is in progress, a referenced container initializer may be invoked. If the initializer further tries to access the referring project classpath, it will not see the new assigned classpath until the operation has completed. Note that once the Java change notification occurs (at the end of the operation), the model has been updated, and the project classpath can be queried normally.

        This method is called by the Java model to give the party that defined this particular kind of classpath container the chance to install classpath container objects that will be used to convert classpath container entries into simpler classpath entries. The method is typically called exactly once for a given Java project and classpath container entry. This method must not be called by other clients.

        There are a wide variety of conditions under which this method may be invoked. To ensure that the implementation does not interfere with correct functioning of the Java model, the implementation should use only the following Java model APIs:

        • JavaCore.setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor)
        • JavaCore.getClasspathContainer(IPath, IJavaProject)
        • JavaCore.create(org.eclipse.core.resources.IWorkspaceRoot)
        • JavaCore.create(org.eclipse.core.resources.IProject)
        • IJavaModel.getJavaProjects()
        • Java element operations marked as "handle-only"
        The effects of using other Java model APIs are unspecified.
        Specified by:
        initialize in class org.eclipse.jdt.core.ClasspathContainerInitializer
        Parameters:
        containerPath - A two-segment path (ID/hint) identifying the container that needs to be resolved.
        project - The Java project in which context the container is to be resolved. This allows generic containers to be bound with project specific values.
        Throws:
        org.eclipse.core.runtime.CoreException - If an exception occurs during the initialization.
        See Also:
        JavaCore.getClasspathContainer(IPath, IJavaProject), JavaCore.setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor), IClasspathContainer
      • getDescription

        public java.lang.String getDescription​(org.eclipse.core.runtime.IPath containerPath,
                                               org.eclipse.jdt.core.IJavaProject project)
        Returns a readable description for a container path. A readable description for a container path can be used for improving the display of references to container, without actually needing to resolve them. A good implementation should answer a description consistent with the description of the associated target container (see IClasspathContainer.getDescription()).
        Overrides:
        getDescription in class org.eclipse.jdt.core.ClasspathContainerInitializer
        Parameters:
        containerPath - The path of the container which requires a readable description.
        project - The project from which the container is referenced.
        Returns:
        A string description of the container.
      • addContainer

        public static boolean addContainer​(IzClasspathContainer.Type type,
                                           org.eclipse.jdt.core.IJavaProject project,
                                           org.eclipse.core.runtime.IProgressMonitor monitor)
                                    throws org.eclipse.core.runtime.CoreException
        Adds an iizi libraries container to classpath if not already present. Any other iizi libraries types are removed.
        Parameters:
        type - The container type.
        project - The Java project.
        monitor - The progress monitor, or null for none.
        Returns:
        true if there were changes made to the classpath, false otherwise.
        Throws:
        org.eclipse.core.runtime.CoreException - when JavaCore#setClasspathContainer would throw any.
      • removeContainers

        public static boolean removeContainers​(org.eclipse.jdt.core.IJavaProject project,
                                               org.eclipse.core.runtime.IProgressMonitor monitor)
                                        throws org.eclipse.core.runtime.CoreException
        Removes all iizi libraries containers from classpath.
        Parameters:
        project - The Java project.
        monitor - The progress monitor, or null for none.
        Returns:
        true if there were changes made to the classpath, false otherwise.
        Throws:
        org.eclipse.core.runtime.CoreException - when JavaCore#setClasspathContainer would throw any.