Customizing EMF context menu [message #1751228] |
Thu, 05 January 2017 16:00  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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 changesGenModelItemProvider(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
|
|
|
Powered by
FUDForum. Page generated in 0.24543 seconds