Search code examples
intellij-plugin

Adding button in toolbar for intellij plugin


I am writing a Plugin for intelliJ IDEA and I have been trying to add a button in the main toolbar, besides the run button:

enter image description here

I have been looking for guides to help me do it, but I haven't found any. It has to be possible, this is just my first plugin and I lack the necessary experience. Any help is greatly appreciated.


Solution

  • It's simple. You have to create an action (descendant of AnAction) and put it in Actions tag within your plugin.xml:

        <actions>
          <action id="your.action.id" class="your.Action"
                text="Some label" description="Action description" icon="AllIcons.General.AddJdk">
            <add-to-group group-id="ToolbarRunGroup" anchor="first" />
          </action>
        </actions>
    

    The "add-to-group" tag will tell IDEA to put it together with other execution related buttons.