net.officefloor.eclipse.classpath
Class ClasspathUtil

java.lang.Object
  extended by net.officefloor.eclipse.classpath.ClasspathUtil

public class ClasspathUtil
extends Object

Utility methods for working with class path.

Author:
Daniel Sagenschneider

Method Summary
static void attemptAddExtensionClasspathProvidersToOfficeFloorClasspath(AbstractOfficeFloorEditPart<?,?,?> editPart, org.eclipse.core.runtime.IProgressMonitor monitor, String... extensionClassNames)
           Attempts to add the ExtensionClasspathProvider instances to the class path of the IJavaProject for the edit part.
static org.eclipse.jdt.core.IClasspathEntry createClasspathEntry(Class<?> clazz, OfficeFloorClasspathContainer container)
          Obtains the IClasspathEntry of the class path containing the Class.
static org.eclipse.jdt.core.IClasspathEntry createClasspathEntry(ClasspathProvision provision, OfficeFloorClasspathContainer container)
          Creates the IClasspathEntry from a ClasspathProvision.
static org.eclipse.jdt.core.IClasspathEntry createClasspathEntry(String variable, String path)
          Obtains the IClasspathEntry of the input variable and path.
static void ensureProjectHasOfficeFloorClasspathContainer(org.eclipse.jdt.core.IJavaProject project, org.eclipse.core.runtime.IProgressMonitor monitor)
          Ensures the OfficeFloorClasspathContainer is on the IJavaProject.
static Object[] getChildren(org.eclipse.jdt.core.IJarEntryResource jarEntryResource)
          Obtains the children of the IJarEntryResource.
static Object[] getChildren(org.eclipse.jdt.core.IJavaElement javaElement)
          Obtains the children of the IJavaElement.
static Object[] getChildren(org.eclipse.core.resources.IResource resource)
          Obtains the children of the IResource.
static Object[] getChildren(Object parent)
          Obtains the children of the input parent.
static String getClassName(org.eclipse.jdt.core.IJavaElement javaElement)
          Obtains the class name of the input IJavaElement.
static String getClassPathLocation(org.eclipse.core.runtime.IPath path)
          Obtains the location on the class path for the input IPath.
static String getClassPathLocation(String fullPath)
          Obtains the location on the class path for the input full path.
static Object[] getDescendants(Object item)
          Deprecated. 
static Object getSpecificProject(org.eclipse.core.resources.IProject project)
          Obtains the specific project, being either IJavaProject of the input IProject or the input IProject.
static void loadDescendants(Object item, List<Object> descendants)
          Loads the descendants of the input item.
static Class<?> loadPluginClass(String className)
          Loads the Class from the plug-in class path.
static Class<?> loadProjectClass(org.eclipse.core.resources.IProject project, String className)
          Loads the Class from the IProject class path.
static void openClasspathResource(String resourcePath, AbstractOfficeFloorEditor<?,?> editor)
          Opens the class path resource.
static void openEditor(AbstractOfficeFloorEditor<?,?> editor, org.eclipse.core.resources.IFile file)
          Opens the editor for the IFile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadProjectClass

public static Class<?> loadProjectClass(org.eclipse.core.resources.IProject project,
                                        String className)
                                 throws ClassNotFoundException
Loads the Class from the IProject class path.

Parameters:
project - IProject.
className - Class name.
Returns:
Class.
Throws:
ClassNotFoundException - If Class not found.

loadPluginClass

public static Class<?> loadPluginClass(String className)
                                throws ClassNotFoundException
Loads the Class from the plug-in class path.

Parameters:
className - Class name.
Returns:
Class.
Throws:
ClassNotFoundException - If Class not found.

ensureProjectHasOfficeFloorClasspathContainer

public static void ensureProjectHasOfficeFloorClasspathContainer(org.eclipse.jdt.core.IJavaProject project,
                                                                 org.eclipse.core.runtime.IProgressMonitor monitor)
Ensures the OfficeFloorClasspathContainer is on the IJavaProject.

Parameters:
project - IJavaProject.
monitor - IProgressMonitor. May be null.

attemptAddExtensionClasspathProvidersToOfficeFloorClasspath

public static void attemptAddExtensionClasspathProvidersToOfficeFloorClasspath(AbstractOfficeFloorEditPart<?,?,?> editPart,
                                                                               org.eclipse.core.runtime.IProgressMonitor monitor,
                                                                               String... extensionClassNames)

