How do I activate a tool window to a specific "tab" (content)?

830 views Asked by At

I have defined my toolwindow in plugin.xml, and added some contents (tabs) in the createToolWindowContent function of the corresponding class that implements ToolWindowFactory.

I have a separate action, for which I would like to activate the toolwindow to a specific tab. For that, I do:

    ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(tool_window_id);
    toolWindow.activate(null); // don't need to execute something when done... or should I?

So right now I cannot select the tab that I want. I found the method

    toolWindow.getContentManager().setSelectedContent(content)

but what if I don't have a reference to the created content?

1

There are 1 answers

0
yole On BEST ANSWER

You can use ContentManager.getContents() to get the list of all contents displayed in the toolwindow, or findContent() or getContent() to find a content by index, name or the component shown in it.