Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2015-06-02 09:06:46 -0400
committerJeff Johnston2015-06-02 15:38:32 -0400
commit604ec6fffb57d20a4d3114b2b25e7811e5040d31 (patch)
treed839de81e831b95c2ee57a7a7086ccbd28cac3cb
parent952e1ad5814c18c09c094f4769ff0d8c4a13ad1d (diff)
downloadorg.eclipse.linuxtools-604ec6fffb57d20a4d3114b2b25e7811e5040d31.tar.gz
org.eclipse.linuxtools-604ec6fffb57d20a4d3114b2b25e7811e5040d31.tar.xz
org.eclipse.linuxtools-604ec6fffb57d20a4d3114b2b25e7811e5040d31.zip
Bug 468606 - Remove the Docker connection settings in the workbench preferences
Change-Id: I71cf2f8443d23e0d2997eef84856ab1e6dd1cbe7 Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/49243 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/DockerPreferencePage.java232
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/PreferenceInitializer.java32
2 files changed, 27 insertions, 237 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/DockerPreferencePage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/DockerPreferencePage.java
index d3e40e2ce2..f426e8e51e 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/DockerPreferencePage.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/DockerPreferencePage.java
@@ -10,36 +10,19 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.docker.ui.preferences;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.BINDING_MODE;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.TCP_CERT_PATH;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.TCP_CONNECTION;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.TCP_HOST;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.TCP_TLS_VERIFY;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.UNIX_SOCKET;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.UNIX_SOCKET_PATH;
-
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings;
import org.eclipse.linuxtools.docker.ui.Activator;
import org.eclipse.linuxtools.internal.docker.core.DockerContainerRefreshManager;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -48,51 +31,30 @@ public class DockerPreferencePage extends PreferencePage implements
private static final String REFRESH_TIME_MSG = "RefreshTime.label"; //$NON-NLS-1$
- private Button unixSocketBtn;
- private Text unixSocketPathText;
+ private IntegerFieldEditor refreshTimeField;
- private EnumDockerConnectionSettings bindingMode;
- private String unixSocketPath = null;
- private String tcpHost = null;
- private boolean tcpTLSVerify = false;
- private String tcpCertPath = null;
-
public DockerPreferencePage() {
super();
setPreferenceStore(Activator.getDefault().getPreferenceStore());
}
-
- /**:
+ /**
* (non-Javadoc)
*
- * @see
- * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- *
- * Preferences are initialized by the {@link PreferenceInitializer} which attempts to find
- * DOCKER environment variables at the system level.
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*
- * @see PreferenceInitializer
+ * @see PreferenceInitializer
*/
public void init(final IWorkbench workbench) {
- final IPreferenceStore preferenceStore = getPreferenceStore();
- this.bindingMode = EnumDockerConnectionSettings.valueOf(preferenceStore.getString(BINDING_MODE.toString()));
- this.unixSocketPath = preferenceStore.getString(UNIX_SOCKET_PATH.toString());
- this.tcpHost = preferenceStore.getString(TCP_HOST.toString());
- this.tcpTLSVerify = preferenceStore.getBoolean(TCP_TLS_VERIFY.toString());
- this.tcpCertPath = preferenceStore.getString(TCP_CERT_PATH.toString());
}
/**
* Saves the current values in the {@link PreferenceStore}.
*/
private void savePreferences() {
- final IPreferenceStore preferenceStore = getPreferenceStore();
- preferenceStore.setValue(BINDING_MODE.toString(), this.bindingMode.toString());
- preferenceStore.setValue(UNIX_SOCKET_PATH.toString(), this.unixSocketPath);
- preferenceStore.setValue(TCP_HOST.toString(), this.tcpHost);
- preferenceStore.setValue(TCP_TLS_VERIFY.toString(), this.tcpTLSVerify);
- preferenceStore.setValue(TCP_CERT_PATH.toString(), this.tcpCertPath);
+ if (this.refreshTimeField != null) {
+ this.refreshTimeField.store();
+ }
}
@Override
@@ -104,13 +66,12 @@ public class DockerPreferencePage extends PreferencePage implements
@Override
protected void performApply() {
- // TODO Auto-generated method stub
+ savePreferences();
super.performApply();
}
@Override
protected void performDefaults() {
- // TODO Auto-generated method stub
super.performDefaults();
}
@@ -119,155 +80,11 @@ public class DockerPreferencePage extends PreferencePage implements
final Composite container = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(container);
- createConnectionSettingsContainer(container);
createContainerRefreshContainer(container);
return container;
}
/**
- * Creates the connection settings container, where the user can choose how to
- * connect to the docker daemon (using sockets or TCP with SSL - or not)
- *
- * @param parent the parent container (ie, the main container in the preference page)
- */
- private void createConnectionSettingsContainer(final Composite parent) {
- final int COLUMNS = 3;
- final int INDENT = 20;
- final Group container = new Group(parent, SWT.BORDER);
- container.setText("Docker deamon binding settings");
- container.setToolTipText("Select the binding mode to use to connect to the Docker daemon");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(1, 1).grab(true, false).applyTo(container);
- GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(0, 0).spacing(10, 2).applyTo(container);
-
- unixSocketBtn = new Button(container, SWT.RADIO);
- unixSocketBtn.setText("Unix socket");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).applyTo(unixSocketBtn);
- final Label socketPathLabel = new Label(container, SWT.NONE);
- socketPathLabel.setText("Location:");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).applyTo(socketPathLabel);
- unixSocketPathText = new Text(container, SWT.BORDER);
- unixSocketPathText.setToolTipText("Path to the socket file");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(unixSocketPathText);
- final Button socketPathBrowseButton = new Button(container, SWT.BUTTON1);
- socketPathBrowseButton.setText("Browse...");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(socketPathBrowseButton);
- unixSocketBtn.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent e) {
- final Button targetButton = ((Button)e.widget);
- if(targetButton.getSelection()) {
- bindingMode = UNIX_SOCKET;
- unixSocketPathText.setEnabled(true);
- socketPathBrowseButton.setEnabled(true);
- } else {
- unixSocketPathText.setEnabled(false);
- socketPathBrowseButton.setEnabled(false);
- }
- }
- });
- unixSocketPathText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent evt) {
- unixSocketPath = ((Text)evt.widget).getText();
- }
- });
-
- // TCP Connection with optional TLS
- final Button tcpConnectionBtn = new Button(container, SWT.RADIO);
- tcpConnectionBtn.setText("TCP Connection");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(COLUMNS, 1).applyTo(tcpConnectionBtn);
- final Label tcpHostLabel = new Label(container, SWT.NONE);
- tcpHostLabel.setText("Host:");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).applyTo(tcpHostLabel);
- final Text tcpHostText = new Text(container, SWT.BORDER);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(2, 1).grab(true, false).applyTo(tcpHostText);
- final Button tcpAuthButton = new Button(container, SWT.CHECK);
- tcpAuthButton.setText("Enable authentication");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT, 0).span(3, 1).applyTo(tcpAuthButton);
- final Label tcpCertPathLabel = new Label(container, SWT.NONE);
- tcpCertPathLabel.setText("Path:");
- tcpCertPathLabel.setToolTipText("Path to the certificates folder");
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(INDENT * 2, 0).applyTo(tcpCertPathLabel);
- final Text tcpCertPathText = new Text(container, SWT.BORDER);
- tcpCertPathText.setEnabled(false);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(tcpCertPathText);
- final Button tcpCertPathBrowseButton = new Button(container, SWT.BUTTON1);
- tcpCertPathBrowseButton.setText("Browse...");
- tcpCertPathText.setEnabled(false);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(tcpCertPathBrowseButton);
-
- tcpConnectionBtn.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent e) {
- final Button targetButton = ((Button)e.widget);
- if(targetButton.getSelection()) {
- bindingMode = TCP_CONNECTION;
- tcpHostText.setEnabled(true);
- tcpAuthButton.setEnabled(true);
- } else {
- tcpHostText.setEnabled(false);
- tcpAuthButton.setEnabled(false);
- tcpCertPathText.setEnabled(false);
- tcpCertPathBrowseButton.setEnabled(false);
- }
- }
- });
- tcpAuthButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent e) {
- final Button targetButton = ((Button)e.widget);
- if(targetButton.getSelection()) {
- tcpTLSVerify = true;
- tcpCertPathText.setEnabled(true);
- tcpCertPathBrowseButton.setEnabled(true);
- } else {
- tcpTLSVerify = false;
- tcpCertPathText.setEnabled(false);
- tcpCertPathBrowseButton.setEnabled(false);
- }
- }
- });
- tcpHostText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent evt) {
- tcpHost = ((Text)evt.widget).getText();
- }
- });
- tcpCertPathText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent evt) {
- tcpCertPath = ((Text)evt.widget).getText();
- }
- });
-
- // now that all widgets and their selectionAdapters are instanciated, let's set the values
- if(this.bindingMode == UNIX_SOCKET) {
- unixSocketBtn.setSelection(true);
- if(this.unixSocketPath != null) {
- unixSocketPathText.setText(this.unixSocketPath);
- }
- // disable other widgets
- tcpHostText.setEnabled(false);
- tcpAuthButton.setEnabled(false);
- tcpCertPathText.setEnabled(false);
- tcpCertPathBrowseButton.setEnabled(false);
- } else {
- tcpConnectionBtn.setSelection(true);
- if(this.tcpHost != null) {
- tcpHostText.setText(this.tcpHost);
- }
- if(this.tcpTLSVerify) {
- tcpAuthButton.setSelection(true);
- tcpCertPathText.setEnabled(true);
- if(this.tcpCertPath != null) {
- tcpCertPathText.setText(this.tcpCertPath);
- }
- tcpCertPathBrowseButton.setEnabled(true);
- }
- // disable other widgets
- unixSocketBtn.setSelection(false);
- unixSocketPathText.setEnabled(false);
- }
- }
-
- /**
* Create a container for the refresh rate property
* @param parent the parent container
*/
@@ -275,21 +92,26 @@ public class DockerPreferencePage extends PreferencePage implements
final Composite container = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).span(1, 1).grab(true, false).applyTo(container);
GridLayoutFactory.fillDefaults().margins(0, 0).spacing(10, 2).applyTo(container);
- final IntegerFieldEditor refreshTime = new IntegerFieldEditor(PreferenceConstants.REFRESH_TIME,
+ refreshTimeField = new IntegerFieldEditor(
+ PreferenceConstants.REFRESH_TIME,
Messages.getString(REFRESH_TIME_MSG), container);
-
- refreshTime.setValidRange(5, 200);
+ refreshTimeField.setPreferenceStore(getPreferenceStore());
+ refreshTimeField
+ .setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
+ refreshTimeField.setValidRange(5, 200);
+ refreshTimeField.load();
// If the preference changes, alert the Refresh Manager
- Activator.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(PreferenceConstants.REFRESH_TIME))
- DockerContainerRefreshManager.getInstance().setRefreshTime(refreshTime.getIntValue());
- }
- });
+ refreshTimeField
+ .setPropertyChangeListener(new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getSource().equals(refreshTimeField)) {
+ DockerContainerRefreshManager.getInstance()
+ .setRefreshTime(
+ refreshTimeField.getIntValue());
+ }
+ }
+ });
}
-
-
-
} \ No newline at end of file
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/PreferenceInitializer.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/PreferenceInitializer.java
index aa7c26b1e0..71885e81ce 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/PreferenceInitializer.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/preferences/PreferenceInitializer.java
@@ -10,13 +10,6 @@
*******************************************************************************/
package org.eclipse.linuxtools.internal.docker.ui.preferences;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.BINDING_MODE;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.TCP_CERT_PATH;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.TCP_CONNECTION;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.TCP_HOST;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.TCP_TLS_VERIFY;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.UNIX_SOCKET;
-import static org.eclipse.linuxtools.docker.core.EnumDockerConnectionSettings.UNIX_SOCKET_PATH;
import static org.eclipse.linuxtools.internal.docker.ui.preferences.PreferenceConstants.AUTOLOG_ON_START;
import static org.eclipse.linuxtools.internal.docker.ui.preferences.PreferenceConstants.LOG_TIMESTAMP;
import static org.eclipse.linuxtools.internal.docker.ui.preferences.PreferenceConstants.REFRESH_TIME;
@@ -24,7 +17,6 @@ import static org.eclipse.linuxtools.internal.docker.ui.preferences.PreferenceCo
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.linuxtools.docker.ui.Activator;
-import org.eclipse.linuxtools.internal.docker.core.DockerConnection;
/**
* Class used to initialize default preference values.
@@ -40,30 +32,6 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
public void initializeDefaultPreferences() {
final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(REFRESH_TIME, 15);
- // sadly, this will only work if the DOCKER environment variables were set
- // as the system level, not in a .bash_rc or similar terminal session script
- // which Eclipse cannot access when it is launched from the Dock (or menu).
- final String defaultDockerHost = System.getenv("DOCKER_HOST"); //$NON-NLS-1$
- final String defaultDockerTLSVerify = System.getenv("DOCKER_TLS_VERIFY"); //$NON-NLS-1$
- final String defaultDockerCertPath = System.getenv("DOCKER_CERT_PATH"); //$NON-NLS-1$
- //FIXME: can we use the OS name to provide smarter default values ?
- if (defaultDockerHost == null || defaultDockerHost.equals("")) {
- store.setDefault(BINDING_MODE.toString(), UNIX_SOCKET.toString());
- store.setDefault(UNIX_SOCKET_PATH.toString(), DockerConnection.Defaults.DEFAULT_UNIX_SOCKET_PATH);
- } else if(defaultDockerHost.startsWith("unix://")) {
- store.setDefault(BINDING_MODE.toString(), UNIX_SOCKET.toString());
- store.setDefault(UNIX_SOCKET_PATH.toString(), defaultDockerHost);
- } else {
- store.setDefault(BINDING_MODE.toString(), TCP_CONNECTION.toString());
- store.setDefault(TCP_HOST.toString(), defaultDockerHost);
- if("1".equals(defaultDockerTLSVerify)) {
- store.setDefault(TCP_TLS_VERIFY.toString(), Boolean.TRUE);
- }
- if(defaultDockerCertPath != null && !defaultDockerCertPath.isEmpty()) {
- store.setDefault(TCP_CERT_PATH.toString(), defaultDockerCertPath);
- }
- }
-
store.setDefault(AUTOLOG_ON_START, true);
store.setDefault(LOG_TIMESTAMP, true);
}

Back to the top