Package net.officefloor.eclipse.osgi
Class OfficeFloorOsgiBridge
- java.lang.Object
-
- net.officefloor.eclipse.osgi.OfficeFloorOsgiBridge
-
public class OfficeFloorOsgiBridge extends java.lang.Object
Bridge forIJavaProject
toOfficeFloorCompiler
functionality.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description OfficeFloorOsgiBridge(java.lang.ClassLoader classLoader)
Instantiate to use the specifiedClassLoader
.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 theClassLoader
for theIJavaProject
.static OfficeFloorOsgiBridge
getClassLoaderInstance()
Obtains anOfficeFloorOsgiBridge
for the currentClassLoader
.java.lang.String
getClassPathLocation(org.eclipse.core.resources.IFile file)
Obtains the class path location for theIFile
.org.eclipse.jdt.core.IJavaProject
getJavaProject()
Obtains theIJavaProject
.OfficeFloorCompiler
getOfficeFloorCompiler()
Obtains theOfficeFloorCompiler
.boolean
isClassOnClassPath(java.lang.String className)
Indicates if theClass
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 theClass
.java.lang.String
selectClass(java.lang.String className, org.eclipse.swt.widgets.Shell parentShell, java.lang.String superTypeName)
Allows for selecting aClass
.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.
-
-
-
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 currentClassLoader
.This should NOT be used in the Eclipse OSGi environment, as it takes the
ClassLoader
from the currentThread
or system (which is indeterminate within the OSGi environment).This is useful for testing outside the OSGi environment.
- Returns:
OfficeFloorOsgiBridge
for the currentClassLoader
.
-
getJavaProject
public org.eclipse.jdt.core.IJavaProject getJavaProject()
Obtains theIJavaProject
.- Returns:
IJavaProject
.
-
getClassLoader
public java.lang.ClassLoader getClassLoader() throws java.lang.Exception
Obtains theClassLoader
for theIJavaProject
.- Returns:
ClassLoader
for theIJavaProject
.- Throws:
java.lang.Exception
- If fails to extract class path fromIJavaProject
.
-
loadClass
public <T> java.lang.Class<? extends T> loadClass(java.lang.String className, java.lang.Class<T> superType) throws java.lang.Exception
Loads theClass
.- Type Parameters:
T
-Class
type.- Parameters:
className
- Name of theClass
.superType
- Super type of theClass
.- Returns:
Class
.- Throws:
java.lang.Exception
- IfClass
not found or fails to load theClass
.
-
isClassOnClassPath
public boolean isClassOnClassPath(java.lang.String className) throws java.lang.Exception
Indicates if theClass
is on the class path.- Parameters:
className
- Name of theClass
.- Returns:
true
if theClass
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 aClass
.- Parameters:
className
- Existing class name (or part of). Used to pre-filter the list ofClass
names to select from. May benull
for no filtering.parentShell
- ParentShell
(for SWT dialogs in selecting theClass
).superTypeName
- Optional super type name. May benull
.- Returns:
- Selected
Class
name ornull
if noClass
selected. - Throws:
java.lang.Exception
- If fails to select aClass
.
-
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 benull
for no filtering.consideredTypes
-IJavaSearchConstants
value.parentShell
- ParentShell
(for SWT dialogs in selecting the type).superTypeName
- Optional super type name. May benull
.- 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 theIFile
.- 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 benull
for no filtering.parentShell
- ParentShell
(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.
-
getOfficeFloorCompiler
public OfficeFloorCompiler getOfficeFloorCompiler() throws java.lang.Exception
Obtains theOfficeFloorCompiler
.- Returns:
OfficeFloorCompiler
.- Throws:
java.lang.Exception
- If fails to extract class path fromIJavaProject
.
-
-