IDEA-144272 - IAE at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.a
authorMichael Golubev <michael.golubev@jetbrains.com>
Fri, 6 Nov 2015 12:30:43 +0000 (13:30 +0100)
committerMichael Golubev <michael.golubev@jetbrains.com>
Fri, 6 Nov 2015 12:59:12 +0000 (13:59 +0100)
platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowManager.java

index 2b3c4f8baa06091eb738c0b2addd8d008174cd73..d8c1064928b216b567db3b9616e234c74b66e971 100644 (file)
@@ -64,33 +64,34 @@ public class ServersToolWindowManager extends AbstractProjectComponent {
     });
   }
 
-  private void updateWindowAvailable(boolean showIfAvailable) {
-    boolean available = ServersToolWindowFactory.isAvailable(myProject);
-
+  private void updateWindowAvailable(final boolean showIfAvailable) {
     final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
-    final ToolWindow toolWindow = toolWindowManager.getToolWindow(WINDOW_ID);
 
-    if (toolWindow == null) {
-      if (available) {
-        toolWindowManager.invokeLater(new Runnable() {
+    toolWindowManager.invokeLater(new Runnable() {
+
+      @Override
+      public void run() {
+        boolean available = ServersToolWindowFactory.isAvailable(myProject);
 
-          @Override
-          public void run() {
+        final ToolWindow toolWindow = toolWindowManager.getToolWindow(WINDOW_ID);
+
+        if (toolWindow == null) {
+          if (available) {
             createToolWindow(myProject, toolWindowManager).show(null);
           }
-        });
-      }
-      return;
-    }
+          return;
+        }
 
-    boolean doShow = !toolWindow.isAvailable() && available;
-    if (toolWindow.isAvailable() && !available) {
-      toolWindow.hide(null);
-    }
-    toolWindow.setAvailable(available, null);
-    if (showIfAvailable && doShow) {
-      toolWindow.show(null);
-    }
+        boolean doShow = !toolWindow.isAvailable() && available;
+        if (toolWindow.isAvailable() && !available) {
+          toolWindow.hide(null);
+        }
+        toolWindow.setAvailable(available, null);
+        if (showIfAvailable && doShow) {
+          toolWindow.show(null);
+        }
+      }
+    });
   }
 
   private static ToolWindow createToolWindow(Project project, ToolWindowManager toolWindowManager) {