Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to disable all popup menu items?
How to disable all popup menu items? [message #1384954] Tue, 03 June 2014 09:34 Go to next message
Bartosz Popiela is currently offline Bartosz PopielaFriend
Messages: 21
Registered: March 2012
Junior Member
Hi!
1. I have some.domain.SomeDiagramEditor editor extending org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.
If I click RMB on some node on diagram, then default popup appears. For a specific node I would like to hide all existing items in this popup menu and show only my contributed popup item. I use org.eclipse.ui.menus extension point to contribute my custom action. Should I use org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders extension point and popupPredefiniedItem element for every already contributed action? What if some new plugin will contribute some new item, that I didn't hide this way? - it will be displayed.

2. I use org.eclipse.ui.commands extension point to define my custom action. MyActionHandler extends org.eclipse.core.commands.AbstractHandler. I would like to make popup action enabled depending on a selected node state. org.eclipse.core.commands.AbstractHandler has
public void setEnabled(Object evaluationContext)
method, but it isn't invoked when poup shows at first time.
What is the correct way to do this?

[Updated on: Tue, 03 June 2014 11:37]

Report message to a moderator

Re: How to disable all popup menu items? [message #1385536 is a reply to message #1384954] Mon, 09 June 2014 02:59 Go to previous messageGo to next message
Benjamin NoOnesBusiness is currently offline Benjamin NoOnesBusinessFriend
Messages: 3
Registered: June 2014
Junior Member
Hi,

yeah it's a bit tricky. Here my code, thinks its explains itself.
If you have questions, just ask.
<plugin>
   <extension
      point="org.eclipse.ui.commands">
      <command
         defaultHandler="de.woep.blub.custom.generator.GenerateCodeAction"
         id="de.woep.blub.generateCodeCommand"
         name="Sample Command">
      </command>
   </extension>
   <extension
      point="org.eclipse.ui.menus">
      <menuContribution
         locationURI=
         "popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu">
         <menu
            id="org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu.generateCodeMenu"
            label="My perfect menu">
            <command
               id="org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu.generateCode"
               commandId="de.woep.blub.generateCodeCommand"
               label="Generate code"
               tooltip="Generates code from a model file">
              </command>
           </menu>
        </menuContribution>
     </extension>
  </plugin>

Re: How to disable all popup menu items? [message #1385605 is a reply to message #1385536] Mon, 09 June 2014 21:22 Go to previous message
Bartosz Popiela is currently offline Bartosz PopielaFriend
Messages: 21
Registered: March 2012
Junior Member
Thank you for response! Smile
Actually, above code contributes new submenu "My perfect menu" to existing popup.
What i want to achieve is to disable all items in existing
popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu
popup except my own contributions, if my context is set. I know that I can remove every item using
org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders
extension point and popupPredefiniedItem element, and contribute my own items, but different plugins can contribute different menu items and I don't have list of all contributed menu items.

I set context using
"org.eclipse.ui.contexts"
extenstion point and use
activeContexts
variable for
visibleWhen
statement.

[Updated on: Mon, 09 June 2014 21:23]

Report message to a moderator

Previous Topic:Customize Scalable Polygon Figure
Next Topic:use of visual effect mapping
Goto Forum:
  


Current Time: Wed Apr 24 16:58:26 GMT 2024

Powered by FUDForum. Page generated in 0.02780 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top