[英]Adding shortcut to shortcutles Eclipse actions defined in plugins
There is a plugin that has an action (action itself is even placed on toolbar ie Tomcat runner and Vim editing mode).有一个具有动作的插件(动作本身甚至被放置在工具栏上,即 Tomcat 跑步者和 Vim 编辑模式)。
So is there any way to add conveniently shortcuts to these actions, which have no shortcuts implicitly defined, by say changing an XML configuration...那么有什么方法可以方便地为这些操作添加快捷方式,这些操作没有隐式定义快捷方式,比如更改 XML 配置......
Any advices are appreciated.任何建议表示赞赏。
There are two different ways to contribute to the Eclipse Workbench: Actions and Commands.有两种不同的方式可以为 Eclipse 工作台做出贡献:操作和命令。
Prefer using the command framework taht is newer & more complete than the action one and that allows to add key binding easily.更喜欢使用命令框架,它比操作框架更新、更完整,并且允许轻松添加键绑定。
Have a look to the org.eclipse.ui.bindings extension point to contribute a key binding for a given command: http://wiki.eclipse.org/FAQ_How_do_I_provide_a_keyboard_shortcut_for_my_action%3F Have a look to the org.eclipse.ui.bindings extension point to contribute a key binding for a given command: http://wiki.eclipse.org/FAQ_How_do_I_provide_a_keyboard_shortcut_for_my_action%3F
A more complete article about the Eclipse command framework: http://www.vogella.de/articles/EclipseCommands/article.html关于Eclipse命令框架的更完整的文章: http://www.vogella.de/articles/EclipseCommands/article.html
The answer is Yes you can do it.答案是肯定的,你可以做到。
window->preferences->keys
now here you create new bindings or can change the old ones.window->preferences->keys
在这里您可以创建新绑定或更改旧绑定。 Example:例子:
>>Original >>原创
>>Setting it >>设置
>>Result >>结果
Note: There is a hard way as mentioned in @greydet answer.注意: @greydet 回答中提到了一种艰难的方式。 But, don't worry its not that hard.
但是,不要担心它没有那么难。 Follow these steps:
按着这些次序:
org.eclipse.jdt.ui
.org.eclipse.jdt.ui
中找到它。 Mostly a well written plugin divides its UI and processing component in different plugins.name
or some fuzzy id etc.name
或一些模糊 ID 等修改的操作项。 For example for java getter and setter action following is the command extension point:例如对于 java getter 和 setter 操作,以下是命令扩展点:
<command
name="%ActionDefinition.getterSetter.name"
description="%ActionDefinition.getterSetter.description"
categoryId="org.eclipse.jdt.ui.category.source"
id="org.eclipse.jdt.ui.edit.text.java.create.getter.setter">
</command>
The corresponding binding extension I have written:我写的相应的绑定扩展:
<plugin>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="org.eclipse.jdt.ui.edit.text.java.create.getter.setter"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="CTRL+T">
</key>
</extension>
</plugin>
The Problem: The command you earlier found is for package explorer
view.问题:您之前找到的命令适用于
package explorer
视图。 There is a command contributed by the java editor also. java 编辑器也提供了一个命令。 You have to create a binding for that.
您必须为此创建一个绑定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.