From 013671a637eb2e9bdeec8ed4e6f025174b06914f Mon Sep 17 00:00:00 2001 From: Michael Golubev Date: Fri, 1 Dec 2017 09:51:56 +0100 Subject: [PATCH] IDEA-177938 - Docker - Enable Docker item in View | Tool Windows menu - defer Docker TW content creation until first shown --- .../runtime/ui/ServersToolWindowManager.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowManager.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowManager.java index f23a54d91890..92a684dee25e 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowManager.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowManager.java @@ -22,6 +22,7 @@ import com.intellij.openapi.wm.ToolWindowAnchor; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.remoteServer.configuration.RemoteServer; import com.intellij.remoteServer.configuration.RemoteServerListener; +import com.intellij.util.ui.update.UiNotifyConnector; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -64,7 +65,7 @@ public abstract class ServersToolWindowManager { if (toolWindow == null) { if (available) { - createToolWindow(myProject, toolWindowManager).show(null); + createToolWindow(myProject, toolWindowManager, false).show(null); } return; } @@ -84,10 +85,25 @@ public abstract class ServersToolWindowManager { } } + /** + * @deprecated use {@link #createToolWindow(Project, ToolWindowManager, boolean)} + */ + @Deprecated protected ToolWindow createToolWindow(Project project, ToolWindowManager toolWindowManager) { + return createToolWindow(project, toolWindowManager, false); + } + + protected ToolWindow createToolWindow(Project project, ToolWindowManager toolWindowManager, boolean deferContentCreation) { ToolWindow toolWindow = toolWindowManager.registerToolWindow(myWindowId, false, ToolWindowAnchor.BOTTOM); toolWindow.setIcon(myIcon); - getFactory().createToolWindowContent(project, toolWindow); + + Runnable createContent = () -> getFactory().createToolWindowContent(project, toolWindow); + if (deferContentCreation) { + UiNotifyConnector.doWhenFirstShown(toolWindow.getContentManager().getComponent(), createContent); + } + else { + createContent.run(); + } return toolWindow; }