EGF Engine
Release 0.1.0

org.eclipse.egf.common.ui.helper
Class WorkbenchHelper

java.lang.Object
  extended by org.eclipse.egf.common.ui.helper.WorkbenchHelper

public class WorkbenchHelper
extends Object

Provides services to easily deal with workbench stuffs (e.g open an editor).
Most of the services need to be called within the UI Thread.


Constructor Summary
WorkbenchHelper()
           
 
Method Summary
static void addPartListener(IPartListener listener_p)
          Add a part listener in the active workbench page.
static boolean closeEditor(IEditorPart editor_p, boolean save_p)
          Close the given editor.
static boolean closeFileEditors(String fileRelativePath_p)
          Close file based editors for given file relative path.
static void closeView(String viewId_p)
          Close a view for specified id in the current workbench page.
static IWorkbenchPage getActiveWorkbenchPage()
          Returns the currently active page for the active workbench window.
static IEditorReference[] getAllOpenEditors(String editorId_p)
          Get all open editors in the active workbench page for given editor id.
static PackageExplorerPart getPackageExplorerView()
          Get the Package Explorer view.
static boolean isViewOpen(String viewId_p)
          Return whether or not the view for specified id is open.
static IEditorPart openDefaultFileEditor(String fileRelativePath_p, Shell shell_p)
          Open file based editor for given file relative path with registered editor as default one.
static IEditorPart openEditor(IEditorInput editorInput_p, String editorId_p, Shell shell_p)
          Open an editor on the given input.
static IEditorPart openFileEditor(String fileRelativePath_p, String editorId_p, boolean editable_p)
          Open file based editor for given file relative path.
static void openView(String viewId_p)
          Open a view for specified id in the current workbench page.
static void saveEditor(IEditorPart editor_p)
          Save given editor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkbenchHelper

public WorkbenchHelper()
Method Detail

getActiveWorkbenchPage

public static IWorkbenchPage getActiveWorkbenchPage()
Returns the currently active page for the active workbench window.
Returns null if there is no active workbench page.
Returns null if called from a non-UI thread.

Returns:
the active workbench page, or null if there is no active workbench page or if called from a non-UI thread

openFileEditor

public static IEditorPart openFileEditor(String fileRelativePath_p,
                                         String editorId_p,
                                         boolean editable_p)
Open file based editor for given file relative path.

Parameters:
fileRelativePath_p - A path relative to workspace, starting with the project name.
editorId_p -
Returns:

openEditor

public static IEditorPart openEditor(IEditorInput editorInput_p,
                                     String editorId_p,
                                     Shell shell_p)
Open an editor on the given input.

Parameters:
editorInput_p -
editorId_p -
Returns:
an open and active editor, or null if an external editor was opened.

openDefaultFileEditor

public static IEditorPart openDefaultFileEditor(String fileRelativePath_p,
                                                Shell shell_p)
Open file based editor for given file relative path with registered editor as default one.

Parameters:
fileRelativePath_p - A path relative to workspace, starting with the project name.
Returns:

saveEditor

public static void saveEditor(IEditorPart editor_p)
Save given editor.

Parameters:
editor_p -

closeFileEditors

public static boolean closeFileEditors(String fileRelativePath_p)
Close file based editors for given file relative path.
Note that all editors are asked to save content as they are closed.

Parameters:
fileRelativePath_p -
Returns:

closeEditor

public static boolean closeEditor(IEditorPart editor_p,
                                  boolean save_p)
Close the given editor. The editor must belong to this workbench page.

If the editor has unsaved content and save_p is true,
the user will be given the opportunity to save it.

Parameters:
editor_p - the edit or to close.
save_p - true to save the editor contents if required (recommended),
and false to discard any unsaved changes.
Returns:
true if the editor was successfully closed, and false if the editor is still open.

closeView

public static void closeView(String viewId_p)
Close a view for specified id in the current workbench page.

Parameters:
viewId_p -

openView

public static void openView(String viewId_p)
Open a view for specified id in the current workbench page.

Parameters:
viewId_p -

isViewOpen

public static boolean isViewOpen(String viewId_p)
Return whether or not the view for specified id is open.

Parameters:
viewId_p -
Returns:
true means open.

addPartListener

public static void addPartListener(IPartListener listener_p)
Add a part listener in the active workbench page.

Parameters:
listener_p -

getAllOpenEditors

public static IEditorReference[] getAllOpenEditors(String editorId_p)
Get all open editors in the active workbench page for given editor id.

Parameters:
editorId_p - the editor id, the one use to open the related editor.
Returns:
a not null array.

getPackageExplorerView

public static PackageExplorerPart getPackageExplorerView()
Get the Package Explorer view.
Returns null if there is no active workbench page.
Returns null if called from a non-UI thread.
Returns null if package explorer is not open.

Returns:
the Package Explorer view, or null if there is no active workbench page or if called from a non-UI thread or if package explorer is not open.

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.