Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2016-01-14 17:37:08 +0000
committerJeff Johnston2016-01-18 17:59:28 +0000
commit0a03290b076819c83377b6c62aa3950f2cd66e25 (patch)
treec5f9f0a3e6b228061f6c91b86ae602aecba62cf8
parent4efe6175fba2ee2d8d62cbc51c5957a04d109d7f (diff)
downloadorg.eclipse.linuxtools-0a03290b076819c83377b6c62aa3950f2cd66e25.tar.gz
org.eclipse.linuxtools-0a03290b076819c83377b6c62aa3950f2cd66e25.tar.xz
org.eclipse.linuxtools-0a03290b076819c83377b6c62aa3950f2cd66e25.zip
Bug 475333 - NullPointerException in PullImageCommandHandler$1.run
Underlying problem should have been fixed while working on bug 469072. Added a check on the selected connection and displaying an error message if no connection was found in the selection Change-Id: I1112ce2b4c66661f03e426fcface44c8fb108641 Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/64345 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> (cherry picked from commit 5e77f8c39aa0417edb508885043df0ab9d3902e6) Reviewed-on: https://git.eclipse.org/r/64413
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandMessages.properties5
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PullImageCommandHandler.java21
2 files changed, 19 insertions, 7 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandMessages.properties b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandMessages.properties
index b942924940..64eb748baf 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandMessages.properties
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandMessages.properties
@@ -4,4 +4,7 @@ command.showIn.webBrowser.failure=Failed to open in Web Browser
command.showIn.systemExplorer=Opening in System Explorer...
command.showIn.systemExplorer.failure=Failed to open in Web Browser
command.showIn.systemExplorer.failure.command_unavailable=Failed to open in Web Browser: command unavailable
-command.showIn.systemExplorer.failure.execute=Failed to execute {0}. Return code was: {1} \ No newline at end of file
+command.showIn.systemExplorer.failure.execute=Failed to execute {0}. Return code was: {1}
+
+missing_connection=Missing connection
+command.pullImage.failure.no_connection=Unable to pull an image: no connection was not found in the selection. \ No newline at end of file
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PullImageCommandHandler.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PullImageCommandHandler.java
index f0111dd2c9..cdcd679a3e 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PullImageCommandHandler.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/PullImageCommandHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Red Hat.
+ * Copyright (c) 2015,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
@@ -38,17 +38,26 @@ public class PullImageCommandHandler extends AbstractHandler {
private final static String PULL_IMAGE_JOB_TITLE = "ImagePull.title"; //$NON-NLS-1$
private final static String PULL_IMAGE_JOB_TASK = "ImagePull.msg"; //$NON-NLS-1$
private static final String ERROR_PULLING_IMAGE = "ImagePullError.msg"; //$NON-NLS-1$
+ private static final String ERROR_PULLING_IMAGE_NO_CONNECTION = "command.pullImage.failure.no_connection"; //$NON-NLS-1$
+ private static final String MISSING_CONNECTION = "missing_connection"; //$NON-NLS-1$
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final IDockerConnection connection = CommandUtils
.getCurrentConnection(activePart);
- final ImagePull wizard = new ImagePull(connection);
- final boolean pullImage = CommandUtils.openWizard(wizard,
- HandlerUtil.getActiveShell(event));
- if (pullImage) {
- performPullImage(connection, wizard.getImageName());
+ if (connection == null) {
+ MessageDialog.openError(Display.getCurrent().getActiveShell(),
+ CommandMessages.getString(MISSING_CONNECTION),
+ CommandMessages
+ .getString(ERROR_PULLING_IMAGE_NO_CONNECTION));
+ } else {
+ final ImagePull wizard = new ImagePull(connection);
+ final boolean pullImage = CommandUtils.openWizard(wizard,
+ HandlerUtil.getActiveShell(event));
+ if (pullImage) {
+ performPullImage(connection, wizard.getImageName());
+ }
}
return null;
}

Back to the top