Skip to main content



      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 05:34 Go to next message
Eclipse UserFriend
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 07:37] by Moderator

Re: How to disable all popup menu items? [message #1385536 is a reply to message #1384954] Sun, 08 June 2014 22:59 Go to previous messageGo to next message
Eclipse UserFriend
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 17:22 Go to previous message
Eclipse UserFriend
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 17:23] by Moderator

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


Current Time: Tue Jul 15 06:17:43 EDT 2025

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

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

Back to the top