Class OfficeFloorOsgiBridge


  • public class OfficeFloorOsgiBridge
    extends java.lang.Object
    Bridge for IJavaProject to OfficeFloorCompiler functionality.
    Author:
    Daniel Sagenschneider
    • Constructor Summary

      Constructors 
      Constructor Description
      OfficeFloorOsgiBridge​(java.lang.ClassLoader classLoader)
      Instantiate to use the specified ClassLoader.
      OfficeFloorOsgiBridge​(org.eclipse.jdt.core.IJavaProject javaProject)
      Instantiate.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.ClassLoader getClassLoader()
      Obtains the ClassLoader for the IJavaProject.
      static OfficeFloorOsgiBridge getClassLoaderInstance()
      Obtains an OfficeFloorOsgiBridge for the current ClassLoader.
      java.lang.String getClassPathLocation​(org.eclipse.core.resources.IFile file)
      Obtains the class path location for the IFile.
      org.eclipse.jdt.core.IJavaProject getJavaProject()
      Obtains the IJavaProject.
      OfficeFloorCompiler getOfficeFloorCompiler()
      Obtains the OfficeFloorCompiler.
      boolean isClassOnClassPath​(java.lang.String className)
      Indicates if the Class is on the class path.
      boolean isResourceOnClassPath​(java.lang.String resourcePath)
      Indicates if the resource is on the class path.
      boolean isSuperType​(java.lang.String className, java.lang.String superTypeName)
      Checks whether the super type relationship.
      <T> java.lang.Class<? extends T> loadClass​(java.lang.String className, java.lang.Class<T> superType)
      Loads the Class.
      java.lang.String selectClass​(java.lang.String className, org.eclipse.swt.widgets.Shell parentShell, java.lang.String superTypeName)
      Allows for selecting a Class.
      java.lang.String selectClassPathResource​(java.lang.String resourcePath, org.eclipse.swt.widgets.Shell parentShell)
      Selects a resource on the class path.
      java.lang.String selectType​(java.lang.String typeName, int consideredTypes, org.eclipse.swt.widgets.Shell parentShell, java.lang.String superTypeName)
      Allows for selecting a type.
      • Methods inherited from class java.lang.Object

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

      • OfficeFloorOsgiBridge

        public OfficeFloorOsgiBridge​(org.eclipse.jdt.core.IJavaProject javaProject)
        Instantiate.
        Parameters:
        javaProject - IJavaProject.
      • OfficeFloorOsgiBridge

        public OfficeFloorOsgiBridge​(java.lang.ClassLoader classLoader)

        Instantiate to use the specified ClassLoader.

        Typically this is only used for testing. When using for plugins should bridge to the IJavaProject to get latest class path.

        Parameters:
        classLoader - ClassLoader.
    • Method Detail

      • getClassLoaderInstance

        public static OfficeFloorOsgiBridge getClassLoaderInstance()

        Obtains an OfficeFloorOsgiBridge for the current ClassLoader.

        This should NOT be used in the Eclipse OSGi environment, as it takes the ClassLoader from the current Thread or system (which is indeterminate within the OSGi environment).

        This is useful for testing outside the OSGi environment.

        Returns:
        OfficeFloorOsgiBridge for the current ClassLoader.
      • getJavaProject

        public org.eclipse.jdt.core.IJavaProject getJavaProject()
        Obtains the IJavaProject.
        Returns:
        IJavaProject.
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
                                             throws java.lang.Exception
        Obtains the ClassLoader for the IJavaProject.
        Returns:
        ClassLoader for the IJavaProject.
        Throws:
        java.lang.Exception - If fails to extract class path from IJavaProject.
      • loadClass

        public <T> java.lang.Class<? extends T> loadClass​(java.lang.String className,
                                                          java.lang.Class<T> superType)
                                                   throws java.lang.Exception
        Loads the Class.
        Type Parameters:
        T - Class type.
        Parameters:
        className - Name of the Class.
        superType - Super type of the Class.
        Returns:
        Class.
        Throws:
        java.lang.Exception - If Class not found or fails to load the Class.
      • isClassOnClassPath

        public boolean isClassOnClassPath​(java.lang.String className)
                                   throws java.lang.Exception
        Indicates if the Class is on the class path.
        Parameters:
        className - Name of the Class.
        Returns:
        true if the Class is on the class path.
        Throws:
        java.lang.Exception - If fails to determine if on class path.
      • isSuperType

        public boolean isSuperType​(java.lang.String className,
                                   java.lang.String superTypeName)
                            throws java.lang.Exception
        Checks whether the super type relationship.
        Parameters:
        className - Name of class to extend super type.
        superTypeName - Name of super type.
        Returns:
        true if class extends super type.
        Throws:
        java.lang.Exception - If fails determining if inheritance relationship.
      • selectClass

        public java.lang.String selectClass​(java.lang.String className,
                                            org.eclipse.swt.widgets.Shell parentShell,
                                            java.lang.String superTypeName)
                                     throws java.lang.Exception
        Allows for selecting a Class.
        Parameters:
        className - Existing class name (or part of). Used to pre-filter the list of Class names to select from. May be null for no filtering.
        parentShell - Parent Shell (for SWT dialogs in selecting the Class).
        superTypeName - Optional super type name. May be null.
        Returns:
        Selected Class name or null if no Class selected.
        Throws:
        java.lang.Exception - If fails to select a Class.
      • selectType

        public java.lang.String selectType​(java.lang.String typeName,
                                           int consideredTypes,
                                           org.eclipse.swt.widgets.Shell parentShell,
                                           java.lang.String superTypeName)
                                    throws java.lang.Exception
        Allows for selecting a type.
        Parameters:
        typeName - Existing type name (or part of). Used to pre-filter the list of type names to select from. May be null for no filtering.
        consideredTypes - IJavaSearchConstants value.
        parentShell - Parent Shell (for SWT dialogs in selecting the type).
        superTypeName - Optional super type name. May be null.
        Returns:
        Selected type name or null if no type selected.
        Throws:
        java.lang.Exception - If fails to select a type.
      • isResourceOnClassPath

        public boolean isResourceOnClassPath​(java.lang.String resourcePath)
                                      throws java.lang.Exception
        Indicates if the resource is on the class path.
        Parameters:
        resourcePath - Path for the resource.
        Returns:
        true if the resource is on the class path.
        Throws:
        java.lang.Exception - If fails to determine if resource on class path.
      • getClassPathLocation

        public java.lang.String getClassPathLocation​(org.eclipse.core.resources.IFile file)
        Obtains the class path location for the IFile.
        Parameters:
        file - IFile.
        Returns:
        Class path location for the IFile.
      • selectClassPathResource

        public java.lang.String selectClassPathResource​(java.lang.String resourcePath,
                                                        org.eclipse.swt.widgets.Shell parentShell)
                                                 throws java.lang.Exception
        Selects a resource on the class path.
        Parameters:
        resourcePath - Existing resource path (or part of). Used to pre-filter the list of resources to select from. May be null for no filtering.
        parentShell - Parent Shell (for SWT dialogs in selecting the type).
        Returns:
        Selected resource path or null if no resource selected.
        Throws:
        java.lang.Exception - If fails to select a resource.