public interface IWorkbench extends IAdaptable, IServiceLocator
A workbench has one or more main windows which present to the end user information based on some underlying model, typically on resources in an underlying workspace. A workbench usually starts with a single open window, and automatically closes when its last window closes.
Each workbench window has a collection of pages; the active page is the one that is being presented to the end user; at most one page is active in a window at a time.
Each workbench page has a collection of workbench parts, of which there are two kinds: views and editors. A page's parts are arranged (tiled or stacked) for presentation on the screen. The arrangement is not fixed; the user can arrange the parts as they see fit. A perspective is a template for a page, capturing a collection of parts and their arrangement.
The platform creates a workbench when the workbench plug-in is activated;
since this happens at most once during the life of the running platform,
there is only one workbench instance. Due to its singular nature, it is
commonly referred to as
The workbench supports a few services
by default. If
these services are used to allocate resources, it is important to remember to
clean up those resources after you are done with them. Otherwise, the
resources will exist until the workbench shuts down. The supported services
are:
This interface is not intended to be implemented by clients.
PlatformUI.getWorkbench()
Modifier and Type | Method and Description |
---|---|
void |
addWindowListener(IWindowListener listener)
Adds a window listener.
|
void |
addWorkbenchListener(IWorkbenchListener listener)
Adds a workbench listener.
|
boolean |
close()
Closes this workbench and all its open windows.
|
ILocalWorkingSetManager |
createLocalWorkingSetManager()
Creates a new local working set manager.
|
IWorkbenchWindow |
getActiveWorkbenchWindow()
Returns the currently active window for this workbench (if any).
|
IWorkbenchActivitySupport |
getActivitySupport()
Returns an interface to manage activities at the workbench level.
|
IWorkbenchBrowserSupport |
getBrowserSupport()
Return the browser support for this workbench.
|
IWorkbenchCommandSupport |
getCommandSupport()
Deprecated.
Please use
IServiceLocator.getService(Class) instead. |
IWorkbenchContextSupport |
getContextSupport()
Deprecated.
Please use
IServiceLocator.getService(Class) instead. |
IDecoratorManager |
getDecoratorManager()
Returns the decorator manager.
|
Display |
getDisplay()
Returns the display for this workbench.
|
IEditorRegistry |
getEditorRegistry()
Returns the editor registry for the workbench.
|
IElementFactory |
getElementFactory(String factoryId)
Returns the element factory with the given id.
|
IWizardRegistry |
getExportWizardRegistry()
Return the export wizard registry.
|
IExtensionTracker |
getExtensionTracker()
Return the extension tracker for the workbench.
|
IWorkbenchHelpSystem |
getHelpSystem()
Return the help system for this workbench.
|
IWizardRegistry |
getImportWizardRegistry()
Return the import wizard registry.
|
IIntroManager |
getIntroManager()
Return the intro manager for this workbench.
|
IShellProvider |
getModalDialogShellProvider()
Return a shell provider that can be used to get the best parenting
possible for a modal dialog.
|
IWizardRegistry |
getNewWizardRegistry()
Return the new wizard registry.
|
IWorkbenchOperationSupport |
getOperationSupport()
Returns the undoable operation support for the workbench.
|
IPerspectiveRegistry |
getPerspectiveRegistry()
Returns the perspective registry for the workbench.
|
PreferenceManager |
getPreferenceManager()
Returns the preference manager for the workbench.
|
IPreferenceStore |
getPreferenceStore()
Deprecated.
this returns the internal preference store for the workbench,
which clients should not use. Use
PlatformUI.getPreferenceStore() instead. Note that
these preference stores are not the same. If you were
previously storing preferences in the store returned by this
method you should move them to your own plugin preference
store. |
IProgressService |
getProgressService()
Returns the progress service for the workbench.
|
ISharedImages |
getSharedImages()
Returns the shared images for the workbench.
|
IThemeManager |
getThemeManager()
Return the theme manager for this workbench.
|
IViewRegistry |
getViewRegistry()
Returns the view registry for the workbench.
|
int |
getWorkbenchWindowCount()
Returns the number of open main windows associated with this workbench.
|
IWorkbenchWindow[] |
getWorkbenchWindows()
Returns a list of the open main windows associated with this workbench.
|
IWorkingSetManager |
getWorkingSetManager()
Returns the working set manager for the workbench.
|
boolean |
isClosing()
Returns a boolean indicating whether the workbench is in the process of
closing.
|
boolean |
isStarting()
Returns a boolean indicating whether the workbench is in the process of
starting.
|
IWorkbenchWindow |
openWorkbenchWindow(IAdaptable input)
Creates and opens a new workbench window with one page.
|
IWorkbenchWindow |
openWorkbenchWindow(String perspectiveId,
IAdaptable input)
Creates and opens a new workbench window with one page.
|
void |
removeWindowListener(IWindowListener listener)
Removes a window listener.
|
void |
removeWorkbenchListener(IWorkbenchListener listener)
Removes a workbench listener.
|
boolean |
restart()
Closes then restarts this workbench.
|
boolean |
saveAll(IShellProvider shellProvider,
IRunnableContext runnableContext,
ISaveableFilter filter,
boolean confirm)
Save all dirty saveables in the workbench that match the given filter.
|
boolean |
saveAllEditors(boolean confirm)
Save all dirty editors in the workbench.
|
IWorkbenchPage |
showPerspective(String perspectiveId,
IWorkbenchWindow window)
Shows the specified perspective to the user.
|
IWorkbenchPage |
showPerspective(String perspectiveId,
IWorkbenchWindow window,
IAdaptable input)
Shows the specified perspective to the user.
|
getAdapter
getService, hasService
Display getDisplay()
Code should always ask the workbench for the display rather than rely on
Display.getDefault()
.
IProgressService getProgressService()
void addWorkbenchListener(IWorkbenchListener listener)
listener
- the workbench listener to addvoid removeWorkbenchListener(IWorkbenchListener listener)
listener
- the workbench listener to removevoid addWindowListener(IWindowListener listener)
listener
- the window listener to addvoid removeWindowListener(IWindowListener listener)
listener
- the window listener to removeboolean close()
If the workbench has an open editor with unsaved content, the user will be given the opportunity to save it.
true
if the workbench was successfully closed, and
false
if it is still openIWorkbenchWindow getActiveWorkbenchWindow()
null
if there is no active workbench window. Returns
null
if called from a non-UI thread.null
if there is
no active workbench window or if called from a non-UI threadIEditorRegistry getEditorRegistry()
IWorkbenchOperationSupport getOperationSupport()
Returns the undoable operation support for the workbench.
IPerspectiveRegistry getPerspectiveRegistry()
PreferenceManager getPreferenceManager()
@Deprecated IPreferenceStore getPreferenceStore()
PlatformUI.getPreferenceStore()
instead. Note that
these preference stores are not the same. If you were
previously storing preferences in the store returned by this
method you should move them to your own plugin preference
store.ISharedImages getSharedImages()
int getWorkbenchWindowCount()
IWorkbenchWindow[] getWorkbenchWindows()
IWorkingSetManager getWorkingSetManager()
ILocalWorkingSetManager createLocalWorkingSetManager()
IWorkingSetManager.dispose()
when the working sets it manages are no longer needed.IWorkbenchWindow openWorkbenchWindow(String perspectiveId, IAdaptable input) throws WorkbenchException
Note: The caller is responsible to ensure the action using this
method will explicitly inform the user a new window will be opened.
Otherwise, callers are strongly recommended to use the
openPerspective
APIs to programmatically show a
perspective to avoid confusing the user.
In most cases where this method is used the caller is tightly coupled to a particular perspective. They define it in the registry and contribute some user interface action to open or activate it. In situations like this a static variable is often used to identify the perspective ID.
perspectiveId
- the perspective id for the window's initial page, or
null
for no initial pageinput
- the page input, or null
if there is no current
input. This is used to seed the input for the new page's
views.WorkbenchException
- if a new window and page could not be openedshowPerspective(String, IWorkbenchWindow, IAdaptable)
IWorkbenchWindow openWorkbenchWindow(IAdaptable input) throws WorkbenchException
Note: The caller is responsible to ensure the action using this
method will explicitly inform the user a new window will be opened.
Otherwise, callers are strongly recommended to use the
openPerspective
APIs to programmatically show a
perspective to avoid confusing the user.
input
- the page input, or null
if there is no current
input. This is used to seed the input for the new page's
views.WorkbenchException
- if a new window and page could not be openedshowPerspective(String, IWorkbenchWindow, IAdaptable)
boolean restart()
If the workbench has an open editor with unsaved content, the user will be given the opportunity to save it.
true
if the workbench was successfully closed, and
false
if it could not be closedIWorkbenchPage showPerspective(String perspectiveId, IWorkbenchWindow window) throws WorkbenchException
The perspective may be shown in the specified window, in another existing window, or in a new window depending on user preferences. The exact policy is controlled by the workbench to ensure consistency to the user. The policy is subject to change. The current policy is as follows:
The workbench also defines a number of menu items to activate or open
each registered perspective. A complete list of these perspectives is
available from the perspective registry found on IWorkbench
.
perspectiveId
- the perspective ID to showwindow
- the workbench window of the action calling this method.WorkbenchException
- if the perspective could not be shownIWorkbenchPage showPerspective(String perspectiveId, IWorkbenchWindow window, IAdaptable input) throws WorkbenchException
The perspective may be shown in the specified window, in another existing window, or in a new window depending on user preferences. The exact policy is controlled by the workbench to ensure consistency to the user. The policy is subject to change. The current policy is as follows:
The workbench also defines a number of menu items to activate or open
each registered perspective. A complete list of these perspectives is
available from the perspective registry found on IWorkbench
.
perspectiveId
- the perspective ID to showwindow
- the workbench window of the action calling this method.input
- the page input, or null
if there is no current
input. This is used to seed the input for the page's viewsWorkbenchException
- if the perspective could not be shownIDecoratorManager getDecoratorManager()
Any client using the decorator manager should come up with the text and image for the element (including any of the part's own decorations) before calling the decorator manager. It should also add a listener to be notified when decorations change.
Note that if the element implements IAdaptable
,
decorators may use this mechanism to obtain an adapter (for example an
IResource
), and derive the decoration from the adapter
rather than the element. Since the adapter may differ from the original
element, those using the decorator manager should be prepared to handle
notification that the decoration for the adapter has changed, in addition
to handling notification that the decoration for the element has changed.
That is, it needs to be able to map back from the adapter to the element.
boolean saveAllEditors(boolean confirm)
confirm
is true. Return true if successful. Return
false if the user has canceled the command.confirm
- true
to ask the user before saving unsaved
changes (recommended), and false
to save
unsaved changes without askingtrue
if the command succeeded, and
false
if the operation was canceled by the user or
an error occurred while savingIElementFactory getElementFactory(String factoryId)
factoryId
- the id of the element factorynull
if noneIElementFactory
IWorkbenchActivitySupport getActivitySupport()
null
.@Deprecated IWorkbenchCommandSupport getCommandSupport()
IServiceLocator.getService(Class)
instead.null
.ICommandService
,
IHandlerService
@Deprecated IWorkbenchContextSupport getContextSupport()
IServiceLocator.getService(Class)
instead.null
.IContextService
IThemeManager getThemeManager()
null
.IIntroManager getIntroManager()
null
.IWorkbenchHelpSystem getHelpSystem()
IWorkbenchBrowserSupport getBrowserSupport()
boolean isStarting()
IStartup
or Display.asyncExec(Runnable)
.true
if the workbench is in the process of starting,
false
otherwiseboolean isClosing()
true
if the workbench is in the process of
closing, false
otherwiseIExtensionTracker getExtensionTracker()
Return the extension tracker for the workbench. This tracker may be used by plug-ins to ensure responsiveness to changes to the plug-in registry.
The tracker at this level of the workbench is typically used to track
elements that persist for the life of the workbench. For example,
IEditorDescriptor
objects fall into this category.
IWorkbenchWindow.getExtensionTracker()
,
IWorkbenchPage.getExtensionTracker()
IViewRegistry getViewRegistry()
IWizardRegistry getNewWizardRegistry()
IWizardRegistry getImportWizardRegistry()
IWizardRegistry getExportWizardRegistry()
boolean saveAll(IShellProvider shellProvider, IRunnableContext runnableContext, ISaveableFilter filter, boolean confirm)
confirm
is true.
Return true if successful. Return false if the user has canceled the
command.shellProvider
- the provider used to obtain a shell in prompting is
required. Clients can use a workbench window for this.runnableContext
- a runnable context that will be used to provide a
progress monitor while the save is taking place. Clients can
use a workbench window for this.filter
- the filter used to determine if a particular dirty saveable
needs to be saved or null
if all dirty
saveables should be saved.confirm
- true
to ask the user before saving unsaved
changes (recommended), and false
to save
unsaved changes without askingtrue
if the command succeeded, and
false
if the operation was canceled by the user or
an error occurred while savingIShellProvider getModalDialogShellProvider()
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.