How to unregister toolWindow?


Hello team:

 I'm developing a plugin which register a toolwindow by code below:

var toolWindowManager = ToolWindowManager.getInstance(project);
var registerToolWindowTask = new RegisterToolWindowTask ("My_Toolwindow",.....);//ignore some variables
var toolWindow = toolWindowManager.registerToolWindow(registerToolWindowTask);

Then I want to unregister the toolWindow when user close current project ,But I found the method toolWindowManager.unregisterToolWindow was marked as deprecated. And I cannot find method instead in source code. Is there anyway to unregister toolWindow  by code?

Here is the code :

public class ProjectListener implements ProjectManagerListener{
	public void projectClosed(@NotNull Project project){
		var toolWindowManager = ToolWindowManager.getInstance(project);
		toolWindowManager.unregisterToolWindow("My_Toolwindow");//this method is marked as deprecated
1 comment

Why do you need to close the tool window explicitly? 

There is no replacmement for above method, so you can continue using it for programmatic use cases if needed.


Please sign in to leave a comment.