Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Customizing EMF context menu
Customizing EMF context menu [message #1751228] Thu, 05 January 2017 21:00 Go to next message
Jonas M. is currently offline Jonas M.Friend
Messages: 2
Registered: January 2017
Junior Member
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 06:45 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31917
Registered: July 2009
Senior Member
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	

Ed Merks
Professional Support:
Previous Topic:Beginner EMF Drag and Drop Notes
Next Topic:EMF Drag and Drop
Goto Forum:

Current Time: Tue Jun 22 11:35:17 GMT 2021

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

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

Back to the top