Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Remove a contribution action in the contextual menu
icon9.gif  Remove a contribution action in the contextual menu [message #890496] Fri, 22 June 2012 08:29 Go to next message
Marc Gil is currently offline Marc Gil
Messages: 189
Registered: July 2009
Location: Valencia, Spain
Senior Member
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 #890500 is a reply to message #890496] Fri, 22 June 2012 08:38 Go to previous messageGo to next message
Marc Gil is currently offline Marc Gil
Messages: 189
Registered: July 2009
Location: Valencia, Spain
Senior Member
Well, finally I get it Very Happy
Re: Remove a contribution action in the contextual menu [message #891581 is a reply to message #890500] Mon, 25 June 2012 05:46 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph Gerbig
Messages: 697
Registered: November 2009
Senior Member
Hi Marc,

can you share how you did it?

Thanks,

Ralph
Re: Remove a contribution action in the contextual menu [message #891772 is a reply to message #891581] Mon, 25 June 2012 16:34 Go to previous message
Marc Gil is currently offline Marc Gil
Messages: 189
Registered: July 2009
Location: Valencia, Spain
Senior Member
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
Previous Topic:How to change icon color
Next Topic:CDO Dawn problem
Goto Forum:
  


Current Time: Tue Jul 22 11:42:44 EDT 2014

Powered by FUDForum. Page generated in 0.02827 seconds