diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/ServerConnection.java b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/ServerConnection.java index 8c1489770a79..ba3b4188f148 100644 --- a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/ServerConnection.java +++ b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/ServerConnection.java @@ -3,6 +3,7 @@ package com.intellij.remoteServer.runtime; import com.intellij.openapi.ui.ComponentContainer; import com.intellij.remoteServer.configuration.RemoteServer; import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration; +import com.intellij.remoteServer.runtime.deployment.DeploymentRuntime; import com.intellij.remoteServer.runtime.deployment.DeploymentTask; import com.intellij.util.ParameterizedRunnable; import org.jetbrains.annotations.NotNull; @@ -31,6 +32,8 @@ public interface ServerConnection { void computeDeployments(@NotNull Runnable onFinished); + void undeploy(@NotNull Deployment deployment, @NotNull DeploymentRuntime runtime); + @NotNull Collection getDeployments(); diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionImpl.java index d3712333f98f..6176998ef4e7 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/ServerConnectionImpl.java @@ -32,7 +32,7 @@ public class ServerConnectionImpl implements private volatile String myStatusText; private volatile ServerRuntimeInstance myRuntimeInstance; private final Map myRemoteDeployments = new HashMap(); - private final Map myLocalDeployments = Collections.synchronizedMap(new HashMap()); + private final Map myLocalDeployments = Collections.synchronizedMap(new HashMap()); private final Map myLoggingHandlers = new ConcurrentHashMap(); public ServerConnectionImpl(RemoteServer server, ServerConnector connector, ServerConnectionEventDispatcher eventDispatcher) { @@ -90,7 +90,7 @@ public class ServerConnectionImpl implements public void connected(@NotNull ServerRuntimeInstance instance) { DeploymentSource source = task.getSource(); String deploymentName = instance.getDeploymentName(source); - myLocalDeployments.put(source, new DeploymentImpl(deploymentName, DeploymentStatus.DEPLOYING, null, null)); + myLocalDeployments.put(deploymentName, new DeploymentImpl(deploymentName, DeploymentStatus.DEPLOYING, null, null)); myLoggingHandlers.put(deploymentName, (LoggingHandlerImpl)task.getLoggingHandler()); onDeploymentStarted.run(deploymentName); instance.deploy(task, new DeploymentOperationCallbackImpl(task.getSource(), deploymentName)); @@ -137,6 +137,26 @@ public class ServerConnectionImpl implements }); } + @Override + public void undeploy(@NotNull Deployment deployment, @NotNull final DeploymentRuntime runtime) { + final String deploymentName = deployment.getName(); + myLocalDeployments.put(deploymentName, new DeploymentImpl(deploymentName, DeploymentStatus.UNDEPLOYING, null, null)); + myEventDispatcher.queueDeploymentsChanged(this); + runtime.undeploy(new DeploymentRuntime.UndeploymentTaskCallback() { + @Override + public void succeeded() { + myLocalDeployments.put(deploymentName, new DeploymentImpl(deploymentName, DeploymentStatus.NOT_DEPLOYED, null, null)); + myEventDispatcher.queueDeploymentsChanged(ServerConnectionImpl.this); + } + + @Override + public void errorOccurred(@NotNull String errorMessage) { + myLocalDeployments.put(deploymentName, new DeploymentImpl(deploymentName, DeploymentStatus.DEPLOYED, errorMessage, runtime)); + myEventDispatcher.queueDeploymentsChanged(ServerConnectionImpl.this); + } + }); + } + @NotNull @Override public Collection getDeployments() { @@ -200,13 +220,13 @@ public class ServerConnectionImpl implements @Override public void succeeded(@NotNull DeploymentRuntime deployment) { - myLocalDeployments.put(mySource, new DeploymentImpl(myDeploymentName, DeploymentStatus.DEPLOYED, null, deployment)); + myLocalDeployments.put(myDeploymentName, new DeploymentImpl(myDeploymentName, DeploymentStatus.DEPLOYED, null, deployment)); myEventDispatcher.queueDeploymentsChanged(ServerConnectionImpl.this); } @Override public void errorOccurred(@NotNull String errorMessage) { - myLocalDeployments.put(mySource, new DeploymentImpl(myDeploymentName, DeploymentStatus.NOT_DEPLOYED, errorMessage, null)); + myLocalDeployments.put(myDeploymentName, new DeploymentImpl(myDeploymentName, DeploymentStatus.NOT_DEPLOYED, errorMessage, null)); myEventDispatcher.queueDeploymentsChanged(ServerConnectionImpl.this); } }