Skip to main content



      Home
Home » Modeling » EMF » Customizing EMF context menu
Customizing EMF context menu [message #1751228] Thu, 05 January 2017 16:00 Go to next message
Eclipse UserFriend
I want to customize context menu bases on EditingDomainActionBarContributor. Namely, I want to hide such context menu items as cut/copy/paste for some pages of an editor. What is the best way to do this?
I've looked into generated ActionBarContributor classes, and see that all actions are created programmatically. Can I contribute new actions using plugin.xml?
Also I'm a little bit confused about enabling/disabling cut/copy/paste and delete commands. I tried to override createRemoveCommand() to always return UnexecutableCommand, but this method never get called.
Re: Customizing EMF context menu [message #1751521 is a reply to message #1751228] Wed, 11 January 2017 01:45 Go to previous message
Eclipse UserFriend
There are various ways to contribute to menus via the plugin.xml. The older approach, using actions, is to use the org.eclipse.ui.popupMenus extension point. The newer way, using commands and handlers, is to use the org.eclipse.ui.menus extension point.

I see createRemoveCommand being called when the editor's selection changes
GenModelItemProvider(ItemProviderAdapter).createRemoveCommand(EditingDomain, EObject, EStructuralFeature, Collection<?>) line: 1157	
GenModelItemProvider(ItemProviderAdapter).factorRemoveCommand(EditingDomain, CommandParameter) line: 1362	
GenModelItemProvider(ItemProviderAdapter).createCommand(Object, EditingDomain, Class<Command>, CommandParameter) line: 1015	
EcoreEditor$6(AdapterFactoryEditingDomain).createCommand(Class<Command>, CommandParameter) line: 462	
EcoreEditor$6(AdapterFactoryEditingDomain).createCommand(Class<Command>, CommandParameter) line: 516	
RemoveCommand.create(EditingDomain, Object, Object, Collection<?>) line: 93	
RemoveCommand.create(EditingDomain, Collection<?>) line: 85	
DeleteCommand.prepareCommand() line: 104	
DeleteCommand.prepare() line: 98	
DeleteCommand(AbstractCommand).canExecute() line: 108	
DeleteAction(CommandActionHandler).updateSelection(IStructuredSelection) line: 99	
DeleteAction(BaseSelectionListenerAction).selectionChanged(IStructuredSelection) line: 124	
DeleteAction(BaseSelectionListenerAction).selectionChanged(SelectionChangedEvent) line: 138	
EcoreEditor.setSelection(ISelection) line: 1915	
EcoreEditor$8.selectionChanged(SelectionChangedEvent) line: 1071	
Previous Topic:Beginner EMF Drag and Drop Notes
Next Topic:EMF Drag and Drop
Goto Forum:
  


Current Time: Sun Jul 27 14:12:30 EDT 2025

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

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

Back to the top