Get all available tool window IDs, including tool windows hidden in the "..." menu (new UI)
Answered
Hi, I'm trying to implement https://youtrack.jetbrains.com/issue/IJPL-163433
I tried to list all available tool window IDs (please see https://youtrack.jetbrains.com/issue/IJPL-163433/Move-all-tool-window-buttons-outside-more-by-a-single-click#focus=Comments-27-10826642.0-0). It partially works, as I see IDs for available tool windows, but not for tool window that are still hidden in the “…” menu (new UI only).
Do you have any idea? Thanks
Please sign in to leave a comment.
Hum, ToolWindowsGroup.getToolWindowActions(project, true) returns the missing tool window IDs (what's in “…”), but I have no idea how to activate them.
Have you tried retrieving the tool window from the tool window manager (`ToolWindowManager.getInstance(project).getToolWindow(toolWindowId)`) and calling `activate(null)` on the returned tool window?
Yes, I tried, but getToolWindow returns null for tool windows hidden in “…”.
Hmm… It doesn't for me. I've just tried activating the Bookmarks tool window, the `toolWindowId` property of its corresponding activate action is `Bookmarks` and the tool window manager returns a valid tool window.
Does it happen for all tool windows hidden under the More button? Do you get the ide from the `toolWindowId` property?
It works partially. I can get the Bookmarks toolwindow, but not the Run toolwindow. Same thing for Debug.
I tried:
And I get:
This is what I see in the “…” popup
Oh, yes, those windows are a bit tricky. They're on-demand dynamic windows, created when you have something to fill them with (like when starting a run configuration or invoking one of the hierarchy actions). When you activate such a toolwindow through the More button, it works around this by providing a special empty state, but it's encapsulated into the action itself and I don't see any API to use it from a plugin.
What you can do, though, instead of getting an ID and activating the window through the window manager, you can just try to perform those actions directly using
com.intellij.openapi.actionSystem.ex.ActionUtil#invokeAction(com.intellij.openapi.actionSystem.AnAction, com.intellij.openapi.actionSystem.AnActionEvent, java.lang.Runnable)
. By doing that, you just delegate all the work to these actions and basically do the same thing as clicking on those menu items.OMG, you're absolutely right. I forgot these tool windows were special. Thx!
I think this is fine if I don't activate them, because the user will activate them automatically when invoking a Run action, a Find action, etc.
BTW, thanks for the
ActionUtil
idea!I think my issue is solved.