Cancel Tool Window appearance on startup

I would like to stop my custom tool window from appearing on startup. I thought I'd make use of overriding ToolWindowFactory.isDoNotActivateOnStart() with returning true, but it fails to do what's needed even though the debugger drops into this method correctly. I tried to debug further and saw to it that 'visible' property of WindowInfoImpl.kt becomes false. However, I'm not very good at Kotlin and can't be sure of the functionality of the class. So please give me some tips about the method or some other solution. 

I had another idea of creating project level component and calling explicitly ToolWindow.hide() in its projectClosed() method, but it's a dead-end for sure. 

4 comments
Comment actions Permalink

Does "appearing" means it is visible in the list of available tool windows, or that it is expanded and focused when project is opened? 
`isDoNotActivateOnStart` should stop IDE from activating it on project opening (ex: if it's expensive).
You can use `shouldBeAvailable` to hide it from list of toolwindows until it is needed (like Run/Debug/Find tool windows do).

Also you can register tool window using `com.intellij.openapi.wm.ToolWindowManager#registerToolWindow` when it's needed (and is not registered yet: `getToolWindow` returns null) instead of using `ToolWindowFactory` / `com.intellij.toolWindow` EP (if they do not work as expected for some reason).

0
Comment actions Permalink

Thanks! That's what strikes me as weird. As I understand it `isDoNotActivateOnStart` blocks expanding and seeing the window itself, but it keeps showing after restart in my case. I tried `shouldBeAvailable` and the window disappeared from the right panel. What I need is to see the window icon on the panel, but not have it expand after project restart.

0
Avatar
Vassiliy Kudryashov
Comment actions Permalink

JavaDoc updated: active (visible and focused) tool window would be activated anyway, even if method shouldBeAvailable() returns false.

0
Comment actions Permalink

I'm testing it right now and I can see shouldBeAvailable() returning false does the trick though (i.e. makes the window completely unavailable) whereas isDoNotActivateOnStart returning true doesn't help and the window appears expanded and focused. So I'm still looking for ways of having the window available, but closed after project restart.

0

Please sign in to leave a comment.