Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2015-06-05 12:32:26 -0400
committerJeff Johnston2015-06-08 21:07:21 -0400
commitc716b1ce515aed9acb5522f4cff49ca4cdf0082b (patch)
tree93463cabdf361694749fd5bf1d3927cfa5b6801c
parenta8161780a8c832a315af49cde935f4f7910a8b8a (diff)
downloadorg.eclipse.linuxtools-c716b1ce515aed9acb5522f4cff49ca4cdf0082b.tar.gz
org.eclipse.linuxtools-c716b1ce515aed9acb5522f4cff49ca4cdf0082b.tar.xz
org.eclipse.linuxtools-c716b1ce515aed9acb5522f4cff49ca4cdf0082b.zip
Bug 469352 - Browse button are stubs in Docker Tooling
Fixed bugs where buttons were stubs Fixed bugs on tables where 'edit' and 'remove' buttons would remain enabled even after all items were removed Fixed bugs where dialogs'OK button were enabled by default (despite not data was input) Change-Id: I88a12c2ee06d5e6244767addec35c727cb26adc8 Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/49669 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/49710
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerDataVolumeDialog.java156
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerEnvironmentVariableDialog.java19
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerLinkDialog.java27
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerPortDialog.java17
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesModel.java20
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesPage.java87
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionPage.java57
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearch.java2
8 files changed, 218 insertions, 167 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerDataVolumeDialog.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerDataVolumeDialog.java
index 4740f59514..a5b7461f75 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerDataVolumeDialog.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerDataVolumeDialog.java
@@ -53,6 +53,8 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
@@ -100,6 +102,20 @@ public class ContainerDataVolumeDialog extends Dialog {
shell.setText("Data Volume");
}
+ /**
+ * Disable the 'OK' button by default
+ */
+ @Override
+ protected Button createButton(Composite parent, int id, String label,
+ boolean defaultButton) {
+ final Button button = super.createButton(parent, id, label,
+ defaultButton);
+ if (id == IDialogConstants.OK_ID) {
+ button.setEnabled(false);
+ }
+ return button;
+ }
+
@Override
protected Point getInitialSize() {
return new Point(450, super.getInitialSize().y);
@@ -111,29 +127,46 @@ public class ContainerDataVolumeDialog extends Dialog {
final int COLUMNS = 3;
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(1, 1)
.grab(true, true).applyTo(container);
- GridLayoutFactory.fillDefaults().margins(6, 6).numColumns(COLUMNS)
+ GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(COLUMNS)
.applyTo(container);
+
+ // Container path
+ final Label containerPathLabel = new Label(container, SWT.NONE);
+ containerPathLabel.setText("Container path:");
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
+ .grab(false, false).applyTo(containerPathLabel);
+ final Text containerPathText = new Text(container, SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
+ .grab(true, false).applyTo(containerPathText);
+ final IObservableValue containerPathObservable = BeanProperties
+ .value(DataVolumeModel.class, DataVolumeModel.CONTAINER_PATH)
+ .observe(model);
+ dbc.bindValue(
+ WidgetProperties.text(SWT.Modify).observe(containerPathText),
+ containerPathObservable);
+ // mount type
final Label explanationLabel = new Label(container, SWT.NONE);
- explanationLabel.setText("Specify the Data Volume to mount:"); //$NON-NLS-1$
+ explanationLabel.setText("Specify the type of mount:"); //$NON-NLS-1$
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
.span(COLUMNS, 1).grab(true, false).applyTo(explanationLabel);
-
+ final int INDENT = 20;
// No mount
final Button noMountButton = new Button(container, SWT.RADIO);
noMountButton.setText("No external mount");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
- .span(COLUMNS, 1).grab(true, false).applyTo(noMountButton);
+ .indent(INDENT, 0).span(COLUMNS, 1).grab(true, false)
+ .applyTo(noMountButton);
bindButton(noMountButton, MountType.NONE);
// File System mount
final Button fileSystemMountButton = new Button(container, SWT.RADIO);
fileSystemMountButton.setText("Mount a host directory or host file");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
- .span(COLUMNS, 1).grab(true, false)
+ .indent(INDENT, 0).span(COLUMNS, 1).grab(true, false)
.applyTo(fileSystemMountButton);
final Label hostPathLabel = new Label(container, SWT.NONE);
hostPathLabel.setText("Path:"); //$NON-NLS-1$
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
- .indent(20, SWT.DEFAULT).grab(false, false)
+ .indent(2 * INDENT, SWT.DEFAULT).grab(false, false)
.applyTo(hostPathLabel);
final Text hostPathText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
@@ -143,21 +176,21 @@ public class ContainerDataVolumeDialog extends Dialog {
.observe(model);
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(hostPathText),
hostPathObservable);
-
- final Button hostPathBrowseButton = new Button(container, SWT.NONE);
- hostPathBrowseButton.setText("Browse...");
+ // browse for directory
+ final Button hostPathDirectoryButton = new Button(container, SWT.NONE);
+ hostPathDirectoryButton.setText("Directory...");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
- .grab(false, false).applyTo(hostPathBrowseButton);
- hostPathBrowseButton.addSelectionListener(onHostPathBrowse());
- // optional read-only access
+ .grab(false, false).applyTo(hostPathDirectoryButton);
+ hostPathDirectoryButton.addSelectionListener(onHostDirectoryPath());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
.grab(false, false).applyTo(new Label(container, SWT.NONE));
+ // optional read-only access
final Button readOnlyButton = new Button(container, SWT.CHECK);
readOnlyButton.setText("Read-only access"); //$NON-NLS-1$
readOnlyButton.setToolTipText(
"Specify if the mounted host directory or path is read-only"); //$NON-NLS-1$
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
- .span(COLUMNS - 1, 1).grab(true, false).applyTo(readOnlyButton);
+ .span(COLUMNS - 2, 1).grab(true, false).applyTo(readOnlyButton);
final ISWTObservableValue readOnlyButtonObservable = WidgetProperties
.selection().observe(readOnlyButton);
dbc.bindValue(readOnlyButtonObservable,
@@ -165,19 +198,27 @@ public class ContainerDataVolumeDialog extends Dialog {
.value(DataVolumeModel.class,
DataVolumeModel.READ_ONLY_VOLUME)
.observe(model));
+ // browse for file
+ final Button hostPathFileButton = new Button(container, SWT.NONE);
+ hostPathFileButton.setText("File...");
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
+ .grab(false, false).applyTo(hostPathFileButton);
+ hostPathFileButton.addSelectionListener(onHostFilePath());
bindButton(fileSystemMountButton, MountType.HOST_FILE_SYSTEM,
- hostPathText, hostPathBrowseButton, readOnlyButton);
+ hostPathText, hostPathDirectoryButton, hostPathFileButton,
+ readOnlyButton);
// Container mount
final Button containerMountButton = new Button(container, SWT.RADIO);
containerMountButton.setText("Mount a data volume container");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
- .span(COLUMNS, 1).grab(true, false)
+ .indent(INDENT, 0).span(COLUMNS, 1).grab(true, false)
.applyTo(containerMountButton);
final Label containerSelectionLabel = new Label(container, SWT.NONE);
containerSelectionLabel.setText("Container:"); //$NON-NLS-1$
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
- .indent(20, SWT.DEFAULT).applyTo(containerSelectionLabel);
+ .indent(2 * INDENT, SWT.DEFAULT)
+ .applyTo(containerSelectionLabel);
final Combo containerSelectionCombo = new Combo(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
.grab(true, false).span(1, 1).applyTo(containerSelectionCombo);
@@ -240,7 +281,6 @@ public class ContainerDataVolumeDialog extends Dialog {
final Binding binding = iterator.next();
binding.getModel().addChangeListener(onDataVolumeSettingsChanged(
errorMessageIcon, errorMessageLabel));
-
}
}
@@ -292,7 +332,22 @@ public class ContainerDataVolumeDialog extends Dialog {
});
}
- private SelectionListener onHostPathBrowse() {
+ private SelectionListener onHostDirectoryPath() {
+ return new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ final DirectoryDialog directoryDialog = new DirectoryDialog(
+ getShell());
+ final String selectedPath = directoryDialog.open();
+ if (selectedPath != null) {
+ model.setHostPathMount(selectedPath);
+ }
+ }
+ };
+ }
+
+ private SelectionListener onHostFilePath() {
return new SelectionAdapter() {
@Override
@@ -340,36 +395,54 @@ public class ContainerDataVolumeDialog extends Dialog {
@Override
public void handleChange(ChangeEvent event) {
- final IStatus status = validateInput(errorMessageLabel);
- if (status.isOK()) {
- errorMessageIcon.setVisible(false);
- errorMessageLabel.setVisible(false);
- setOkButtonEnabled(true);
- } else if (status.matches(IStatus.WARNING)) {
- errorMessageIcon.setVisible(true);
- errorMessageIcon.setImage(
- SWTImagesFactory.DESC_WARNING.createImage());
- errorMessageLabel.setVisible(true);
- errorMessageLabel.setText(status.getMessage());
- setOkButtonEnabled(true);
- } else if (status.matches(IStatus.ERROR)) {
- errorMessageIcon.setVisible(true);
- errorMessageIcon.setImage(
- SWTImagesFactory.DESC_ERROR.createImage());
- errorMessageLabel.setVisible(true);
- errorMessageLabel.setText(status.getMessage());
- setOkButtonEnabled(true);
+ final IStatus status = validateInput();
+ if (Display.getCurrent() == null) {
+ return;
}
+ Display.getCurrent().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ if (status.isOK()) {
+ errorMessageIcon.setVisible(false);
+ errorMessageLabel.setVisible(false);
+ setOkButtonEnabled(true);
+ } else if (status.matches(IStatus.WARNING)) {
+ errorMessageIcon.setVisible(true);
+ errorMessageIcon
+ .setImage(SWTImagesFactory.DESC_WARNING
+ .createImage());
+ errorMessageLabel.setVisible(true);
+ errorMessageLabel.setText(status.getMessage());
+ setOkButtonEnabled(true);
+ } else if (status.matches(IStatus.ERROR)) {
+ if (status.getMessage() != null
+ && !status.getMessage().isEmpty()) {
+ errorMessageIcon.setVisible(true);
+ errorMessageIcon.setImage(
+ SWTImagesFactory.DESC_ERROR.createImage());
+ errorMessageLabel.setVisible(true);
+ errorMessageLabel.setText(status.getMessage());
+ }
+ setOkButtonEnabled(false);
+ }
+ }
+ });
}
};
}
- private IStatus validateInput(final Label errorMessageLabel) {
+ private IStatus validateInput() {
+ final String containerPath = model.getContainerPath();
final MountType mountType = model.getMountType();
final String hostPath = model.getHostPathMount();
- if (mountType == MountType.HOST_FILE_SYSTEM
+ if (containerPath == null || containerPath.isEmpty()) {
+ return ValidationStatus.error(null);
+ } else if (mountType == null) {
+ return ValidationStatus.error(null);
+ } else if (mountType == MountType.HOST_FILE_SYSTEM
&& (hostPath == null || hostPath.isEmpty())) {
- return ValidationStatus.ok();
+ return ValidationStatus.error(null);
} else if (mountType == MountType.HOST_FILE_SYSTEM
&& !new File(hostPath).exists()) {
return ValidationStatus
@@ -378,7 +451,8 @@ public class ContainerDataVolumeDialog extends Dialog {
final IDockerContainer container = WizardUtils
.getContainer(connection, model.getContainerMount());
if (container == null) {
- return ValidationStatus.error("");
+ // just make sure that the dialog cannot complete
+ return ValidationStatus.error(null);
}
final IDockerContainerInfo selectedContainerInfo = container.info();
if (!selectedContainerInfo.volumes()
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerEnvironmentVariableDialog.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerEnvironmentVariableDialog.java
index 60539cfcb5..d438c32a5c 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerEnvironmentVariableDialog.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerEnvironmentVariableDialog.java
@@ -23,6 +23,7 @@ import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
@@ -62,13 +63,27 @@ public class ContainerEnvironmentVariableDialog extends Dialog {
return new Point(400, super.getInitialSize().y);
}
+ /**
+ * Disable the 'OK' button by default
+ */
+ @Override
+ protected Button createButton(Composite parent, int id, String label,
+ boolean defaultButton) {
+ final Button button = super.createButton(parent, id, label,
+ defaultButton);
+ if (id == IDialogConstants.OK_ID) {
+ button.setEnabled(false);
+ }
+ return button;
+ }
+
@Override
protected Control createDialogArea(Composite parent) {
final int COLUMNS = 2;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL)
.span(COLUMNS, 1).grab(true, true).applyTo(container);
- GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(6, 6)
+ GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10)
.applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel
@@ -83,7 +98,7 @@ public class ContainerEnvironmentVariableDialog extends Dialog {
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
.grab(true, false).applyTo(variableNameText);
final Label variableValueLabel = new Label(container, SWT.NONE);
- variableValueLabel.setText("Host address:"); //$NON-NLS-1$
+ variableValueLabel.setText("Value:"); //$NON-NLS-1$
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
.grab(false, false).applyTo(variableValueLabel);
final Text variableValueText = new Text(container, SWT.BORDER);
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerLinkDialog.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerLinkDialog.java
index fcb4c64abc..9287df4e5d 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerLinkDialog.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerLinkDialog.java
@@ -89,13 +89,27 @@ public class ContainerLinkDialog extends Dialog {
return new Point(400, super.getInitialSize().y);
}
+ /**
+ * Disable the 'OK' button by default
+ */
+ @Override
+ protected Button createButton(Composite parent, int id, String label,
+ boolean defaultButton) {
+ final Button button = super.createButton(parent, id, label,
+ defaultButton);
+ if (id == IDialogConstants.OK_ID) {
+ button.setEnabled(false);
+ }
+ return button;
+ }
+
@Override
protected Control createDialogArea(final Composite parent) {
final int COLUMNS = 2;
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL)
.span(COLUMNS, 1).grab(true, false).applyTo(container);
- GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(6, 6)
+ GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10)
.applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel
@@ -175,17 +189,6 @@ public class ContainerLinkDialog extends Dialog {
};
}
- @Override
- protected Button createButton(Composite parent, int id, String label,
- boolean defaultButton) {
- final Button button = super.createButton(parent, id, label,
- defaultButton);
- if (id == IDialogConstants.OK_ID) {
- button.setEnabled(false);
- }
- return button;
- }
-
public String getContainerName() {
return model.getContainerName();
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerPortDialog.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerPortDialog.java
index db02a03140..fb97433de0 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerPortDialog.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ContainerPortDialog.java
@@ -25,6 +25,7 @@ import org.eclipse.linuxtools.internal.docker.ui.databinding.BaseDatabindingMode
import org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunSelectionModel.ExposedPortModel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
@@ -64,6 +65,20 @@ public class ContainerPortDialog extends Dialog {
shell.setText("Exposing a Container Port");
}
+ /**
+ * Disable the 'OK' button by default
+ */
+ @Override
+ protected Button createButton(Composite parent, int id, String label,
+ boolean defaultButton) {
+ final Button button = super.createButton(parent, id, label,
+ defaultButton);
+ if (id == IDialogConstants.OK_ID) {
+ button.setEnabled(false);
+ }
+ return button;
+ }
+
@Override
protected Point getInitialSize() {
return new Point(400, super.getInitialSize().y);
@@ -75,7 +90,7 @@ public class ContainerPortDialog extends Dialog {
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL)
.span(COLUMNS, 1).grab(true, true).applyTo(container);
- GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(6, 6)
+ GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(10, 10)
.applyTo(container);
final Label explanationLabel = new Label(container, SWT.NONE);
explanationLabel.setText("Specify the container port to expose:"); //$NON-NLS-1$
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesModel.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesModel.java
index a6b471fad5..5456fc3886 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesModel.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesModel.java
@@ -115,24 +115,12 @@ public class ImageRunResourceVolumesVariablesModel
this.dataVolumes.addAll(dataVolumes);
}
- public Set<DataVolumeModel> getSelectedDataVolumes() {
- return selectedDataVolumes;
- }
-
- public void addSelectedDataVolume(
- final DataVolumeModel selectedDataVolume) {
- // we must use a different collection to fire an event for the change
- // afterwards
- final Set<DataVolumeModel> updatedDataVolumesSelection = new HashSet<>(
- this.selectedDataVolumes);
- updatedDataVolumesSelection.add(selectedDataVolume);
- setSelectedDataVolumes(updatedDataVolumesSelection);
+ public void removeDataVolume(final DataVolumeModel dataVolume) {
+ this.dataVolumes.remove(dataVolume);
}
- public void setSelectedDataVolumes(
- final Set<DataVolumeModel> selectedDataVolumes) {
- firePropertyChange(SELECTED_DATA_VOLUMES, this.selectedDataVolumes,
- this.selectedDataVolumes = selectedDataVolumes);
+ public Set<DataVolumeModel> getSelectedDataVolumes() {
+ return selectedDataVolumes;
}
public WritableList getEnvironmentVariables() {
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesPage.java
index c5afbebecf..4f9dbe5835 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesPage.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunResourceVolumesVariablesPage.java
@@ -12,13 +12,10 @@ package org.eclipse.linuxtools.internal.docker.ui.wizards;
import java.io.File;
import java.util.Iterator;
-import java.util.List;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
import org.eclipse.core.databinding.beans.IBeanValueProperty;
-import org.eclipse.core.databinding.observable.ChangeEvent;
-import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.map.IObservableMap;
import org.eclipse.core.databinding.property.Properties;
@@ -271,12 +268,13 @@ public class ImageRunResourceVolumesVariablesPage extends WizardPage {
editButton
.addSelectionListener(onEditDataVolume(dataVolumesTableViewer));
editButton.setEnabled(false);
- final Button resetButton = new Button(buttonsContainers, SWT.NONE);
+ final Button removeButton = new Button(buttonsContainers, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP)
- .grab(true, false).applyTo(resetButton);
- resetButton.setText("Remove"); //$NON-NLS-1$
- resetButton.addSelectionListener(onRemoveDataVolumes());
- resetButton.setEnabled(false);
+ .grab(true, false).applyTo(removeButton);
+ removeButton.setText("Remove"); //$NON-NLS-1$
+ removeButton.addSelectionListener(
+ onRemoveDataVolumes(dataVolumesTableViewer));
+ removeButton.setEnabled(false);
// update table content when selected image changes
bind(dataVolumesTableViewer, model.getDataVolumes(),
BeanProperties.values(DataVolumeModel.class,
@@ -289,9 +287,10 @@ public class ImageRunResourceVolumesVariablesPage extends WizardPage {
BeanProperties
.set(ImageRunResourceVolumesVariablesModel.SELECTED_DATA_VOLUMES)
.observe(model));
- ViewersObservables.observeMultiSelection(dataVolumesTableViewer)
- .addChangeListener(
- onDataVolumesSelection(editButton, resetButton));
+ // disable the edit and removeButton if the table is empty
+ dataVolumesTableViewer.addSelectionChangedListener(
+ onSelectionChanged(editButton, removeButton));
+
}
/**
@@ -320,16 +319,19 @@ public class ImageRunResourceVolumesVariablesPage extends WizardPage {
}
- private IChangeListener onDataVolumesSelection(
+ private ISelectionChangedListener onSelectionChanged(
final Button... targetButtons) {
- return new IChangeListener() {
+ return new ISelectionChangedListener() {
@Override
- public void handleChange(ChangeEvent event) {
- if (event.getSource() != null) {
+ public void selectionChanged(final SelectionChangedEvent e) {
+ if (e.getSelection().isEmpty()) {
+ setControlsEnabled(targetButtons, false);
+ } else {
setControlsEnabled(targetButtons, true);
}
}
+
};
}
@@ -339,11 +341,6 @@ public class ImageRunResourceVolumesVariablesPage extends WizardPage {
@Override
public void widgetSelected(final SelectionEvent e) {
- final IStructuredSelection selection = (IStructuredSelection) dataVolumesTableViewer
- .getSelection();
- if (selection.isEmpty()) {
- return;
- }
final ContainerDataVolumeDialog dialog = new ContainerDataVolumeDialog(
getShell(), model.getConnection());
dialog.create();
@@ -389,12 +386,20 @@ public class ImageRunResourceVolumesVariablesPage extends WizardPage {
};
}
- private SelectionListener onRemoveDataVolumes() {
+ private SelectionListener onRemoveDataVolumes(
+ final TableViewer dataVolumesTableViewer) {
return new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
- // TODO
+ final IStructuredSelection selection = dataVolumesTableViewer
+ .getStructuredSelection();
+ for (@SuppressWarnings("unchecked")
+ Iterator<DataVolumeModel> iterator = selection
+ .iterator(); iterator.hasNext();) {
+ model.removeDataVolume(iterator.next());
+ }
+
}
};
}
@@ -477,11 +482,9 @@ public class ImageRunResourceVolumesVariablesPage extends WizardPage {
BeanProperties.values(EnvironmentVariableModel.class,
new String[] { EnvironmentVariableModel.NAME,
EnvironmentVariableModel.VALUE }));
- environmentVariablesTableViewer.addSelectionChangedListener(
- onEnvironmentVariableSelected(editButton, removeButton));
// disable the edit and removeButton if the table is empty
- model.getEnvironmentVariables().addChangeListener(
- onRemoveEnvironmentVariables(editButton, removeButton));
+ environmentVariablesTableViewer.addSelectionChangedListener(
+ onSelectionChanged(editButton, removeButton));
}
private TableViewer createEnvironmentVariablesTable(Composite container) {
@@ -497,22 +500,6 @@ public class ImageRunResourceVolumesVariablesPage extends WizardPage {
return tableViewer;
}
- private ISelectionChangedListener onEnvironmentVariableSelected(
- final Control... controls) {
- return new ISelectionChangedListener() {
-
- @Override
- public void selectionChanged(final SelectionChangedEvent e) {
- if (e.getSelection().isEmpty()) {
- setControlsEnabled(controls, false);
- } else {
- setControlsEnabled(controls, true);
- }
- }
-
- };
- }
-
private SelectionListener onAddEnvironmentVariable() {
return new SelectionAdapter() {
@Override
@@ -550,22 +537,6 @@ public class ImageRunResourceVolumesVariablesPage extends WizardPage {
};
}
- private IChangeListener onRemoveEnvironmentVariables(
- final Button... buttons) {
- return new IChangeListener() {
-
- @Override
- public void handleChange(final ChangeEvent event) {
- @SuppressWarnings("unchecked")
- final List<EnvironmentVariableModel> links = (List<EnvironmentVariableModel>) event
- .getSource();
- if (links.isEmpty()) {
- setControlsEnabled(buttons, false);
- }
- }
- };
- }
-
private SelectionListener onRemoveEnvironmentVariables(
final TableViewer linksTableViewer) {
return new SelectionAdapter() {
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionPage.java
index afd833574c..3b8c2dff12 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionPage.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageRunSelectionPage.java
@@ -19,8 +19,6 @@ import java.util.Set;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
-import org.eclipse.core.databinding.observable.ChangeEvent;
-import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -376,11 +374,30 @@ public class ImageRunSelectionPage extends WizardPage {
exposedPortsTableViewer, ExposedPortModel.class),
BeanProperties.set(ImageRunSelectionModel.SELECTED_PORTS)
.observe(model));
+ // disable the edit and removeButton if the table is empty
+ exposedPortsTableViewer.addSelectionChangedListener(
+ onSelectionChanged(editButton, removeButton));
togglePortMappingControls(exposedPortsTableViewer.getTable(), addButton,
removeButton);
}
+ private ISelectionChangedListener onSelectionChanged(
+ final Button... targetButtons) {
+ return new ISelectionChangedListener() {
+
+ @Override
+ public void selectionChanged(final SelectionChangedEvent e) {
+ if (e.getSelection().isEmpty()) {
+ setControlsEnabled(targetButtons, false);
+ } else {
+ setControlsEnabled(targetButtons, true);
+ }
+ }
+
+ };
+ }
+
private CheckboxTableViewer createPortSettingsTable(
final Composite container) {
final Table table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION
@@ -452,27 +469,10 @@ public class ImageRunSelectionPage extends WizardPage {
new String[] {
ContainerLinkModel.CONTAINER_NAME,
ContainerLinkModel.CONTAINER_ALIAS }));
- linksTableViewer.addSelectionChangedListener(
- onLinkSelected(editButton, removeButton));
// disable the edit and removeButton if the table is empty
- model.getLinks()
- .addChangeListener(onRemoveLinks(editButton, removeButton));
- }
-
- private ISelectionChangedListener onLinkSelected(
- final Control... controls) {
- return new ISelectionChangedListener() {
-
- @Override
- public void selectionChanged(final SelectionChangedEvent e) {
- if (e.getSelection().isEmpty()) {
- setControlsEnabled(controls, false);
- } else {
- setControlsEnabled(controls, true);
- }
- }
+ linksTableViewer.addSelectionChangedListener(
+ onSelectionChanged(editButton, removeButton));
- };
}
private TableViewer createLinksTable(final Composite container) {
@@ -529,21 +529,6 @@ public class ImageRunSelectionPage extends WizardPage {
};
}
- private IChangeListener onRemoveLinks(final Button... buttons) {
- return new IChangeListener() {
-
- @Override
- public void handleChange(final ChangeEvent event) {
- @SuppressWarnings("unchecked")
- final List<ContainerLinkModel> links = (List<ContainerLinkModel>) event
- .getSource();
- if (links.isEmpty()) {
- setControlsEnabled(buttons, false);
- }
- }
- };
- }
-
private SelectionListener onRemoveLinks(
final TableViewer linksTableViewer) {
return new SelectionAdapter() {
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearch.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearch.java
index efbb20621d..04fd3e8fd1 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearch.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImageSearch.java
@@ -14,7 +14,7 @@ package org.eclipse.linuxtools.internal.docker.ui.wizards;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.linuxtools.docker.core.IDockerConnection;
-import org.eclipse.linuxtools.docker.core.IDockerImageSearchResult;;
+import org.eclipse.linuxtools.docker.core.IDockerImageSearchResult;
/**
* Wizard to search for images.

Back to the top