Bug 508405 - Fix copy to container to support stopped containers
- fix ContainerCopyToCommandHandler to issue cause of any
DockerException to the user
- fix CopyToContainer wizard to pass whether the container is
stopped or not
- fix CopyToContainerPage to override the destination controls
when stopped to just add a single Text widget and no browse
button
- fix ContainerDirectoryDialog invocation to include a message
which contains the container name in it
- fix CopyFromContainer as well with regards to displaying the
cause of any DockerException rather than the top-level message
- fix the copyfromcommand handler enablement to be if the container
status is not unknown
Change-Id: Ibd620c615e5bfa6ee7fcb28e1f8afc3ac318e296
Reviewed-on: https://git.eclipse.org/r/85991
Tested-by: Hudson CI
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
diff --git a/containers/org.eclipse.linuxtools.docker.ui/plugin.xml b/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
index c352c1a..3f748e7 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
+++ b/containers/org.eclipse.linuxtools.docker.ui/plugin.xml
@@ -701,24 +701,17 @@
<count
value="1">
</count>
- <iterate
+ <iterate
ifEmpty="false">
<and>
<instanceof
value="org.eclipse.linuxtools.docker.core.IDockerContainer">
</instanceof>
- <or>
- <test
- forcePluginActivation="true"
- property="org.eclipse.linuxtools.docker.propertytesters.container.isStopped"
- value="false">
- </test>
- <test
- forcePluginActivation="true"
- property="org.eclipse.linuxtools.docker.propertytesters.container.isUnknown"
- value="true">
- </test>
- </or>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.linuxtools.docker.propertytesters.container.isUnknown"
+ value="false">
+ </test>
</and>
</iterate>
</with>
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 84cf006..f5e3b96 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
@@ -15,17 +15,17 @@
missing_connection=Missing connection
command.pullImage.failure.no_connection=Unable to pull an image: no connection was found in the selection.
-command.copyfromcontainer.failure.no_connection=Unable to copy from container: no conection was found.
+command.copyfromcontainer.failure.no_connection=Unable to copy from container: no connection was found.
command.copyfromcontainer.job.title=Copying files from {0}
command.copyfromcontainer.job.task=Copying files
command.copyfromcontainer.job.subtask=Copying {0}
-command.copyfromcontainer.error.msg=Error copying [{0}] from <{1}>
+command.copyfromcontainer.error.msg=Error copying [{0}] from container: <{1}>
-command.copytocontainer.failure.no_connection=Unable to copy to container: no conection was found.
+command.copytocontainer.failure.no_connection=Unable to copy to container: no connection was found.
command.copytocontainer.job.title=Copying files to {0}
command.copytocontainer.job.task=Copying files
command.copytocontainer.job.subtask=Copying {0}
-command.copytocontainer.error.msg=Error copying [{0}] to <{1}>
+command.copytocontainer.error.msg=Error copying to folder "{0}" in container: <{1}>
command.enableconnection=Opening connection to {0}
command.enableconnection.failure=Failed to connect to {0}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CopyFromContainerCommandHandler.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CopyFromContainerCommandHandler.java
index ae71f8c..d1c479e 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CopyFromContainerCommandHandler.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CopyFromContainerCommandHandler.java
@@ -151,7 +151,7 @@
ERROR_COPYING_FROM_CONTAINER,
proxy.getLink(),
container.name()),
- e.getMessage()));
+ e.getCause().getMessage()));
// for now
}
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CopyToContainerCommandHandler.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CopyToContainerCommandHandler.java
index 8c5a9bb..5dd0b12 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CopyToContainerCommandHandler.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/commands/CopyToContainerCommandHandler.java
@@ -199,8 +199,8 @@
.getShell(),
CommandMessages.getFormattedString(
ERROR_COPYING_TO_CONTAINER,
- tmpDirName, container.name()),
- e.getMessage()));
+ target, container.name()),
+ e.getCause().getMessage()));
}
} catch (InterruptedException e) {
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyTo.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyTo.java
index 7a16f1c..08665ce 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyTo.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyTo.java
@@ -15,6 +15,7 @@
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.linuxtools.docker.core.EnumDockerStatus;
import org.eclipse.linuxtools.docker.core.IDockerConnection;
import org.eclipse.linuxtools.docker.core.IDockerContainer;
import org.eclipse.linuxtools.docker.ui.Activator;
@@ -61,8 +62,12 @@
e.printStackTrace();
}
+ boolean isRunning = EnumDockerStatus.fromStatusMessage(
+ container.status()) == EnumDockerStatus.RUNNING;
+
+
mainPage = new ContainerCopyToPage(sfo.getResult(), provider,
- container.name());
+ container.name(), isRunning);
addPage(mainPage);
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyToPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyToPage.java
index 21b7c5e..10092a0 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyToPage.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerCopyToPage.java
@@ -58,6 +58,7 @@
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.FileSystemElement;
import org.eclipse.ui.dialogs.WizardResourceImportPage;
@@ -109,12 +110,20 @@
protected static final String DESTINATION_EMPTY_MESSAGE = CopyToContainerMessages.ContainerCopyTo_destinationEmpty;
+ protected static final String INTO_FOLDER_LABEL = CopyToContainerMessages.ContainerCopyTo_intoFolder;
+
+ protected static final String CONTAINER_DIRECTORY_MSG = CopyToContainerMessages.ContainerCopyTo_containerDirectoryMsg;
+
private FileSystemElement root;
+ private boolean isRunning;
+
private ContainerFileSystemProvider provider;
private String containerName;
+ private Text containerNameField;
+
private List<Object> fileSystemObjects = new ArrayList<>();
private IPath destination;
@@ -126,11 +135,13 @@
* @param selection IStructuredSelection
*/
public ContainerCopyToPage(FileSystemElement root,
- ContainerFileSystemProvider provider, String containerName) {
+ ContainerFileSystemProvider provider, String containerName,
+ boolean isRunning) {
super("ContainerCopyToPage1", StructuredSelection.EMPTY);//$NON-NLS-1$
this.root = root;
this.provider = provider;
this.containerName = containerName;
+ this.isRunning = isRunning;
setTitle(NLS.bind(CopyToContainerMessages.ContainerCopyTo_title,
this.containerName));
setDescription(
@@ -158,8 +169,8 @@
* @param label
* the label from the button
* @param defaultButton
- * <code>true</code> if the button is to be the default button,
- * and <code>false</code> otherwise
+ * <code>true</code> if thdocker stop vs pausee button is to be
+ * the default button, and <code>false</code> otherwise
*/
protected Button createButton(Composite parent, int id, String label,
boolean defaultButton) {
@@ -257,6 +268,41 @@
// do nothing
}
+ @Override
+ protected void createDestinationGroup(Composite parent) {
+ if (isRunning) {
+ super.createDestinationGroup(parent);
+ } else {
+ // container specification group
+ Composite containerGroup = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ containerGroup.setLayout(layout);
+ containerGroup.setLayoutData(new GridData(
+ GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
+ containerGroup.setFont(parent.getFont());
+
+ // container label
+ Label resourcesLabel = new Label(containerGroup, SWT.NONE);
+ resourcesLabel.setText(INTO_FOLDER_LABEL);
+ resourcesLabel.setFont(parent.getFont());
+
+ // container name entry field
+ containerNameField = new Text(containerGroup,
+ SWT.SINGLE | SWT.BORDER);
+ BidiUtils.applyBidiProcessing(containerNameField, "file"); //$NON-NLS-1$
+
+ containerNameField.addListener(SWT.Modify, this);
+ GridData data = new GridData(
+ GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+ data.widthHint = SIZING_TEXT_FIELD_WIDTH;
+ containerNameField.setLayoutData(data);
+ containerNameField.setFont(parent.getFont());
+
+ Label dummyLabel = new Label(containerGroup, SWT.NONE);
+ dummyLabel.setText(" "); //$NON-NLS-1$
+ }
+ }
/**
* Create the group for creating the root directory
*/
@@ -451,6 +497,14 @@
return false;
}
+ @Override
+ protected IPath getResourcePath() {
+ if (isRunning) {
+ return super.getResourcePath();
+ }
+ return new Path(containerNameField.getText());
+ }
+
/**
* Return the destination path chosen by the user.
*
@@ -651,7 +705,8 @@
@Override
protected void handleContainerBrowseButtonPressed() {
ContainerDirectorySelectionDialog dialog = new ContainerDirectorySelectionDialog(
- sourceNameField.getShell(), this.root, this.provider, null);
+ sourceNameField.getShell(), this.root, this.provider,
+ NLS.bind(CONTAINER_DIRECTORY_MSG, containerName));
if (dialog.open() == IStatus.OK) {
Object[] result = dialog.getResult();
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/CopyToContainerMessages.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/CopyToContainerMessages.java
index 95a13d3..2a968ee 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/CopyToContainerMessages.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/CopyToContainerMessages.java
@@ -58,6 +58,8 @@
public static String ContainerCopyTo_importProblems;
public static String ContainerCopyTo_showAdvanced;
public static String ContainerCopyTo_hideAdvanced;
+ public static String ContainerCopyTo_intoFolder;
+ public static String ContainerCopyTo_containerDirectoryMsg;
static {
// load message values from bundle file
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/CopyToContainerMessages.properties b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/CopyToContainerMessages.properties
index e51f4c6..f3cb46a 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/CopyToContainerMessages.properties
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/CopyToContainerMessages.properties
@@ -53,6 +53,8 @@
ContainerCopyTo_sourceEmpty = Source directory must not be empty.
ContainerCopyTo_destinationEmpty = Destination directory must not be empty.
ContainerCopyTo_importProblems = Copy Problems
+ContainerCopyTo_intoFolder = Into fo&lder:
+ContainerCopyTo_containerDirectoryMsg = Select a directory from container: <{0}>
ContainerCopyTo_showAdvanced = Show Advanced
ContainerCopyTo_hideAdvanced = Hide Advanced