使用 Eclipse e4(使用 Application.e4xmi 文件)创建自定义菜单不会在产品启动期间显示(在调试模式下)

Creating custom menus with Eclipse e4 (using Application.e4xmi file) is not getting displayed during product launch (in debug mode)

我使用 Luna 创建了一个新的 'Eclipse 4 Application Project',并使用这个 'Application.e4xmi' 文件创建了自定义菜单。我还添加了一个处理程序 Class,它将在单击我的自定义菜单时触发(所有这些内容都已在 Application.e4xmi 中指定)。

使用此设置如果我在调试模式下启动我的产品(作为 Eclipse 产品),我将看不到我的自定义菜单,而且如果我尝试导出为产品并尝试启动 Eclipse 产品我 运行 遇到了问题。

xmi 内容包括:

<application:Application xmi:version="2.0"  xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_hHQuoFh2EeWNzdEqyCDxmA" elementId="org.eclipse.e4.ide.application" bindingContexts="_hHQuqVh2EeWNzdEqyCDxmA">
  <children xsi:type="basic:TrimmedWindow" xmi:id="_hHQuoVh2EeWNzdEqyCDxmA" label="com.ami.test.e4project" width="500" height="400"/>
  <handlers xmi:id="_6WD5YFh2EeWNzdEqyCDxmA" elementId="com.ami.test.e4project.handler.0" contributionURI="bundleclass://com.ami.test.e4project/com.ami.test.e4project.HandlerImplementation" command="_3T-ocFh2EeWNzdEqyCDxmA"/>
  <rootContext xmi:id="_hHQuqVh2EeWNzdEqyCDxmA" elementId="org.eclipse.ui.contexts.dialogAndWindow" name="In Dialog and Windows">
    <children xmi:id="_hHQuqlh2EeWNzdEqyCDxmA" elementId="org.eclipse.ui.contexts.window" name="In Windows"/>
    <children xmi:id="_hHQuq1h2EeWNzdEqyCDxmA" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/>
  </rootContext>
  <menuContributions xmi:id="_s3SAEFh2EeWNzdEqyCDxmA" elementId="com.ami.test.e4project.menucontribution.0" parentId="org.eclipse.e4.legacy.ide.application">
    <children xsi:type="menu:Menu" xmi:id="_z21zMFh2EeWNzdEqyCDxmA" elementId="com.ami.test.e4project.menu.filee" label="Filee">
      <children xsi:type="menu:HandledMenuItem" xmi:id="_0PiAAFh2EeWNzdEqyCDxmA" elementId="com.ami.test.e4project.handledmenuitem.new" label="New" command="_3T-ocFh2EeWNzdEqyCDxmA"/>
    </children>
  </menuContributions>
  <commands xmi:id="_3T-ocFh2EeWNzdEqyCDxmA" elementId="com.ami.test.e4project.command.command" commandName="command"/>
  <addons xmi:id="_hHQuolh2EeWNzdEqyCDxmA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
  <addons xmi:id="_hHQuo1h2EeWNzdEqyCDxmA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
  <addons xmi:id="_hHQupFh2EeWNzdEqyCDxmA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
  <addons xmi:id="_hHQupVh2EeWNzdEqyCDxmA" elementId="org.eclipse.e4.ui.workbench.commands.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon"/>
  <addons xmi:id="_hHQuplh2EeWNzdEqyCDxmA" el ementId="org.eclipse.e4.ui.workbench.handler.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon"/>
  <addons xmi:id="_hHQup1h2EeWNzdEqyCDxmA" elementId="org.eclipse.e4.ui.workbench.contexts.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon"/>
  <addons xmi:id="_hHQuqFh2EeWNzdEqyCDxmA" elementId="org.eclipse.e4.ui.workbench.bindings.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"/>
</application:Application>

您正在对不存在的菜单 (org.eclipse.e4.legacy.ide.application) 使用菜单贡献。

当您使用 Application.e4xmi 创建 e4 应用程序时,没有 预定义菜单或其他任何内容。您必须定义所需的菜单。添加一个 'Main Menu' 子项到您的 'Trimmed Window' 并将菜单项放在那里。