我在 3.x RCP 工作区中定义的键绑定:
<extension
id="vebscheme.scheme"
name="vebscheme.scheme"
point="org.eclipse.ui.bindings">
<key
commandId="com.ami.veb.ui.menu.file.new.command"
contextId="com.ami.veb.ui.context"
schemeId="com.ami.veb.ui.scheme"
sequence="CTRL+N"/>
<key
commandId="com.ami.veb.ui.menu.file.openexternalfile.command"
contextId="com.ami.veb.ui.context"
schemeId="com.ami.veb.ui.scheme"
sequence="CTRL+O"/>
<key
commandId="com.ami.veb.ui.menu.file.new.components.addcomponentwizard.command"
contextId="com.ami.veb.ui.context"
schemeId="com.ami.veb.ui.scheme"
sequence="CTRL+ALT+A"/>
<key
commandId="com.ami.veb.ui.menu.file.new.components.updatecomponentwizard.command"
contextId="com.ami.veb.ui.context"
schemeId="com.ami.veb.ui.scheme"
sequence="CTRL+ALT+U"/>
/** Scheme for the key-bindings **/
<scheme
id="com.ami.veb.ui.scheme"
name="com.ami.veb.ui.scheme">
</scheme>
//----------------
-----------------//
</extension>
方案激活:
IBindingService bindingService = (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class);
BindingService bindingServiceObj = (BindingService) bindingService;
//get the binding manager for the binding service
BindingManager bindingManager = bindingServiceObj.getBindingManager();
//constructs a scheme instance with the schemeId
Scheme newScheme = bindingManager.getScheme("com.ami.veb.ui.scheme");
//check if the newScheme is not null
//then set the scheme as active scheme
if(newScheme != null) {
try {
bindingManager.setActiveScheme(newScheme);
} catch (NotDefinedException e) {
String message = "Problem occurred when updating current active scheme."+
" This may result in issues with shortcut key bindings. "+
"Exit and re-launch the application to resolve this issue";
VeBLogger.getInstance().log(message);
VeBPluginActivator.getDefault().logPluginError(e);
}
}
上下文激活:
IContextService contextService = (IContextService) PlatformUI.getWorkbench().getService(IContextService.class);
contextService.activateContext("com.ami.veb.ui.context");
我已经生成了一个产品(使用 Luna)。我观察到,一旦我启动产品,键盘快捷键就不起作用(直到我保存了快捷键)。
BindingTable table = getTable(c.getId());
if (table != null) {
currentResult = table.getPerfectMatch(triggerSequence);
}
在调试时,我注意到BindingTable table
我的绑定上下文最初是空的,因此我得到的是 Eclipse 定义的快捷方式,而不是我为我的上下文定义的快捷方式。
PS 我最近将我的 RCP 工作区从 Eclipse Indigo (3.x RCP) 迁移到 Luna (e4 系列),我观察到,一旦我导出我的 RCP 产品,我的绑定就被清除了,当我尝试按下任何快捷键时 (说 Ctrl+N) 我只能看到 Eclipse 快捷方式,而不是我在 plugin.xml 中定义的快捷方式。
另外,请注意迁移是部分迁移(或软迁移)而不是完全迁移(纯“e4”),应用程序仍然基于兼容层。
与我的绑定上下文相关的键绑定(在 plugin.xml 中定义)在产品发布时被清除。
我对迁移出了什么问题感到困惑:( :(
欢迎提出建议,我们将不胜感激!