EGF Engine
Release 0.1.0

org.eclipse.egf.common.helper
Class ProjectHelper

java.lang.Object
  extended by org.eclipse.egf.common.helper.ProjectHelper

public class ProjectHelper
extends Object

Workspace projects helper.


Nested Class Summary
static class ProjectHelper.ProjectExistenceStatus
          Project existence status after check.
 
Field Summary
protected static String CLASS_PATH_ENTRY_REQUIRED_PLUGINS_PATH_ID
          Required plug-ins class path entry path identifier.
 
Constructor Summary
ProjectHelper()
           
 
Method Summary
static boolean canBeConvertedToFC(String elementId_p)
          Can identified project element be converted to a factory component ?
static IFolder createFolder(String folderName_p, IProject project_p, IProgressMonitor monitor_p)
          Create a folder with given name in given project.
static boolean createSourceFolder(String sourceFolderName_p, IProject project_p, IProgressMonitor monitor_p)
          Create a source folder in given project.
static ProjectHelper.ProjectExistenceStatus ensurePluginProjectExists(String projectName_p)
          Make sure named plug-in project exists.
static ProjectHelper.ProjectExistenceStatus ensureProjectExists(String projectName_p)
          Make sure named project exists.
static ClassLoader getClassLoaderFor(IJavaProject javaProject_p, ClassLoader parentClassLoader_p)
          Create a new class loader for a java project, son of specified parent class loader.
static IJavaProject getJavaProject(IProject project_p)
          Get java project from workspace project.
static IJavaProject getJavaProject(String projectName_p)
          Get java project in the workspace from its project name.
static IProject getProject(IPluginModelBase pluginModelBase_p)
          Get the IProject for specified plug-in model.
static IProject getProject(String projectName_p)
          Get project from its name.
protected static URL[] getProjectDependencies(IJavaProject javaProject_p)
          Get given java project dependencies in terms of compilation.
static void refreshProject(IProject projectToRefresh_p, int depth_p, IProgressMonitor monitor_p)
          Refresh a project in the workspace.
static void refreshProject(IProject project_p, IProgressMonitor monitor_p)
          Refresh given project in the workspace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_PATH_ENTRY_REQUIRED_PLUGINS_PATH_ID

protected static final String CLASS_PATH_ENTRY_REQUIRED_PLUGINS_PATH_ID
Required plug-ins class path entry path identifier.

See Also:
Constant Field Values
Constructor Detail

ProjectHelper

public ProjectHelper()
Method Detail

getProject

public static IProject getProject(String projectName_p)
Get project from its name.
It is assumed that this project name refers to a plug-in.
If not, the method ResourcesPlugin.getWorkspace().getRoot().getProject(projectName_p) is invoked as result.

Parameters:
projectName_p - A project name that points to a plug-in in the workspace.
Returns:

getProject

public static IProject getProject(IPluginModelBase pluginModelBase_p)
Get the IProject for specified plug-in model.

Parameters:
pluginModelBase_p -
Returns:
null if the plug-in is not in the workspace.

canBeConvertedToFC

public static boolean canBeConvertedToFC(String elementId_p)
Can identified project element be converted to a factory component ?

Parameters:
elementId_p - The chosen project element id. Can either be the project name or the plug-in id.
Returns:
false if no project can be found, or it is not a plug-in, or its id does not match its name. true if it can be converted to a FC.

getJavaProject

public static IJavaProject getJavaProject(String projectName_p)
Get java project in the workspace from its project name.

Parameters:
projectName_p - It is assumed given project name points to a plug-in project. If not, use getJavaProject(IProject) instead.
Returns:
null if it could not be found. Either the given name is null, or there is no java project in the workspace with this name (maybe then the project is deployed instead).

getJavaProject

public static IJavaProject getJavaProject(IProject project_p)
Get java project from workspace project.

Parameters:
project_p -
Returns:
null if it could not be found. The given project is not a Java one, or JDT has not been initialized correctly.

getClassLoaderFor

public static ClassLoader getClassLoaderFor(IJavaProject javaProject_p,
                                            ClassLoader parentClassLoader_p)
                                     throws Exception
Create a new class loader for a java project, son of specified parent class loader.

Parameters:
javaProject_p -
parentClassLoader_p -
Returns:
null if one of the parameter is null or no extra dependency was found in the java project
Throws:
Exception

getProjectDependencies

protected static URL[] getProjectDependencies(IJavaProject javaProject_p)
                                       throws Exception
Get given java project dependencies in terms of compilation.
The resulting array can be used to feed a specific class loader.

Parameters:
javaProject_p -
Returns:
An array of URL.
Not null, but possibly empty.
Throws:
Exception

refreshProject

public static void refreshProject(IProject project_p,
                                  IProgressMonitor monitor_p)
Refresh given project in the workspace.

Parameters:
project_p -
monitor_p -

refreshProject

public static void refreshProject(IProject projectToRefresh_p,
                                  int depth_p,
                                  IProgressMonitor monitor_p)
Refresh a project in the workspace.

Parameters:
projectToRefresh_p -
depth_p -
monitor_p -
See Also:
IResource#refreshLocal(int, IProgressMonitor)}

createSourceFolder

public static boolean createSourceFolder(String sourceFolderName_p,
                                         IProject project_p,
                                         IProgressMonitor monitor_p)
Create a source folder in given project.

Parameters:
sourceFolderName_p - the name of the source folder.
project_p - the hosting project.
monitor_p - progress monitor.
Returns:
true means the creation is successful.

createFolder

public static IFolder createFolder(String folderName_p,
                                   IProject project_p,
                                   IProgressMonitor monitor_p)
Create a folder with given name in given project.

Parameters:
folderName_p -
project_p -
monitor_p -
Returns:
null if creation failed.

ensurePluginProjectExists

public static ProjectHelper.ProjectExistenceStatus ensurePluginProjectExists(String projectName_p)
Make sure named plug-in project exists.
If not try and create a new one with given name.

Parameters:
projectName_p - The expected project name.
Returns:

ensureProjectExists

public static ProjectHelper.ProjectExistenceStatus ensureProjectExists(String projectName_p)
Make sure named project exists.
If not try and create a new one with given name.

Parameters:
projectName_p - The expected project name.
Returns:

EGF Engine
Release 0.1.0

Copyright (c) Thales Corporate Services S.A.S, 2009.

This page is made available under license. For full details see the LEGAL in the documentation book that contains this page.