From ca2d6e2555a7ed2fc41aaf8e250ccd25ec249338 Mon Sep 17 00:00:00 2001 From: Michael Golubev Date: Wed, 17 Dec 2014 23:39:41 +0100 Subject: [PATCH] Docker integration - nice deployments list - move comparator to server type --- .../com/intellij/remoteServer/ServerType.java | 15 ++++++++++++++- .../runtime/deployment/DeploymentRuntime.java | 4 ---- .../impl/runtime/ServerConnectionImpl.java | 16 +--------------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/ServerType.java b/platform/remote-servers/api/src/com/intellij/remoteServer/ServerType.java index 5835c92143bb..34452ce5c15e 100644 --- a/platform/remote-servers/api/src/com/intellij/remoteServer/ServerType.java +++ b/platform/remote-servers/api/src/com/intellij/remoteServer/ServerType.java @@ -6,6 +6,7 @@ import com.intellij.openapi.project.Project; import com.intellij.remoteServer.configuration.RemoteServer; import com.intellij.remoteServer.configuration.ServerConfiguration; import com.intellij.remoteServer.configuration.deployment.DeploymentConfigurator; +import com.intellij.remoteServer.runtime.Deployment; import com.intellij.remoteServer.runtime.ServerConnector; import com.intellij.remoteServer.runtime.ServerTaskExecutor; import com.intellij.remoteServer.runtime.deployment.debug.DebugConnector; @@ -13,6 +14,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.util.Comparator; /** * @author nik @@ -66,7 +68,18 @@ public abstract class ServerType { * @return a non-null instance of {@link DebugConnector} if the server supports deployment in debug mode */ @Nullable - public DebugConnector createDebugConnector() { + public DebugConnector createDebugConnector() { return null; } + + @NotNull + public Comparator getDeploymentComparator() { + return new Comparator() { + + @Override + public int compare(Deployment o1, Deployment o2) { + return o1.getName().compareTo(o2.getName()); + } + }; + } } diff --git a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentRuntime.java b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentRuntime.java index c07c1045f032..7a6cbd177b70 100644 --- a/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentRuntime.java +++ b/platform/remote-servers/api/src/com/intellij/remoteServer/runtime/deployment/DeploymentRuntime.java @@ -16,8 +16,4 @@ public abstract class DeploymentRuntime { public interface UndeploymentTaskCallback extends RemoteOperationCallback { void succeeded(); } - - public Integer compareTo(DeploymentRuntime other) { - return null; - } } 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 06e3ae63c486..8636ce3edab9 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 @@ -290,21 +290,7 @@ public class ServerConnectionImpl implements @NotNull @Override public Collection getDeployments() { - Set result = new TreeSet(new Comparator() { - - @Override - public int compare(Deployment o1, Deployment o2) { - DeploymentRuntime runtime1 = o1.getRuntime(); - DeploymentRuntime runtime2 = o2.getRuntime(); - if (runtime1 != null && runtime2 != null) { - Integer runtimeCompareResult = runtime1.compareTo(runtime2); - if (runtimeCompareResult != null) { - return runtimeCompareResult; - } - } - return o1.getName().compareTo(o2.getName()); - } - }); + Set result = new TreeSet(getServer().getType().getDeploymentComparator()); synchronized (myLocalDeployments) { result.addAll(myLocalDeployments.values()); }