Class WorkbenchWindow
- All Implemented Interfaces:
IRunnableContext
,IShellProvider
,IPageService
,IWorkbenchWindow
,IServiceLocator
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final int
Constant (bit mask) indicating which the New Wizard submenu is probably present somewhere in this window.static final int
Constant (bit mask) indicating which the Open Perspective submenu is probably present somewhere in this window.static final String
The 'elementId' of the spacer used to right-align it in the trimstatic final String
Coolbar visibility change property.static final String
Perspective bar visibility change property.static final String
The status line visibility change property. for internal use only.static final int
Constant (bit mask) indicating which the Show View submenu is probably present somewhere in this window.static final String
static final String
-
Constructor Summary
ConstructorDescriptionWorkbenchWindow
(IAdaptable input, IPerspectiveDescriptor pers) Creates and initializes a new workbench window. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given listener for page lifecycle events.void
Adds the given listener for a page's perspective lifecycle events.void
Add a generic property listener.void
addSubmenu
(int type) Remembers that this window contains the given submenu.boolean
close()
Closes this workbench window.boolean
close
(boolean remove) boolean
containsSubmenu
(int type) Checks to see if this window contains the given type of submenu.org.eclipse.ui.internal.dialogs.cpd.CustomizePerspectiveDialog
createCustomizePerspectiveDialog
(Perspective persp, IEclipseContext context) void
fillActionBars
(int flags) Fills the window's real action bars.void
fillActionBars
(org.eclipse.ui.internal.provisional.application.IActionBarConfigurer2 proxyBars, int flags) Fills the window's proxy action bars.void
firePerspectiveChanged
(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) Fires perspective changedvoid
firePerspectiveChanged
(IWorkbenchPage page, IPerspectiveDescriptor perspective, IWorkbenchPartReference partRef, String changeId) Fires perspective changed for an affected partReturns the action bars for this window.static String
Returns the currently active page for this workbench window.static String
getCommandId
(IConfigurationElement element) boolean
static String
getDefinitionId
(IConfigurationElement element) Return the extension tracker for the workbench.getICEFor
(MToolControl mtc) static String
getId
(IConfigurationElement element) protected Layout
Returns the layout for the shell.getModel()
getPages()
Returns a list of the pages in this workbench window.Returns the part service which tracks part activation within this workbench window.boolean
org.eclipse.ui.internal.progress.ProgressRegion
static boolean
getRetarget
(IConfigurationElement element) Returns the selection service which tracks selection within this workbench window.final <T> T
getService
(Class<T> key) Retrieves the service corresponding to the given API.getShell()
Returns this workbench window's shell.boolean
Returnstrue
when the window's shell is activated,false
when it's shell is deactivatedboolean
org.eclipse.jface.internal.provisional.action.IToolBarManager2
Returns the workbench for this window.final boolean
hasService
(Class<?> key) Whether this service exists within the scope of this service locator.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.boolean
Return true if the toolbar is visible.final void
Indicates the end of a large update within this window.final void
Indicates the start of a large update within this window.openPage
(String perspectiveId, IAdaptable input) Creates and opens a new workbench page.openPage
(IAdaptable input) Creates and opens a new workbench page.protected int
Return the style bits for the shortcut bar.void
Removes the given page listener.void
Removes the given page's perspective listener.void
Removes a generic property listener.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
Sets or clears the currently active page for this workbench window.void
setCoolBarVisible
(boolean visible) Cause the coolbar to be shown or hidden; note that the coolbar may still be visible depending on the visibility state of other elements.void
setPerspectiveBarVisible
(boolean visible) Cause the perspective bar to be shown or hidden; note that the perspective bar may still be visible depending on the visibility state of other elements.void
setStatusLineVisible
(boolean visible) void
setup()
void
showHeapStatus
(boolean show) protected boolean
void
Toggle the visibility of the coolbar/perspective bar.void
update the action bars.void
Update the visible action sets.
-
Field Details
-
PERSPECTIVE_SPACER_ID
The 'elementId' of the spacer used to right-align it in the trim- See Also:
-
STATUS_LINE_ID
- See Also:
-
TRIM_CONTRIBUTION_URI
- See Also:
-
ACTION_SET_CMD_PREFIX
- See Also:
-
PROP_COOLBAR_VISIBLE
Coolbar visibility change property.- Since:
- 3.3
- See Also:
-
PROP_PERSPECTIVEBAR_VISIBLE
Perspective bar visibility change property.- Since:
- 3.3
- See Also:
-
PROP_STATUS_LINE_VISIBLE
The status line visibility change property. for internal use only.- Since:
- 3.4
- See Also:
-
SHOW_VIEW_SUBMENU
public static final int SHOW_VIEW_SUBMENUConstant (bit mask) indicating which the Show View submenu is probably present somewhere in this window.- Since:
- 3.0
- See Also:
-
OPEN_PERSPECTIVE_SUBMENU
public static final int OPEN_PERSPECTIVE_SUBMENUConstant (bit mask) indicating which the Open Perspective submenu is probably present somewhere in this window.- Since:
- 3.0
- See Also:
-
NEW_WIZARD_SUBMENU
public static final int NEW_WIZARD_SUBMENUConstant (bit mask) indicating which the New Wizard submenu is probably present somewhere in this window.- Since:
- 3.0
- See Also:
-
-
Constructor Details
-
WorkbenchWindow
Creates and initializes a new workbench window.- Parameters:
input
- the input for this workbench windowpers
- the perspective to initialize this workbench window with
-
-
Method Details
-
setup
@PostConstruct public void setup() -
getTopTrim
-
getId
-
getCommandId
-
getActionSetCommandId
-
getDefinitionId
-
getRetarget
-
perspectiveBarStyle
protected int perspectiveBarStyle()Return the style bits for the shortcut bar.- Returns:
- int
-
addPropertyChangeListener
Add a generic property listener.- Parameters:
listener
- the listener to add- Since:
- 3.3
-
removePropertyChangeListener
Removes a generic property listener.- Parameters:
listener
- the listener to remove- Since:
- 3.3
-
addPageListener
Description copied from interface:IPageService
Adds the given listener for page lifecycle events. Has no effect if an identical listener is already registered.Note: listeners should be removed when no longer necessary. If not, they will be removed when the IServiceLocator used to acquire this service is disposed.
- Specified by:
addPageListener
in interfaceIPageService
- Parameters:
l
- a page listener- See Also:
-
addPerspectiveListener
Description copied from interface:IPageService
Adds the given listener for a page's perspective lifecycle events. Has no effect if an identical listener is already registered.Note: listeners should be removed when no longer necessary. If not, they will be removed when the IServiceLocator used to acquire this service is disposed.
- Specified by:
addPerspectiveListener
in interfaceIPageService
- Parameters:
l
- a perspective listener- See Also:
-
getShell
Description copied from interface:IWorkbenchWindow
Returns this workbench window's shell.- Specified by:
getShell
in interfaceIShellProvider
- Specified by:
getShell
in interfaceIWorkbenchWindow
- 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
-
close
public boolean close(boolean remove) -
close
public boolean close()Description copied from interface:IWorkbenchWindow
Closes this workbench window.If the window has an open editor with unsaved content, the user will be given the opportunity to save it.
- Specified by:
close
in interfaceIWorkbenchWindow
- Returns:
true
if the window was successfully closed, andfalse
if it is still open- See Also:
-
isClosing
public boolean isClosing()Description copied from interface:IWorkbenchWindow
Returns a boolean indicating whether the workbench window is in the process of closing.- Specified by:
isClosing
in interfaceIWorkbenchWindow
- Returns:
true
if the workbench window is in the process of closing,false
otherwise
-
firePerspectiveChanged
public void firePerspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) Fires perspective changed -
firePerspectiveChanged
public void firePerspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, IWorkbenchPartReference partRef, String changeId) Fires perspective changed for an affected part -
getActionBars
Returns the action bars for this window.- Returns:
- this window's action bars
-
getActivePage
Description copied from interface:IWorkbenchWindow
Returns the currently active page for this workbench window.- Specified by:
getActivePage
in interfaceIPageService
- Specified by:
getActivePage
in interfaceIWorkbenchWindow
- Returns:
- the active page, or
null
if none
-
getPages
Description copied from interface:IWorkbenchWindow
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.
- Specified by:
getPages
in interfaceIWorkbenchWindow
- Returns:
- a list of pages
-
getPartService
Description copied from interface:IWorkbenchWindow
Returns the part service which tracks part activation within this workbench window.- Specified by:
getPartService
in interfaceIWorkbenchWindow
- Returns:
- the part service
- See Also:
-
getLayout
Returns the layout for the shell.- Returns:
- the layout for the shell
-
getSelectionService
Description copied from interface:IWorkbenchWindow
Returns the selection service which tracks selection within this workbench window.- Specified by:
getSelectionService
in interfaceIWorkbenchWindow
- Returns:
- the selection service
- See Also:
-
getShellActivated
public boolean getShellActivated()Returnstrue
when the window's shell is activated,false
when it's shell is deactivated- Returns:
- boolean
true
when shell activated,false
when shell deactivated
-
getWorkbench
Description copied from interface:IWorkbenchWindow
Returns the workbench for this window.- Specified by:
getWorkbench
in interfaceIWorkbenchWindow
- Returns:
- the workbench
- See Also:
-
isApplicationMenu
Description copied from interface:IWorkbenchWindow
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.
- Specified by:
isApplicationMenu
in interfaceIWorkbenchWindow
- Parameters:
menuID
- the menu id- Returns:
true
if the specified menu is an application menu, andfalse
if it is not- See Also:
-
openPage
Description copied from interface:IWorkbenchWindow
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.- Specified by:
openPage
in interfaceIWorkbenchWindow
- 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
Description copied from interface:IWorkbenchWindow
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.- Specified by:
openPage
in interfaceIWorkbenchWindow
- 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:
-
removePageListener
Description copied from interface:IPageService
Removes the given page listener. Has no effect if an identical listener is not registered.- Specified by:
removePageListener
in interfaceIPageService
- Parameters:
l
- a page listener
-
removePerspectiveListener
Description copied from interface:IPageService
Removes the given page's perspective listener. Has no effect if an identical listener is not registered.- Specified by:
removePerspectiveListener
in interfaceIPageService
- Parameters:
l
- a perspective listener- See Also:
-
run
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException Description copied from interface:IWorkbenchWindow
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
- Specified by:
run
in interfaceIWorkbenchWindow
- 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
.
-
setActivePage
Description copied from interface:IWorkbenchWindow
Sets or clears the currently active page for this workbench window.- Specified by:
setActivePage
in interfaceIWorkbenchWindow
- Parameters:
in
- the new active page, ornull
for no active page
-
getMenuRestrictions
-
updateActionBars
public void updateActionBars()update the action bars. -
largeUpdateStart
public final void largeUpdateStart()Indicates the start of a large update within this window. 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
!- Since:
- 3.1
-
largeUpdateEnd
public final void largeUpdateEnd()Indicates the end of a large update within this window. 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
!- Since:
- 3.1
-
updateActionSets
public void updateActionSets()Update the visible action sets. This method is typically called from a page when the user changes the visible action sets within the prespective. -
showHeapStatus
public void showHeapStatus(boolean show) -
fillActionBars
public void fillActionBars(int flags) Fills the window's real action bars.- Parameters:
flags
- indicate which bars to fill
-
fillActionBars
public void fillActionBars(org.eclipse.ui.internal.provisional.application.IActionBarConfigurer2 proxyBars, int flags) Fills the window's proxy action bars.- Parameters:
proxyBars
- the proxy configurerflags
- indicate which bars to fill
-
setCoolBarVisible
public void setCoolBarVisible(boolean visible) Cause the coolbar to be shown or hidden; note that the coolbar may still be visible depending on the visibility state of other elements. This method is a lower-level method that affects the visibility but does not update any associated preference values.- Parameters:
visible
- whether the cool bar should be shown. This is only applicable if the window configurer also wishes either the cool bar to be visible.- Since:
- 3.0
-
getCoolBarVisible
public boolean getCoolBarVisible()- Returns:
- whether the cool bar should be shown. This is only applicable if the window configurer also wishes either the cool bar to be visible.
- Since:
- 3.0
-
getActionPresentation
-
setPerspectiveBarVisible
public void setPerspectiveBarVisible(boolean visible) Cause the perspective bar to be shown or hidden; note that the perspective bar may still be visible depending on the visibility state of other elements. This method is a lower-level method that affects the visibility but does not update any associated preference values.- Parameters:
visible
- whether the perspective bar should be shown. This is only applicable if the window configurer also wishes either the perspective bar to be visible.- Since:
- 3.0
-
getPerspectiveBarVisible
public boolean getPerspectiveBarVisible()- Returns:
- whether the perspective bar should be shown. This is only applicable if the window configurer also wishes either the perspective bar to be visible.
- Since:
- 3.0
-
setStatusLineVisible
public void setStatusLineVisible(boolean visible) - Parameters:
visible
- whether the perspective bar should be shown. This is only applicable if the window configurer also wishes either the perspective bar to be visible.- Since:
- 3.0
-
getStatusLineVisible
public boolean getStatusLineVisible()- Returns:
- whether the perspective bar should be shown. This is only applicable if the window configurer also wishes either the perspective bar to be visible.
- Since:
- 3.0
-
showTopSeperator
protected boolean showTopSeperator() -
getProgressRegion
public org.eclipse.ui.internal.progress.ProgressRegion getProgressRegion()- Returns:
- Returns the progressRegion.
-
getExtensionTracker
Description copied from interface:IWorkbenchWindow
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.
- Specified by:
getExtensionTracker
in interfaceIWorkbenchWindow
- Returns:
- the extension tracker
- See Also:
-
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.
-
toggleToolbarVisibility
public void toggleToolbarVisibility()Toggle the visibility of the coolbar/perspective bar. This method respects the window configurer and will only toggle visibility if the item in question was originally declared visible by the window advisor.- Since:
- 3.3
-
isToolbarVisible
public boolean isToolbarVisible()Return true if the toolbar is visible. Note that it may not be possible to make the toolbar visible (i.e., the window configurer).- Returns:
- true if the toolbar is visible
- Since:
- 4.2
-
getModel
-
getStatusLineManager
-
getCoolBarManager2
-
getCoolBarManager
-
getMenuManager
-
getMenuBarManager
-
getToolBarManager2
public org.eclipse.jface.internal.provisional.action.IToolBarManager2 getToolBarManager2() -
getToolBarManager
-
createCustomizePerspectiveDialog
public org.eclipse.ui.internal.dialogs.cpd.CustomizePerspectiveDialog createCustomizePerspectiveDialog(Perspective persp, IEclipseContext context)