Class Workbench
- All Implemented Interfaces:
IAdaptable
,IWorkbench
,IWorkbench
,IServiceLocator
Note that any code that is run during the creation of a workbench instance should not required access to the display.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
Family for the early startup job.static final String
static final String
static final String
static final String
Fields inherited from interface org.eclipse.e4.ui.workbench.IWorkbench
APPLICATION_CONTEXT_KEY, CLEAR_PERSISTED_STATE, CSS_RESOURCE_URI_ARG, CSS_URI_ARG, LIFE_CYCLE_URI_ARG, MODEL_RESOURCE_HANDLER, ON_TOP, PERSIST_STATE, PRESENTATION_URI_ARG, XMI_URI_ARG
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addShowingMenus
(Set menuIds, ISelection localSelection, ISelection localEditorInput) Adds the ids of a menu that is now showing to the menu source provider.void
Adds a window listener.void
addWorkbenchListener
(IWorkbenchListener listener) Adds a workbench listener.boolean
close()
Closes this workbench and all its open windows.static int
createAndRunWorkbench
(Display display, WorkbenchAdvisor advisor) Creates the workbench and associates it with the the given display and workbench advisor, and runs the workbench UI.static Display
Creates theDisplay
to be used by the workbench.protected String
createId()
Creates a new local working set manager.protected void
fireWindowActivated
(IWorkbenchWindow window) Fire window activated event.protected void
fireWindowClosed
(IWorkbenchWindow window) Fire window closed event.protected void
Fire window deactivated event.protected void
fireWindowOpened
(IWorkbenchWindow window) Fire window opened event.Returns the currently active window for this workbench (if any).Returns an interface to manage activities at the workbench level.<T> T
getAdapter
(Class<T> key) Returns an object which is an instance of the given class associated with this object.Return the browser support for this workbench.Returns an interface to manage contexts at the workbench level.Returns the decorator manager.Returns the default workbench window page input.Returns the default perspective id, which may benull
.String[]
Returns the ids of the early activated plug-ins that have been disabled by the user.Returns the display for this workbench.Returns the ids of all plug-ins that extend theorg.eclipse.ui.startup
extension point.Returns the editor registry for the workbench.getElementFactory
(String factoryId) Returns the element factory with the given id.Return the export wizard registry.Return the extension tracker for the workbench.Return the help system for this workbench.getId()
Return the import wizard registry.static Workbench
Returns the one and only instance of the workbench, if there is one.org.eclipse.ui.internal.intro.IntroDescriptor
Return the intro manager for this workbench.Returns the id of the preference page that should be presented most prominently.Return a shell provider that can be used to get the best parenting possible for a modal dialog.Return the new wizard registry.Returns the undoable operation support for the workbench.Returns the perspective registry for the workbench.Returns the preference manager for the workbench.Returns the preference store for the workbench.Returns the progress service for the workbench.<T> T
getService
(Class<T> key) Retrieves the service corresponding to the given API.Returns the shared images for the workbench.Return the theme manager for this workbench.Returns the view registry for the workbench.static org.eclipse.ui.internal.testing.WorkbenchTestable
Returns the testable object facade, for use by the test harness.int
Returns the number of open main windows associated with this workbench.Returns a list of the open main windows associated with this workbench.Returns the working set manager for the workbench.boolean
hasService
(Class<?> key) Whether this service exists within the scope of this service locator.boolean
Returns a boolean indicating whether the workbench is in the process of closing.boolean
Returnstrue
if the workbench is running,false
if it has been terminated.boolean
Returns true if the Workbench is in the process of starting.void
Indicates the end of a large update within the workbench.void
Indicates the start of a large update within the workbench.openWorkbenchWindow
(String perspectiveId, IAdaptable input) Creates and opens a new workbench window with one page.openWorkbenchWindow
(IAdaptable input) Creates and opens a new workbench window with one page.openWorkbenchWindow
(IAdaptable input, IPerspectiveDescriptor descriptor, MWindow window, boolean newWindow) void
registerService
(Class api, Object service) Registers a service with this locator.void
removeShowingMenus
(Set menuIds, ISelection localSelection, ISelection localEditorInput) Removes the ids of a menu that is now hidden from the menu source provider.void
Removes a window listener.void
removeWorkbenchListener
(IWorkbenchListener listener) Removes a workbench listener.boolean
restart()
Closes then restarts the workbench with the same command line as used for the previous launch.boolean
restart
(boolean useCurrrentWorkspace) Closes then restarts this workbench using the current workspace ifuseCurrentWorkspace
istrue
.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.void
setEnableAutoSave
(boolean b) Disable the Workbench Auto-Save job on startup during tests.void
setIntroDescriptor
(org.eclipse.ui.internal.intro.IntroDescriptor descriptor) This method exists as a test hook.static Object
setRestartArguments
(String workspacePath) Sets the arguments required to restart the workbench using the specified path as the workspace location.showPerspective
(String perspectiveId, IWorkbenchWindow window) Shows the specified perspective to the user.showPerspective
(String perspectiveId, IWorkbenchWindow targetWindow, IAdaptable input) Shows the specified perspective to the user.Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Field Details
-
WORKBENCH_AUTO_SAVE_JOB
- See Also:
-
MEMENTO_KEY
- See Also:
-
EDITOR_TAG
- See Also:
-
PROP_EXIT_CODE
- See Also:
-
EARLY_STARTUP_FAMILY
Family for the early startup job.- See Also:
-
DEFAULT_WORKBENCH_STATE_FILENAME
- See Also:
-
-
Method Details
-
getInstance
Returns the one and only instance of the workbench, if there is one.- Returns:
- the workbench, or
null
if the workbench has not been created, or has been created and already completed
-
createAndRunWorkbench
Creates the workbench and associates it with the the given display and workbench advisor, and runs the workbench UI. This entails processing and dispatching events until the workbench is closed or restarted.This method is intended to be called by
PlatformUI
. Fails if the workbench UI has already been created.The display passed in must be the default display.
- Parameters:
display
- the display to be used for all UI interactions with the workbenchadvisor
- the application-specific advisor that configures and specializes the workbench- Returns:
- return code
RETURN_OK
for normal exit;RETURN_RESTART
if the workbench was terminated with a call toIWorkbench.restart
; other values reserved for future use
-
createDisplay
Creates theDisplay
to be used by the workbench.- Returns:
- the display
-
getWorkbenchTestable
public static org.eclipse.ui.internal.testing.WorkbenchTestable getWorkbenchTestable()Returns the testable object facade, for use by the test harness.- Returns:
- the testable object facade
- Since:
- 3.0
-
addWorkbenchListener
Description copied from interface:IWorkbench
Adds a workbench listener.- Specified by:
addWorkbenchListener
in interfaceIWorkbench
- Parameters:
listener
- the workbench listener to add
-
removeWorkbenchListener
Description copied from interface:IWorkbench
Removes a workbench listener.- Specified by:
removeWorkbenchListener
in interfaceIWorkbench
- Parameters:
listener
- the workbench listener to remove
-
addWindowListener
Description copied from interface:IWorkbench
Adds a window listener.- Specified by:
addWindowListener
in interfaceIWorkbench
- Parameters:
l
- the window listener to add
-
removeWindowListener
Description copied from interface:IWorkbench
Removes a window listener.- Specified by:
removeWindowListener
in interfaceIWorkbench
- Parameters:
l
- the window listener to remove
-
fireWindowOpened
Fire window opened event.- Parameters:
window
- The window which just opened; should not benull
.
-
fireWindowClosed
Fire window closed event.- Parameters:
window
- The window which just closed; should not benull
.
-
fireWindowActivated
Fire window activated event.- Parameters:
window
- The window which was just activated; should not benull
.
-
fireWindowDeactivated
Fire window deactivated event.- Parameters:
window
- The window which was just deactivated; should not benull
.
-
saveAllEditors
public boolean saveAllEditors(boolean confirm) Description copied from interface:IWorkbench
Save all dirty editors in the workbench. Opens a dialog to prompt the user ifconfirm
is true. Return true if successful. Return false if the user has canceled the command.- Specified by:
saveAllEditors
in interfaceIWorkbench
- Parameters:
confirm
-true
to ask the user before saving unsaved changes (recommended), andfalse
to save unsaved changes without asking- Returns:
true
if the command succeeded, andfalse
if the operation was canceled by the user or an error occurred while saving
-
close
public boolean close()Description copied from interface:IWorkbench
Closes this workbench and all its open windows.If the workbench has an open editor with unsaved content, the user will be given the opportunity to save it.
- Specified by:
close
in interfaceIWorkbench
- Specified by:
close
in interfaceIWorkbench
- Returns:
true
if the workbench was successfully closed, andfalse
if it is still open
-
getActiveWorkbenchWindow
Description copied from interface:IWorkbench
Returns the currently active window for this workbench (if any). Returnsnull
if there is no active workbench window. Returnsnull
if called from a non-UI thread.In the special case when there's no active workbench window and a workbench window is under construction this workbench window instance is returned.
- Specified by:
getActiveWorkbenchWindow
in interfaceIWorkbench
- Returns:
- the active workbench window, or
null
if there is no active workbench window or if called from a non-UI thread
-
getEditorHistory
-
getEditorRegistry
Description copied from interface:IWorkbench
Returns the editor registry for the workbench.- Specified by:
getEditorRegistry
in interfaceIWorkbench
- Returns:
- the workbench editor registry
-
getOperationSupport
Description copied from interface:IWorkbench
Returns the undoable operation support for the workbench.
- Specified by:
getOperationSupport
in interfaceIWorkbench
- Returns:
- the workbench operation support
-
getPerspectiveRegistry
Description copied from interface:IWorkbench
Returns the perspective registry for the workbench.- Specified by:
getPerspectiveRegistry
in interfaceIWorkbench
- Returns:
- the workbench perspective registry
-
getPreferenceManager
Description copied from interface:IWorkbench
Returns the preference manager for the workbench.- Specified by:
getPreferenceManager
in interfaceIWorkbench
- Returns:
- the workbench preference manager
-
getPreferenceStore
Description copied from interface:IWorkbench
Returns the preference store for the workbench.- Specified by:
getPreferenceStore
in interfaceIWorkbench
- Returns:
- the workbench preference store
-
getWorkbenchWindowCount
public int getWorkbenchWindowCount()Description copied from interface:IWorkbench
Returns the number of open main windows associated with this workbench. Note that wizards and dialogs are not included in this list since they are not considered main windows.- Specified by:
getWorkbenchWindowCount
in interfaceIWorkbench
- Returns:
- the number of open windows
-
getWorkbenchWindows
Description copied from interface:IWorkbench
Returns a list of the open main windows associated with this workbench. Note that wizards and dialogs are not included in this list since they are not considered main windows.- Specified by:
getWorkbenchWindows
in interfaceIWorkbench
- Returns:
- a list of open windows
-
getWorkingSetManager
Description copied from interface:IWorkbench
Returns the working set manager for the workbench.- Specified by:
getWorkingSetManager
in interfaceIWorkbench
- Returns:
- the working set manager
-
createLocalWorkingSetManager
Description copied from interface:IWorkbench
Creates a new local working set manager. Clients of local working set managers are responsible for callingIWorkingSetManager.dispose()
when the working sets it manages are no longer needed.- Specified by:
createLocalWorkingSetManager
in interfaceIWorkbench
- Returns:
- the local working set manager
-
isClosing
public boolean isClosing()Description copied from interface:IWorkbench
Returns a boolean indicating whether the workbench is in the process of closing.- Specified by:
isClosing
in interfaceIWorkbench
- Returns:
true
if the workbench is in the process of closing,false
otherwise
-
getBindingContext
-
isStarting
public boolean isStarting()Returns true if the Workbench is in the process of starting.- Specified by:
isStarting
in interfaceIWorkbench
- Returns:
true
if the Workbench is starting, but not yet running the event loop.
-
openWorkbenchWindow
Description copied from interface:IWorkbench
Creates and opens a new workbench window with one page. The perspective of the new page is defined by the default perspective ID. The new window and new page become active.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.- Specified by:
openWorkbenchWindow
in interfaceIWorkbench
- Parameters:
input
- the page input, ornull
if there is no current input. This is used to seed the input for the new page's views.- Returns:
- the new workbench window
- Throws:
WorkbenchException
- if a new window and page could not be opened- See Also:
-
openWorkbenchWindow
public IWorkbenchWindow openWorkbenchWindow(String perspectiveId, IAdaptable input) throws WorkbenchException Description copied from interface:IWorkbench
Creates and opens a new workbench window with one page. The perspective of the new page is defined by the specified perspective ID. The new window and new page become active.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.
- Specified by:
openWorkbenchWindow
in interfaceIWorkbench
- Parameters:
perspectiveId
- the perspective id for the window's initial page, ornull
for no initial pageinput
- the page input, ornull
if there is no current input. This is used to seed the input for the new page's views.- Returns:
- the new workbench window
- Throws:
WorkbenchException
- if a new window and page could not be opened- See Also:
-
openWorkbenchWindow
public WorkbenchWindow openWorkbenchWindow(IAdaptable input, IPerspectiveDescriptor descriptor, MWindow window, boolean newWindow) -
restart
public boolean restart()Description copied from interface:IWorkbench
Closes then restarts the workbench with the same command line as used for the previous launch.If the workbench has an open editor with unsaved content, the user will be given the opportunity to save it.
- Specified by:
restart
in interfaceIWorkbench
- Specified by:
restart
in interfaceIWorkbench
- Returns:
true
if the workbench was successfully closed, andfalse
if it could not be closed
-
restart
public boolean restart(boolean useCurrrentWorkspace) Description copied from interface:IWorkbench
Closes then restarts this workbench using the current workspace ifuseCurrentWorkspace
istrue
. Otherwise, works asIWorkbench.restart()
.If the workbench has an open editor with unsaved content, the user will be given the opportunity to save it.
- Specified by:
restart
in interfaceIWorkbench
- Parameters:
useCurrrentWorkspace
-true
to use the current workspace while restarting this workbench, andfalse
to restart the workbench with the same command line as used for the previous launch- Returns:
true
if the workbench was successfully closed, andfalse
if it could not be closed
-
setRestartArguments
Sets the arguments required to restart the workbench using the specified path as the workspace location.- Parameters:
workspacePath
- the new workspace location- Returns:
IApplication.EXIT_OK
orIApplication.EXIT_RELAUNCH
-
getEarlyActivatedPlugins
Returns the ids of all plug-ins that extend theorg.eclipse.ui.startup
extension point.- Returns:
- the ids of all plug-ins containing 1 or more startup extensions
-
getDisabledEarlyActivatedPlugins
Returns the ids of the early activated plug-ins that have been disabled by the user.- Returns:
- the ids of the early activated plug-ins that have been disabled by the user
-
setEnableAutoSave
public void setEnableAutoSave(boolean b) Disable the Workbench Auto-Save job on startup during tests.- Parameters:
b
-false
to disable the tests.
-
showPerspective
public IWorkbenchPage showPerspective(String perspectiveId, IWorkbenchWindow window) throws WorkbenchException Description copied from interface:IWorkbench
Shows the specified perspective to the user. The caller should use this method when the perspective to be shown is not dependent on the page's input. That is, the perspective can open in any page depending on user preferences.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:
- If the specified window has the requested perspective open, then the window is given focus and the perspective is shown. The page's input is ignored.
- If another window that has the workspace root as input and the requested perspective open and active, then the window is given focus.
- Otherwise the requested perspective is opened and shown in the specified window or in a new window depending on the current user preference for opening perspectives, and that window is given focus.
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
.- Specified by:
showPerspective
in interfaceIWorkbench
- Parameters:
perspectiveId
- the perspective ID to showwindow
- the workbench window of the action calling this method.- Returns:
- the workbench page that the perspective was shown
- Throws:
WorkbenchException
- if the perspective could not be shown
-
showPerspective
public IWorkbenchPage showPerspective(String perspectiveId, IWorkbenchWindow targetWindow, IAdaptable input) throws WorkbenchException Description copied from interface:IWorkbench
Shows the specified perspective to the user. The caller should use this method when the perspective to be shown is dependent on the page's input. That is, the perspective can only open in any page with the specified input.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:
- If the specified window has the requested perspective open and the same requested input, then the window is given focus and the perspective is shown.
- If another window has the requested input and the requested perspective open and active, then that window is given focus.
- If the specified window has the same requested input but not the requested perspective, then the window is given focus and the perspective is opened and shown on condition that the user preference is not to open perspectives in a new window.
- Otherwise the requested perspective is opened and shown in a new window, and the window is given focus.
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
.- Specified by:
showPerspective
in interfaceIWorkbench
- Parameters:
perspectiveId
- the perspective ID to showtargetWindow
- the workbench window of the action calling this method.input
- the page input, ornull
if there is no current input. This is used to seed the input for the page's views- Returns:
- the workbench page that the perspective was shown
- Throws:
WorkbenchException
- if the perspective could not be shown
-
getDecoratorManager
Description copied from interface:IWorkbench
Returns the decorator manager.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 anIResource
), 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.- Specified by:
getDecoratorManager
in interfaceIWorkbench
- Returns:
- the decorator manager
-
getDisplay
Description copied from interface:IWorkbench
Returns the display for this workbench.Code should always ask the workbench for the display rather than rely on
Display.getDefault()
.- Specified by:
getDisplay
in interfaceIWorkbench
- Returns:
- the display to be used for all UI interactions with this workbench
-
getDefaultPerspectiveId
Returns the default perspective id, which may benull
.- Returns:
- the default perspective id, or
null
-
getDefaultPageInput
Returns the default workbench window page input.- Returns:
- the default window page input or
null
if none
-
getMainPreferencePageId
Returns the id of the preference page that should be presented most prominently.- Returns:
- the id of the preference page, or
null
if none
-
getElementFactory
Description copied from interface:IWorkbench
Returns the element factory with the given id.- Specified by:
getElementFactory
in interfaceIWorkbench
- Parameters:
factoryId
- the id of the element factory- Returns:
- the element factory, or
null
if none - See Also:
-
getProgressService
Description copied from interface:IWorkbench
Returns the progress service for the workbench.- Specified by:
getProgressService
in interfaceIWorkbench
- Returns:
- the progress service
-
getActivitySupport
Description copied from interface:IWorkbench
Returns an interface to manage activities at the workbench level.- Specified by:
getActivitySupport
in interfaceIWorkbench
- Returns:
- an interface to manage activities at the workbench level. Guaranteed
not to be
null
.
-
getContextSupport
Description copied from interface:IWorkbench
Returns an interface to manage contexts at the workbench level.- Specified by:
getContextSupport
in interfaceIWorkbench
- Returns:
- an interface to manage contexts at the workbench level. Guaranteed
not to be
null
. - See Also:
-
getIntroManager
Description copied from interface:IWorkbench
Return the intro manager for this workbench.- Specified by:
getIntroManager
in interfaceIWorkbench
- Returns:
- the intro manager for this workbench. Guaranteed not to be
null
.
-
getIntroDescriptor
public org.eclipse.ui.internal.intro.IntroDescriptor getIntroDescriptor()- Returns:
- the intro extension for this workbench.
- Since:
- 3.0
-
setIntroDescriptor
public void setIntroDescriptor(org.eclipse.ui.internal.intro.IntroDescriptor descriptor) This method exists as a test hook. This method should NEVER be called by clients.- Parameters:
descriptor
- The intro descriptor to use.- Since:
- 3.0
-
getThemeManager
Description copied from interface:IWorkbench
Return the theme manager for this workbench.- Specified by:
getThemeManager
in interfaceIWorkbench
- Returns:
- the theme manager for this workbench.Guaranteed not to be
null
.
-
isRunning
public boolean isRunning()Returnstrue
if the workbench is running,false
if it has been terminated.- Returns:
true
if the workbench is running,false
if it has been terminated.
-
largeUpdateStart
public void largeUpdateStart()Indicates the start of a large update within the workbench. This is used to disable CPU-intensive, change-sensitive services that were temporarily disabled in the midst of large changes. This method should always be called in tandem with
largeUpdateEnd
, and the event loop should not be allowed to spin before that method is called.Important: always use with
largeUpdateEnd
! -
largeUpdateEnd
public void largeUpdateEnd()Indicates the end of a large update within the workbench. This is used to re-enable services that were temporarily disabled in the midst of large changes. This method should always be called in tandem with
largeUpdateStart
, and the event loop should not be allowed to spin before this method is called.Important: always protect this call by using
finally
! -
getExtensionTracker
Description copied from interface:IWorkbench
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.- Specified by:
getExtensionTracker
in interfaceIWorkbench
- Returns:
- the extension tracker
- See Also:
-
getHelpSystem
Description copied from interface:IWorkbench
Return the help system for this workbench.- Specified by:
getHelpSystem
in interfaceIWorkbench
- Returns:
- the help system
-
getBrowserSupport
Description copied from interface:IWorkbench
Return the browser support for this workbench.- Specified by:
getBrowserSupport
in interfaceIWorkbench
- Returns:
- the browser support system
-
getViewRegistry
Description copied from interface:IWorkbench
Returns the view registry for the workbench.- Specified by:
getViewRegistry
in interfaceIWorkbench
- Returns:
- the workbench view registry
-
getNewWizardRegistry
Description copied from interface:IWorkbench
Return the new wizard registry.- Specified by:
getNewWizardRegistry
in interfaceIWorkbench
- Returns:
- the new wizard registry
-
getImportWizardRegistry
Description copied from interface:IWorkbench
Return the import wizard registry.- Specified by:
getImportWizardRegistry
in interfaceIWorkbench
- Returns:
- the import wizard registry
-
getExportWizardRegistry
Description copied from interface:IWorkbench
Return the export wizard registry.- Specified by:
getExportWizardRegistry
in interfaceIWorkbench
- Returns:
- the export wizard registry
-
getAdapter
Description copied from interface:IAdaptable
Returns an object which is an instance of the given class associated with this object. Returnsnull
if no such object can be found.Clients may implement this method but should generally call
Adapters.adapt(Object, Class, boolean)
rather than invoking it directly.- Specified by:
getAdapter
in interfaceIAdaptable
- Type Parameters:
T
- the class type- Parameters:
key
- the adapter class to look up- Returns:
- a object of the given class, or
null
if this object does not have an adapter for the given class
-
getService
Description copied from interface:IServiceLocator
Retrieves the service corresponding to the given API.- Specified by:
getService
in interfaceIServiceLocator
- Parameters:
key
- This is the interface that the service implements. Must not benull
.- Returns:
- The service, or
null
if no such service could be found.
-
hasService
Description copied from interface:IServiceLocator
Whether this service exists within the scope of this service locator. This does not include looking for the service within the scope of the parents. This method can be used to determine whether a particular service supports nesting in this scope.- Specified by:
hasService
in interfaceIServiceLocator
- Parameters:
key
- This is the interface that the service implements. Must not benull
.- Returns:
true
if the service locator can find a service for the given API;false
otherwise.
-
registerService
Registers a service with this locator. If there is an existing service matching the sameapi
and it implementsIDisposable
, it will be disposed.- Parameters:
api
- This is the interface that the service implements. Must not benull
.service
- The service to register. This must be some implementation ofapi
. This value must not benull
.
-
addShowingMenus
Adds the ids of a menu that is now showing to the menu source provider. This is used for legacy action-based handlers which need to become active only for the duration of a menu being visible.- Parameters:
menuIds
- The identifiers of the menu that is now showing; must not benull
.
-
removeShowingMenus
Removes the ids of a menu that is now hidden from the menu source provider. This is used for legacy action-based handlers which need to become active only for the duration of a menu being visible.- Parameters:
menuIds
- The identifiers of the menu that is now hidden; must not benull
.
-
saveAll
public boolean saveAll(IShellProvider shellProvider, IRunnableContext runnableContext, ISaveableFilter filter, boolean confirm) Description copied from interface:IWorkbench
Save all dirty saveables in the workbench that match the given filter. Opens a dialog to prompt the user ifconfirm
is true. Return true if successful. Return false if the user has canceled the command.- Specified by:
saveAll
in interfaceIWorkbench
- Parameters:
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 ornull
if all dirty saveables should be saved.confirm
-true
to ask the user before saving unsaved changes (recommended), andfalse
to save unsaved changes without asking- Returns:
true
if the command succeeded, andfalse
if the operation was canceled by the user or an error occurred while saving
-
getModalDialogShellProvider
Description copied from interface:IWorkbench
Return a shell provider that can be used to get the best parenting possible for a modal dialog. If modal shells are already created, use the topmost modal shell as the parent to avoid two modal dialogs. If there are no modal shells, use the shell of the active workbench window.- Specified by:
getModalDialogShellProvider
in interfaceIWorkbench
- Returns:
- a shell provider that provides the best parenting possible for a modal dialog.
-
getContext
-
getApplication
- Specified by:
getApplication
in interfaceIWorkbench
- Returns:
- the application model driving the workbench
-
getId
- Specified by:
getId
in interfaceIWorkbench
- Returns:
- unique id of the instance
-
createId
-