IDEA-116466 - Heroku deployment: provide possibility to refresh ApplicationServers view w/o server restart

This commit is contained in:
Michael Golubev
2014-07-03 16:09:47 +02:00
parent e4f7dd08d7
commit f01c3e3644
4 changed files with 33 additions and 15 deletions
@@ -67,18 +67,13 @@ public class DeployToServerState<S extends ServerConfiguration, D extends Deploy
else {
debugConnector = null;
}
connection.computeDeployments(new Runnable() {
@Override
public void run() {
connection.deploy(new DeploymentTaskImpl(mySource, myConfiguration, project, debugConnector, myEnvironment),
new ParameterizedRunnable<String>() {
@Override
public void run(String s) {
RemoteServersView.getInstance(project).showDeployment(connection, s);
}
});
}
});
connection.deploy(new DeploymentTaskImpl(mySource, myConfiguration, project, debugConnector, myEnvironment),
new ParameterizedRunnable<String>() {
@Override
public void run(String s) {
RemoteServersView.getInstance(project).showDeployment(connection, s);
}
});
return null;
}
}
@@ -1,10 +1,12 @@
package com.intellij.remoteServer.impl.runtime;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.remoteServer.configuration.RemoteServer;
import com.intellij.remoteServer.configuration.ServerConfiguration;
import com.intellij.remoteServer.runtime.ServerConnection;
import com.intellij.remoteServer.runtime.ServerConnectionManager;
import com.intellij.util.Alarm;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -17,6 +19,9 @@ import java.util.Map;
* @author nik
*/
public class ServerConnectionManagerImpl extends ServerConnectionManager {
private static final int POLL_DEPLOYMENTS_DELAY = 2000;
private final Map<RemoteServer<?>, ServerConnection> myConnections = new HashMap<RemoteServer<?>, ServerConnection>();
private final ServerConnectionEventDispatcher myEventDispatcher = new ServerConnectionEventDispatcher();
@@ -29,10 +34,29 @@ 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 <C extends ServerConfiguration> ServerConnection createTemporaryConnection(@NotNull RemoteServer<C> server) {
@@ -108,7 +108,7 @@ public class ServersToolWindowContent extends JPanel implements Disposable {
Set<ServersTreeStructure.RemoteServerNode> nodes = getSelectedRemoteServerNodes();
if (nodes.size() == 1) {
RemoteServer<?> server = nodes.iterator().next().getValue();
ServerConnectionManager.getInstance().getOrCreateConnection(server).computeDeployments(EmptyRunnable.INSTANCE);
ServerConnectionManager.getInstance().getOrCreateConnection(server);
return true;
}
return false;
@@ -255,8 +255,7 @@ public class ServersTreeStructure extends AbstractTreeStructureBase {
@Override
public void startServer(@NotNull Executor executor) {
ServerConnection<?> connection = ServerConnectionManager.getInstance().getOrCreateConnection(getValue());
connection.computeDeployments(EmptyRunnable.INSTANCE);
ServerConnectionManager.getInstance().getOrCreateConnection(getValue());
}
@Override