将上下文添加到我的视图和绑定密钥到这个上下文 [英] Adding context to my view and binding key to this context
问题描述
我的问题与这里一>。但是在这里提供的解决方案对我来说没有用。
My question is same as asked here. But the solution provided there not works for me.
我已经通过 greg-449 在 createPartControl
我的看法。
I have activated the context as said in the answer by greg-449 in createPartControl
of my view.
IContextService contextService = IContextService)getSite().getService(IContextService.class);
contextService.activateContext(myViewContextId);
当我的视图被激活时,我在eclipse控制台上得到低于警告
When my view was activated I am getting below warning on eclipse console
!MESSAGE CTRL + F 发生冲突:
绑定( CTRL + F ,
ParameterizedCommand(Command( myFindCmdId ,Find,
,
类别(org.eclipse.core.commands.categories.autogenerated,未分类,自动生成或没有类别的命令,true),
org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@f41266e,
,, true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
myViewContextId ,,,系统)
Binding(CTRL+F, ParameterizedCommand(Command(myFindCmdId,Find, , Category(org.eclipse.core.commands.categories.autogenerated,Uncategorized,Commands that were either auto-generated or have no category,true), org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@f41266e, ,,true),null), org.eclipse.ui.defaultAcceleratorConfiguration, myViewContextId,,,system)
Binding( CTRL + F ,
ParameterizedCommand(Command(org.eclipse.ui.edit.findReplace,Find and Replace,
查找和替换文本
类别(org.eclipse.ui.category.edit,编辑,null,true),
org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@24ad92b0,
,, true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window ,,,系统)
Binding(CTRL+F, ParameterizedCommand(Command(org.eclipse.ui.edit.findReplace,Find and Replace, Find and replace text, Category(org.eclipse.ui.category.edit,Edit,null,true), org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@24ad92b0, ,,true),null), org.eclipse.ui.defaultAcceleratorConfiguration, org.eclipse.ui.contexts.window,,,system)
=== Plugin.xml有====
===Plugin.xml has ====
<extension
point="org.eclipse.ui.contexts">
<context
id=<myViewContextId>
name="abc">
</context>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId=<myFindCmdId>
contextId=<myViewContextId>
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+F">
</key>
//some more key binding here
</extension>
推荐答案
为避免冲突消息定义您自己的密钥绑定方案使用 org.eclipse.ui.bindings
扩展点,并将标准 org.eclipse.ui.defaultAcceleratorConfiguration
指定为方案的父ID。把你的钥匙绑定在这个新的方案。
To avoid the conflict message define you own key binding scheme using the org.eclipse.ui.bindings
extension point and specify the standard org.eclipse.ui.defaultAcceleratorConfiguration
as the parent id for the scheme. Put your key bindings in this new scheme.
使用:
org.eclipse.ui/KEY_CONFIGURATION_ID=schemeid
/ code>选择您的方案作为默认。
in your plugin_customization.ini
to select your scheme as the default.
更多这里
注意:如果 Ctrl + F 是一个查找命令,您应该挂钩到现有的Eclipse find / replace可重定位操作,而不是定义新的命令和键绑定。
Note: If your Ctrl+F is a Find command you should hook in to the existing Eclipse find/replace retargetable action rather than defining new commands and key bindings.
所以对于Find不定义任何命令,处理程序或键绑定。而在ViewPart中使用
So for Find do not define any command, handler or key bindings. Instead in your ViewPart use
IActionBars bars = getViewSite().getActionBars();
bars.setGlobalActionHandler(ActionFactory.FIND.getId(), your find Action);
这篇关于将上下文添加到我的视图和绑定密钥到这个上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!