Add an action buttons to my custom tool window

Answered

Hi, I want to add action buttons to my custom tool window, like gradle tool window for example:

Are there any instructions or a clear example of how to do it?

 

Thanks!

3 comments
Comment actions Permalink

Use ActionToolBar, see http://www.jetbrains.org/intellij/sdk/docs/basics/action_system.html#building-ui-from-actions. You can use base class com.intellij.openapi.ui.SimpleToolWindowPanel and call setToolbar.

1
Comment actions Permalink

Thanks, it worked.

I have a follow-up question. I'm trying to make the action toolbar to appear horizontally without a success :|

This is what I've tried: 

public class SettingsPanel extends SimpleToolWindowPanel {

public SettingsPanel(Project project) {
super(false, true);
final ActionManager actionManager = ActionManager.getInstance();
DefaultActionGroup actionGroup = new DefaultActionGroup("ACTION_GROUP", false);
actionGroup.add(ActionManager.getInstance().getAction("deployAction"));
ActionToolbar actionToolbar = actionManager.createActionToolbar("ACTION_TOOLBAR", actionGroup, true);
actionToolbar.setOrientation(SwingConstants.HORIZONTAL);
this.setToolbar(actionToolbar.getComponent());

It looks like this:

 

Thanks again :)

0
Comment actions Permalink

I found the issue.

The first parameter of the super class (SimpleToolWindow) is boolean vertical.

0

Please sign in to leave a comment.