Error while registering a task in toolWindow in Intellij IDEA 2022.2

Answered

Hello,

I am trying to register a new task to ToolWindow. It works for version 2021, but it is throwing me below error IDEA version 2022. 

java.lang.IllegalStateException: You must not register toolwindow programmatically so early. Rework code or use ToolWindowManager.invokeLater
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.getToolWindowPaneIfInitialized(ToolWindowManagerImpl.kt:500)
    at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.registerToolWindow(ToolWindowManagerImpl.kt:931)

 

This is the code:

toolWindow = ToolWindowManagerImpl(project!!)
val task = RegisterToolWindowTask("windowName", ToolWindowAnchor.BOTTOM,icon = PluginIcons.Icon)
toolWindow!!.registerToolWindow(task)

 

0
1 comment

Hi Baraiya,

Did you try to solve it as the exception message says so by wrapping the registration code into ToolWindowManager.invokeLater()?

Also, do not create ToolWindowManager via instantiating ToolWindowManagerImpl. Use ToolWindowManager.getInstance(project).

0

Please sign in to leave a comment.