Class NavigatorActionService
- java.lang.Object
-
- org.eclipse.ui.actions.ActionGroup
-
- org.eclipse.ui.navigator.NavigatorActionService
-
- All Implemented Interfaces:
IMementoAware
public final class NavigatorActionService extends ActionGroup implements IMementoAware
Provides context menu items and
IActionBars
contributions for a particular abstract viewer. The interface matches that ofActionGroup
and may be used in the same manner. Clients must callprepareMenuForPlatformContributions(MenuManager, ISelectionProvider, boolean)
when using this class to allow object or viewer contributions. The org.eclipse.ui.navigator.viewer/viewer/popupMenu element may override whether platform contributions are allowed to the menu with its allowsPlatformContributions attribute. "Platform Contributions" are menu items that are added through the org.eclipse.ui.popupMenus extension point.A
CommonActionProvider
has opportunities to contribute to the context menu andIActionBars
whenever the selection in the viewer changes. Action Providers are selected based on the enablement expressions of their associated content extension or their own enablement expression if it is declared as a top-level <actionProvider /> element (of the org.eclipse.ui.navigator.navigatorContent extension point). See the schema documentation of org.eclipse.ui.navigator.navigatorContent for more information on how to specify an Action Provider.Clients that reuse this service outside of an instance of
CommonNavigator
must be sure that {fillActionBars(IActionBars)
is called whenever the selection changes. The retargetable actions for each selection could change, based on who contributed the items.- Since:
- 3.2
-
-
Constructor Summary
Constructors Constructor Description NavigatorActionService(ICommonViewerSite aCommonViewerSite, StructuredViewer aStructuredViewer, INavigatorContentService aContentService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Dispose of any state or resources held by the service.void
fillActionBars(IActionBars theActionBars)
Request that the service invoke extensions to fill the given IActionBars with retargetable actions or view menu contributions from Action Providers that are interested in the given selection.void
fillContextMenu(IMenuManager aMenu)
Requests that the service invoke extensions to fill the given menu with Action Providers that are interested in elements from the given selection.CommonActionProvider
getActionProviderInstance(org.eclipse.ui.internal.navigator.actions.CommonActionProviderDescriptor aProviderDescriptor)
void
prepareMenuForPlatformContributions(MenuManager menu, ISelectionProvider aSelectionProvider, boolean force)
Prepares the menu for object contributions, if the option is set in the extension.void
restoreState(IMemento aMemento)
Use the given memento to restore the state of each Action Provider as it is initialized.void
saveState(IMemento aMemento)
Request that Action Providers save any state that they find interesting.-
Methods inherited from class org.eclipse.ui.actions.ActionGroup
getContext, setContext, updateActionBars
-
-
-
-
Constructor Detail
-
NavigatorActionService
public NavigatorActionService(ICommonViewerSite aCommonViewerSite, StructuredViewer aStructuredViewer, INavigatorContentService aContentService)
- Parameters:
aCommonViewerSite
- A site that provides information about the context for extensions.aStructuredViewer
- The associated StructuredViewer. Used to initialize extensions. May NOT be null.aContentService
- The associated INavigatorContentService (for extensions that coordinate behavior with content extensions -- either nested or top-level action providers). May NOT be null.
-
-
Method Detail
-
prepareMenuForPlatformContributions
public void prepareMenuForPlatformContributions(MenuManager menu, ISelectionProvider aSelectionProvider, boolean force)
Prepares the menu for object contributions, if the option is set in the extension. The option is controlled by the<popupMenu />
element's 'allowPlatformContributions' attribute. Clients may choose to ignore this setting by supplying a value of true for theforce
attribute.- Parameters:
menu
- The context menu of the IViewPartaSelectionProvider
- The selection provider that will supplement actions with a valid, current selection.force
- A value of 'true' forces the menu to be registered for object/view contributions. Otherwise, the option from the extension point will be respected. See org.eclipse.ui.navigator.viewer/viewer for more information.
-
fillContextMenu
public void fillContextMenu(IMenuManager aMenu)
Requests that the service invoke extensions to fill the given menu with Action Providers that are interested in elements from the given selection.Object contributions (see org.eclipes.ui.popupMenus) may also respected by this method if
toRespectObjectContributions
is true.- Overrides:
fillContextMenu
in classActionGroup
- Parameters:
aMenu
- The menu being presented to the user.- See Also:
ActionGroup.fillContextMenu(IMenuManager)
-
fillActionBars
public void fillActionBars(IActionBars theActionBars)
Request that the service invoke extensions to fill the given IActionBars with retargetable actions or view menu contributions from Action Providers that are interested in the given selection.- Overrides:
fillActionBars
in classActionGroup
- Parameters:
theActionBars
- The action bars in use by the current view site.- See Also:
ActionGroup.fillActionBars(IActionBars)
-
dispose
public void dispose()
Dispose of any state or resources held by the service.- Overrides:
dispose
in classActionGroup
- See Also:
ActionGroup.dispose()
-
restoreState
public void restoreState(IMemento aMemento)
Use the given memento to restore the state of each Action Provider as it is initialized.- Specified by:
restoreState
in interfaceIMementoAware
- Parameters:
aMemento
- The memento retrieved from the dialog settings
-
saveState
public void saveState(IMemento aMemento)
Request that Action Providers save any state that they find interesting.- Specified by:
saveState
in interfaceIMementoAware
- Parameters:
aMemento
- The memento retrieved from the dialog settings
-
getActionProviderInstance
public CommonActionProvider getActionProviderInstance(org.eclipse.ui.internal.navigator.actions.CommonActionProviderDescriptor aProviderDescriptor)
- Parameters:
aProviderDescriptor
- descriptor of action provider to get- Returns:
- a CommonActionProvider
- Restriction:
- This method is not intended to be referenced by clients.
-
-