如何在 Eclipse 的工具栏中添加撤消/重做按钮?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/819846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add undo / redo buttons to toolbar in Eclipse?
提问by mark
I feel a bit embarrassed asking this questions, but how the heck can I get regular undo/redo buttons into the toolbar of eclipse?
问这个问题我有点尴尬,但是我怎么能在 eclipse 的工具栏中获得常规的撤消/重做按钮?
I've often to switch between German and English keyboard layout. Yand Zon those layouts is interchanged and thus I constantly trigger the wrong action for undo / redo. I've observed myself how I figure this without other editors: I just use the toolbars for this operations.
我经常在德语和英语键盘布局之间切换。这些布局上的Y和Z是互换的,因此我不断触发撤消/重做的错误操作。我已经观察到自己是如何在没有其他编辑器的情况下计算出来的:我只是使用工具栏进行此操作。
I've already tried Google and such, as well as going through the Customize Perspective dialog, but wasn't able to find what I'm looking for :-(
我已经尝试过谷歌等,以及通过自定义透视对话框,但无法找到我正在寻找的东西:-(
回答by Peter ?tibrany
One way is to use custom plugin. In fact, such custom plugin doesn't need to do anything, only declare new toolbar contribution using existing undo/redo commands.
一种方法是使用自定义插件。事实上,这样的自定义插件不需要做任何事情,只需使用现有的撤消/重做命令声明新的工具栏贡献。
I've built such plugin for you: http://www.foglyn.com/misc/undoredo_1.0.0.jar. There is absolutely no code, only plugin.xml:
我已经为你构建了这样的插件:http: //www.foglyn.com/misc/undoredo_1.0.0.jar。绝对没有代码,只有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>
And MANIFEST.MF:
和 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
You can download it, and drop into your 'dropins' directory of Eclipse, restart, and you'll see Undo/Redo buttons on your toolbar.
您可以下载它,然后放入 Eclipse 的“dropins”目录,重新启动,您将在工具栏上看到撤消/重做按钮。
Works for me in Eclipse 3.4 and Eclipse 3.5M7.
适用于 Eclipse 3.4 和 Eclipse 3.5M7。
回答by Cuga
Perhaps if can't get the undo toolbar working, you can change the mapping of the Undo / Redo key combinations to ones you could become more comfortable with.
也许如果无法使撤消工具栏工作,您可以将撤消/重做组合键的映射更改为您可以更习惯的组合。
In Eclipse, go to Window > Preferences and in the left-tree, go to General > Keys.
在 Eclipse 中,转到 Window > Preferences,然后在左侧树中转到 General > Keys。
In the 'type filter text' box, type Undo and you'll see the Undo command appear in the bottom list. You're free to change this mapping from the default Ctrl + Z to another mapping. You may likewise do the same for Redo and any other actions, such as removing trailing whitespace, etc.
在“类型过滤器文本”框中,输入“撤消”,您将看到“撤消”命令出现在底部列表中。您可以自由地将此映射从默认的 Ctrl + Z 更改为另一个映射。您也可以对重做和任何其他操作执行相同的操作,例如删除尾随空格等。
回答by Mr.Oz
Edit: this is now included in Peter ?tibrany's answer
编辑:这现在包含在 Peter ?tibrany 的回答中
Old thread, but still helpful... Made a small addition to Peter ?tibrany's excellent answer. Changed the opening toolbartag to:
旧线程,但仍然有帮助......对彼得做了一个小补充?tibrany 的出色回答。将打开工具栏标签更改为:
<toolbar
id="undoredo.toolbar"
label="Undo/Redo">
This makes the new toolbar show up with the label Undo/Redoin the Customize Perspective dialog instead of showing up as a blank entry. (Don't have enough rep to add it to the comments!)
这使得新工具栏在“自定义透视”对话框中显示为带有“撤消/重做”标签,而不是显示为空白条目。(没有足够的代表将其添加到评论中!)
回答by tamalet
The toolbars and menus are dependent on the current perspective. To change them go to Window > Customize Perspective...
工具栏和菜单取决于当前的视角。要更改它们,请转到窗口 > 自定义透视...