From f957dd8e188e245722a08a493172ea0859edd001 Mon Sep 17 00:00:00 2001 From: Nate Jensen Date: Thu, 26 Jun 2014 14:03:14 -0500 Subject: [PATCH] Omaha #3236 thin client pref page supports proxy server as text or combo field Change-Id: I7514d27a9b404e1c33cb6f7292475ff99bed4de0 Former-commit-id: e5c3c32bcb3f453f71315556b70158b00a8abf07 [formerly f4c1691c8d43a3990bfc7e2857c5fc88d7ca4b21] [formerly e5c3c32bcb3f453f71315556b70158b00a8abf07 [formerly f4c1691c8d43a3990bfc7e2857c5fc88d7ca4b21] [formerly 061482b0157f73e69136f85d689495b47ef2c700 [formerly 1a9433a524e5b8267fc3303db0763ac4685ec46d]]] Former-commit-id: 061482b0157f73e69136f85d689495b47ef2c700 Former-commit-id: dc99cf6c15f47203731ae7a1bee7e9ca23efc95e [formerly 40a3c0a372ecb35c50a647176650ed798ec14e5a] Former-commit-id: 392ddd5ce0bc31928aae66993afecdc609ee9a34 --- .../ThinClientServerPreferences.java | 30 ++++++++++++------- .../ui/ThinClientConnectivityDialog.java | 14 +++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/preferences/ThinClientServerPreferences.java b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/preferences/ThinClientServerPreferences.java index c215164a25..42c5e8935f 100644 --- a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/preferences/ThinClientServerPreferences.java +++ b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/preferences/ThinClientServerPreferences.java @@ -22,7 +22,6 @@ package com.raytheon.uf.viz.thinclient.cave.preferences; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -30,11 +29,12 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Text; import com.raytheon.uf.viz.core.comm.ConnectivityManager; import com.raytheon.uf.viz.core.comm.ConnectivityManager.ConnectivityResult; import com.raytheon.uf.viz.core.comm.IConnectivityCallback; +import com.raytheon.uf.viz.core.localization.TextOrCombo; +import com.raytheon.uf.viz.core.localization.TextOrComboEditor; import com.raytheon.uf.viz.thinclient.Activator; import com.raytheon.uf.viz.thinclient.ThinClientUriUtil; import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; @@ -53,6 +53,7 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; * preference. * Aug 02, 2013 2202 bsteffen Add edex specific connectivity checking. * Feb 04, 2014 2704 njensen Only one field for proxy server + * Jun 26, 2014 3236 njensen Proxy server can now be text or combo field * * * @@ -63,7 +64,7 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage { private BooleanFieldEditor useProxies; - private StringFieldEditor proxyServer; + private TextOrComboEditor proxyServer; private Button connectivityButton; @@ -86,15 +87,23 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage { */ @Override protected void createFieldEditors() { - useProxies = new BooleanFieldEditor( ThinClientPreferenceConstants.P_USE_PROXIES, "&Use Proxy Servers", getFieldEditorParent()); addField(useProxies); - proxyServer = new StringFieldEditor( + proxyServer = new TextOrComboEditor(getFieldEditorParent(), + this.getPreferenceStore(), ThinClientPreferenceConstants.P_PROXY_ADDRESS, - "&Proxy Address: ", getFieldEditorParent()); + ThinClientPreferenceConstants.P_PROXY_SERVER_OPTIONS, + "&Proxy Address: "); + proxyServer.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + checkConnectivity(); + } + }); + proxyServer.setErrorMessage("Cannot connect to Proxy server"); addField(proxyServer); @@ -132,7 +141,8 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage { boolean serverError = false; // check HTTP Server - Text text = proxyServer.getTextControl(getFieldEditorParent()); + TextOrCombo text = proxyServer + .getTextOrComboControl(getFieldEditorParent()); String proxyAddr = text.getText().trim(); ConnectivityManager.checkLocalizationServer( ThinClientUriUtil.getServicesAddress(proxyAddr), @@ -154,10 +164,10 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage { }); if (servicesResult.hasConnectivity && pypiesResult.hasConnectivity) { - text.setBackground(Display.getDefault().getSystemColor( - SWT.COLOR_WHITE)); + text.widget.setBackground(null); + proxyServer.clearErrorMessage(); } else { - text.setBackground(Display.getDefault().getSystemColor( + text.widget.setBackground(Display.getDefault().getSystemColor( SWT.COLOR_RED)); serverError = true; } diff --git a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ui/ThinClientConnectivityDialog.java b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ui/ThinClientConnectivityDialog.java index 24dbf89898..41deab339f 100644 --- a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ui/ThinClientConnectivityDialog.java +++ b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ui/ThinClientConnectivityDialog.java @@ -26,6 +26,7 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -194,6 +195,19 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { proxySrv.widget.setLayoutData(gd); proxySrv.setText(proxyAddress == null ? "" : proxyAddress); proxySrv.widget.setBackground(getTextColor(servicesGood && pypiesGood)); + proxySrv.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + // user clicked an option + validate(); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // user hit Enter + performOk(); + } + }); new Label(textBoxComp, SWT.NONE);