remote servers: 'undeploy' action implemented

This commit is contained in:
nik
2013-08-15 09:37:19 +04:00
parent 4c9ca8f1b0
commit 3bf6850d7c
2 changed files with 27 additions and 4 deletions
@@ -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<D extends DeploymentConfiguration> {
void computeDeployments(@NotNull Runnable onFinished);
void undeploy(@NotNull Deployment deployment, @NotNull DeploymentRuntime runtime);
@NotNull
Collection<Deployment> getDeployments();
@@ -32,7 +32,7 @@ public class ServerConnectionImpl<D extends DeploymentConfiguration> implements
private volatile String myStatusText;
private volatile ServerRuntimeInstance<D> myRuntimeInstance;
private final Map<String, Deployment> myRemoteDeployments = new HashMap<String, Deployment>();
private final Map<DeploymentSource, Deployment> myLocalDeployments = Collections.synchronizedMap(new HashMap<DeploymentSource, Deployment>());
private final Map<String, Deployment> myLocalDeployments = Collections.synchronizedMap(new HashMap<String, Deployment>());
private final Map<String, LoggingHandlerImpl> myLoggingHandlers = new ConcurrentHashMap<String, LoggingHandlerImpl>();
public ServerConnectionImpl(RemoteServer<?> server, ServerConnector<D> connector, ServerConnectionEventDispatcher eventDispatcher) {
@@ -90,7 +90,7 @@ public class ServerConnectionImpl<D extends DeploymentConfiguration> implements
public void connected(@NotNull ServerRuntimeInstance<D> 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<D extends DeploymentConfiguration> 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<Deployment> getDeployments() {
@@ -200,13 +220,13 @@ public class ServerConnectionImpl<D extends DeploymentConfiguration> 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);
}
}