Package org.eclipse.ui.internal
Class PartSite
java.lang.Object
org.eclipse.ui.internal.PartSite
- All Implemented Interfaces:
IAdaptable
,IShellProvider
,IWorkbenchPartSite
,IWorkbenchSite
,IServiceLocator
- Direct Known Subclasses:
EditorSite
,ViewSite
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 ..
- a site is constructed
- a part is constructed and stored in the part
- the site calls part.init()
- a pane is constructed and stored in the site
- the action bars for a part are constructed and stored in the site
- the pane is added to a presentation
- the SWT widgets for the pane and part are created
- the site is activated, causing the actions to become visible
-
Field Summary
Modifier and TypeFieldDescriptionprotected ArrayList<PopupMenuExtender>
protected MPart
protected org.eclipse.ui.internal.services.ServiceLocator
-
Constructor Summary
ConstructorDescriptionPartSite
(MPart model, IWorkbenchPart part, IWorkbenchPartReference ref, IConfigurationElement element) Build the part site. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activateActionBars
(boolean forceVisibility) void
deactivateActionBars
(boolean forceHide) void
dispose()
Dispose the contributions.Returns the action bars for the part.final <T> T
getAdapter
(Class<T> adapter) Get an adapter for this type.String[]
Get the registered popup menu identifiersgetId()
Returns the part registry extension id for this workbench site's part.protected String
Returns the key binding service in use.getModel()
getPage()
Returns the page containing this workbench site's part.getPart()
Returns the part.Returns the part reference.Returns the unique identifier of the plug-in that defines this workbench site's part.Returns the registered name for this workbench site's part.Returns the selection provider for a part.final <T> T
getService
(Class<T> key) Retrieves the service corresponding to the given API.getShell()
Returns the shell containing this part.Returns the workbench window containing this part.final boolean
hasService
(Class<?> key) Whether this service exists within the scope of this service locator.void
registerContextMenu
(String menuID, MenuManager menuMgr, ISelectionProvider selProvider) Register a popup menu for extension.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.void
registerContextMenu
(MenuManager menuMgr, ISelectionProvider selProvider) Register a popup menu with the default id for extension.void
setActionBars
(SubActionBars bars) Sets the action bars for the part.void
setPart
(IWorkbenchPart newPart) Sets the part.void
setSelectionProvider
(ISelectionProvider provider) Set the selection provider for a part.toString()
Prints out the identifier, the plug-in identifier and the registered name.
-
Field Details
-
serviceLocator
protected org.eclipse.ui.internal.services.ServiceLocator serviceLocator -
model
-
Constructor Details
-
PartSite
public PartSite(MPart model, IWorkbenchPart part, IWorkbenchPartReference ref, IConfigurationElement element) Build the part site.- Parameters:
ref
- the part referencepart
- the part
-
-
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 theIWorkbenchPartSite
interface don't have to worry about how context menus should work.- Parameters:
menuId
- the menu idmenuManager
- the menu managerselectionProvider
- the selection providerincludeEditorInput
- whether editor inputs should be included in the structured selection when calculating contributionspart
- the part for this sitemenuExtenders
- the collection of menu extenders for this site- See Also:
-
dispose
public void dispose()Dispose the contributions. -
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
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 interfaceIWorkbenchPartSite
- Returns:
- the registry extension id
-
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 interfaceIWorkbenchPartSite
- Returns:
- the unique identifier of the declaring plug-in
-
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 interfaceIWorkbenchPartSite
- Returns:
- the part name
-
getPage
Returns the page containing this workbench site's part.- Specified by:
getPage
in interfaceIWorkbenchSite
- Returns:
- the page containing this part
-
getPart
Returns the part.- Specified by:
getPart
in interfaceIWorkbenchPartSite
- Returns:
- the part associated with this site
-
getPartReference
Returns the part reference. -
getSelectionProvider
Returns the selection provider for a part.- Specified by:
getSelectionProvider
in interfaceIWorkbenchSite
- Returns:
- the selection provider, or
null
if none
-
getShell
Returns the shell containing this part.- Specified by:
getShell
in interfaceIShellProvider
- Specified by:
getShell
in interfaceIWorkbenchSite
- Returns:
- the shell containing this part
-
getWorkbenchWindow
Returns the workbench window containing this part.- Specified by:
getWorkbenchWindow
in interfaceIWorkbenchSite
- Returns:
- the workbench window containing this part
-
registerContextMenu
Register a popup menu for extension.- Specified by:
registerContextMenu
in interfaceIWorkbenchPartSite
- Parameters:
menuID
- the menu idmenuMgr
- the menu managerselProvider
- the selection provider
-
registerContextMenu
Register a popup menu with the default id for extension.- Specified by:
registerContextMenu
in interfaceIWorkbenchPartSite
- Parameters:
menuMgr
- the menu managerselProvider
- the selection provider
-
getContextMenuIds
Get the registered popup menu identifiers -
setActionBars
Sets the action bars for the part. -
setPart
Sets the part. -
setSelectionProvider
Set the selection provider for a part.- Specified by:
setSelectionProvider
in interfaceIWorkbenchSite
- Parameters:
provider
- the selection provider, ornull
to clear it
-
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 interfaceIWorkbenchPartSite
- Returns:
- the key binding service in use
- See Also:
-
getInitialScopeId
-
getAdapter
Get an adapter for this type.- Specified by:
getAdapter
in interfaceIAdaptable
- 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
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.
-
toString
Prints out the identifier, the plug-in identifier and the registered name. This is for debugging purposes only. -
getModel
-
getContext
-