init ToolWindow programmatically
Hi folks,
i can show and hide a toolwindow programmatically if i "initialize" it first.
But how can i do that programmatically?
Where can i get the ToolWindow object which is passed to the createToolWindowContent method?
kind regards
syt
Please sign in to leave a comment.
Hello,
Why would you need to add new tool window at runtime? Recommended approach is to create your ToolWindowFactory implementation and register it at plugin.xml like
It will be automatically picked up by the ide then.
Denis
Hi, in my plugin i use toolwindow.show & toolwindow.hide
but i cant call these methods if the toolwindow isn't initialized.
I discovered it is initialized if i click on toolwindowbutton. Then createToolWindowContent(Project project, ToolWindow toolWindow) is called internally.
My question was how can i to that on plugin initialisation programatically.
If i'm doin this:
I get a NullPointerException and i don't know why.
kind regards
syt
Did you specify tool window factory at your plugin.xml as I mentioned at the previous post?
Denis
yes, and it is working pretty well, all i want to do now is to init it programatically.
greetz
syt
You can try to call ToolWindowImpl.ensureContentInitialized() for that then.
Denis
Hi, thx for your quick reply.
I figured out that ProjectManager.getInstance().getDefaultProject() ius not returning my actually project.
I am trying to init my plugin through one of these components, but it alsways return "Default (Template) Project" instead of my Projekt
project-components
application-components
module-components
How and when can I call ProjectManager.getInstance().getDefaultProject() to get the actuall project without interacting with keyboard or mouse just programatically?
'Default project' != active project (all details are provided at ProjectManager.getDefaultProject() javadoc).
You can get a list of all open projects via ProjectManager.getInstance().getOpenProjects().
Alternatively, active project can be obtained during action processing via PlatformDataKeys.PROJECT.getData(DataContext)
Denis