Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2015-11-19 13:39:14 +0000
committerXavier Coulon2015-11-19 17:33:59 +0000
commitd1dff6d88fba6ee7fc820306c918175b093602ce (patch)
tree8e9563fae39fd08a7a69d7977312e0a52b59fda0 /containers/org.eclipse.linuxtools.docker.core/src/org/eclipse
parentfd718c5f08046458acab7a889f1881cf200aba13 (diff)
downloadorg.eclipse.linuxtools-d1dff6d88fba6ee7fc820306c918175b093602ce.tar.gz
org.eclipse.linuxtools-d1dff6d88fba6ee7fc820306c918175b093602ce.tar.xz
org.eclipse.linuxtools-d1dff6d88fba6ee7fc820306c918175b093602ce.zip
bug 471666 - Show nested elements with most relevant info in Explorer View
Showing ports, links and volumes for each container Loading ContainerInfo in background if it was not already loaded (hence, a new method in IDockerContainer) Make sure the 'volumes', 'ports' and 'links' nodes remain expanded when the 'refresh' command is called Added UI tests Running SWTBot tests on MacOSX (until they can also run on Hudson at Eclipse) Change-Id: Id7b5f3982c660970824a8c8a564d49c9717fc0ce Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/60725 Tested-by: Hudson CI
Diffstat (limited to 'containers/org.eclipse.linuxtools.docker.core/src/org/eclipse')
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerContainer.java19
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerPortMapping.java2
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java2
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainer.java17
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerPortBinding.java32
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerPortMapping.java5
6 files changed, 73 insertions, 4 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerContainer.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerContainer.java
index 89573f3836..a38e7ab73e 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerContainer.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerContainer.java
@@ -49,11 +49,28 @@ public interface IDockerContainer {
public IDockerConnection getConnection();
/**
+ * @return <code>true</code> if the {@link IDockerContainerInfo} has been
+ * loaded, <code>false</code> otherwise.
+ */
+ public boolean isInfoLoaded();
+
+ /**
* @return the {@link IDockerContainerInfo} by calling the Docker daemon
* using the {@link IDockerConnection} associated with this
- * {@link IDockerContainer}.
+ * {@link IDockerContainer} if it was not loaded before, otherwise
+ * uses the previous version.
*/
public IDockerContainerInfo info();
+ /**
+ * @param force
+ * <code>true</code> to force refresh, <code>false</code> to use
+ * existing {@link IDockerContainerInfo} if it was loaded before.
+ * @return the {@link IDockerContainerInfo} by calling the Docker daemon
+ * using the {@link IDockerConnection} associated with this
+ * {@link IDockerContainer}.
+ */
+ public IDockerContainerInfo info(boolean force);
+
}
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerPortMapping.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerPortMapping.java
index eb7919f9b9..a9cd77f38b 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerPortMapping.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerPortMapping.java
@@ -15,7 +15,7 @@ package org.eclipse.linuxtools.docker.core;
* Port mapping for {@link IDockerContainer}
*
*/
-public interface IDockerPortMapping {
+public interface IDockerPortMapping extends Comparable<IDockerPortMapping> {
public int getPrivatePort();
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
index 386a92dec3..209a2183fc 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
@@ -590,7 +590,7 @@ public class DockerConnection implements IDockerConnection, Closeable {
}
@Override
- public IDockerContainerInfo getContainerInfo(String id) {
+ public IDockerContainerInfo getContainerInfo(final String id) {
try {
final ContainerInfo info = client.inspectContainer(id);
return new DockerContainerInfo(info);
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainer.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainer.java
index ef5c42f871..408bbdc637 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainer.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainer.java
@@ -32,6 +32,7 @@ public class DockerContainer implements IDockerContainer {
private List<IDockerPortMapping> ports;
private Long sizeRw;
private Long sizeRootFs;
+ private IDockerContainerInfo containerInfo;
public DockerContainer(final IDockerConnection connection,
Container container) {
@@ -115,10 +116,24 @@ public class DockerContainer implements IDockerContainer {
public List<String> names() {
return names;
}
+
@Override
public IDockerContainerInfo info() {
- return this.parent.getContainerInfo(id);
+ return info(false);
+ }
+
+ @Override
+ public IDockerContainerInfo info(final boolean force) {
+ if (force || isInfoLoaded()) {
+ this.containerInfo = this.parent.getContainerInfo(id);
+ }
+ return this.containerInfo;
+ }
+
+ @Override
+ public boolean isInfoLoaded() {
+ return this.containerInfo != null;
}
@Override
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerPortBinding.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerPortBinding.java
index c1cafa570d..e781915919 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerPortBinding.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerPortBinding.java
@@ -45,4 +45,36 @@ public class DockerPortBinding implements IDockerPortBinding {
+ "\n";
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((hostIp == null) ? 0 : hostIp.hashCode());
+ result = prime * result
+ + ((hostPort == null) ? 0 : hostPort.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DockerPortBinding other = (DockerPortBinding) obj;
+ if (hostIp == null) {
+ if (other.hostIp != null)
+ return false;
+ } else if (!hostIp.equals(other.hostIp))
+ return false;
+ if (hostPort == null) {
+ if (other.hostPort != null)
+ return false;
+ } else if (!hostPort.equals(other.hostPort))
+ return false;
+ return true;
+ }
+
}
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerPortMapping.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerPortMapping.java
index 8c1f7a09d6..28589d3095 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerPortMapping.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerPortMapping.java
@@ -108,6 +108,11 @@ public class DockerPortMapping implements IDockerPortMapping {
return false;
return true;
}
+
+ @Override
+ public int compareTo(final IDockerPortMapping other) {
+ return other.getPublicPort() - this.publicPort;
+ }

Back to the top