Access toolwindow from an action

Answered

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: https://github.com/uwolfer/gerrit-intellij-plugin/commit/40189fa7745717be668b413f0a34c595451cb044

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

4 comments
Comment actions Permalink

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

Or you can create projectService and store necessary data there.

1
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.

0
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. 

0

Please sign in to leave a comment.