public interface IWorkbenchWindow extends IPageService, IRunnableContext, IServiceLocator, IShellProvider
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.
IWorkbenchPage
Modifier and Type | Method and Description |
---|---|
boolean |
close()
Closes this workbench window.
|
IWorkbenchPage |
getActivePage()
Returns the currently active page for this workbench window.
|
IExtensionTracker |
getExtensionTracker()
Return the extension tracker for the workbench.
|
IWorkbenchPage[] |
getPages()
Returns a list of the pages in this workbench window.
|
IPartService |
getPartService()
Returns the part service which tracks part activation within this
workbench window.
|
ISelectionService |
getSelectionService()
Returns the selection service which tracks selection within this
workbench window.
|
Shell |
getShell()
Returns this workbench window's shell.
|
IWorkbench |
getWorkbench()
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.
|
IWorkbenchPage |
openPage(IAdaptable input)
Creates and opens a new workbench page.
|
IWorkbenchPage |
openPage(String perspectiveId,
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 of
fork . |
void |
setActivePage(IWorkbenchPage page)
Sets or clears the currently active page for this workbench window.
|
addPageListener, addPerspectiveListener, removePageListener, removePerspectiveListener
getService, hasService
boolean close()
If the window has an open editor with unsaved content, the user will be given the opportunity to save it.
true
if the window was successfully closed, and
false
if it is still openIWorkbenchPage getActivePage()
getActivePage
in interface IPageService
null
if noneIWorkbenchPage[] getPages()
Note that each window has its own pages; pages are never shared between different windows.
IPartService getPartService()
ISelectionService getSelectionService()
Shell getShell()
getShell
in interface IShellProvider
null
if the shell has not been created yet or if the window has been closedIWorkbench getWorkbench()
boolean isApplicationMenu(String menuId)
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.
menuId
- the menu idtrue
if the specified menu is an application
menu, and false
if it is notIWorkbenchPage openPage(String perspectiveId, IAdaptable input) throws WorkbenchException
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.
perspectiveId
- the perspective id for the window's 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 page could not be openedIWorkbench.showPerspective(String, IWorkbenchWindow, IAdaptable)
IWorkbenchPage openPage(IAdaptable input) throws WorkbenchException
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.
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 page could not be openedIWorkbench.showPerspective(String, IWorkbenchWindow, IAdaptable)
void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
fork
.
It is recommended that fork
is set to
true in most cases. If fork
is set to false
,
the runnable will run in the UI thread and it is the runnable's
responsibility to call Display.readAndDispatch()
to ensure UI responsiveness.run
in interface IRunnableContext
fork
- true
if the runnable should be run in a separate thread,
and false
to run in the same threadcancelable
- true
to enable the cancelation, and
false
to make the operation uncancellablerunnable
- the runnable to runInvocationTargetException
- 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 is false
.void setActivePage(IWorkbenchPage page)
page
- the new active page, or null
for no active pageIExtensionTracker 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.
IWorkbench.getExtensionTracker()
,
IWorkbenchPage.getExtensionTracker()
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.