Attempts to add the ExtensionClasspathProvider instances to the class path of the IJavaProject for the edit part.

No exception is thrown if unable to update the class path and the class path is subsequently not updated.

Parameters:
editPart - AbstractOfficeFloorEditPart.
monitor - IProgressMonitor.
extensionClassNames - Listing of class names that may have extension associated.

createClasspathEntry

public static org.eclipse.jdt.core.IClasspathEntry createClasspathEntry(ClasspathProvision provision,
                                                                        OfficeFloorClasspathContainer container)
Creates the IClasspathEntry from a ClasspathProvision.

Parameters:
provision - ClasspathProvision.
container - OfficeFloorClasspathContainer.
Returns:
IClasspathEntry or null if fails.

createClasspathEntry

public static org.eclipse.jdt.core.IClasspathEntry createClasspathEntry(String variable,
                                                                        String path)
Obtains the IClasspathEntry of the input variable and path.

Parameters:
variable - Name of variable.
path - Path from variable.
Returns:
IClasspathEntry for the variable or null if fails to create.

createClasspathEntry

public static org.eclipse.jdt.core.IClasspathEntry createClasspathEntry(Class<?> clazz,
                                                                        OfficeFloorClasspathContainer container)
Obtains the IClasspathEntry of the class path containing the Class.

Parameters:
clazz - Class.
container - OfficeFloorClasspathContainer. May be null if do not require source attachments.
Returns:
IClasspathEntry of the class path containing the Class or null if issue obtaining.

openClasspathResource

public static void openClasspathResource(String resourcePath,
                                         AbstractOfficeFloorEditor<?,?> editor)
Opens the class path resource.

Parameters:
resourcePath - Path to the resource on the class path.
editor - AbstractOfficeFloorEditor opening the resource.

openEditor

public static void openEditor(AbstractOfficeFloorEditor<?,?> editor,
                              org.eclipse.core.resources.IFile file)
Opens the editor for the IFile.

Parameters:
editor - AbstractOfficeFloorEditor requiring to open the IFile.
file - IFile to open.

getClassName

public static String getClassName(org.eclipse.jdt.core.IJavaElement javaElement)
Obtains the class name of the input IJavaElement.

Parameters:
classFile - IClassFile.
Returns:
Class name or null if IJavaElement not a class or contained within a class.

getClassPathLocation

public static String getClassPathLocation(String fullPath)
Obtains the location on the class path for the input full path.

Parameters:
fullPath - Full path.
Returns:
Location on the class path for the input full path.

getClassPathLocation

public static String getClassPathLocation(org.eclipse.core.runtime.IPath path)
Obtains the location on the class path for the input IPath.

Parameters:
path - IPath.
Returns:
Location on the class path for the input IPath.

getDescendants

@Deprecated
public static Object[] getDescendants(Object item)
Deprecated. 

Obtains the descendants of the input item.

Parameters:
item - Item.
Returns:
Descendants of the item.

loadDescendants

public static void loadDescendants(Object item,
                                   List<Object> descendants)
Loads the descendants of the input item.

Parameters:
item - Item.
descendants - Listing to add descendants.

getChildren

public static Object[] getChildren(Object parent)
Obtains the children of the input parent.

Parameters:
parent - Parent.
Returns:
Children.

getChildren

public static Object[] getChildren(org.eclipse.core.resources.IResource resource)
Obtains the children of the IResource.

Parameters:
resource - IResource.
Returns:
Children.

getChildren

public static Object[] getChildren(org.eclipse.jdt.core.IJavaElement javaElement)
Obtains the children of the IJavaElement.

Parameters:
javaElement - IJavaElement.
Returns:
Children.

getChildren

public static Object[] getChildren(org.eclipse.jdt.core.IJarEntryResource jarEntryResource)
Obtains the children of the IJarEntryResource.

Parameters:
jarEntryResource - IJarEntryResource.
Returns:
Children.

getSpecificProject

public static Object getSpecificProject(org.eclipse.core.resources.IProject project)
Obtains the specific project, being either IJavaProject of the input IProject or the input IProject.

Parameters:
project - IProject.
Returns:
Specific project.


Copyright © 2005-2013. All Rights Reserved.