Class WorkbenchWindow

java.lang.Object
org.eclipse.ui.internal.WorkbenchWindow
All Implemented Interfaces:
IRunnableContext, IShellProvider, IPageService, IWorkbenchWindow, IServiceLocator

public class WorkbenchWindow extends Object implements IWorkbenchWindow
A window within the workbench.
  • Field Details

    • PERSPECTIVE_SPACER_ID

      public static final String PERSPECTIVE_SPACER_ID
      The 'elementId' of the spacer used to right-align it in the trim
      See Also:
    • STATUS_LINE_ID

      public static final String STATUS_LINE_ID
      See Also:
    • TRIM_CONTRIBUTION_URI

      public static final String TRIM_CONTRIBUTION_URI
      See Also:
    • ACTION_SET_CMD_PREFIX

      public static final String ACTION_SET_CMD_PREFIX
      See Also:
    • PROP_COOLBAR_VISIBLE

      public static final String PROP_COOLBAR_VISIBLE
      Coolbar visibility change property.
      Since:
      3.3
      See Also:
    • PROP_PERSPECTIVEBAR_VISIBLE

      public static final String PROP_PERSPECTIVEBAR_VISIBLE
      Perspective bar visibility change property.
      Since:
      3.3
      See Also:
    • PROP_STATUS_LINE_VISIBLE

      public static final String 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_SUBMENU
      Constant (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_SUBMENU
      Constant (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_SUBMENU
      Constant (bit mask) indicating which the New Wizard submenu is probably present somewhere in this window.
      Since:
      3.0
      See Also:
  • Constructor Details

    • WorkbenchWindow

      public WorkbenchWindow(IAdaptable input, IPerspectiveDescriptor pers)
      Creates and initializes a new workbench window.
      Parameters:
      input - the input for this workbench window
      pers - the perspective to initialize this workbench window with
  • Method Details

    • getICEFor

      public IConfigurationElement getICEFor(MToolControl mtc)
    • addSubmenu

      public void addSubmenu(int type)
      Remembers that this window contains the given submenu.
      Parameters:
      type - the type of submenu, one of: NEW_WIZARD_SUBMENU, OPEN_PERSPECTIVE_SUBMENU, SHOW_VIEW_SUBMENU
      Since:
      3.0
      See Also:
    • containsSubmenu

      public boolean containsSubmenu(int type)
      Checks to see if this window contains the given type of submenu.
      Parameters:
      type - the type of submenu, one of: NEW_WIZARD_SUBMENU, OPEN_PERSPECTIVE_SUBMENU, SHOW_VIEW_SUBMENU
      Returns:
      true if window contains submenu, false otherwise
      Since:
      3.0
      See Also:
    • setup

      @PostConstruct public void setup()
    • getTopTrim

      public MTrimBar getTopTrim()
    • getId

      public static String getId(IConfigurationElement element)
    • getCommandId

      public static String getCommandId(IConfigurationElement element)
    • getActionSetCommandId

      public static String getActionSetCommandId(IConfigurationElement element)
    • getDefinitionId

      public static String getDefinitionId(IConfigurationElement element)
    • getRetarget

      public static boolean getRetarget(IConfigurationElement element)
    • perspectiveBarStyle

      protected int perspectiveBarStyle()
      Return the style bits for the shortcut bar.
      Returns:
      int
    • addPropertyChangeListener

      public void addPropertyChangeListener(IPropertyChangeListener listener)
      Add a generic property listener.
      Parameters:
      listener - the listener to add
      Since:
      3.3
    • removePropertyChangeListener

      public void removePropertyChangeListener(IPropertyChangeListener listener)
      Removes a generic property listener.
      Parameters:
      listener - the listener to remove
      Since:
      3.3
    • addPageListener

      public void addPageListener(IPageListener l)
      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 interface IPageService
      Parameters:
      l - a page listener
      See Also:
    • addPerspectiveListener

      public void addPerspectiveListener(IPerspectiveListener l)
      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 interface IPageService
      Parameters:
      l - a perspective listener
      See Also:
    • getShell

      public Shell getShell()
      Description copied from interface: IWorkbenchWindow
      Returns this workbench window's shell.
      Specified by:
      getShell in interface IShellProvider
      Specified by:
      getShell in interface IWorkbenchWindow
      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 interface IWorkbenchWindow
      Returns:
      true if the window was successfully closed, and false 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 interface IWorkbenchWindow
      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

      public WWinActionBars getActionBars()
      Returns the action bars for this window.
      Returns:
      this window's action bars
    • getActivePage

      public IWorkbenchPage getActivePage()
      Description copied from interface: IWorkbenchWindow
      Returns the currently active page for this workbench window.
      Specified by:
      getActivePage in interface IPageService
      Specified by:
      getActivePage in interface IWorkbenchWindow
      Returns:
      the active page, or null if none
    • getPages

      public IWorkbenchPage[] 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 interface IWorkbenchWindow
      Returns:
      a list of pages
    • getPartService

      public IPartService getPartService()
      Description copied from interface: IWorkbenchWindow
      Returns the part service which tracks part activation within this workbench window.
      Specified by:
      getPartService in interface IWorkbenchWindow
      Returns:
      the part service
      See Also:
    • getLayout

      protected Layout getLayout()
      Returns the layout for the shell.
      Returns:
      the layout for the shell
    • getSelectionService

      public ISelectionService getSelectionService()
      Description copied from interface: IWorkbenchWindow
      Returns the selection service which tracks selection within this workbench window.
      Specified by:
      getSelectionService in interface IWorkbenchWindow
      Returns:
      the selection service
      See Also:
    • getShellActivated

      public boolean getShellActivated()
      Returns true 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

      public IWorkbench getWorkbench()
      Description copied from interface: IWorkbenchWindow
      Returns the workbench for this window.
      Specified by:
      getWorkbench in interface IWorkbenchWindow
      Returns:
      the workbench
      See Also:
    • isApplicationMenu

      public boolean isApplicationMenu(String menuID)
      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 interface IWorkbenchWindow
      Parameters:
      menuID - the menu id
      Returns:
      true if the specified menu is an application menu, and false if it is not
      See Also:
    • openPage

      public IWorkbenchPage openPage(String perspectiveId, IAdaptable input) throws WorkbenchException
      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 interface IWorkbenchWindow
      Parameters:
      perspectiveId - the perspective id for the window's initial page
      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.
      Returns:
      the new workbench page
      Throws:
      WorkbenchException - if a page could not be opened
      See Also:
    • openPage

      public IWorkbenchPage openPage(IAdaptable input) throws WorkbenchException
      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 interface IWorkbenchWindow
      Parameters:
      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.
      Returns:
      the new workbench window
      Throws:
      WorkbenchException - if a page could not be opened
      See Also:
    • removePageListener

      public void removePageListener(IPageListener l)
      Description copied from interface: IPageService
      Removes the given page listener. Has no effect if an identical listener is not registered.
      Specified by:
      removePageListener in interface IPageService
      Parameters:
      l - a page listener
    • removePerspectiveListener

      public void removePerspectiveListener(IPerspectiveListener l)
      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 interface IPageService
      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 of 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.
      Specified by:
      run in interface IRunnableContext
      Specified by:
      run in interface IWorkbenchWindow
      Parameters:
      fork - true if the runnable should be run in a separate thread, and false to run in the same thread
      cancelable - true to enable the cancelation, and false to make the operation uncancellable
      runnable - the runnable to run
      Throws:
      InvocationTargetException - wraps any exception or error which occurs while running the runnable
      InterruptedException - propagated by the context if the runnable acknowledges cancelation by throwing this exception. This should not be thrown if cancelable is false.
    • setActivePage

      public void setActivePage(IWorkbenchPage in)
      Description copied from interface: IWorkbenchWindow
      Sets or clears the currently active page for this workbench window.
      Specified by:
      setActivePage in interface IWorkbenchWindow
      Parameters:
      in - the new active page, or null for no active page
    • getMenuRestrictions

      public Set<Object> 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 configurer
      flags - 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

      public ActionPresentation 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

      public IExtensionTracker 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 interface IWorkbenchWindow
      Returns:
      the extension tracker
      See Also:
    • getService

      public final <T> T getService(Class<T> key)
      Description copied from interface: IServiceLocator
      Retrieves the service corresponding to the given API.
      Specified by:
      getService in interface IServiceLocator
      Parameters:
      key - This is the interface that the service implements. Must not be null.
      Returns:
      The service, or null if no such service could be found.
    • hasService

      public final boolean hasService(Class<?> key)
      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 interface IServiceLocator
      Parameters:
      key - This is the interface that the service implements. Must not be null.
      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

      public MWindow getModel()
    • getStatusLineManager

      public StatusLineManager getStatusLineManager()
    • getCoolBarManager2

      public ICoolBarManager getCoolBarManager2()
    • getCoolBarManager

      public CoolBarManager getCoolBarManager()
    • getMenuManager

      public MenuManager getMenuManager()
    • getMenuBarManager

      public IMenuManager getMenuBarManager()
    • getToolBarManager2

      public org.eclipse.jface.internal.provisional.action.IToolBarManager2 getToolBarManager2()
    • getToolBarManager

      public IToolBarManager getToolBarManager()
    • createCustomizePerspectiveDialog

      public org.eclipse.ui.internal.dialogs.cpd.CustomizePerspectiveDialog createCustomizePerspectiveDialog(Perspective persp, IEclipseContext context)