Java Eclipse4插件-密钥绑定

Java Eclipse4插件-密钥绑定,java,eclipse,eclipse-plugin,eclipse-rcp,Java,Eclipse,Eclipse Plugin,Eclipse Rcp,我想迁移我的eclipse插件以使用Eclipse4。这基本上意味着摆脱对兼容性层的依赖? 我的插件有一个Activator类、一个带有附加处理程序的命令和一个触发该命令的键绑定。到目前为止,我所做的是安装e4工具,并将fragment.e4xmi添加到我的插件项目中,将org.eclipse.e4.workbench.model添加到plugin.xml中的扩展中。按照这些说明,我能够向eclipse的主菜单添加一个菜单贡献,并将一个e4处理程序附加到此菜单(它使用了很酷的依赖注入工具!) 我

我想迁移我的eclipse插件以使用Eclipse4。这基本上意味着摆脱对兼容性层的依赖? 我的插件有一个Activator类、一个带有附加处理程序的命令和一个触发该命令的键绑定。到目前为止,我所做的是安装e4工具,并将fragment.e4xmi添加到我的插件项目中,将org.eclipse.e4.workbench.model添加到plugin.xml中的扩展中。按照这些说明,我能够向eclipse的主菜单添加一个菜单贡献,并将一个e4处理程序附加到此菜单(它使用了很酷的依赖注入工具!)

我的问题是键绑定。在我的plugin.xml中,它看起来是这样的

<extension
         point="org.eclipse.ui.bindings">
      <key
            commandId="com.florian.regexfindandreplace.commands.FindAndReplaceCommand"
            contextId="org.eclipse.ui.textEditorScope"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
            sequence="M1+F5">
      </key>

       <scheme
  name="Default"
  description="Default shortcuts for Eclipse"
  id="default.id" />
</extension>

在fragment.e4xmi中,我添加了一个具有扩展元素id的模型片段:org.eclipse.e4.legacy.ide.application和功能名称keyBindings

在该节点下,我创建了一个Id为org.eclipse.ui.contexts.window的BindingContext(我导入了该绑定上下文),以及一个使用该上下文和M1+F5上的键绑定的BindingTable

但是当我在插件运行时按Ctrl+F5时(菜单可见,可以从那里触发命令),命令不会被触发

这是我的frament.e4xmi文件

    <?xml version="1.0" encoding="ASCII"?>
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_GxS4UF4xEea8x7AIe1PlrQ">
  <imports xsi:type="commands:BindingContext" xmi:id="_vgCiAF8lEea2fbkyfFHzhA" elementId="org.eclipse.ui.contexts.dialogAndWindow"/>
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_OX6rcF4xEea8x7AIe1PlrQ" featurename="commands" parentElementId="org.eclipse.e4.legacy.ide.application">
    <elements xsi:type="commands:Command" xmi:id="_XcrQgF4xEea8x7AIe1PlrQ" elementId="com.florian.regexfindandreplace.command.openfindreplacedialog" commandName="Open find/replace dialog" description="Opens the find/replace dialog"/>
  </fragments>
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_dc1cIF4xEea8x7AIe1PlrQ" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
    <elements xsi:type="commands:Handler" xmi:id="_ioC8wF4xEea8x7AIe1PlrQ" elementId="com.florian.regexfindandreplace.handler.openfindreplacedialog" contributionURI="bundleclass://com.florian.regexfindandreplace/com.florian.regexfindandreplace.handlers.OpenFindReplaceDialogE4Handler" command="_XcrQgF4xEea8x7AIe1PlrQ"/>
  </fragments>
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_ok-OMF4xEea8x7AIe1PlrQ" featurename="menuContributions" parentElementId="org.eclipse.e4.legacy.ide.application">
    <elements xsi:type="menu:MenuContribution" xmi:id="_1fot0F4xEea8x7AIe1PlrQ" elementId="com.florian.regexfindandreplace.menucontribution.firstmenu" positionInParent="after=additions" parentId="org.eclipse.ui.main.menu">
      <children xsi:type="menu:HandledMenuItem" xmi:id="_FTLfEF4yEea8x7AIe1PlrQ" elementId="id.openfindreplacedialog" label="Open find/replace dialog" command="_XcrQgF4xEea8x7AIe1PlrQ"/>
    </elements>
  </fragments>
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="__aNm8F45Eea8x7AIe1PlrQ" featurename="keyBindings" parentElementId="org.eclipse.e4.legacy.ide.application">
    <elements xsi:type="commands:BindingTable" xmi:id="_2seTgF8lEea2fbkyfFHzhA" elementId="com.florian.regexfindandreplace.bindingtable.0" bindingContext="_vgCiAF8lEea2fbkyfFHzhA">
      <bindings xmi:id="_3ySFAF8lEea2fbkyfFHzhA" elementId="com.florian.regexfindandreplace.keybinding.0" keySequence="CTRL+F5" command="_XcrQgF4xEea8x7AIe1PlrQ"/>
    </elements>
  </fragments>
</fragment:ModelFragments>


我做错了什么?感谢您的帮助

我的问题解决了。我的键绑定的模型片段必须具有featurename=“bindingTables”。所以这里不能有一个任意的名字,就像我在给它命名“keyBindings”时想的那样。

我的问题解决了。我的键绑定的模型片段必须具有featurename=“bindingTables”。所以这里不能有一个任意的名字,就像我在给它命名为“keyBindings”时想的那样