Adding actions to the Project view's toolbar
Answered
Hello there,
I'm making a plugin that adds functionality to the Project view and I'd like to add actions to its tool window's toolbar.
I'm aware of:
com.intellij.openapi.wm.ex.ToolWindowEx#setTitleActions
and:
com.intellij.openapi.wm.ex.ToolWindowEx#setAdditionalGearActions
However these simply replace all existing actions with new ones. I obviously don't want to remove the default ones (since it's an existing ToolWindow), and there doesn't seem to be any method to either add or at least retrieve the list of actions :(
I'm afraid this isn't possible (which is a shame) but if you know of a way, I'd be glad to hear it.
Thanks!
Please sign in to leave a comment.
So after asking the same question on Gitter (thanks to @Wicpar and @krasa), it seems like the only solution would be to use Java Reflection to access the non-public properties. Even though that's obviously super ugly.
Here's the code I'm using right now (which also caches retrieved values):
You then access project view's tool window > decorator > header > action group using this.
To get the ToolWindow:
If anyone has a better solution, feel free to share it.
Hi Jeto,
Reflection is a bad practice. You can use it, but I recommend to file a feature request for needed API.
Hello Sergey,
Of course, you're completely right, I realize it's ugly and should be avoided. I do plan to submit a feature request (as I mentioned on Gitter).