Class PartSite

java.lang.Object
org.eclipse.ui.internal.PartSite
All Implemented Interfaces:
IAdaptable, IShellProvider, IWorkbenchPartSite, IWorkbenchSite, IServiceLocator
Direct Known Subclasses:
EditorSite, ViewSite

public abstract class PartSite extends Object implements IWorkbenchPartSite
PartSite is the general implementation for an IWorkbenchPartSite. A site maintains the context for a part, including the part, its pane, active contributions, selection provider, etc. Together, these components make up the complete behavior for a part as if it was implemented by one person. The PartSite lifecycle is as follows ..
  1. a site is constructed
  2. a part is constructed and stored in the part
  3. the site calls part.init()
  4. a pane is constructed and stored in the site
  5. the action bars for a part are constructed and stored in the site
  6. the pane is added to a presentation
  7. the SWT widgets for the pane and part are created
  8. the site is activated, causing the actions to become visible
  • Field Details

    • serviceLocator

      protected org.eclipse.ui.internal.services.ServiceLocator serviceLocator
    • model

      protected MPart model
  • Constructor Details

  • Method Details

    • registerContextMenu

      public static final void registerContextMenu(String menuId, MenuManager menuManager, ISelectionProvider selectionProvider, boolean includeEditorInput, IWorkbenchPart part, IEclipseContext context, Collection<PopupMenuExtender> menuExtenders)
      This is a helper method for the register context menu functionality. It is provided so that different implementations of the IWorkbenchPartSite interface don't have to worry about how context menus should work.
      Parameters:
      menuId - the menu id
      menuManager - the menu manager
      selectionProvider - the selection provider
      includeEditorInput - whether editor inputs should be included in the structured selection when calculating contributions
      part - the part for this site
      menuExtenders - the collection of menu extenders for this site
      See Also:
    • dispose

      public void dispose()
      Dispose the contributions.
    • getActionBars

      public IActionBars getActionBars()
      Returns the action bars for the part. If this part is a view then it has exclusive use of the action bars. If this part is an editor then the action bars are shared among this editor and other editors of the same type.
    • getId

      public String getId()
      Description copied from interface: IWorkbenchPartSite
      Returns the part registry extension id for this workbench site's part.

      The name comes from the id attribute in the configuration element.

      Specified by:
      getId in interface IWorkbenchPartSite
      Returns:
      the registry extension id
    • getPluginId

      public String getPluginId()
      Description copied from interface: IWorkbenchPartSite
      Returns the unique identifier of the plug-in that defines this workbench site's part.
      Specified by:
      getPluginId in interface IWorkbenchPartSite
      Returns:
      the unique identifier of the declaring plug-in
    • getRegisteredName

      public String getRegisteredName()
      Description copied from interface: IWorkbenchPartSite
      Returns the registered name for this workbench site's part.

      The name comes from the name attribute in the configuration element.

      Specified by:
      getRegisteredName in interface IWorkbenchPartSite
      Returns:
      the part name
    • getPage

      public IWorkbenchPage getPage()
      Returns the page containing this workbench site's part.
      Specified by:
      getPage in interface IWorkbenchSite
      Returns:
      the page containing this part
    • getPart

      public IWorkbenchPart getPart()
      Returns the part.
      Specified by:
      getPart in interface IWorkbenchPartSite
      Returns:
      the part associated with this site
    • getPartReference

      public IWorkbenchPartReference getPartReference()
      Returns the part reference.
    • getSelectionProvider

      public ISelectionProvider getSelectionProvider()
      Returns the selection provider for a part.
      Specified by:
      getSelectionProvider in interface IWorkbenchSite
      Returns:
      the selection provider, or null if none
    • getShell

      public Shell getShell()
      Returns the shell containing this part.
      Specified by:
      getShell in interface IShellProvider
      Specified by:
      getShell in interface IWorkbenchSite
      Returns:
      the shell containing this part
    • getWorkbenchWindow

      public IWorkbenchWindow getWorkbenchWindow()
      Returns the workbench window containing this part.
      Specified by:
      getWorkbenchWindow in interface IWorkbenchSite
      Returns:
      the workbench window containing this part
    • registerContextMenu

      public void registerContextMenu(String menuID, MenuManager menuMgr, ISelectionProvider selProvider)
      Register a popup menu for extension.
      Specified by:
      registerContextMenu in interface IWorkbenchPartSite
      Parameters:
      menuID - the menu id
      menuMgr - the menu manager
      selProvider - the selection provider
    • registerContextMenu

      public void registerContextMenu(MenuManager menuMgr, ISelectionProvider selProvider)
      Register a popup menu with the default id for extension.
      Specified by:
      registerContextMenu in interface IWorkbenchPartSite
      Parameters:
      menuMgr - the menu manager
      selProvider - the selection provider
    • getContextMenuIds

      public String[] getContextMenuIds()
      Get the registered popup menu identifiers
    • setActionBars

      public void setActionBars(SubActionBars bars)
      Sets the action bars for the part.
    • setPart

      public void setPart(IWorkbenchPart newPart)
      Sets the part.
    • setSelectionProvider

      public void setSelectionProvider(ISelectionProvider provider)
      Set the selection provider for a part.
      Specified by:
      setSelectionProvider in interface IWorkbenchSite
      Parameters:
      provider - the selection provider, or null to clear it
    • getKeyBindingService

      public IKeyBindingService getKeyBindingService()
      Description copied from interface: IWorkbenchPartSite
      Returns the key binding service in use.

      The part will access this service to register all of its actions, to set the active scope.

      Specified by:
      getKeyBindingService in interface IWorkbenchPartSite
      Returns:
      the key binding service in use
      See Also:
    • getInitialScopeId

      protected String getInitialScopeId()
    • getAdapter

      public final <T> T getAdapter(Class<T> adapter)
      Get an adapter for this type.
      Specified by:
      getAdapter in interface IAdaptable
      Type Parameters:
      T - the class type
      Parameters:
      adapter - 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
    • activateActionBars

      public void activateActionBars(boolean forceVisibility)
    • deactivateActionBars

      public void deactivateActionBars(boolean forceHide)
    • 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.
    • toString

      public String toString()
      Prints out the identifier, the plug-in identifier and the registered name. This is for debugging purposes only.
      Overrides:
      toString in class Object
      Since:
      3.2
    • getModel

      public MPart getModel()
    • getContext

      public IEclipseContext getContext()