By default, there are no Undo/Redo toolbar buttons in the Eclipse toolbar. With Eclipse as an open and extensible framework, how to add them?
Toolbar buttons in Eclipse are configured through the menu Window > Customize Perspective. But somehow there are no buttons available for undo/redo:
They only exist as menu items:
Adding Undo/Redo Buttons
The Eclipse framework allows to define new toolbar groups/items. No need to write code. All what is needed is a description XML file plus a manifest file (see http://stackoverflow.com/questions/819846/how-to-add-undo-redo-buttons-to-toolbar-in-eclipse/821801#821801).
plugin.xml:
<?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> <extension point="org.eclipse.ui.menus"> <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions"> <toolbar id="undoredo.toolbar" label="Undo/Redo"> <command commandId="org.eclipse.ui.edit.undo" id="undoredo.undo" style="push"> </command> <command commandId="org.eclipse.ui.edit.redo" id="undoredo.redo" style="push"> </command> </toolbar> </menuContribution> </extension> </plugin>
MANIFEST.MF:
Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Undoredo Bundle-SymbolicName: undoredo;singleton:=true Bundle-Version: 1.0.0 Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: org.eclipse.ui
If you don’t want to build the .jar file, here is a link to it: http://www.foglyn.com/misc/undoredo_1.0.0.jar
Installation of Undo/Redo Toolbar
To install undo/redo buttons, follow the steps below:
- Close Eclipse
- Place the file undoredo*.jar file into the eclipse\dropin folder:
- Restart Eclipse
- This shows the undo/redo in the toolbar:
- To configure it, use the menu Window > Customize Perspective:
- That’s it 🙂
Summary
The undo/redo menu item can be added as toolbar button with an XML file and a manifest file. I have not tried it for other functions, but that should work for anything else available too. It worked fine e.g. in Eclipse Luna based Freescale (now NXP) Kinetis Design Studio v3.0.0 and Eclipse MARS. Another case where the Eclipse framework shows its extensibility :-).
Links
- StackOverflow article: http://stackoverflow.com/questions/819846/how-to-add-undo-redo-buttons-to-toolbar-in-eclipse/821801#821801
- Link to the plugin used: http://www.foglyn.com/misc/undoredo_1.0.0.jar
Thanks worked perfectly, I was very useful.
LikeLike
Glad to hear that this was helpful for you 🙂
LikeLike