Standard main menu not reacting to own handler #714
I have a question on how to add an undo/redo handler to the main menu of Eclipse IDE.
I use Eclipse SDK as base system and that environment has already undo and redo menu entries in the main menu under
I have an editor which uses the Eclipse 3 API i.e. extends the class EditPart. Before reading this tutorial I extended the undo/redo functionality by adding handlers to the plugin.xml of my plug-in.
I added a handler in the file fragment.e4xmi which I registered in the plugin.xml of my plugin. I added a "Model Fragment for Application - handler" with a handler entry for undo and redo.
Where do I get the command ids from, i.e. org.eclipse.ui.edit.undo and org.eclipse.ui.edit.redo? I tried importing them in the imports section of the e4 model fragment. But the Find button for the Reference-ID does not find any command id except the ids I defined myself in the import section. Should it find the ids from the org.eclipse.ui plug-in, too and why is it not shown?
The handler entry uses an e4 handler with the 2 annotated methods (@Execute and @CanExecute). For the command id of the handler I use the imported command id e.g. org.eclipse.ui.edit.undo. For the id of the handler I use my own id.
When I add an own menu (main menu or main toolbar) with the command id org.eclipse.ui.edit.undo then the buttons in the menu are enabled/disabled correctly as the state of my editor changes. But the main menu/main toolbar entries which are already added by the Eclipse SDK (see main menu Edit) are always disabled and do not reflect the editing state of my editor.
What am I missing? For Copy/Cut/Paste it works and the main menu shows the editor state and for these commands I just added a handler with the corresponding Eclipse command id e.g. org.eclipse.ui.edit.copy.
I use Eclipse DSL Tools (includes Incubating components), Version: 2021-06 (4.20.0), Build id: 20210612-2011 while developing my plug-in and Eclipse e4 Tools verion 4.20.0.v20210427-1802.
Please login to write a comment.