Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2015-06-02 07:10:16 -0400
committerJeff Johnston2015-06-02 19:09:02 -0400
commitd6f468567725ef2ac4d0207badcc9f1f50ce311a (patch)
tree4fcf7da72cf09ec8f4c0c69e16d2d18065211433
parent4f3cdb83564c1ba898fba88b41793d3c43cc6b31 (diff)
downloadorg.eclipse.linuxtools-d6f468567725ef2ac4d0207badcc9f1f50ce311a.tar.gz
org.eclipse.linuxtools-d6f468567725ef2ac4d0207badcc9f1f50ce311a.tar.xz
org.eclipse.linuxtools-d6f468567725ef2ac4d0207badcc9f1f50ce311a.zip
Bug 469072 - Add Containers and Images views commands to the Explorer
view Change-Id: Id6f8da409e8bf1541e36fc15f0de11572037b16d Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/49192 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com> Reviewed-on: https://git.eclipse.org/r/49265
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java25
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/plugin.properties14
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/plugin.xml324
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java19
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerContentProvider.java52
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java90
6 files changed, 514 insertions, 10 deletions
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 623d7e8b3e..a37b6b058f 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
@@ -1642,4 +1642,29 @@ public class DockerConnection implements IDockerConnection {
return tcpCertPath;
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.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;
+ DockerConnection other = (DockerConnection) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/plugin.properties b/containers/org.eclipse.linuxtools.docker.ui/plugin.properties
index ca0bb80dcd..296dfa54e7 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/plugin.properties
+++ b/containers/org.eclipse.linuxtools.docker.ui/plugin.properties
@@ -29,22 +29,22 @@ command.refreshcontainers.tooltip=Refresh list of containers
command.refreshcontainers.name=Refresh Containers
command.refreshcontainers.description=Refresh the list of containers
-command.startcontainers.name=&Start Selected Containers
+command.startcontainers.name=&Start Containers
command.startcontainers.description=Stop the selected containers
-command.pausecontainers.name=&Pause Selected Containers
+command.pausecontainers.name=&Pause Containers
command.pausecontainers.description=Pause the selected containers
-command.unpausecontainers.name=&Unpause Selected Containers
+command.unpausecontainers.name=&Unpause Containers
command.unpausecontainers.description=Unpause the selected containers
-command.stopcontainers.name=&Stop Selected Containers
+command.stopcontainers.name=&Stop Containers
command.stopcontainers.description=Stop the selected containers
-command.killcontainers.name=&Kill Selected Containers
+command.killcontainers.name=&Kill Containers
command.killcontainers.description=Kill the selected containers
-command.removecontainers.name=&Remove Selected Containers
+command.removecontainers.name=&Remove Containers
command.removecontainers.description=Remove the selected containers
command.showallcontainers.name=&Show all Containers
@@ -62,7 +62,7 @@ command.removecontainerlog.description=Remove the console log for the selected c
command.showallcontainers.name=&Show all Containers
command.showallcontainers.description=Show all Containers, including non-running ones.
-command.removeimages.name=Re&move Selected Images
+command.removeimages.name=Re&move Images
command.removeimages.description=Remove the selected images
command.refreshimages.name=&Refresh Images
diff --git a/containers/org.eclipse.linuxtools.docker.ui/plugin.xml b/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
index aa1f7ccfbe..20f7fa7010 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
+++ b/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
@@ -562,6 +562,330 @@
style="push">
</command>
</menuContribution>
+ <!-- explorer view context menu: start containers -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.startContainers"
+ icon="icons/running.gif"
+ id="org.eclipse.linuxtools.docker.ui.commands.startContainers"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerContainer" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: pause containers -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.pauseContainers"
+ icon="icons/suspend.gif"
+ id="org.eclipse.linuxtools.docker.ui.commands.pauseContainers"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerContainer" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: unpause containers -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.unpauseContainers"
+ icon="icons/resume.gif"
+ id="org.eclipse.linuxtools.docker.ui.commands.unpauseContainers"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerContainer" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: stop containers -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.stopContainers"
+ icon="icons/stopped.gif"
+ id="org.eclipse.linuxtools.docker.ui.commands.stopContainers"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerContainer" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: kill containers -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.killContainers"
+ icon="icons/kill.gif"
+ id="org.eclipse.linuxtools.docker.ui.commands.killContainers"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerContainer" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: remove containers -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.removeContainers"
+ icon="icons/delete.gif"
+ id="org.eclipse.linuxtools.docker.ui.commands.removeContainers"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerContainer" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: commit container -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.commitContainer"
+ id="org.eclipse.linuxtools.docker.ui.commands.commitContainer"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerContainer" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: display container log -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.displayContainerLog"
+ id="org.eclipse.linuxtools.docker.ui.commands.displayContainerLog"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerContainer" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: remove container log -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.removeContainerLog"
+ id="org.eclipse.linuxtools.docker.ui.commands.removeContainerLog"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerContainer" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: push image -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.pushImage"
+ icon="icons/push.gif"
+ id="org.eclipse.linuxtools.docker.ui.commands.pushImage"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerImage" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: tag image -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.tagImage"
+ icon="icons/tag.gif"
+ id="org.eclipse.linuxtools.docker.ui.commands.tagImage"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerImage" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: remove tag -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.removeTag"
+ id="org.eclipse.linuxtools.docker.ui.commands.removeTag"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerImage" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <!-- explorer view context menu: remove images -->
+ <menuContribution
+ locationURI="popup:org.eclipse.linuxtools.docker.ui.dockerExplorerView">
+ <command
+ commandId="org.eclipse.linuxtools.docker.ui.commands.removeImages"
+ icon="icons/delete.gif"
+ id="org.eclipse.linuxtools.docker.ui.commands.removeImages"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <count
+ value="1">
+ </count>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof
+ value="org.eclipse.linuxtools.docker.core.IDockerImage" />
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+
+
+
<!-- containers view toolbar: start containers -->
<menuContribution
locationURI="toolbar:org.eclipse.linuxtools.docker.ui.dockerContainersView">
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java
index 95a2a50011..b3d30bb75c 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtils.java
@@ -19,6 +19,7 @@ import java.util.List;
import org.eclipse.core.commands.IHandler;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizard;
@@ -30,6 +31,7 @@ import org.eclipse.linuxtools.docker.ui.Activator;
import org.eclipse.linuxtools.internal.docker.ui.RunConsole;
import org.eclipse.linuxtools.internal.docker.ui.preferences.PreferenceConstants;
import org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView;
+import org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView;
import org.eclipse.linuxtools.internal.docker.ui.views.DockerImagesView;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
@@ -70,6 +72,15 @@ public class CommandUtils {
return ((DockerContainersView) activePart).getConnection();
} else if (activePart instanceof DockerImagesView) {
return ((DockerImagesView) activePart).getConnection();
+ } else if (activePart instanceof DockerExplorerView) {
+ final ITreeSelection selection = ((DockerExplorerView) activePart)
+ .getCommonViewer().getStructuredSelection();
+ final Object firstElement = selection.getFirstElement();
+ if (firstElement instanceof IDockerContainer) {
+ return ((IDockerContainer) firstElement).getConnection();
+ } else if (firstElement instanceof IDockerImage) {
+ return ((IDockerImage) firstElement).getConnection();
+ }
}
return null;
}
@@ -85,6 +96,10 @@ public class CommandUtils {
if (activePart instanceof DockerContainersView) {
final ISelection selection = ((DockerContainersView) activePart).getSelection();
return getSelectedContainers(selection);
+ } else if (activePart instanceof DockerExplorerView) {
+ final ISelection selection = ((DockerExplorerView) activePart)
+ .getCommonViewer().getSelection();
+ return getSelectedContainers(selection);
}
return Collections.emptyList();
}
@@ -124,6 +139,10 @@ public class CommandUtils {
final ISelection selection = ((DockerImagesView) activePart)
.getSelection();
return getSelectedImages(selection);
+ } else if (activePart instanceof DockerExplorerView) {
+ final ISelection selection = ((DockerExplorerView) activePart)
+ .getCommonViewer().getSelection();
+ return getSelectedImages(selection);
}
return Collections.emptyList();
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerContentProvider.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerContentProvider.java
index 92b55f737f..8788aea68a 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerContentProvider.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerContentProvider.java
@@ -200,6 +200,32 @@ public class DockerExplorerContentProvider implements ITreeContentProvider {
return connection;
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((connection == null) ? 0 : connection.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;
+ DockerImagesCategory other = (DockerImagesCategory) obj;
+ if (connection == null) {
+ if (other.connection != null)
+ return false;
+ } else if (!connection.equals(other.connection))
+ return false;
+ return true;
+ }
+
}
public static class DockerContainersCategory {
@@ -218,6 +244,32 @@ public class DockerExplorerContentProvider implements ITreeContentProvider {
return connection;
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((connection == null) ? 0 : connection.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;
+ DockerContainersCategory other = (DockerContainersCategory) obj;
+ if (connection == null) {
+ if (other.connection != null)
+ return false;
+ } else if (!connection.equals(other.connection))
+ return false;
+ return true;
+ }
+
}
public static class LoadingStub {
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java
index adacc982b1..4d1602ca82 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java
@@ -11,18 +11,26 @@
package org.eclipse.linuxtools.internal.docker.ui.views;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
+import org.eclipse.linuxtools.docker.core.IDockerConnection;
import org.eclipse.linuxtools.docker.core.IDockerConnectionManagerListener;
import org.eclipse.linuxtools.docker.core.IDockerContainer;
+import org.eclipse.linuxtools.docker.core.IDockerContainerListener;
import org.eclipse.linuxtools.docker.core.IDockerImage;
+import org.eclipse.linuxtools.docker.core.IDockerImageListener;
import org.eclipse.linuxtools.internal.docker.ui.wizards.NewDockerConnection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -31,6 +39,7 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
@@ -57,6 +66,7 @@ public class DockerExplorerView extends CommonNavigator implements
private Control connectionsPane;
private Control explanationsPane;
private PageBook pageBook;
+ private Map<IDockerConnection, DockerContainersRefresher> containersRefreshers = new HashMap<>();
/** the search text widget. to filter containers and images. */
private Text search;
@@ -72,8 +82,6 @@ public class DockerExplorerView extends CommonNavigator implements
protected CommonViewer createCommonViewer(final Composite parent) {
final CommonViewer viewer = super.createCommonViewer(parent);
setLinkingEnabled(false);
- DockerConnectionManager.getInstance()
- .addConnectionManagerListener(this);
return viewer;
}
@@ -106,6 +114,9 @@ public class DockerExplorerView extends CommonNavigator implements
showConnectionsOrExplanations();
this.containersAndImagesSearchFilter = getContainersAndImagesSearchFilter();
getCommonViewer().addFilter(containersAndImagesSearchFilter);
+ DockerConnectionManager.getInstance()
+ .addConnectionManagerListener(this);
+
}
/**
@@ -207,7 +218,6 @@ public class DockerExplorerView extends CommonNavigator implements
// DockerExplorerView#changeEvent(int) method
// will be called and the pageBook will show the connectionsPane
// instead of the explanationsPane
-
}
};
}
@@ -222,12 +232,86 @@ public class DockerExplorerView extends CommonNavigator implements
pageBook.showPage(explanationsPane);
} else {
pageBook.showPage(connectionsPane);
+ registerListeners();
}
}
@Override
public void changeEvent(int type) {
showConnectionsOrExplanations();
+ switch(type) {
+ case IDockerConnectionManagerListener.ADD_EVENT:
+ registerListeners();
+ break;
+ case IDockerConnectionManagerListener.REMOVE_EVENT:
+ unregisterListeners();
+ break;
+ }
+ }
+
+ private void registerListeners() {
+ for (IDockerConnection connection : DockerConnectionManager
+ .getInstance().getConnections()) {
+ if (!containersRefreshers.containsKey(connection)) {
+ final DockerContainersRefresher containerRefresher = new DockerContainersRefresher();
+ connection.addContainerListener(containerRefresher);
+ containersRefreshers.put(connection, containerRefresher);
+ }
+ }
+ }
+
+ private void unregisterListeners() {
+ for (IDockerConnection connection : DockerConnectionManager
+ .getInstance().getConnections()) {
+ if (containersRefreshers.containsKey(connection)) {
+ final DockerContainersRefresher dockerContainersRefresher = containersRefreshers
+ .get(connection);
+ connection.removeContainerListener(dockerContainersRefresher);
+ containersRefreshers.remove(connection);
+ }
+ }
+ }
+
+ class DockerContainersRefresher implements IDockerContainerListener {
+ @Override
+ public void listChanged(final IDockerConnection connection,
+ final List<IDockerContainer> list) {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ // following is to force Container property testers
+ // to run again after list is updated. They won't do so by
+ // default.
+ ISelection selection = getCommonViewer().getSelection();
+ if (selection != null) {
+ getCommonViewer().setSelection(selection, false);
+ }
+ getCommonViewer().refresh(connection, true);
+ }
+ });
+ }
+ }
+
+ class DockerImagesRefresher implements IDockerImageListener {
+ @Override
+ public void listChanged(final IDockerConnection connection,
+ final List<IDockerImage> list) {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ // following is to force Image property testers
+ // to run again after list is updated. They won't do so by
+ // default.
+ ISelection selection = getCommonViewer().getSelection();
+ if (selection != null) {
+ getCommonViewer().setSelection(selection, false);
+ }
+ getCommonViewer().refresh(connection, true);
+ }
+ });
+ }
}
}

Back to the top