自定义Eclipse内容辅助的关键绑定 [英] Key-Binding for a Custom Eclipse Content Assist

查看:253
本文介绍了自定义Eclipse内容辅助的关键绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了一个内容辅助提议计算机作为eclipse插件(使用 org.eclipse.jdt.ui.javaCompletionProposalComputer )。我现在想绑定它自己的组合键(否则自定义提案出现在提案列表的底部)。



我尝试这样做,通过扩展 org.eclipse.ui.bindings ,但这需要定义 org.eclipse.ui.commands ,一个处理程序,可能还有更多的东西。



似乎已经有一个命令为我的自定义内容辅助计算机创建,因为它出现在键绑定菜单(在 Windows-> Preferences-> Keys 中),但是我不知道这个命令的id是什么。如果该命令在运行时创建,那么我甚至可以在我的plugin.xml中引用它的 commandId



还有另一个更简单的方法吗?

解决方案

在尝试了许多不同的实现方式后,我发现: p>

1)与自定义完成提案计算机相关联的命令为 org.eclipse.jdt.ui.specific_content_assist.command ,它在 org.eclipse.jdt.ui 插件(由eclipse提供)插件的 plugin.xml 中定义。



2)这是一个参数化的命令,这意味着它需要一个commandParameter,具有 id = org.eclipse.jdt.ui.specific_content_assist.category_id 。该参数的值应为 javaCompletionProposalComputer proposalCategory 的I​​D。



以下是我如何定义自定义键绑定的示例:

 < extension point =org .eclipse.ui.bindings> 
< key
sequence =CTRL + ALT + SPACE
contextId =org.eclipse.ui.contexts.dialogAndWindow
schemeId =org.eclipse.ui。 defaultAcceleratorConfiguration
commandId =org.eclipse.jdt.ui.specific_content_assist.command>
< parameter
id =org.eclipse.jdt.ui.specific_content_assist.category_id
value =YOUR_PROPOSAL_CATEGORY_GOES_HERE/>
< / key>
< / extension>

无需定义新的命令或处理程序!


I've implemented a content assist proposal computer as an eclipse plugin (using org.eclipse.jdt.ui.javaCompletionProposalComputer). I would now like to bind it to it's own key combination (otherwise the custom proposals appear at the bottom of the proposal list).

I tried doing this by extending org.eclipse.ui.bindings, but this requires defining org.eclipse.ui.commands, a handler, and possibly more things.

It seems that there is already a command created for my custom content assist computer, since it appears under the key binding menu (in Windows->Preferences->Keys), but I don't know what is the id of this command. If that command is created at runtime, then can I even refer to its commandId in my plugin.xml?

Is there another, simpler way of doing this?

解决方案

After experimenting with many different ways of implementing this I found that:

1) The command associated with custom completion proposal computers is org.eclipse.jdt.ui.specific_content_assist.command, and it is defined in the plugin.xml of the org.eclipse.jdt.ui plugin (provided by eclipse).

2) This is a parametrized command, which means it takes a commandParameter with id=org.eclipse.jdt.ui.specific_content_assist.category_id. The value of this parameter should be the id of the proposalCategory for your javaCompletionProposalComputer.

Here's an example of how I defined custom key-binding:

<extension point="org.eclipse.ui.bindings">   
    <key
        sequence="CTRL+ALT+SPACE"
        contextId="org.eclipse.ui.contexts.dialogAndWindow"
        schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
        commandId="org.eclipse.jdt.ui.specific_content_assist.command">
        <parameter
            id="org.eclipse.jdt.ui.specific_content_assist.category_id"
            value="YOUR_PROPOSAL_CATEGORY_GOES_HERE"/>
    </key>
</extension> 

No need to define a new command or handler!

这篇关于自定义Eclipse内容辅助的关键绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