Access toolwindow from an action


I need to access my custom toolwindow from an action. In my case, the action triggers an update of the list displayed in the toolwindow. I tried two ways:

1) Make the toolwindow accessible via action-data. This did not work when assigning a shortcut to the action and the shortcut is used from some place outside of the toolwindow.

2) Make the toolwindow a singleton. This does not work when multiple IntelliJ projects / windows are open.

Related change (where I switched from method 1 to  2, but broke multipe IntelliJ window support:

Any ideas how this could be solved in a clean way?

Comment actions Permalink

You can use `ToolWindowManager.getInstance(project).getToolWindow(TOOLWINDOW_ID)`.

Or you can create projectService and store necessary data there.

Comment actions Permalink

Could you please provide some samples for the new API? I tried both ways but it seems they're not working as expected.

Comment actions Permalink

Could you explain what you tried and what went wrong? It is hard to guess what was "expected" from them in your case. 


Please sign in to leave a comment.