Creating ToolWindow programmatically (not plugin.xml)

Answered

I want to create a tool window without using plugin.xml, mostly because I've been having issues where the tool window of the first project crashes when I open a second one. I know you used to be able to use the registerToolWindow() method but that's deprecated now. What should we be using instead? My plugin class is a Project Component and is managed by an Application Component manager.

Thanks!

0
3 comments

If you have an issues with toolwindows registered via plugin.xml it would be better to find out the cause of these issues, otherwise you may get the same problems if you register a toolwindow in code. Anyway some of registerToolWindow methods in ToolWindowManager are deprecated but all of them have link to a method which should be used instead in their javadocs.

BTW usually you don't need to use ProjectComponent or ApplicationComponent in your plugin, see javadocs from corresponding classes for details.

0

I'm trying to get rid of deprecation warnings in my plugin and I'm confused by this same topic. The documentation here: https://www.jetbrains.org/intellij/sdk/docs/user_interface_components/tool_windows.html identifies two types of tool windows, those that are always available and those that are generated from user actions. I'd prefer the second for my particular plugin (GenProtobuf,) as it's not likely to be used all that often and the tool windows it creates are just for debugging output after the plugin is run so I'd rather not clutter up the user interface with an always present empty tool window. That page indicates I should be using ToolWindowManager.registerToolWindow but that method is deprecated and the recommended replacement indicates I should be using a ToolWindowFactory and the toolWindow extension point which seems to me to be using the first method described in the link I've provided which would mean the associated tool window would always be visible? Is the idea of the second kind of ToolWindow being deprecated or maybe there will be additional APIs to replace it that aren't out yet? Is there some other convenient way for me to send occasional textual output to the user? 

0

William,

First of all - I'd suggest creating a new thread instead of bumping the old one.

Regarding your issue - can't you just implement your ToolWindow as an Extension Point with setting the isDoNotActivateOnStart flag to avoid presenting such TW on startup?

0

Please sign in to leave a comment.