Interface IWorkbenchWindow
- All Superinterfaces:
IPageService
,IRunnableContext
,IServiceLocator
,IShellProvider
- All Known Implementing Classes:
WorkbenchWindow
Each workbench window has a collection of 0 or more 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.
The workbench window 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 window is closed. The supported
services are:
ICommandService
IContextService
IHandlerService
IBindingService
. Resources allocated through this service will not be cleaned up until the workbench shuts down.
This interface is not intended to be implemented by clients.
- See Also:
- Restriction:
- This interface is not intended to be implemented by clients.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
close()
Closes this workbench window.Returns the currently active page for this workbench window.Return the extension tracker for the workbench.getPages()
Returns a list of the pages in this workbench window.Returns the part service which tracks part activation within this workbench window.Returns the selection service which tracks selection within this workbench window.getShell()
Returns this workbench window's shell.Returns the workbench for this window.boolean
isApplicationMenu
(String menuId) Returns whether the specified menu is an application menu as opposed to a part menu.boolean
Returns a boolean indicating whether the workbench window is in the process of closing.openPage
(String perspectiveId, IAdaptable input) Creates and opens a new workbench page.openPage
(IAdaptable input) Creates and opens a new workbench page.void
run
(boolean fork, boolean cancelable, IRunnableWithProgress runnable) This specialization of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) blocks until the runnable has been run, regardless of the value offork
.void
setActivePage
(IWorkbenchPage page) Sets or clears the currently active page for this workbench window.Methods inherited from interface org.eclipse.ui.IPageService
addPageListener, addPerspectiveListener, removePageListener, removePerspectiveListener
Methods inherited from interface org.eclipse.ui.services.IServiceLocator
getService, hasService
-
Method Details
-
close
boolean close()Closes this workbench window.If the window has an open editor with unsaved content, the user will be given the opportunity to save it.
- Returns:
true
if the window was successfully closed, andfalse
if it is still open
-
getActivePage
IWorkbenchPage getActivePage()Returns the currently active page for this workbench window.- Specified by:
getActivePage
in interfaceIPageService
- Returns:
- the active page, or
null
if none
-
getPages
IWorkbenchPage[] getPages()Returns a list of the pages in this workbench window.Note that each window has its own pages; pages are never shared between different windows.
- Returns:
- a list of pages
-
getPartService
IPartService getPartService()Returns the part service which tracks part activation within this workbench window.- Returns:
- the part service
-
getSelectionService
ISelectionService getSelectionService()Returns the selection service which tracks selection within this workbench window.- Returns:
- the selection service
-
getShell
Shell getShell()Returns this workbench window's shell.- Specified by:
getShell
in interfaceIShellProvider
- Returns:
- the shell containing this window's controls or
null
if the shell has not been created yet or if the window has been closed
-
getWorkbench
IWorkbench getWorkbench()Returns the workbench for this window.- Returns:
- the workbench
-
isApplicationMenu
Returns whether the specified menu is an application menu as opposed to a part menu. Application menus contain items which affect the workbench or window. Part menus contain items which affect the active part (view or editor).This is typically used during "in place" editing. Application menus should be preserved during menu merging. All other menus may be removed from the window.
- Parameters:
menuId
- the menu id- Returns:
true
if the specified menu is an application menu, andfalse
if it is not
-
openPage
Creates and opens a new workbench page. The perspective of the new page is defined by the specified perspective ID. The new page become active.Note: Since release 2.0, a window is limited to contain at most one page. If a page exist in the window when this method is used, then another window is created for the new page. Callers are strongly recommended to use the
IWorkbench.showPerspective
APIs to programmatically show a perspective.- Parameters:
perspectiveId
- the perspective id for the window's 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 page
- Throws:
WorkbenchException
- if a page could not be opened- See Also:
-
openPage
Creates and opens a new workbench page. The default perspective is used as a template for creating the page. The page becomes active.Note: Since release 2.0, a window is limited to contain at most one page. If a page exist in the window when this method is used, then another window is created for the new page. Callers are strongly recommended to use the
IWorkbench.showPerspective
APIs to programmatically show a perspective.- 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 page could not be opened- See Also:
-
run
void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException This specialization of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) blocks until the runnable has been run, regardless of the value offork
. It is recommended thatfork
is set to true in most cases. Iffork
is set tofalse
, the runnable will run in the UI thread and it is the runnable's responsibility to callDisplay.readAndDispatch()
to ensure UI responsiveness.- Specified by:
run
in interfaceIRunnableContext
- Parameters:
fork
-true
if the runnable should be run in a separate thread, andfalse
to run in the same threadcancelable
-true
to enable the cancelation, andfalse
to make the operation uncancellablerunnable
- the runnable to run- Throws:
InvocationTargetException
- wraps any exception or error which occurs while running the runnableInterruptedException
- propagated by the context if the runnable acknowledges cancelation by throwing this exception. This should not be thrown if cancelable isfalse
.- Since:
- 3.2
-
setActivePage
Sets or clears the currently active page for this workbench window.- Parameters:
page
- the new active page, ornull
for no active page
-
getExtensionTracker
IExtensionTracker 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, the action objects corresponding to new wizards contributed by plug-ins fall into this category.
- Returns:
- the extension tracker
- Since:
- 3.1
- See Also:
-
isClosing
boolean isClosing()Returns a boolean indicating whether the workbench window is in the process of closing.- Returns:
true
if the workbench window is in the process of closing,false
otherwise- Since:
- 3.112
-