Remove a contribution action in the contextual menu [message #890496] |
Fri, 22 June 2012 12:29 |
|
Hello!
I want to know if there exists any way to remove or replace a contribution action from the contextual menu in the GMF Diagrams.
For instance, I want to replace the "File/Save As Image File..." action with another one customized by me.
How can I do it?
Thanks a lot!
Marc
|
|
|
|
|
Re: Remove a contribution action in the contextual menu [message #891772 is a reply to message #891581] |
Mon, 25 June 2012 20:34 |
|
Yes of course.
First you need to know the ID of the GMF action you want to remove or to replace. In my case I want to replace the "CopyToImageAction" that allows to export the diagram (or selected EditParts) to a Image. You can find them looking throught the GMF plugins. In this page I found some of GMF actions (http://blog.lgylym.info/2010/05/add-new-entry-to-existing-context-menu.html)
Then you need to contribute an extension point into the desired plugin, something like the following code:
<extension
id="MOSKittExportToFile"
point="org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders">
<contributionItemProvider
class="es.cv.gvcase.mdt.common.actions.MOSKittCopyToImageItemProvider">
<Priority
name="Medium">
</Priority>
<popupContribution
class="org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider">
<popupStructuredContributionCriteria
objectClass="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart">
</popupStructuredContributionCriteria>
<popupAction
id="MOSKittCopyToImageAction"
path="/fileMenu/saveGroup">
</popupAction>
<popupPredefinedItem
id="CopyToImageAction"
path="/fileMenu/saveGroup"
remove="true">
</popupPredefinedItem></popupContribution>
</contributionItemProvider>
</extension>
As you can see, in the popupContribution entry I define two elements: my new Action (MOSKittCopyToImageAction) and the original action to be removed.
It's so easy to do. The main difficulty is to look for the ID of the action to be removed.
Best regards,
Marc
|
|
|
Powered by
FUDForum. Page generated in 0.04203 seconds