org.eclipse.gmf.runtime.common.ui.services.action.contributionitem
Class AbstractContributionItemProvider
java.lang.Object
org.eclipse.gmf.runtime.common.core.service.AbstractProvider
org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider
-
All Implemented Interfaces:
-
IProvider, org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionDescriptorReader, org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionItemProvider
-
Direct Known Subclasses:
-
DiagramContributionItemProvider
-
public abstract class AbstractContributionItemProvider
- extends
AbstractProvider
- implements org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionItemProvider, org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionDescriptorReader
An abstract implementation of the IContributionItemProvider interface
This provider performs the contribution by reading its XML contribution
descriptor and parsing it in the correct format.
Contribution item providers wishing "not" to read an XML-based descriptor
but rather performs the contribution totally programatically should not
subclass this class but rather implement the IContributionItemProvider
interface directly.
Method Summary
|
void
|
contributeToActionBars
(
IActionBars actionBars,
IWorkbenchPartDescriptor partDescriptor)
Contributes to the given action bars that belong to a part
described with the given part descriptor. |
void
|
contributeToPopupMenu
(
IMenuManager popupMenu,
IWorkbenchPart workbenchPart)
Contributes to the given popup menu of the given part
The popup menu id has to match the id used to register this
menu with the part's site. |
protected
IAction
|
createAction
(java.lang.String actionId,
IWorkbenchPartDescriptor partDescriptor)
Creates the action with the given id. |
protected
ActionGroup
|
createActionGroup
(java.lang.String actionGroupId,
IWorkbenchPartDescriptor partDescriptor)
Creates the action group for the given id. |
protected
IContributionItem
|
createCustomContributionItem
(java.lang.String customId,
IWorkbenchPartDescriptor partDescriptor)
Creates the custom contribution with the given id. |
protected
IMenuManager
|
createMenuManager
(java.lang.String menuId,
IWorkbenchPartDescriptor partDescriptor)
Creates the menu manager with the given id. |
void
|
disposeContributions
(IWorkbenchPartDescriptor partDescriptor)
Gives the provider a chance to clean up and dispose any cached contributions
previously targeted at a part described by the given descriptor. |
protected
IAction
|
getAction
(java.lang.String actionId,
IWorkbenchPartDescriptor partDescriptor)
Returns the action with the given id that is created for the given part id. |
protected
IAction
|
getAction
(java.lang.String actionId,
IWorkbenchPartDescriptor partDescriptor,
IPartSelector partSelector)
Returns the action with the given id that is created for the given part
id. |
protected
IAction
|
getActionFromRegistry
(java.lang.String actionId,
IWorkbenchPartDescriptor partDescriptor,
ActionRegistry registry)
This method put in order to override the action registry caching. |
protected
ActionGroup
|
getActionGroup
(java.lang.String actionGroupId,
IWorkbenchPartDescriptor partDescriptor)
Returns the ActionGroup with the given id that is created for the given part id
An ActionGroup is created once and cached for each unique part's id |
protected java.lang.Object
|
getSelectedObject
(IWorkbenchPartDescriptor partDescriptor)
Gets the first object in the selection in the workbench part described by
partDescriptor . |
protected
IStructuredSelection
|
getStructuredSelection
(IWorkbenchPartDescriptor partDescriptor)
Gets the structured selection from the workbench part described by
partDescriptor . |
boolean
|
provides
(
IOperation operation)
Indicates whether this provider provides the specified operation. |
void
|
setContributionDescriptor
(org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.ProviderContributionDescriptor descriptor)
Sets the contribution descriptor of the provider. |
void
|
updateActionBars
(
IActionBars actionBars,
IWorkbenchPartDescriptor partDescriptor)
Contributes to the given action bars that belong to a part described with
the given part descriptor ONLY IF this provider has not already
contributed to this part. |
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
|
AbstractContributionItemProvider
public AbstractContributionItemProvider()
getStructuredSelection
protected
IStructuredSelection getStructuredSelection(IWorkbenchPartDescriptor partDescriptor)
- Gets the structured selection from the workbench part described by
partDescriptor
.
-
-
-
Parameters:
-
partDescriptor
- the part descriptor
-
Returns:
- the structured selection
getSelectedObject
protected java.lang.Object getSelectedObject(IWorkbenchPartDescriptor partDescriptor)
- Gets the first object in the selection in the workbench part described by
partDescriptor
.
-
-
-
Parameters:
-
partDescriptor
- the part descriptor
-
Returns:
- the first object in the selection
setContributionDescriptor
public final void setContributionDescriptor(org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.ProviderContributionDescriptor descriptor)
-
Description copied from interface:
org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionDescriptorReader
- Sets the contribution descriptor of the provider.
-
-
Specified by:
-
setContributionDescriptor
in interface org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionDescriptorReader
-
-
Parameters:
-
descriptor
- the contribution descriptor of the provider
contributeToActionBars
public final void contributeToActionBars(
IActionBars actionBars,
IWorkbenchPartDescriptor partDescriptor)
-
Description copied from interface:
org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionItemProvider
- Contributes to the given action bars that belong to a part
described with the given part descriptor.
This API is usually called from the init()
method
of a EditorActionBarContributor
class for editors
and from init()
method of IViewPart
implementation for views.
-
-
Specified by:
-
contributeToActionBars
in interface org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionItemProvider
-
-
Parameters:
-
actionBars
- The target action bars -
partDescriptor
- The context workbench part descriptor
updateActionBars
public final void updateActionBars(
IActionBars actionBars,
IWorkbenchPartDescriptor partDescriptor)
-
Description copied from interface:
org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionItemProvider
- Contributes to the given action bars that belong to a part described with
the given part descriptor ONLY IF this provider has not already
contributed to this part.
This API is usually called when an event takes place such that new
providers may now provide contributions to the actionbars. Only those new
providers need to add their contributions.
-
-
Specified by:
-
updateActionBars
in interface org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionItemProvider
-
-
Parameters:
-
actionBars
- The target action bars -
partDescriptor
- The context workbench part descriptor
contributeToPopupMenu
public final void contributeToPopupMenu(
IMenuManager popupMenu,
IWorkbenchPart workbenchPart)
-
Description copied from interface:
org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionItemProvider
- Contributes to the given popup menu of the given part
The popup menu id has to match the id used to register this
menu with the part's site. Since the current selection could be
a context to this API, a selection could be retrieved from the
part's site's selection provider.
This API is usually called from menuAboutToShow()
method
of the main IMenuListener
to a given context menu.
-
-
Specified by:
-
contributeToPopupMenu
in interface org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionItemProvider
-
-
Parameters:
-
popupMenu
- The target popup menu manager -
workbenchPart
- The context workbench part
disposeContributions
public final void disposeContributions(IWorkbenchPartDescriptor partDescriptor)
-
Description copied from interface:
org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionItemProvider
- Gives the provider a chance to clean up and dispose any cached contributions
previously targeted at a part described by the given descriptor.
This API is usually called when the part contributor is disposing. This
would be form the dispose
method of the
EditorActioBarContributor
for editors and the dispose
method of IViewPart
for views.
-
-
Specified by:
-
disposeContributions
in interface org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.IContributionItemProvider
-
-
Parameters:
-
partDescriptor
- The context workbench part descriptor
provides
public final boolean provides(
IOperation operation)
-
Description copied from interface:
IProvider
- Indicates whether this provider provides the specified operation.
Providers generally cast the operation to a service specific
IOperation
-derived class in order to determine whether they
support the request.
-
-
Specified by:
-
provides
in interface
IProvider
-
-
Parameters:
-
operation
- The operation in question.
-
Returns:
-
true
if this provider provides the operation;
false
otherwise.
getAction
protected final
IAction getAction(java.lang.String actionId,
IWorkbenchPartDescriptor partDescriptor)
- Returns the action with the given id that is created for the given part id.
An action is created once and cached for each unique part's id.
-
-
-
Parameters:
-
actionId
- The request action id -
partDescriptor
- The workbench part descriptor
-
Returns:
- The action with the given id
getAction
protected final
IAction getAction(java.lang.String actionId,
IWorkbenchPartDescriptor partDescriptor,
IPartSelector partSelector)
- Returns the action with the given id that is created for the given part
id. An action is created once and cached for each unique part's id.
The part selector is used is when the new action is an
AbstractActionHandler
to determine whether or not the
action is applicable to a given selected part. If the part is not
applicable, the action will not be refreshed when selection changes in
the part.
-
-
-
Parameters:
-
actionId
- The request action id -
partDescriptor
- The workbench part descriptor -
partSelector
- The part selector
-
Returns:
- The action with the given id
getActionGroup
protected final
ActionGroup getActionGroup(java.lang.String actionGroupId,
IWorkbenchPartDescriptor partDescriptor)
- Returns the ActionGroup with the given id that is created for the given part id
An ActionGroup is created once and cached for each unique part's id
-
-
-
Parameters:
-
actionGroupId
- The request action group id -
partDescriptor
- The workbench part descriptor
-
Returns:
- The ActionGroup with the given id
getActionFromRegistry
protected
IAction getActionFromRegistry(java.lang.String actionId,
IWorkbenchPartDescriptor partDescriptor,
ActionRegistry registry)
- This method put in order to override the action registry caching. Used to
get around unimplemented features of contribution item service.
-
-
-
Parameters:
-
actionId
- the action id -
partDescriptor
- the part descriptor -
registry
- the action registry
-
Returns:
- the action with
actionId
retrieved from the action
registry
.
createAction
protected
IAction createAction(java.lang.String actionId,
IWorkbenchPartDescriptor partDescriptor)
- Creates the action with the given id. By default, this method does
nothing. Subclasses must override to provide their own implementation of
action creation.
-
-
-
Parameters:
-
actionId
- The action id -
partDescriptor
- The workbench part descriptor
-
Returns:
- The action with the given id
createActionGroup
protected
ActionGroup createActionGroup(java.lang.String actionGroupId,
IWorkbenchPartDescriptor partDescriptor)
- Creates the action group for the given id. By default, this method does
nothing. Subclasses must override to provide their own implementation of
action group creation.
-
-
-
Parameters:
-
actionGroupId
- The action group id -
partDescriptor
- The workbench part descriptor
-
Returns:
- Action Group for the given id
createMenuManager
protected
IMenuManager createMenuManager(java.lang.String menuId,
IWorkbenchPartDescriptor partDescriptor)
- Creates the menu manager with the given id. By default, this method does
nothing. Subclasses must override to provide their own implementation of
menu manager creation.
-
-
-
Parameters:
-
menuId
- The menu manager id -
partDescriptor
- The workbench part descriptor
-
Returns:
- The menu manager with the given id
createCustomContributionItem
protected
IContributionItem createCustomContributionItem(java.lang.String customId,
IWorkbenchPartDescriptor partDescriptor)
- Creates the custom contribution with the given id. By default, this
method does nothing. Subclasses must override to provide their own
implementation of custom contribution creation.
-
-
-
Parameters:
-
customId
- The custom contribution id -
partDescriptor
- The workbench part descriptor
-
Returns:
- The custom contribution with the given id
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.