Creating a new menu group

I am trying to create a new menu group for my plugin.

This is what I define in plugin.xml.

]]>

When I execute the plugin, I get the following exception and it fails.

java.lang.IllegalArgumentException: cannot add an action twice
at com.intellij.openapi.actionSystem.DefaultActionGroup.add(DefaultActionGroup.java:99)
at com.intellij.openapi.actionSystem.DefaultActionGroup.add(DefaultActionGroup.java:59)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.b(ActionManagerImpl.java:234)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.processActionsElement(ActionManagerImpl.java:384)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.a(ActionManagerImpl.java:383)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.readExternal(ActionManagerImpl.java:115)
at com.intellij.openapi.components.impl.ComponentManagerImpl.doInitJdomExternalizable(ComponentManagerImpl.java:80)
at com.intellij.openapi.components.impl.ComponentManagerImpl.initJdomExternalizable(ComponentManagerImpl.java:291)
at com.intellij.openapi.components.impl.ComponentManagerImpl.a(ComponentManagerImpl.java:64)
at com.intellij.openapi.components.impl.ComponentManagerImpl.access$000(ComponentManagerImpl.java:279)
at com.intellij.openapi.components.impl.ComponentManagerImpl$MyComponentAdapterFactory$1.getComponentInstance(ComponentManagerImpl.java:1)
at org.picocontainer.defaults.DecoratingComponentAdapter.getComponentInstance(DecoratingComponentAdapter.java:44)
at org.picocontainer.defaults.CachingComponentAdapter.getComponentInstance(CachingComponentAdapter.java:38)
at org.picocontainer.defaults.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:322)
at org.picocontainer.defaults.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:305)
at com.intellij.openapi.extensions.impl.AreaPicoContainerImpl$4.visitContainer(AreaPicoContainerImpl.java:120)
at org.picocontainer.defaults.DefaultPicoContainer.accept(DefaultPicoContainer.java:416)
at org.picocontainer.alternatives.AbstractDelegatingMutablePicoContainer.accept(AbstractDelegatingMutablePicoContainer.java:134)
at com.intellij.openapi.extensions.impl.AreaPicoContainerImpl.getComponentInstance(AreaPicoContainerImpl.java:107)
at com.intellij.openapi.components.impl.ComponentManagerImpl.instantiateComponent(ComponentManagerImpl.java:122)
at com.intellij.openapi.components.impl.ComponentManagerImpl.a(ComponentManagerImpl.java:172)
at com.intellij.openapi.components.impl.ComponentManagerImpl.a(ComponentManagerImpl.java:114)
at com.intellij.openapi.components.impl.ComponentManagerImpl.initComponents(ComponentManagerImpl.java:272)
at com.intellij.openapi.application.impl.ApplicationImpl.initComponents(ApplicationImpl.java:149)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:39)
at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:23)
at com.intellij.idea.Main$3.run(Main.java:1)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:94)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:119)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:25)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


Any ideas how to fix this? Can I not define new groups this way? Should I do that programmatically?

1 comment

Fixed it.

]]>
<add-to-group group-id="CMVCGroup" anchor="last" />
</action>
<add-to-group group-id="MainMenu" anchor="before" relative-to-action="HelpMenu" />
</group>

The <add-to-group> inside the action was creating the "action" / "group" a second time. Once I removed that , it worked just fine.

0

Please sign in to leave a comment.