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

0
7 comments

Hum, ToolWindowsGroup.getToolWindowActions(project, true) returns the missing tool window IDs (what's in “…”), but I have no idea how to activate them.

0

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?

0

Yes, I tried, but getToolWindow returns null for tool windows hidden in “…”.

0

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?

0

It works partially. I can get the Bookmarks toolwindow, but not the Run toolwindow. Same thing for Debug.  

I tried:

ToolWindowManager twm = ToolWindowManager.getInstance(project);
ToolWindowsGroup.getToolWindowActions(project, true).forEach((atw) -> {
    LOGGER.warn(atw.getToolWindowId() + ": " + twm.getToolWindow(atw.getToolWindowId()));
});

And I get: 

Bookmarks: com.intellij.openapi.wm.impl.ToolWindowImpl@2538da9
Find: null
Run: null
Debug: null
Gradle: com.intellij.openapi.wm.impl.ToolWindowImpl@739b4964
Hierarchy: null
Learn: com.intellij.openapi.wm.impl.ToolWindowImpl@33c1859b
Meet New UI: null
Merge Requests: com.intellij.openapi.wm.impl.ToolWindowImpl@6e76edc5
Pull Requests: com.intellij.openapi.wm.impl.ToolWindowImpl@70d61b67

This is what I see in the “…” popup

0

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.

0

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.

0

Please sign in to leave a comment.