如何在Eclipse中的工具栏中添加撤消/重做按钮?

时间:2023-01-20 17:35:56

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. Y and Z on 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 :-(

我已经尝试了谷歌等,以及通过自定义视角对话框,但无法找到我正在寻找的东西:-(

4 个解决方案

#1


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.

一种方法是使用自定义插件。实际上,这样的自定义插件不需要做任何事情,只使用现有的undo / redo命令声明新的工具栏贡献。

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-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'目录,重新启动,你会看到工具栏上的Undo / Redo按钮。

Works for me in Eclipse 3.4 and Eclipse 3.5M7.

适用于Eclipse 3.4和Eclipse 3.5M7。

#2


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更改为另一个映射。您也可以对重做和任何其他操作执行相同的操作,例如删除尾随空格等。

#3


Edit: this is now included in Peter Štibraný's answer

编辑:现在包含在PeterŠtibraný的回答中

Old thread, but still helpful... Made a small addition to Peter Štibraný's excellent answer. Changed the opening toolbar tag to:

老线程,但仍然有用......为PeterŠtibraný的优秀答案做了一个小小的补充。将打开的工具栏标记更改为:

<toolbar
    id="undoredo.toolbar"
    label="Undo/Redo">

This makes the new toolbar show up with the label Undo/Redo in the Customize Perspective dialog instead of showing up as a blank entry. (Don't have enough rep to add it to the comments!)

这使得新工具栏在“自定义透视图”对话框中显示标签“撤消/重做”,而不是显示为空白条目。 (没有足够的代表将其添加到评论中!)

#4


The toolbars and menus are dependent on the current perspective. To change them go to Window > Customize Perspective...

工具栏和菜单取决于当前的视角。要更改它们,请转到Window> Customize Perspective ...

#1


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.

一种方法是使用自定义插件。实际上,这样的自定义插件不需要做任何事情,只使用现有的undo / redo命令声明新的工具栏贡献。

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-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'目录,重新启动,你会看到工具栏上的Undo / Redo按钮。

Works for me in Eclipse 3.4 and Eclipse 3.5M7.

适用于Eclipse 3.4和Eclipse 3.5M7。

#2


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更改为另一个映射。您也可以对重做和任何其他操作执行相同的操作,例如删除尾随空格等。

#3


Edit: this is now included in Peter Štibraný's answer

编辑:现在包含在PeterŠtibraný的回答中

Old thread, but still helpful... Made a small addition to Peter Štibraný's excellent answer. Changed the opening toolbar tag to:

老线程,但仍然有用......为PeterŠtibraný的优秀答案做了一个小小的补充。将打开的工具栏标记更改为:

<toolbar
    id="undoredo.toolbar"
    label="Undo/Redo">

This makes the new toolbar show up with the label Undo/Redo in the Customize Perspective dialog instead of showing up as a blank entry. (Don't have enough rep to add it to the comments!)

这使得新工具栏在“自定义透视图”对话框中显示标签“撤消/重做”,而不是显示为空白条目。 (没有足够的代表将其添加到评论中!)

#4


The toolbars and menus are dependent on the current perspective. To change them go to Window > Customize Perspective...

工具栏和菜单取决于当前的视角。要更改它们,请转到Window> Customize Perspective ...