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
FieldsModifier and TypeFieldDescriptionprotected ArrayList<PopupMenuExtender> protected MPartprotected org.eclipse.ui.internal.services.ServiceLocator -
Constructor Summary
ConstructorsConstructorDescriptionPartSite(MPart model, IWorkbenchPart part, IWorkbenchPartReference ref, IConfigurationElement element) Build the part site. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivateActionBars(boolean forceVisibility) voiddeactivateActionBars(boolean forceHide) voiddispose()Dispose the contributions.Returns the action bars for the part.final <T> TgetAdapter(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 StringReturns 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> TgetService(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 booleanhasService(Class<?> key) Whether this service exists within the scope of this service locator.voidregisterContextMenu(String menuID, MenuManager menuMgr, ISelectionProvider selProvider) Register a popup menu for extension.static final voidregisterContextMenu(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.voidregisterContextMenu(MenuManager menuMgr, ISelectionProvider selProvider) Register a popup menu with the default id for extension.voidsetActionBars(SubActionBars bars) Sets the action bars for the part.voidsetPart(IWorkbenchPart newPart) Sets the part.voidsetSelectionProvider(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:
part- the partref- the part reference
-
-
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 theIWorkbenchPartSiteinterface 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:IWorkbenchPartSiteReturns the part registry extension id for this workbench site's part.The name comes from the
idattribute in the configuration element.- Specified by:
getIdin interfaceIWorkbenchPartSite- Returns:
- the registry extension id
-
getPluginId
Description copied from interface:IWorkbenchPartSiteReturns the unique identifier of the plug-in that defines this workbench site's part.- Specified by:
getPluginIdin interfaceIWorkbenchPartSite- Returns:
- the unique identifier of the declaring plug-in
-
getRegisteredName
Description copied from interface:IWorkbenchPartSiteReturns the registered name for this workbench site's part.The name comes from the
nameattribute in the configuration element.- Specified by:
getRegisteredNamein interfaceIWorkbenchPartSite- Returns:
- the part name
-
getPage
Returns the page containing this workbench site's part.- Specified by:
getPagein interfaceIWorkbenchSite- Returns:
- the page containing this part
-
getPart
Returns the part.- Specified by:
getPartin interfaceIWorkbenchPartSite- Returns:
- the part associated with this site
-
getPartReference
Returns the part reference. -
getSelectionProvider
Returns the selection provider for a part.- Specified by:
getSelectionProviderin interfaceIWorkbenchSite- Returns:
- the selection provider, or
nullif none
-
getShell
Returns the shell containing this part.- Specified by:
getShellin interfaceIShellProvider- Specified by:
getShellin interfaceIWorkbenchSite- Returns:
- the shell containing this part
-
getWorkbenchWindow
Returns the workbench window containing this part.- Specified by:
getWorkbenchWindowin interfaceIWorkbenchSite- Returns:
- the workbench window containing this part
-
registerContextMenu
Register a popup menu for extension.- Specified by:
registerContextMenuin 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:
registerContextMenuin 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:
setSelectionProviderin interfaceIWorkbenchSite- Parameters:
provider- the selection provider, ornullto clear it
-
getKeyBindingService
Description copied from interface:IWorkbenchPartSiteReturns 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:
getKeyBindingServicein interfaceIWorkbenchPartSite- Returns:
- the key binding service in use
- See Also:
-
getInitialScopeId
-
getAdapter
Get an adapter for this type.- Specified by:
getAdapterin interfaceIAdaptable- Type Parameters:
T- the class type- Parameters:
adapter- the adapter class to look up- Returns:
- a object of the given class, or
nullif 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:IServiceLocatorRetrieves the service corresponding to the given API.- Specified by:
getServicein interfaceIServiceLocator- Parameters:
key- This is the interface that the service implements. Must not benull.- Returns:
- The service, or
nullif no such service could be found.
-
hasService
Description copied from interface:IServiceLocatorWhether 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:
hasServicein interfaceIServiceLocator- Parameters:
key- This is the interface that the service implements. Must not benull.- Returns:
trueif the service locator can find a service for the given API;falseotherwise.
-
toString
Prints out the identifier, the plug-in identifier and the registered name. This is for debugging purposes only. -
getModel
-
getContext
-