我正在将一个menuContribution添加到eclipse插件中,我收到上面的错误消息。以下是 fragment.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="_PPqj4EOQEeedq-IevvWAag">
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_p3R7sEOQEeedq-IevvWAag" featurename="commands" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Command" xmi:id="_4tuLgEOQEeedq-IevvWAag" elementId="com.bodastage.e4.clock.ui.command.hello" commandName="Hello" description="Says Hello World"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_hDBbUEOREeedq-IevvWAag" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Handler" xmi:id="_pG9ckEOREeedq-IevvWAag" elementId="com.bodastage.e4.clock.ui.handler.HelloHandler" contributionURI="bundleclass://com.bodastage.e4.clock.ui/com.bodastage.e4.clock.ui.handlers.HelloHandler" command="_4tuLgEOQEeedq-IevvWAag"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_8OBJMEZTEeehrvUiei9LJA" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="menu:MenuContribution" xmi:id="_JcJ-cEZUEeehrvUiei9LJA" elementId="com.bodastage.e4.clock.ui.menucontribution.0" parentId="help">
<children xsi:type="menu:HandledMenuItem" xmi:id="_OSQxwEZUEeehrvUiei9LJA" elementId="com.bodastage.e4.clock.ui.handledmenuitem.Hello" label="Hello" iconURI="platform:/plugin/com.bodastage.e4.clock.ui/icons/sample.gif" command="_4tuLgEOQEeedq-IevvWAag"/>
</elements>
</fragments>
</fragment:ModelFragments>
以下是运行日志:
Starting application: 1179
!SESSION 2017-06-01 02:10:52.203 -----------------------------------------------
eclipse.buildId=4.6.3.M20170301-0400
java.version=1.8.0_121
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_GB
Framework arguments: -product org.eclipse.platform.ide
Command-line arguments: -product org.eclipse.platform.ide -data C:\Users\Emmanuel\workspace/../runtime-EclipseApplication -dev file:C:/Users/Emmanuel/workspace/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/dev.properties -debug C:\Users\Emmanuel\workspace\.metadata\.plugins\org.eclipse.pde.core\Eclipse Application/.options -os win32 -ws win32 -arch x86_64 -consoleLog
!ENTRY org.eclipse.osgi 4 0 2017-06-01 02:10:54.335
!MESSAGE Application error
!STACK 1
java.lang.ArrayStoreException: org.eclipse.e4.ui.model.application.ui.menu.impl.MenuContributionImpl
at org.eclipse.emf.common.util.BasicEList.assign(BasicEList.java:118)
at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:417)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.doAddUnique(NotifyingListImpl.java:325)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:309)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:303)
at org.eclipse.e4.ui.model.internal.ModelUtils.mergeList(ModelUtils.java:197)
at org.eclipse.e4.ui.model.internal.ModelUtils.merge(ModelUtils.java:145)
at org.eclipse.e4.ui.model.fragment.impl.StringModelFragmentImpl.mergeIdList(StringModelFragmentImpl.java:322)
at org.eclipse.e4.ui.model.fragment.impl.StringModelFragmentImpl.merge(StringModelFragmentImpl.java:300)
at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processModelFragment(ModelAssembler.java:272)
at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processFragmentConfigurationElement(ModelAssembler.java:162)
at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processFragments(ModelAssembler.java:118)
at org.eclipse.e4.ui.internal.workbench.ModelAssembler.processModel(ModelAssembler.java:96)
at org.eclipse.e4.ui.internal.workbench.ResourceHandler.loadMostRecentModel(ResourceHandler.java:197)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(E4Application.java:377)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:252)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:632)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
An error has occurred. See the log file
C:\Users\Emmanuel\runtime-EclipseApplication\.metadata\.log.
在google搜索和浏览stackoveflow for java.lang.ArrayStoreException 相关问题后,我找不到任何有用的信息。我将非常感谢任何指出这一点。
答案 0 :(得分:0)
此:
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_8OBJMEZTEeehrvUiei9LJA" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="menu:MenuContribution" xmi:id="_JcJ-cEZUEeehrvUiei9LJA" elementId="com.bodastage.e4.clock.ui.menucontribution.0" parentId="help">
<children xsi:type="menu:HandledMenuItem" xmi:id="_OSQxwEZUEeehrvUiei9LJA" elementId="com.bodastage.e4.clock.ui.handledmenuitem.Hello" label="Hello" iconURI="platform:/plugin/com.bodastage.e4.clock.ui/icons/sample.gif" command="_4tuLgEOQEeedq-IevvWAag"/>
</elements>
</fragments>
正在尝试添加菜单贡献到处理程序 featurename="handlers"
列表,这是不允许的。您需要更改此选项以将菜单项添加为现有菜单的children
。
答案 1 :(得分:0)
我通过将menuContributions的featurename更改为 menuContributions 来解决了这个问题。下面是一个显示变化的片段。
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_hiF-4EawEeehrvUiei9LJA" featurename="menuContributions" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="menu:MenuContribution" xmi:id="_CnpqgEaxEeehrvUiei9LJA" elementId="com.bodastage.e4.clock.ui.menucontribution.0" parentId="help">
<children xsi:type="menu:HandledMenuItem" xmi:id="_JsBsMEaxEeehrvUiei9LJA" elementId="com.bodastage.e4.clock.ui.handledmenuitem.Hello" label="Hello" iconURI="platform:/plugin/com.bodastage.e4.clock.ui/icons/sample.gif" command="_4tuLgEOQEeedq-IevvWAag"/>
</elements>
</fragments>
以下链接很有用: