fable.framework.toolbox
Class EclipseUtils

java.lang.Object
  extended by fable.framework.toolbox.EclipseUtils

public class EclipseUtils
extends java.lang.Object

Author:
fcp94556

Constructor Summary
EclipseUtils()
           
 
Method Summary
static void addBuilderToProject(org.eclipse.core.resources.IProject project, java.lang.String id)
          Delcare a builder id in a project, this is then called to build it.
static void delay(long waitTimeMillis)
          Process UI input but do not return for the specified time interval.
static java.net.URL getAbsoluteUrl(java.net.URL bundleUrl)
           
static org.eclipse.ui.IEditorPart getActiveEditor()
           
static org.eclipse.ui.IWorkbenchPage getActivePage()
           
static org.eclipse.core.resources.IProject getActiveProject()
          Returns the active project based on active selection
static java.lang.Object getAdapter(java.lang.Object sourceObject, java.lang.Class<?> adapterType)
          If it is possible to adapt the given object to the given type, this returns the adapter.
static org.eclipse.ui.IWorkbenchPage getDefaultPage()
           
static java.io.File getFile(org.eclipse.ui.IEditorInput fileInput)
           
static java.lang.String getFileName(org.eclipse.ui.IEditorInput input)
           
static java.lang.String getFilePath(org.eclipse.ui.IEditorInput fileInput)
          Get the file path from a FileStoreEditorInput.
static org.eclipse.core.resources.IFile getIFile(org.eclipse.ui.IEditorInput input)
          Try to determine the IFile from the edit input
static org.eclipse.ui.IWorkbenchPage getPage()
          Gets the page, even during startup.
static java.lang.String getUnique(org.eclipse.core.resources.IResource res)
           
static org.eclipse.core.resources.IFile getUniqueFile(org.eclipse.core.resources.IFile file, java.lang.String extension)
          Gets a unique file.
static org.eclipse.core.resources.IFile getUniqueFile(org.eclipse.core.resources.IFile file, java.lang.String conjunctive, java.lang.String extension)
          Gets a unique file.
static boolean isActivePerspective(java.lang.String id)
          Checks of the id passed in == the current perspectives.
static org.eclipse.ui.IEditorPart openEditor(org.eclipse.core.resources.IFile file)
          Opens an external editor on a file path
static org.eclipse.ui.IEditorPart openExternalEditor(java.lang.String filename)
          Opens an external editor on a file path
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EclipseUtils

public EclipseUtils()
Method Detail

getFilePath

public static java.lang.String getFilePath(org.eclipse.ui.IEditorInput fileInput)
Get the file path from a FileStoreEditorInput. Removes any "file:" from the URI to the file path if it exists.

Parameters:
fileInput -
Returns:
String

getFile

public static java.io.File getFile(org.eclipse.ui.IEditorInput fileInput)
Parameters:
fileInput -
Returns:
File

getIFile

public static org.eclipse.core.resources.IFile getIFile(org.eclipse.ui.IEditorInput input)
Try to determine the IFile from the edit input

Parameters:
input -
Returns:
file

getFileName

public static java.lang.String getFileName(org.eclipse.ui.IEditorInput input)

getAbsoluteUrl

public static java.net.URL getAbsoluteUrl(java.net.URL bundleUrl)
Parameters:
bundleUrl -
Returns:
bundleUrl

getPage

public static org.eclipse.ui.IWorkbenchPage getPage()
Gets the page, even during startup.

Returns:
the page

getActivePage

public static org.eclipse.ui.IWorkbenchPage getActivePage()
Returns:
IWorkbenchPage

getActiveEditor

public static org.eclipse.ui.IEditorPart getActiveEditor()
Returns:
IWorkbenchPage

getDefaultPage

public static org.eclipse.ui.IWorkbenchPage getDefaultPage()
Returns:
IWorkbenchPage

addBuilderToProject

public static void addBuilderToProject(org.eclipse.core.resources.IProject project,
                                       java.lang.String id)
                                throws org.eclipse.core.runtime.CoreException
Delcare a builder id in a project, this is then called to build it.

Parameters:
project -
id -
Throws:
org.eclipse.core.runtime.CoreException

isActivePerspective

public static boolean isActivePerspective(java.lang.String id)
Checks of the id passed in == the current perspectives.

Parameters:
id -
Returns:
true if is

delay

public static void delay(long waitTimeMillis)
Process UI input but do not return for the specified time interval.

Parameters:
waitTimeMillis - the number of milliseconds

getUniqueFile

public static org.eclipse.core.resources.IFile getUniqueFile(org.eclipse.core.resources.IFile file,
                                                             java.lang.String extension)
Gets a unique file. The file must have a parent of IFolder.

Parameters:
file -
Returns:
new file, not created.

getUniqueFile

public static org.eclipse.core.resources.IFile getUniqueFile(org.eclipse.core.resources.IFile file,
                                                             java.lang.String conjunctive,
                                                             java.lang.String extension)
Gets a unique file. The file must have a parent of IFolder.

Parameters:
file -
Returns:
new file, not created.

getUnique

public static java.lang.String getUnique(org.eclipse.core.resources.IResource res)

getAdapter

public static java.lang.Object getAdapter(java.lang.Object sourceObject,
                                          java.lang.Class<?> adapterType)
If it is possible to adapt the given object to the given type, this returns the adapter. Performs the following checks:
  1. Returns sourceObject if it is an instance of the adapter type.
  2. If sourceObject implements IAdaptable, it is queried for adapters.
  3. If sourceObject is not an instance of PlatformObject (which would have already done so), the adapter manager is queried for adapters
Otherwise returns null.

Parameters:
sourceObject - object to adapt, or null
adapterType - type to adapt to
Returns:
a representation of sourceObject that is assignable to the adapter type, or null if no such representation exists

openEditor

public static org.eclipse.ui.IEditorPart openEditor(org.eclipse.core.resources.IFile file)
                                             throws org.eclipse.ui.PartInitException
Opens an external editor on a file path

Parameters:
file -
Throws:
org.eclipse.ui.PartInitException

openExternalEditor

public static org.eclipse.ui.IEditorPart openExternalEditor(java.lang.String filename)
                                                     throws org.eclipse.ui.PartInitException
Opens an external editor on a file path

Parameters:
filename -
Throws:
org.eclipse.ui.PartInitException

getActiveProject

public static org.eclipse.core.resources.IProject getActiveProject()
Returns the active project based on active selection