Cannot add programmatically action to NavBarToolBar
It works from plugin XML, like:
<actions>
<group id="org.jetbrains.tutorials.actions.ExampleCustomDefaultActionGroup"
text="Example Custom DefaultActionGroup" description="Custom DefaultActionGroup Demo">
<add-to-group group-id="NavBarToolBar" anchor="first"/>
<action class="com.github.clouddevdesktopplugin.actions.DeployAnAction"
id="com.gtihub.clouddevdesktopplugin.actions.DeployAnAction"/>
<action class="com.github.clouddevdesktopplugin.actions.RestartAnAction"
id="com.github.clouddevdesktopplugin.actions.RestartAnAction"/>
<action class="com.github.clouddevdesktopplugin.actions.BuildAnAction"
id="com.github.clouddevdesktopplugin.actions.BuildAnAction"/>
</group>
</actions>
But doesn't work from Project Component like:
DefaultActionGroup windowM = (DefaultActionGroup) actionManager.getAction("NavBarToolBar");
DefaultActionGroup defaultActionGroup = new DefaultActionGroup("Opa", Arrays.asList(deployAnAction, restartAnAction, buildAnAction));
windowM.add(defaultActionGroup);
just no actions in toolbar, at the same time if I use NavBarToolBarOthers I can see actions in slightly different place.
How to do that?
Please sign in to leave a comment.
Please see this sample http://www.jetbrains.org/intellij/sdk/docs/basics/action_system.html?search=action#registering-actions-from-code
Thx for link, I tried that, and it even works for other toolbars, however I'm trying to add a actions, to plane on screen:
I can do that when I define actions in XML, but not from code. Why?
Could you please post link to full plugin sources? Anyway it is preferrable to use XML registration for Actions if possible to avoid unnecessary class-loading.
I use this to add buttons to the toolbars with LivePlugin, since I can't use a plugin.xml then
These are all the imports, just remove those you don't need/are invalid