Class MultiPageEditorSite
- java.lang.Object
-
- org.eclipse.ui.part.MultiPageEditorSite
-
- All Implemented Interfaces:
IAdaptable
,IShellProvider
,IEditorSite
,org.eclipse.ui.internal.services.INestable
,IWorkbenchPartSite
,IWorkbenchSite
,IServiceLocator
public class MultiPageEditorSite extends Object implements IEditorSite, org.eclipse.ui.internal.services.INestable
Site for a nested editor within a multi-page editor. Selection is handled by forwarding the event to the multi-page editor's selection listeners; most other methods are forwarded to the multi-page editor's site.The base implementation of
MultiPageEditor.createSite
creates an instance of this class. This class may be instantiated or subclassed.
-
-
Constructor Summary
Constructors Constructor Description MultiPageEditorSite(MultiPageEditorPart multiPageEditor, IEditorPart editor)
Creates a site for the given editor nested within the given multi-page editor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
activate()
Notifies the multi page editor service that the component within which it exists has become active.void
deactivate()
Notifies the multi page editor service that the component within which it exists has been deactived.void
dispose()
Dispose the contributions.IEditorActionBarContributor
getActionBarContributor()
TheMultiPageEditorSite
implementation of thisIEditorSite
method returnsnull
, since nested editors do not have their own action bar contributor.IActionBars
getActionBars()
TheMultiPageEditorSite
implementation of thisIEditorSite
method forwards to the multi-page editor to return the action bars.<T> T
getAdapter(Class<T> adapter)
Returns an object which is an instance of the given class associated with this object.ILabelDecorator
getDecoratorManager()
Deprecated.use IWorkbench.getDecoratorManager()IEditorPart
getEditor()
Returns the nested editor.String
getId()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method returns an empty string since the nested editor is not created from the registry.IKeyBindingService
getKeyBindingService()
Returns the key binding service in use.MultiPageEditorPart
getMultiPageEditor()
Returns the multi-page editor.protected IWorkbenchPartSite
getNestedEditorSite()
IWorkbenchPage
getPage()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor to return the workbench page.IWorkbenchPart
getPart()
Returns the part associated with this siteString
getPluginId()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method returns an empty string since the nested editor is not created from the registry.String
getRegisteredName()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method returns an empty string since the nested editor is not created from the registry.ISelectionProvider
getSelectionProvider()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method returns the selection provider set bysetSelectionProvider
.<T> T
getService(Class<T> key)
Retrieves the service corresponding to the given API.Shell
getShell()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor to return the shell.IWorkbenchWindow
getWorkbenchWindow()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor to return the workbench window.protected void
handlePostSelectionChanged(SelectionChangedEvent event)
Handles a post selection changed even from the nexted editor.protected void
handleSelectionChanged(SelectionChangedEvent event)
Handles a selection changed event from the nested editor.boolean
hasService(Class key)
Whether this service exists within the scope of this service locator.void
registerContextMenu(String menuID, MenuManager menuMgr, ISelectionProvider selProvider)
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor for registration.void
registerContextMenu(String menuId, MenuManager menuManager, ISelectionProvider selectionProvider, boolean includeEditorInput)
Registers a pop-up menu with a particular id for extension.void
registerContextMenu(MenuManager menuManager, ISelectionProvider selProvider)
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor for registration.void
registerContextMenu(MenuManager menuManager, ISelectionProvider selectionProvider, boolean includeEditorInput)
Registers a pop-up menu with the default id for extension.void
setSelectionProvider(ISelectionProvider provider)
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method remembers the selection provider, and also hooks a listener on it, which callshandleSelectionChanged
when a selection changed event occurs.String
toString()
-
-
-
Constructor Detail
-
MultiPageEditorSite
public MultiPageEditorSite(MultiPageEditorPart multiPageEditor, IEditorPart editor)
Creates a site for the given editor nested within the given multi-page editor.- Parameters:
multiPageEditor
- the multi-page editoreditor
- the nested editor
-
-
Method Detail
-
activate
public final void activate()
Notifies the multi page editor service that the component within which it exists has become active.- Specified by:
activate
in interfaceorg.eclipse.ui.internal.services.INestable
- Since:
- 3.2
-
deactivate
public final void deactivate()
Notifies the multi page editor service that the component within which it exists has been deactived.- Specified by:
deactivate
in interfaceorg.eclipse.ui.internal.services.INestable
- Since:
- 3.2
-
dispose
public void dispose()
Dispose the contributions.
-
getActionBarContributor
public IEditorActionBarContributor getActionBarContributor()
TheMultiPageEditorSite
implementation of thisIEditorSite
method returnsnull
, since nested editors do not have their own action bar contributor.- Specified by:
getActionBarContributor
in interfaceIEditorSite
- Returns:
null
-
getActionBars
public IActionBars getActionBars()
TheMultiPageEditorSite
implementation of thisIEditorSite
method forwards to the multi-page editor to return the action bars.- Specified by:
getActionBars
in interfaceIEditorSite
- Returns:
- The action bars from the parent multi-page editor.
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
Description copied from interface:IAdaptable
Returns an object which is an instance of the given class associated with this object. Returnsnull
if no such object can be found.Clients may implement this method but should generally call
Adapters.adapt(Object, Class, boolean)
rather than invoking it directly.- 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
-
getDecoratorManager
@Deprecated public ILabelDecorator getDecoratorManager()
Deprecated.use IWorkbench.getDecoratorManager()TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor to return the decorator manager.- Returns:
- The decorator from the workbench window.
-
getEditor
public IEditorPart getEditor()
Returns the nested editor.- Returns:
- the nested editor
-
getId
public String getId()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method returns an empty string since the nested editor is not created from the registry.- Specified by:
getId
in interfaceIWorkbenchPartSite
- Returns:
- An empty string.
-
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 interfaceIWorkbenchPartSite
- Returns:
- the key binding service in use
- See Also:
IContextService
,IHandlerService
-
getMultiPageEditor
public MultiPageEditorPart getMultiPageEditor()
Returns the multi-page editor.- Returns:
- the multi-page editor
-
getPage
public IWorkbenchPage getPage()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor to return the workbench page.- Specified by:
getPage
in interfaceIWorkbenchSite
- Returns:
- The workbench page in which this editor site resides.
-
getPart
public IWorkbenchPart getPart()
Description copied from interface:IWorkbenchPartSite
Returns the part associated with this site- Specified by:
getPart
in interfaceIWorkbenchPartSite
- Returns:
- the part associated with this site
-
getPluginId
public String getPluginId()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method returns an empty string since the nested editor is not created from the registry.- Specified by:
getPluginId
in interfaceIWorkbenchPartSite
- Returns:
- An empty string.
-
getRegisteredName
public String getRegisteredName()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method returns an empty string since the nested editor is not created from the registry.- Specified by:
getRegisteredName
in interfaceIWorkbenchPartSite
- Returns:
- An empty string.
-
getSelectionProvider
public ISelectionProvider getSelectionProvider()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method returns the selection provider set bysetSelectionProvider
.- Specified by:
getSelectionProvider
in interfaceIWorkbenchSite
- Returns:
- The current selection provider.
-
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 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.
-
getShell
public Shell getShell()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor to return the shell.- Specified by:
getShell
in interfaceIShellProvider
- Specified by:
getShell
in interfaceIWorkbenchSite
- Returns:
- The shell in which this editor site resides.
-
getWorkbenchWindow
public IWorkbenchWindow getWorkbenchWindow()
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor to return the workbench window.- Specified by:
getWorkbenchWindow
in interfaceIWorkbenchSite
- Returns:
- The workbench window in which this editor site resides.
-
getNestedEditorSite
protected IWorkbenchPartSite getNestedEditorSite()
- Returns:
IWorkbenchPartSite
of the nested multi-page editor.- Since:
- 3.115
-
handlePostSelectionChanged
protected void handlePostSelectionChanged(SelectionChangedEvent event)
Handles a post selection changed even from the nexted editor.Subclasses may extend or reimplement this method
- Parameters:
event
- the event- Since:
- 3.2
-
handleSelectionChanged
protected void handleSelectionChanged(SelectionChangedEvent event)
Handles a selection changed event from the nested editor. The default implementation gets the selection provider from the multi-page editor's site, and callsfireSelectionChanged
on it (only if it is an instance ofMultiPageSelectionProvider
), passing a new event object.Subclasses may extend or reimplement this method.
- Parameters:
event
- the event
-
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 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.
-
registerContextMenu
public void registerContextMenu(MenuManager menuManager, ISelectionProvider selProvider)
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor for registration.- Specified by:
registerContextMenu
in interfaceIWorkbenchPartSite
- Parameters:
menuManager
- The menu managerselProvider
- The selection provider.
-
registerContextMenu
public final void registerContextMenu(MenuManager menuManager, ISelectionProvider selectionProvider, boolean includeEditorInput)
Description copied from interface:IEditorSite
Registers a pop-up menu with the default id for extension. The default id is defined as the part id.
By default, context menus include object contributions based on the editor input for the current editor. It is possible to override this behaviour by calling this method with
includeEditorInput
asfalse
. This might be desirable for editors that present a localized view of an editor input (e.g., a node in a model editor).For a detailed description of context menu registration see
IWorkbenchPartSite.registerContextMenu(MenuManager, ISelectionProvider)
- Specified by:
registerContextMenu
in interfaceIEditorSite
- Parameters:
menuManager
- the menu manager; must not benull
.selectionProvider
- the selection provider; must not benull
.includeEditorInput
- Whether the editor input should be included when adding object contributions to this context menu.- See Also:
IWorkbenchPartSite.registerContextMenu(MenuManager, ISelectionProvider)
-
registerContextMenu
public void registerContextMenu(String menuID, MenuManager menuMgr, ISelectionProvider selProvider)
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method forwards to the multi-page editor for registration.- Specified by:
registerContextMenu
in interfaceIWorkbenchPartSite
- Parameters:
menuID
- The identifier for the menu.menuMgr
- The menu managerselProvider
- The selection provider.
-
registerContextMenu
public final void registerContextMenu(String menuId, MenuManager menuManager, ISelectionProvider selectionProvider, boolean includeEditorInput)
Description copied from interface:IEditorSite
Registers a pop-up menu with a particular id for extension. This method should only be called if the target part has more than one context menu to register.
By default, context menus include object contributions based on the editor input for the current editor. It is possible to override this behaviour by calling this method with
includeEditorInput
asfalse
. This might be desirable for editors that present a localized view of an editor input (e.g., a node in a model editor).For a detailed description of context menu registration see
IWorkbenchPartSite.registerContextMenu(MenuManager, ISelectionProvider)
- Specified by:
registerContextMenu
in interfaceIEditorSite
- Parameters:
menuId
- the menu id; must not benull
.menuManager
- the menu manager; must not benull
.selectionProvider
- the selection provider; must not benull
.includeEditorInput
- Whether the editor input should be included when adding object contributions to this context menu.- See Also:
IWorkbenchPartSite.registerContextMenu(MenuManager, ISelectionProvider)
-
setSelectionProvider
public void setSelectionProvider(ISelectionProvider provider)
TheMultiPageEditorSite
implementation of thisIWorkbenchPartSite
method remembers the selection provider, and also hooks a listener on it, which callshandleSelectionChanged
when a selection changed event occurs.- Specified by:
setSelectionProvider
in interfaceIWorkbenchSite
- Parameters:
provider
- The selection provider.- See Also:
handleSelectionChanged(SelectionChangedEvent)
-
-