Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2016-02-02 20:58:03 +0000
committerJeff Johnston2016-02-02 21:59:18 +0000
commit6e32530e7658ef944a902a1c935ce0d2b898309e (patch)
treecd3ee7fc280a5fbfeda190802991ff7479597b57
parent9e40d478d6ba65c4da23b16b6994a1feec44b8b3 (diff)
downloadorg.eclipse.linuxtools-6e32530e7658ef944a902a1c935ce0d2b898309e.tar.gz
org.eclipse.linuxtools-6e32530e7658ef944a902a1c935ce0d2b898309e.tar.xz
org.eclipse.linuxtools-6e32530e7658ef944a902a1c935ce0d2b898309e.zip
Bug 484485 - Restore dialog when building Docker image if connection does not exist anymore
Showing the launch config editor sheet for the corresponding config when connection is missing Validating that a connection has been specified Added SWTBot tests to cover multiple cases, with utility class to import a project in the unit test workspace Removed "throws InterruptedException" where not applicable and fixed some Javadocs Change-Id: Id4c8477a2c1663fa413335ab48f89fa3e696c129 Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/65446 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> Reviewed-on: https://git.eclipse.org/r/65739
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/META-INF/MANIFEST.MF5
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/build.properties3
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/plugin.xml13
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/projects/foo/.project11
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/projects/foo/Dockerfile15
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/BaseSWTBotTest.java2
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtilsSWTBotTest.java2
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageShortcutSWTBotTest.java238
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/ProjectInitializationRule.java194
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/RunWithProject.java29
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/SyncFileSystemStructureProvider.java143
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/ClearLaunchConfigurationsRule.java57
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/CloseWelcomePageRule.java22
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java53
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/validators/ImageNameValidator.java38
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersViewSWTBotTest.java2
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesViewSWTBotTest.java6
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSWTBotTest.java4
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchSWTBotTest.java107
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/plugin.xml9
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/jobs/BuildDockerImageJob.java1
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationDelegate.java30
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationMainTab.java12
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageShortcut.java2
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/LaunchConfigurationUtils.java7
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/LaunchMessages.properties7
26 files changed, 933 insertions, 79 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/META-INF/MANIFEST.MF b/containers/org.eclipse.linuxtools.docker.ui.tests/META-INF/MANIFEST.MF
index aefebef5ee..b3e3a94c1a 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/META-INF/MANIFEST.MF
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: UI Tests
-Bundle-SymbolicName: org.eclipse.linuxtools.docker.ui.tests
+Bundle-SymbolicName: org.eclipse.linuxtools.docker.ui.tests;singleton:=true
Bundle-Version: 1.2.1.qualifier
Require-Bundle: org.eclipse.linuxtools.docker.ui;bundle-version="1.0.0",
org.junit;bundle-version="4.12.0",
@@ -27,6 +27,7 @@ Require-Bundle: org.eclipse.linuxtools.docker.ui;bundle-version="1.0.0",
com.fasterxml.jackson.core.jackson-core;bundle-version="2.5.0",
com.fasterxml.jackson.core.jackson-databind;bundle-version="2.5.0",
org.slf4j.api;bundle-version="1.7.2",
- org.glassfish.jersey.bundles.repackaged.jersey-guava;bundle-version="2.14.0"
+ org.glassfish.jersey.bundles.repackaged.jersey-guava;bundle-version="2.14.0",
+ org.eclipse.ui.ide
Bundle-ClassPath: .
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/build.properties b/containers/org.eclipse.linuxtools.docker.ui.tests/build.properties
index b107977f4e..cc91072ece 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/build.properties
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/build.properties
@@ -1,3 +1,4 @@
source.. = src/
bin.includes = META-INF/,\
- .
+ .,\
+ plugin.xml
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/plugin.xml b/containers/org.eclipse.linuxtools.docker.ui.tests/plugin.xml
new file mode 100644
index 0000000000..2774b58660
--- /dev/null
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <!-- this provides the "Run As" context menu when running tests with tycho. See http://insights.sigasi.com/tech/run-menu-item-strangely-disappearing-context-menu.html -->
+ <extension point="org.eclipse.core.runtime.adapters">
+ <factory class="org.eclipse.core.runtime.IAdaptable"
+ adaptableType="org.eclipse.core.resources.IResource">
+ <adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
+ </factory>
+ </extension>
+
+
+</plugin>
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/projects/foo/.project b/containers/org.eclipse.linuxtools.docker.ui.tests/projects/foo/.project
new file mode 100644
index 0000000000..96a133d22a
--- /dev/null
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/projects/foo/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>foo</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/projects/foo/Dockerfile b/containers/org.eclipse.linuxtools.docker.ui.tests/projects/foo/Dockerfile
new file mode 100644
index 0000000000..205344ec76
--- /dev/null
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/projects/foo/Dockerfile
@@ -0,0 +1,15 @@
+FROM jboss/wildfly:9.0.2.Final
+MAINTAINER xcoulon@redhat.com
+
+ENV postgres_module_dir=/opt/jboss/wildfly/modules/system/layers/base/postgresql/main/
+# add postgresql-jdbc jar and module.xml files
+RUN mkdir -p ${postgres_module_dir}
+ADD module.xml ${postgres_module_dir}
+WORKDIR ${postgres_module_dir}
+ADD postgresql-9.4-1201.jdbc41.jar ${postgres_module_dir}
+
+# replace the standalone.xml config file with our custom one
+ENV config_dir=/opt/jboss/wildfly/standalone/configuration/
+ADD standalone.xml ${config_dir}
+
+
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/BaseSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/BaseSWTBotTest.java
index 3af208ef59..f923fc9cf8 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/BaseSWTBotTest.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/BaseSWTBotTest.java
@@ -36,7 +36,7 @@ public abstract class BaseSWTBotTest {
bot.perspectiveById("org.eclipse.linuxtools.docker.ui.perspective").activate();
}
- public static void configureConnectionManager(final DockerExplorerView dockerExplorerView, final IDockerConnection... connections) throws InterruptedException {
+ public static void configureConnectionManager(final DockerExplorerView dockerExplorerView, final IDockerConnection... connections) {
DockerConnectionManager.getInstance()
.setConnectionStorageManager(MockDockerConnectionStorageManagerFactory.providing(connections));
SWTUtils.asyncExec(() -> {
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtilsSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtilsSWTBotTest.java
index 4038e979c7..1a8407be3f 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtilsSWTBotTest.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtilsSWTBotTest.java
@@ -51,7 +51,7 @@ public class CommandUtilsSWTBotTest {
public ClearConnectionManagerRule clearConnectionManager = new ClearConnectionManagerRule();
@Before
- public void lookupDockerExplorerView() throws InterruptedException {
+ public void lookupDockerExplorerView() {
SWTUtils.asyncExec(() -> {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageShortcutSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageShortcutSWTBotTest.java
new file mode 100644
index 0000000000..f06857172c
--- /dev/null
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageShortcutSWTBotTest.java
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - Initial Contribution
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.docker.ui.launch;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
+import org.eclipse.linuxtools.internal.docker.core.DockerConnection;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.MockDockerClientFactory;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.MockDockerConnectionFactory;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.ProjectInitializationRule;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.ClearConnectionManagerRule;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.ClearLaunchConfigurationsRule;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.CloseWelcomePageRule;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.DockerConnectionManagerUtils;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.SWTUtils;
+import org.eclipse.linuxtools.internal.docker.ui.wizards.WizardMessages;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+
+import com.spotify.docker.client.DockerClient;
+import com.spotify.docker.client.ProgressHandler;
+
+/**
+ * Testing the {@link BuildDockerImageShortcut}
+ */
+public class BuildDockerImageShortcutSWTBotTest {
+
+ @ClassRule
+ public static CloseWelcomePageRule closeWelcomePage = new CloseWelcomePageRule(
+ "org.eclipse.ui.resourcePerspective");
+
+ @Rule
+ public ClearConnectionManagerRule clearConnectionManager = new ClearConnectionManagerRule();
+
+ @Rule
+ public ProjectInitializationRule projectInit = new ProjectInitializationRule();
+
+ @Rule
+ public ClearLaunchConfigurationsRule clearLaunchConfig = new ClearLaunchConfigurationsRule(
+ IBuildDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID);
+
+ private SWTWorkbenchBot bot = new SWTWorkbenchBot();
+ private SWTBotView projectExplorerBotView;
+
+ @Before
+ public void setup() {
+ this.projectExplorerBotView = bot.viewById("org.eclipse.ui.navigator.ProjectExplorer");
+ this.projectExplorerBotView.setFocus();
+ }
+
+ /**
+ * @return the {@link SWTBotMenu} for the "Run as > Docker Image Build"
+ * shortcut
+ */
+ private SWTBotMenu getRunAsdockerImageBuildContextMenu(final String projectName, final String dockerFileName) {
+ final SWTBotTreeItem fooProjectTreeItem = SWTUtils.getTreeItem(this.projectExplorerBotView, projectName);
+ assertThat(fooProjectTreeItem).isNotNull();
+ SWTUtils.syncExec(() -> fooProjectTreeItem.expand());
+ final SWTBotTreeItem dockerfileTreeItem = SWTUtils.getTreeItem(fooProjectTreeItem, dockerFileName);
+ assertThat(dockerfileTreeItem).isNotNull();
+ SWTUtils.select(dockerfileTreeItem);
+ final SWTBotMenu runAsDockerImageBuildMenu = SWTUtils.getContextMenu(this.projectExplorerBotView.bot().tree(),
+ "Run As", "1 Docker Image Build");
+ return runAsDockerImageBuildMenu;
+ }
+
+ @Test
+ @RunWithProject("foo")
+ public void shouldDisableCommandOnFirstCallWhenMissingConnection() {
+ // given no connection
+ // when
+ SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
+ // then expect an error dialog
+ assertThat(bot.shell(LaunchMessages.getString("ImageBuildShortcut.error.msg"))).isNotNull();
+ // closing the wizard
+ SWTUtils.syncExec(() -> {
+ bot.button("OK").click();
+ });
+ }
+
+ @Test
+ @RunWithProject("foo")
+ public void shouldPromptDialogThenBuildDockerImageOnFirstCall()
+ throws InterruptedException, com.spotify.docker.client.DockerException, IOException {
+ // given
+ final DockerClient client = MockDockerClientFactory.build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // when
+ SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
+ // then expect a dialog, fill the "repository" text field and click "Ok"
+ assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
+ bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
+ // when launching the build
+ SWTUtils.syncExec(() -> {
+ bot.button("OK").click();
+ });
+ // then the 'DockerConnection#buildImage(...) method should have been
+ // called within the specified timeout
+ Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(3)).times(1)).build(
+ Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class),
+ Matchers.anyVararg());
+ }
+
+ @Test
+ @RunWithProject("foo")
+ public void shouldBuildDockerImageImmediatelyOnSecondCall()
+ throws InterruptedException, com.spotify.docker.client.DockerException, IOException {
+ // given
+ final DockerClient client = MockDockerClientFactory.build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // when
+ SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
+ // then expect a dialog, fill the "repository" text field and click "Ok"
+ assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
+ bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
+ // when launching the build
+ SWTUtils.syncExec(() -> {
+ bot.button("OK").click();
+ });
+ // then the 'DockerConnection#buildImage(...) method should have been
+ // called within the specified timeout
+ Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(3)).times(1)).build(
+ Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class),
+ Matchers.anyVararg());
+ // when trying to call again, there should be no dialog
+ SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
+ // then a second call should have been done
+ Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(3)).times(2)).build(
+ Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class),
+ Matchers.anyVararg());
+ }
+
+ @Test
+ @RunWithProject("foo")
+ public void shouldNotBuildDockerImageOnSecondCallWhenAllConnectionWereRemoved()
+ throws InterruptedException, com.spotify.docker.client.DockerException, IOException {
+ // given
+ final DockerClient client = MockDockerClientFactory.build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // when
+ SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
+ // then expect a dialog, fill the "repository" text field and click "Ok"
+ assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
+ bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
+ // when launching the build
+ SWTUtils.syncExec(() -> {
+ bot.button("OK").click();
+ });
+ // then the 'DockerConnection#buildImage(...) method should have been
+ // called within the specified timeout
+ Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(30)).times(1)).build(
+ Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class),
+ Matchers.anyVararg());
+ // when trying to call again after connection was removed, there should
+ // be an error dialog
+ DockerConnectionManager.getInstance().removeConnection(dockerConnection);
+ SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click(), false);
+ final SWTBotShell shell = bot.shell("Edit Configuration");
+ assertThat(shell).isNotNull();
+ assertThat(shell.bot().button("Run").isEnabled()).isFalse();
+ // closing the wizard
+ SWTUtils.asyncExec(() -> {
+ shell.bot().button(IDialogConstants.CLOSE_LABEL).click();
+ }, false);
+ // do not save the config while closing
+ SWTUtils.syncExec(() -> {
+ bot.button(IDialogConstants.NO_LABEL).click();
+ });
+ }
+
+ @RunWithProject("foo")
+ public void shouldPromptForAnotherConnectionWhenBuildingDockerImageOnSecondCallAfterConnectionWasReplaced()
+ throws InterruptedException, com.spotify.docker.client.DockerException, IOException {
+ // given
+ final DockerClient client = MockDockerClientFactory.build();
+ final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
+ // when
+ SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
+ // then expect a dialog, fill the "repository" text field and click "Ok"
+ assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
+ bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
+ // when launching the build
+ SWTUtils.syncExec(() -> {
+ bot.button("OK").click();
+ });
+ // then the 'DockerConnection#buildImage(...) method should have been
+ // called within the specified timeout
+ Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(3)).times(1)).build(
+ Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class),
+ Matchers.anyVararg());
+ // when trying to call again after connection was replaced, there should
+ // be an error dialog
+ final DockerConnection dockerConnection2 = MockDockerConnectionFactory.from("Test 2", client).get();
+ DockerConnectionManagerUtils.configureConnectionManager(dockerConnection2);
+ SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
+ // then expect a dialog, fill the "repository" text field and click "Ok"
+ assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
+ bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
+ // when launching the build
+ SWTUtils.syncExec(() -> {
+ bot.button("OK").click();
+ });
+ // then the 'DockerConnection#buildImage(...) method should have been
+ // called within the specified timeout
+ Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(3)).times(2)).build(
+ Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class),
+ Matchers.anyVararg());
+ }
+}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/ProjectInitializationRule.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/ProjectInitializationRule.java
new file mode 100644
index 0000000000..1811ec1c82
--- /dev/null
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/ProjectInitializationRule.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - Initial Contribution
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.docker.ui.testutils;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+import org.junit.rules.ExternalResource;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+/**
+ * JUnit {@link TestRule} to initialize a {@link IProject} in the test
+ * workspace, by reading the {@link RunWithProject} annotation on the test
+ * method.
+ */
+public class ProjectInitializationRule extends ExternalResource {
+
+ private Description description;
+
+ @Override
+ public Statement apply(final Statement base, final Description description) {
+ this.description = description;
+ return super.apply(base, description);
+ }
+
+ @Override
+ protected void before() throws Throwable {
+ if (description == null) {
+ fail("No method description available while trying to setup test project");
+ }
+ final String projectName = getProjectName();
+ final IWorkspace junitWorkspace = ResourcesPlugin.getWorkspace();
+ getTargetWorkspaceProject(getSampleProjectPath(projectName), junitWorkspace);
+ }
+
+ /**
+ * @return the name of the project to setup before running the JUnit test.
+ * @throws NoSuchMethodException
+ * @throws ClassNotFoundException
+ */
+ private String getProjectName() throws NoSuchMethodException, ClassNotFoundException {
+ final String className = description.getClassName();
+ final String methodName = description.getMethodName();
+ final Class<?> testClass = Class.forName(className);
+ final Method testMethod = testClass.getMethod(methodName);
+ final RunWithProject runWithProjectMethodAnnotation = testMethod.getAnnotation(RunWithProject.class);
+ if (runWithProjectMethodAnnotation != null) {
+ return runWithProjectMethodAnnotation.value();
+ }
+ final RunWithProject runWithProjectTypeAnnotation = testClass.getAnnotation(RunWithProject.class);
+ if (runWithProjectTypeAnnotation != null) {
+ return runWithProjectTypeAnnotation.value();
+ }
+ fail("No @RunWithProject found while running test " + className + "." + methodName);
+ return null;
+ }
+
+ /**
+ * @param projectName
+ * the name of the project
+ * @return the {@link IPath} to the given project, in an absolute form.
+ */
+ public static IPath getSampleProjectPath(final String projectName) {
+ if (System.getProperty("user.dir") != null) {
+ return new Path(System.getProperty("user.dir")).append("projects").append(projectName).makeAbsolute();
+ }
+ fail("The sample project was not found in the launcher workspace under name '" + projectName + "'");
+ return null;
+ }
+
+ /**
+ * Creates or opens the project in the target/JUnit workspace.
+ *
+ * @param projectSourcePath
+ * the absolute path to the project
+ * @param targetWorkspace
+ * the target workspace in which the project should be created
+ * @return the project
+ * @throws CoreException
+ * @throws InvocationTargetException
+ * @throws InterruptedException
+ */
+ public static IProject getTargetWorkspaceProject(final IPath projectSourcePath, final IWorkspace targetWorkspace)
+ throws CoreException, InvocationTargetException, InterruptedException {
+ final IPath dotProjectPath = projectSourcePath.addTrailingSeparator().append(".project");
+ final IProjectDescription description = targetWorkspace.loadProjectDescription(dotProjectPath);
+ final String projectName = description.getName();
+ final IProject project = targetWorkspace.getRoot().getProject(projectName);
+ if (project.exists()
+ && !targetWorkspace.getRoot().getFile(project.getFile(".project").getFullPath()).exists()) {
+ project.delete(true, null);
+ } else if (project.exists() && !project.isOpen()) {
+ project.open(null);
+ } else if (!project.exists()) {
+ createProject(description, projectName, targetWorkspace, project);
+ final SyncFileSystemStructureProvider syncFileSystemStructureProvider = new SyncFileSystemStructureProvider.Builder(
+ projectSourcePath, project.getLocation()).ignoreRelativeSourcePaths(".svn", ".git", "target", "bin")
+ .build();
+ final List<File> filesToImport = syncFileSystemStructureProvider.getChildren(projectSourcePath.toFile());
+ if (filesToImport != null && filesToImport.size() > 0) {
+ ImportOperation operation = new ImportOperation(project.getFullPath(), projectSourcePath.toFile(),
+ syncFileSystemStructureProvider, new IOverwriteQuery() {
+ @Override
+ public String queryOverwrite(String pathString) {
+ return IOverwriteQuery.YES;
+ }
+ }, filesToImport);
+ operation.setContext(null);
+ // need to overwrite modified files
+ operation.setOverwriteResources(true);
+ operation.setCreateContainerStructure(false);
+ operation.run(null);
+ }
+ }
+ return project;
+ }
+
+ /**
+ * @param description
+ * @param projectName
+ * @param workspace
+ * @param project
+ * @throws InvocationTargetException
+ * @throws InterruptedException
+ * @throws CoreException
+ * @throws OperationCanceledException
+ */
+ static void createProject(final IProjectDescription description, final String projectName,
+ final IWorkspace workspace, final IProject project)
+ throws InvocationTargetException, OperationCanceledException, CoreException, InterruptedException {
+ // import from file system
+
+ // import project from location copying files - use default project
+ // location for this workspace
+ // if location is null, project already exists in this location or
+ // some error condition occurred.
+ final IProjectDescription desc = workspace.newProjectDescription(projectName);
+ desc.setBuildSpec(description.getBuildSpec());
+ desc.setComment(description.getComment());
+ desc.setDynamicReferences(description.getDynamicReferences());
+ desc.setNatureIds(description.getNatureIds());
+ desc.setReferencedProjects(description.getReferencedProjects());
+ try {
+ project.create(desc, null);
+ project.open(IResource.BACKGROUND_REFRESH, null);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ buildProject(project);
+ }
+
+ /**
+ * Builds the given project
+ *
+ * @param project
+ * @throws CoreException
+ * @throws OperationCanceledException
+ * @throws InterruptedException
+ */
+ public static void buildProject(final IProject project)
+ throws CoreException, OperationCanceledException, InterruptedException {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ project.build(IncrementalProjectBuilder.FULL_BUILD, null);
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_BUILD, null);
+ }
+}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/RunWithProject.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/RunWithProject.java
new file mode 100644
index 0000000000..e9877e9b96
--- /dev/null
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/RunWithProject.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - Initial Contribution
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.docker.ui.testutils;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Custom annotation that indicates with workspace project should be used.
+ *
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface RunWithProject {
+
+ /** The name of the project to initialize. */
+ public String value();
+
+}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/SyncFileSystemStructureProvider.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/SyncFileSystemStructureProvider.java
new file mode 100644
index 0000000000..feaeec0101
--- /dev/null
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/SyncFileSystemStructureProvider.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - Initial Contribution
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.docker.ui.testutils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
+
+/**
+ * Copy of the org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider
+ * with the following changes : - Removed the singleton nature of the original
+ * class - Only returns modified files between source and destination
+ * directories
+ *
+ */
+@SuppressWarnings("restriction")
+public class SyncFileSystemStructureProvider implements IImportStructureProvider {
+
+ private final IPath source;
+
+ private final IPath destination;
+
+ private final List<String> ignoredRelativePaths;
+
+ /**
+ * Creates an instance of <code>SyncFileSystemStructureProvider</code>.
+ *
+ * @param source
+ */
+ private SyncFileSystemStructureProvider(final IPath source, final IPath destination, final List<String> ignoredRelativePaths) {
+ super();
+ this.source = source;
+ this.destination = destination;
+ this.ignoredRelativePaths = ignoredRelativePaths;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IImportStructureProvider
+ */
+ @Override
+ public List<File> getChildren(Object element) {
+ File folder = (File) element;
+ String[] children = folder.list();
+ int childrenLength = children == null ? 0 : children.length;
+ List<File> result = new ArrayList<>(childrenLength);
+
+ for (int i = 0; i < childrenLength; i++) {
+ File sourceFile = new File(folder, children[i]);
+ IPath relativeSourcePath = new Path(sourceFile.getAbsolutePath()).makeRelativeTo(source);
+ // always add the sub directories
+ if (ignoredRelativePaths.contains(relativeSourcePath.lastSegment())) {
+ continue;
+ }
+ if (sourceFile.isDirectory() && !ignoredRelativePaths.contains(relativeSourcePath.lastSegment())) {
+ result.addAll(getChildren(sourceFile));
+ }
+ // only add the other files if they are missing or were modified in
+ // the destination destination
+ else {
+ IPath relativeDestinationPath = destination.append(relativeSourcePath);
+ File destinationFile = new File(relativeDestinationPath.toOSString());
+ if (!destinationFile.exists() || destinationFile.lastModified() < sourceFile.lastModified()) {
+ result.add(sourceFile);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public InputStream getContents(Object element) {
+ try {
+ return new FileInputStream((File) element);
+ } catch (FileNotFoundException e) {
+ IDEWorkbenchPlugin.log(e.getLocalizedMessage(), e);
+ return null;
+ }
+ }
+
+ @Override
+ public String getFullPath(Object element) {
+ return ((File) element).getPath();
+ }
+
+ @Override
+ public String getLabel(Object element) {
+ // Get the name - if it is empty then return the path as it is a file
+ // root
+ File file = (File) element;
+ String name = file.getName();
+ if (name.length() == 0) {
+ return file.getPath();
+ }
+ return name;
+ }
+
+ @Override
+ public boolean isFolder(Object element) {
+ return ((File) element).isDirectory();
+ }
+
+ public static class Builder {
+ private final IPath source;
+
+ private final IPath destination;
+
+ private final List<String> ignoredRelativePaths = new ArrayList<>();
+
+ public Builder(final IPath source, final IPath destination) {
+ super();
+ this.source = source;
+ this.destination = destination;
+ }
+
+ public Builder ignoreRelativeSourcePaths(final String... relativePaths) {
+ this.ignoredRelativePaths.addAll(Arrays.asList(relativePaths));
+ return this;
+ }
+
+ public SyncFileSystemStructureProvider build() {
+ return new SyncFileSystemStructureProvider(source, destination, ignoredRelativePaths);
+ }
+ }
+
+}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/ClearLaunchConfigurationsRule.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/ClearLaunchConfigurationsRule.java
new file mode 100644
index 0000000000..32843734de
--- /dev/null
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/ClearLaunchConfigurationsRule.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - Initial Contribution
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.docker.ui.testutils.swt;
+
+import static org.junit.Assert.fail;
+
+import java.util.stream.Stream;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.linuxtools.internal.docker.ui.launch.LaunchConfigurationUtils;
+import org.junit.rules.ExternalResource;
+
+/**
+ * Removes all {@link ILaunchConfiguration} of a given type
+ */
+public class ClearLaunchConfigurationsRule extends ExternalResource {
+
+ /** the id of {@link ILaunchConfiguration} type to remove. */
+ private final String launchConfigTypeId;
+
+ /**
+ * Constructor
+ *
+ * @param launchConfigTypeId
+ * the id of the {@link ILaunchConfiguration} type to remove.
+ */
+ public ClearLaunchConfigurationsRule(final String launchConfigTypeId) {
+ this.launchConfigTypeId = launchConfigTypeId;
+ }
+
+ @Override
+ protected void before() throws Throwable {
+ final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ final ILaunchConfigurationType launchConfigType = LaunchConfigurationUtils
+ .getLaunchConfigType(launchConfigTypeId);
+ Stream.of(manager.getLaunchConfigurations(launchConfigType)).forEach(launchConfig -> {
+ try {
+ launchConfig.delete();
+ } catch (Exception e) {
+ fail("Failed to remove a launch configuration '" + launchConfig.getName() + "' of type '"
+ + this.launchConfigTypeId + "'");
+ }
+ });
+ }
+}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/CloseWelcomePageRule.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/CloseWelcomePageRule.java
index 1f51642692..2c08de7172 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/CloseWelcomePageRule.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/CloseWelcomePageRule.java
@@ -17,10 +17,28 @@ import org.eclipse.ui.PlatformUI;
import org.junit.rules.ExternalResource;
/**
- * Closes the Welcome page
+ * Closes the Welcome page and optionally opens a given perspective
*/
public class CloseWelcomePageRule extends ExternalResource {
+ /** the Id of the perspective to open. */
+ private final String defaultPerspectiveId;
+
+ /**
+ * Default constructor when the "Docker tooling" perspective is going to be opened once the welcome page was closed.
+ */
+ public CloseWelcomePageRule() {
+ this.defaultPerspectiveId = "org.eclipse.linuxtools.docker.ui.perspective";
+ }
+
+ /**
+ * Custom constructor with the id of the perspective to open once the welcome page was closed.
+ * @param perspectiveId the id of the perspective to open.
+ */
+ public CloseWelcomePageRule(final String perspectiveId) {
+ this.defaultPerspectiveId = perspectiveId;
+ }
+
@Override
protected void before() {
Display.getDefault().syncExec(() -> {
@@ -30,6 +48,6 @@ public class CloseWelcomePageRule extends ExternalResource {
}
});
final SWTWorkbenchBot bot = new SWTWorkbenchBot();
- bot.perspectiveById("org.eclipse.linuxtools.docker.ui.perspective").activate(); //$NON-NLS-1$
+ bot.perspectiveById(defaultPerspectiveId).activate();
}
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java
index 16277e7c7d..7e8eec72e7 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/SWTUtils.java
@@ -108,10 +108,26 @@ public class SWTUtils {
* @throws InterruptedException
*/
public static void asyncExec(final Runnable runnable) {
+ asyncExec(runnable, true);
+ }
+
+ /**
+ * Executes the given {@link Runnable} <strong>asynchronously</strong> in
+ * the default {@link Display} and waits until all jobs are done before
+ * completing.
+ *
+ * @param runnable
+ * the {@link Runnable} to execute
+ * @param waitForJobsToComplete
+ * boolean flag to indicate if the method should wait for all
+ * jobs to complete before finishing
+ * @throws InterruptedException
+ */
+ public static void asyncExec(final Runnable runnable, final boolean waitForJobsToComplete) {
final Queue<ComparisonFailure> failure = new ArrayBlockingQueue<>(1);
final Queue<SWTException> swtException = new ArrayBlockingQueue<>(1);
Display.getDefault().asyncExec(new Runnable() {
-
+
@Override
public void run() {
try {
@@ -123,7 +139,9 @@ public class SWTUtils {
}
}
});
- waitForJobsToComplete();
+ if(waitForJobsToComplete) {
+ waitForJobsToComplete();
+ }
if (!failure.isEmpty()) {
throw failure.poll();
}
@@ -222,16 +240,45 @@ public class SWTUtils {
*
* @param parentTreeItem
* the parent tree item
+ * @param firstItem
+ * the first item to select
+ * @param otherItems
+ * the other items to select
+ */
+ public static void select(final SWTBotTreeItem parentTreeItem, final String firstItem, final String... otherItems) {
+ final String[] matchItems = new String[otherItems.length];
+ matchItems[0] = firstItem;
+ select(parentTreeItem, matchItems);
+ }
+
+ /**
+ * Selects <strong> all child items</strong> in the given <code>parentTreeItem</code> whose
+ * labels match the given <code>items</code>.
+ *
+ * @param parentTreeItem
+ * the parent tree item
* @param matchItems
* the items to select
*/
- public static void select(SWTBotTreeItem parentTreeItem, String... matchItems) {
+ public static void select(final SWTBotTreeItem parentTreeItem, final String[] matchItems) {
final List<String> fullyQualifiedItems = Stream.of(parentTreeItem.getItems())
.filter(treeItem -> Stream.of(matchItems)
.anyMatch(matchItem -> treeItem.getText().startsWith(matchItem)))
.map(item -> item.getText()).collect(Collectors.toList());
parentTreeItem.select(fullyQualifiedItems.toArray(new String[0]));
}
+ /**
+ * Selects the given <code>treeItem</code> whose
+ * labels match the given <code>items</code>.
+ *
+ * @param treeItem
+ * the parent tree item
+ * @param matchItems
+ * the items to select
+ */
+ public static void select(SWTBotTreeItem treeItem) {
+ treeItem.select();
+ }
/**
* @param tree the root {@link SWTBotTree}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/validators/ImageNameValidator.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/validators/ImageNameValidator.java
new file mode 100644
index 0000000000..402c249b57
--- /dev/null
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/validators/ImageNameValidator.java
@@ -0,0 +1,38 @@
+package org.eclipse.linuxtools.internal.docker.ui.validators;
+
+import java.util.regex.Matcher;
+
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.linuxtools.internal.docker.core.DockerImage;
+import org.eclipse.linuxtools.internal.docker.ui.wizards.WizardMessages;
+
+/**
+ * Validates that the image name matches
+ * [REGISTRY_HOST[:REGISTRY_PORT]/]IMAGE_NAME[:TAG]
+ */
+public class ImageNameValidator implements IValidator {
+
+ @Override
+ public IStatus validate(final Object value) {
+ final String imageName = (String) value;
+ if (imageName.isEmpty()) {
+ return ValidationStatus
+ .cancel(WizardMessages.getString("ImagePull.desc")); //$NON-NLS-1$
+ }
+ final Matcher matcher = DockerImage.imageNamePattern
+ .matcher(imageName);
+ if (!matcher.matches()) {
+ return ValidationStatus.warning(WizardMessages
+ .getString("ImagePull.name.invalidformat.msg")); //$NON-NLS-1$
+ } else if (matcher.group("tag") == null) { //$NON-NLS-1$
+ return ValidationStatus.warning(
+ WizardMessages.getString("ImagePull.assumeLatest.msg")); //$NON-NLS-1$
+
+ }
+ return Status.OK_STATUS;
+ }
+
+} \ No newline at end of file
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersViewSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersViewSWTBotTest.java
index c3d2390efe..2c8aa39a0c 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersViewSWTBotTest.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerContainersViewSWTBotTest.java
@@ -41,7 +41,6 @@ public class DockerContainersViewSWTBotTest {
private SWTWorkbenchBot bot = new SWTWorkbenchBot();
private SWTBotView dockerContainersViewBot;
- private DockerContainersView dockerContainersView;
private SWTBotView dockerExplorerBotView;
@ClassRule
@@ -64,7 +63,6 @@ public class DockerContainersViewSWTBotTest {
Assert.fail("Failed to open Docker Explorer view: " + e.getMessage());
}});
this.dockerContainersViewBot = bot.viewById(DockerContainersView.VIEW_ID);
- this.dockerContainersView = (DockerContainersView) (dockerContainersViewBot.getViewReference().getView(true));
this.dockerExplorerBotView = bot.viewById(DockerExplorerView.VIEW_ID);
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesViewSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesViewSWTBotTest.java
index 68747cd114..9c2bddfd32 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesViewSWTBotTest.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerImagesViewSWTBotTest.java
@@ -26,7 +26,6 @@ import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.ui.PlatformUI;
import org.junit.Assert;
import org.junit.Before;
@@ -44,7 +43,6 @@ public class DockerImagesViewSWTBotTest {
private SWTWorkbenchBot bot = new SWTWorkbenchBot();
private SWTBotView dockerImagesViewBot;
private DockerImagesView dockerImagesView;
- private SWTBotTree dockerImagesViewTreeBot;
@ClassRule
public static CloseWelcomePageRule closeWelcomePage = new CloseWelcomePageRule();
@@ -56,7 +54,7 @@ public class DockerImagesViewSWTBotTest {
public ClearConnectionManagerRule clearConnectionManager = new ClearConnectionManagerRule();
@Before
- public void setup() throws InterruptedException {
+ public void setup() {
this.bot = new SWTWorkbenchBot();
SWTUtils.asyncExec(() -> {try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
@@ -70,7 +68,7 @@ public class DockerImagesViewSWTBotTest {
}
@Test
- public void shouldShowAllImageVariants() throws InterruptedException {
+ public void shouldShowAllImageVariants() {
// given
final DockerClient client = MockDockerClientFactory
.image(MockDockerImageFactory.id("1a2b3c4d5e6f7g").name("foo:1.0", "foo:latest", "bar:1.0", "bar:latest").build())
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSWTBotTest.java
index f19b2e1528..b8ecd8b678 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSWTBotTest.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSWTBotTest.java
@@ -81,7 +81,7 @@ public class ImageRunSWTBotTest {
}
@Test
- public void shouldReportErrorIfContainerWithSameNameExists() throws InterruptedException {
+ public void shouldReportErrorIfContainerWithSameNameExists() {
// given
final DockerClient client = MockDockerClientFactory.image(MockDockerImageFactory.name("foo:latest").build())
.container(MockDockerContainerFactory.name("foo_bar").build()).build();
@@ -106,7 +106,7 @@ public class ImageRunSWTBotTest {
}
@Test
- public void shouldNotReportErrorIfNoContainerWithSameNameExists() throws InterruptedException {
+ public void shouldNotReportErrorIfNoContainerWithSameNameExists() {
// given
final DockerClient client = MockDockerClientFactory.image(MockDockerImageFactory.name("foo:latest").build())
.container(MockDockerContainerFactory.name("foo_bar").build()).build();
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchSWTBotTest.java
index 9f529b3eba..a4c0dd5726 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchSWTBotTest.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearchSWTBotTest.java
@@ -61,57 +61,90 @@ public class ImageSearchSWTBotTest {
dockerExplorerViewBot.setFocus();
}
- @Test
- public void shouldTriggerSearchIfTermWasGiven() throws InterruptedException {
- // given
- final DockerClient client = MockDockerClientFactory
- .onSearch("foo", MockImageSearchResultFactory.name("foo").build()).build();
+ private void openPullWizard(final DockerClient client) {
+ // given
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// expand the 'Images' node
SWTUtils.syncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
final SWTBotTreeItem imagesTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images");
-
// when opening the "Pull..." wizard
final SWTBotTree dockerExplorerViewTreeBot = dockerExplorerViewBot.bot().tree();
dockerExplorerViewTreeBot.select(imagesTreeItem);
dockerExplorerViewTreeBot.contextMenu("Pull...").click();
-
- // when specifying a term
- bot.textWithLabel(WizardMessages.getString("ImagePull.name.label")).setText("foo");
-
- // when clicking on the "Search..." button
- bot.button(WizardMessages.getString("ImagePull.search.label")).click();
- // then the search should have been triggered and results should be
- // available
- assertThat(bot.table().rowCount()).isEqualTo(1);
}
- @Test
- public void shouldNotTriggerSearchIfNoTermWasGiven() throws InterruptedException {
- // given
- final DockerClient client = MockDockerClientFactory
- .onSearch("foo", MockImageSearchResultFactory.name("foo").build()).build();
- final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).get();
- DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
- // expand the 'Images' node
- SWTUtils.syncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
- final SWTBotTreeItem imagesTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images");
-
- // when opening the "Pull..." wizard
- final SWTBotTree dockerExplorerViewTreeBot = dockerExplorerViewBot.bot().tree();
- dockerExplorerViewTreeBot.select(imagesTreeItem);
- dockerExplorerViewTreeBot.contextMenu("Pull...").click();
-
- // when clicking on the "Search..." button *without specifying a term before*
+ private void openSearchWizard() {
+ // click on the "Search..." button
bot.button(WizardMessages.getString("ImagePull.search.label")).click();
- // then the search should have been triggered and results should be
- // available
- assertThat(bot.table().rowCount()).isEqualTo(0);
}
-
+
+ @Test
+ public void shouldTriggerSearchIfTermWasGiven() {
+ // given
+ final DockerClient client = MockDockerClientFactory.onSearch("foo", MockImageSearchResultFactory.name("foo").build())
+ .build();
+ // when opening the pull wizard...
+ openPullWizard(client);
+ // ... and specifying a term...
+ bot.textWithLabel(WizardMessages.getString("ImagePull.name.label")).setText("foo");
+ // ... and then opening the search wizard
+ openSearchWizard();
+ // then the search should have been triggered and results should be available
+ assertThat(bot.table().rowCount()).isEqualTo(1);
+ }
+
+ @Test
+ public void shouldNotTriggerSearchIfNoTermWasGiven() {
+ // given
+ final DockerClient client = MockDockerClientFactory.onSearch("foo", MockImageSearchResultFactory.name("foo").build())
+ .build();
+ // when opening the pull wizard...
+ openPullWizard(client);
+ // ... and directly opening the search wizard
+ openSearchWizard();
+ // then the search should have been triggered and results should be available
+ assertThat(bot.table().rowCount()).isEqualTo(0);
+ }
+
+ @Test
+ public void shouldReduceSearchResultsToExactGivenTerm() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .onSearch("foo/bar", MockImageSearchResultFactory.name("foo/bar").build(),
+ MockImageSearchResultFactory.name("other/bar").build())
+ .build();
+ // when opening the pull wizard...
+ openPullWizard(client);
+ // ... and specifying a term...
+ bot.textWithLabel(WizardMessages.getString("ImagePull.name.label")).setText("foo/bar");
+ // ... and then opening the search wizard
+ openSearchWizard();
+ // then the search should have been triggered and a single result should be
+ // available
+ assertThat(bot.table().rowCount()).isEqualTo(1);
+ }
+
+ @Test
+ public void shouldShowAllSearchResultsForGivenTerm() {
+ // given
+ final DockerClient client = MockDockerClientFactory
+ .onSearch("bar", MockImageSearchResultFactory.name("foo/bar").build(),
+ MockImageSearchResultFactory.name("other/bar").build())
+ .build();
+ // when opening the pull wizard...
+ openPullWizard(client);
+ // ... and specifying a term...
+ bot.textWithLabel(WizardMessages.getString("ImagePull.name.label")).setText("bar");
+ // ... and then opening the search wizard
+ openSearchWizard();
+ // then the search should have been triggered and both results should be
+ // available
+ assertThat(bot.table().rowCount()).isEqualTo(2);
+ }
+
@Test
- public void shouldAllowForDefaultLatestTag() throws InterruptedException {
+ public void shouldAllowForDefaultLatestTag() {
// given
final DockerClient client = MockDockerClientFactory
.onSearch("foo", MockImageSearchResultFactory.name("foo").build()).build();
diff --git a/containers/org.eclipse.linuxtools.docker.ui/plugin.xml b/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
index 18c56269dd..d436a8b223 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
+++ b/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
@@ -1488,13 +1488,16 @@
<enablement>
<with variable="selection">
<count value="1"/>
- <iterate>
+ <iterate
+ ifEmpty="false"
+ operator="or">
<adapt
type="org.eclipse.core.resources.IResource">
<and>
<test
- property="org.eclipse.core.resources.name"
- value="Dockerfile">
+ forcePluginActivation="true"
+ property="org.eclipse.core.resources.name"
+ value="Dockerfile">
</test>
</and>
</adapt>
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/jobs/BuildDockerImageJob.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/jobs/BuildDockerImageJob.java
index 97721c6d9b..3c7f6aad13 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/jobs/BuildDockerImageJob.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/jobs/BuildDockerImageJob.java
@@ -81,6 +81,7 @@ public class BuildDockerImageJob extends Job implements IDockerProgressHandler {
* the optional repoName (i.e., repo[tag]) for the image to build
* @param buildOptions
* build options
+ * @throws DockerException
* @throws IOException
* @see {@link IBuildDockerImageLaunchConfigurationConstants} for build
* options.
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationDelegate.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationDelegate.java
index 387051cb4e..0f8709ce09 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationDelegate.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationDelegate.java
@@ -32,12 +32,15 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
import org.eclipse.linuxtools.docker.core.DockerException;
import org.eclipse.linuxtools.docker.core.IDockerConnection;
import org.eclipse.linuxtools.docker.ui.Activator;
import org.eclipse.linuxtools.internal.docker.core.DockerConnection;
import org.eclipse.linuxtools.internal.docker.ui.jobs.BuildDockerImageJob;
+import org.eclipse.swt.widgets.Display;
/**
* The {@link ILaunchConfigurationDelegate} to trigger the build of a Docker
@@ -47,7 +50,7 @@ import org.eclipse.linuxtools.internal.docker.ui.jobs.BuildDockerImageJob;
public class BuildDockerImageLaunchConfigurationDelegate
implements ILaunchConfigurationDelegate {
- private static final String MISSING_CONNECTION_ERROR_MSG = "MissingConnectionError.msg"; //$NON-NLS-1$
+ private static final String MISSING_CONNECTION_ERROR_MSG = "ImageBuildShortcutMissingConnection.msg"; //$NON-NLS-1$
@Override
public void launch(final ILaunchConfiguration configuration,
@@ -75,22 +78,27 @@ public class BuildDockerImageLaunchConfigurationDelegate
.getAttribute(RM_INTERMEDIATE_CONTAINERS, true));
buildOptions.put(FORCE_RM_INTERMEDIATE_CONTAINERS, configuration
.getAttribute(FORCE_RM_INTERMEDIATE_CONTAINERS, false));
- if (connection == null) {
- Activator
- .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- LaunchMessages.getFormattedString(
- MISSING_CONNECTION_ERROR_MSG,
- connectionName)));
- }
try {
if (connection != null && sourcePath != null) {
final Job buildImageJob = new BuildDockerImageJob(connection,
sourcePath, repoName, buildOptions);
buildImageJob.schedule();
} else {
- Activator.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID,
- LaunchMessages.getString(
- "BuildDockerImageLaunchConfiguration.error.incomplete"))); //$NON-NLS-1$
+ final ILaunchGroup launchGroup = DebugUITools
+ .getLaunchGroup(configuration, "run"); //$NON-NLS-1$
+ // prompt the user with the launch configuration editor
+ Display.getDefault().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ DebugUITools.openLaunchConfigurationDialog(
+ Display.getDefault().getActiveShell(),
+ configuration, launchGroup.getIdentifier(),
+ null);
+ }
+
+ });
+
}
} catch (DockerException e) {
Activator.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationMainTab.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationMainTab.java
index 97d27f0251..4ffe06061d 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationMainTab.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageLaunchConfigurationMainTab.java
@@ -68,6 +68,7 @@ public class BuildDockerImageLaunchConfigurationMainTab
private final String TAB_NAME = "BuildDockerImageLaunchConfigurationMainTab.name"; //$NON-NLS-1$
private final String CONNECTION_LABEL = "BuildDockerImageLaunchConfigurationMainTab.connection.group.label"; //$NON-NLS-1$
private final String CONNECTION_TOOLTIP = "BuildDockerImageLaunchConfigurationMainTab.connection.group.tooltip"; //$NON-NLS-1$
+ private final String CONNECTION_MISSING = "BuildDockerImageLaunchConfigurationMainTab.connection.missing"; //$NON-NLS-1$
private final String BUILD_CONTEXT_PATH_LABEL = "BuildDockerImageLaunchConfigurationMainTab.buildContextPath.group.label"; //$NON-NLS-1$
private final String BUILD_CONTEXT_PATH_MISSING = "BuildDockerImageLaunchConfigurationMainTab.buildContextPath.missing"; //$NON-NLS-1$
private final String DOCKERFILE_PATH_LABEL = "BuildDockerImageLaunchConfigurationMainTab.dockerfilePath.group.label"; //$NON-NLS-1$
@@ -419,12 +420,21 @@ public class BuildDockerImageLaunchConfigurationMainTab
@Override
public boolean isValid(final ILaunchConfiguration launchConfig) {
try {
+ // verify the connection
+ final String dockerConnection = launchConfig
+ .getAttribute(DOCKER_CONNECTION, ""); // $NON-NLS-1$
+ // verify the source path
final String sourcePathLocation = launchConfig
.getAttribute(SOURCE_PATH_LOCATION, ""); // $NON-NLS-1$
final boolean sourcePathWorkspaceRelativeLocation = launchConfig.getAttribute(SOURCE_PATH_WORKSPACE_RELATIVE_LOCATION, false);
final IPath sourcePath = BuildDockerImageUtils.getPath(
sourcePathLocation, sourcePathWorkspaceRelativeLocation);
- if (sourcePathLocation.isEmpty() || sourcePath == null) {
+ if (dockerConnection.isEmpty() || dockerConnection == null
+ || DockerConnectionManager.getInstance()
+ .findConnection(dockerConnection) == null) {
+ setErrorMessage(LaunchMessages.getString(CONNECTION_MISSING));
+ return false;
+ } else if (sourcePathLocation.isEmpty() || sourcePath == null) {
setErrorMessage(
LaunchMessages.getString(BUILD_CONTEXT_PATH_MISSING));
return false;
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageShortcut.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageShortcut.java
index 7ce664e40d..7f134ce963 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageShortcut.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/BuildDockerImageShortcut.java
@@ -48,7 +48,7 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog;
public class BuildDockerImageShortcut implements ILaunchShortcut {
private static final String LaunchShortcut_Error_Launching = "ImageBuildShortcut.error.msg"; //$NON-NLS-1$
- private static final String LaunchShortcut_No_Connections = "NoConnection.error.msg"; //$NON-NLS-1$
+ private static final String LaunchShortcut_No_Connections = "ImageBuildShortcutMissingConnection.msg"; //$NON-NLS-1$
private static final String LaunchShortcut_Config_Selection = "ImageBuildShortcutConfigSelection.title"; //$NON-NLS-1$
private static final String LaunchShortcut_Choose_Launch = "ImageBuildShortcutChooseLaunch.msg"; //$NON-NLS-1$
private static final String LaunchShortcut_Connection_Selection = "ImageBuildShortcutConnectionSelection.title"; //$NON-NLS-1$
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/LaunchConfigurationUtils.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/LaunchConfigurationUtils.java
index 2b8e3c3f90..d34010e495 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/LaunchConfigurationUtils.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/LaunchConfigurationUtils.java
@@ -69,8 +69,6 @@ import org.eclipse.swt.widgets.Button;
*/
public class LaunchConfigurationUtils {
- public static final String RUN_IMAGE_CONFIGURATION_TYPE = "org.eclipse.linuxtools.docker.ui.runDockerImageLaunchConfigurationType"; //$NON-NLS-1$
-
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
"YYYY-MM-dd HH:mm:ss");
@@ -122,7 +120,8 @@ public class LaunchConfigurationUtils {
final ILaunchManager manager = DebugPlugin.getDefault()
.getLaunchManager();
final ILaunchConfigurationType type = manager
- .getLaunchConfigurationType(RUN_IMAGE_CONFIGURATION_TYPE);
+ .getLaunchConfigurationType(
+ IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID);
final String imageName = image.repoTags().get(0);
// using the image repo + first tag
final ILaunchConfigurationWorkingCopy workingCopy = getLaunchConfigurationworkingCopy(
@@ -325,7 +324,6 @@ public class LaunchConfigurationUtils {
return lastLaunchConfiguration;
}
-
/**
* Returns the {@link ILaunchConfigurationWorkingCopy} with the given type
* and <strong>IDockerImage's name</strong>.
@@ -478,4 +476,5 @@ public class LaunchConfigurationUtils {
}
return path;
}
+
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/LaunchMessages.properties b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/LaunchMessages.properties
index 0f26bfc90a..c87e72861b 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/LaunchMessages.properties
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/launch/LaunchMessages.properties
@@ -14,6 +14,7 @@ BuildDockerImageLaunchConfiguration.error.incomplete=Launch configuration to bui
BuildDockerImageLaunchConfigurationMainTab.name=Main
BuildDockerImageLaunchConfigurationMainTab.connection.group.label=Docker Connection
BuildDockerImageLaunchConfigurationMainTab.connection.group.tooltip=The docker daemon that will be used to build the image
+BuildDockerImageLaunchConfigurationMainTab.connection.missing=Docker Connection is missing or invalid
BuildDockerImageLaunchConfigurationMainTab.buildContextPath.group.label=Build Context Path:
BuildDockerImageLaunchConfigurationMainTab.buildContextPath.missing=Build Context Path is missing or invalid
BuildDockerImageLaunchConfigurationMainTab.buildContextPath.browseworkspace.button.label=Browse Workspace...
@@ -28,14 +29,12 @@ BuildDockerImageLaunchConfigurationMainTab.options.noCache.button.label=Do not u
BuildDockerImageLaunchConfigurationMainTab.options.rm.button.label=Remove intermediate containers after a successful build
BuildDockerImageLaunchConfigurationMainTab.options.forceRM.button.label=Always remove intermediate containers
-ImageBuild.msg=Building Docker Image
-ImageBuild.error.msg=Error while building Docker Image
-ImageBuildShortcut.error.msg=Error trying to build Docker Image
+ImageBuildShortcut.error.msg=Error while building Docker Image
ImageBuildShortcutConfigSelection.title=Launch Configuration Selection
ImageBuildShortcutChooseLaunch.msg=Choose a launch configuration to run
ImageBuildShortcutConnectionSelection.title=Launch Configuration Selection
ImageBuildShortcutChooseConnection.msg=Choose the Docker Connection to use
-
+ImageBuildShortcutMissingConnection.msg=No Docker Connection available to build the image.
MissingConnectionError.msg=No Docker connection named ''{0}'' exists.

Back to the top