From 586c2d49f995de7dde2dae32d6b06a0c75c0c69a Mon Sep 17 00:00:00 2001 From: Michael Golubev Date: Mon, 28 Jul 2014 14:51:04 +0200 Subject: [PATCH] CR-IC-5700 - move polling to ui --- .../runtime/ServerConnectionManagerImpl.java | 21 ---------------- .../runtime/ui/ServersToolWindowContent.java | 24 ++++++++++++++++++- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionManagerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionManagerImpl.java index f12e646a72b9..8ed6e68b1915 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionManagerImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionManagerImpl.java @@ -20,8 +20,6 @@ import java.util.Map; */ public class ServerConnectionManagerImpl extends ServerConnectionManager { - private static final int POLL_DEPLOYMENTS_DELAY = 2000; - private final Map, ServerConnection> myConnections = new HashMap, ServerConnection>(); private final ServerConnectionEventDispatcher myEventDispatcher = new ServerConnectionEventDispatcher(); @@ -34,29 +32,10 @@ public class ServerConnectionManagerImpl extends ServerConnectionManager { connection = doCreateConnection(server, this); myConnections.put(server, connection); myEventDispatcher.fireConnectionCreated(connection); - pollDeployments(connection); } return connection; } - private void pollDeployments(final ServerConnection connection) { - connection.computeDeployments(new Runnable() { - - @Override - public void run() { - new Alarm().addRequest(new Runnable() { - - @Override - public void run() { - if (connection == getConnection(connection.getServer())) { - pollDeployments(connection); - } - } - }, POLL_DEPLOYMENTS_DELAY, ModalityState.any()); - } - }); - } - @NotNull @Override public ServerConnection createTemporaryConnection(@NotNull RemoteServer server) { diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowContent.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowContent.java index 7a1f27f3b8ee..8a46887be6cf 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowContent.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ui/ServersToolWindowContent.java @@ -6,6 +6,7 @@ import com.intellij.ide.util.treeView.AbstractTreeNode; import com.intellij.ide.util.treeView.NodeDescriptor; import com.intellij.ide.util.treeView.NodeRenderer; import com.intellij.ide.util.treeView.TreeVisitor; +import com.intellij.openapi.application.ModalityState; import com.intellij.remoteServer.impl.runtime.ui.tree.ServersTreeStructure; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; @@ -13,7 +14,6 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.EmptyRunnable; import com.intellij.remoteServer.configuration.RemoteServer; import com.intellij.remoteServer.impl.runtime.log.LoggingHandlerImpl; import com.intellij.remoteServer.impl.runtime.ui.tree.DeploymentNode; @@ -28,6 +28,7 @@ import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.SideBorder; import com.intellij.ui.components.panels.Wrapper; import com.intellij.ui.treeStructure.Tree; +import com.intellij.util.Alarm; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -56,6 +57,8 @@ public class ServersToolWindowContent extends JPanel implements Disposable { private static final String MESSAGE_CARD = "message"; private static final String EMPTY_SELECTION_MESSAGE = "Select a server or deployment in the tree to view details"; + private static final int POLL_DEPLOYMENTS_DELAY = 2000; + private final Tree myTree; private final CardLayout myPropertiesPanelLayout; private final JPanel myPropertiesPanel; @@ -188,6 +191,7 @@ public class ServersToolWindowContent extends JPanel implements Disposable { @Override public void onConnectionCreated(@NotNull ServerConnection connection) { getBuilder().queueUpdate(); + pollDeployments(connection); } @Override @@ -210,6 +214,24 @@ public class ServersToolWindowContent extends JPanel implements Disposable { } } + private static void pollDeployments(final ServerConnection connection) { + connection.computeDeployments(new Runnable() { + + @Override + public void run() { + new Alarm().addRequest(new Runnable() { + + @Override + public void run() { + if (connection == ServerConnectionManager.getInstance().getConnection(connection.getServer())) { + pollDeployments(connection); + } + } + }, POLL_DEPLOYMENTS_DELAY, ModalityState.any()); + } + }); + } + private JComponent createToolbar() { DefaultActionGroup group = new DefaultActionGroup(); group.add(ActionManager.getInstance().getAction(SERVERS_TOOL_WINDOW_TOOLBAR));