Omaha #3236 thin client connectivity dialog remembers past proxy servers

Change-Id: I54c6032e451366fd3dee67da874f79dc690caa2a

Former-commit-id: 353872377cc3f96db4d3a22c6646fccb3edcb865
This commit is contained in:
Nate Jensen 2014-06-24 17:27:57 -05:00
parent 8dc15b71b5
commit 760b0cb584
2 changed files with 56 additions and 32 deletions

View file

@ -30,7 +30,8 @@ package com.raytheon.uf.viz.thinclient.preferences;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 20, 2011 mschenke Initial creation * Oct 20, 2011 mschenke Initial creation
* Jan 14, 2013 1469 bkowal The hdf5 data directory is no longer a preference constant. * Jan 14, 2013 1469 bkowal The hdf5 data directory is no longer a preference constant.
* Feb 04, 2014 2704 njensen Single proxy preference constant * Feb 04, 2014 2704 njensen Consolidate services and pypies proxy addresses
* Jun 24, 2014 3236 njensen Added proxy address options
* *
* </pre> * </pre>
* *
@ -69,4 +70,6 @@ public class ThinClientPreferenceConstants {
public static String P_PREFERENCE_PLACEHOLDER = "placeholderPreference"; public static String P_PREFERENCE_PLACEHOLDER = "placeholderPreference";
public static String P_PROXY_ADDRESS = "proxyAddress"; public static String P_PROXY_ADDRESS = "proxyAddress";
public static final String P_PROXY_SERVER_OPTIONS = "proxyAddressOptions";
} }

View file

@ -31,7 +31,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.localization.msgs.GetServersResponse; import com.raytheon.uf.common.localization.msgs.GetServersResponse;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
@ -44,6 +43,8 @@ import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.ConnectivityPreferenceDialog; import com.raytheon.uf.viz.core.localization.ConnectivityPreferenceDialog;
import com.raytheon.uf.viz.core.localization.LocalizationConstants; import com.raytheon.uf.viz.core.localization.LocalizationConstants;
import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.core.localization.ServerRemembrance;
import com.raytheon.uf.viz.core.localization.TextOrCombo;
import com.raytheon.uf.viz.thinclient.Activator; import com.raytheon.uf.viz.thinclient.Activator;
import com.raytheon.uf.viz.thinclient.ThinClientUriUtil; import com.raytheon.uf.viz.thinclient.ThinClientUriUtil;
import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
@ -65,6 +66,7 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
* Feb 20, 2014 2704 njensen Fix issues where settings are valid * Feb 20, 2014 2704 njensen Fix issues where settings are valid
* but dialog doesn't realize it * but dialog doesn't realize it
* Jun 03, 2014 3217 bsteffen Add option to always open startup dialog. * Jun 03, 2014 3217 bsteffen Add option to always open startup dialog.
* Jun 24, 2014 3236 njensen Add ability to remember multiple servers
* *
* *
* *
@ -141,7 +143,7 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
private IConnectivityCallback jmsCallback = new JmsCallback(); private IConnectivityCallback jmsCallback = new JmsCallback();
private Text proxyText; private TextOrCombo proxySrv;
private String proxyAddress; private String proxyAddress;
@ -183,11 +185,15 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
} }
}); });
proxyText = new Text(proxyComp, SWT.NONE | SWT.BORDER); IPreferenceStore thinPrefs = Activator.getDefault()
.getPreferenceStore();
String[] proxyOptions = ServerRemembrance.getServerOptions(thinPrefs,
ThinClientPreferenceConstants.P_PROXY_SERVER_OPTIONS);
proxySrv = new TextOrCombo(proxyComp, SWT.BORDER, proxyOptions);
gd = new GridData(SWT.FILL, SWT.CENTER, true, true); gd = new GridData(SWT.FILL, SWT.CENTER, true, true);
proxyText.setLayoutData(gd); proxySrv.widget.setLayoutData(gd);
proxyText.setText(proxyAddress == null ? "" : proxyAddress); proxySrv.setText(proxyAddress == null ? "" : proxyAddress);
proxyText.setBackground(getTextColor(servicesGood && pypiesGood)); proxySrv.widget.setBackground(getTextColor(servicesGood && pypiesGood));
new Label(textBoxComp, SWT.NONE); new Label(textBoxComp, SWT.NONE);
@ -235,20 +241,28 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
@Override @Override
protected void applySettings() { protected void applySettings() {
IPersistentPreferenceStore localStore = LocalizationManager IPersistentPreferenceStore thinStore = Activator.getDefault()
.getInstance()
.getLocalizationStore();
IPersistentPreferenceStore store = Activator.getDefault()
.getPreferenceStore(); .getPreferenceStore();
store.setValue(ThinClientPreferenceConstants.P_DISABLE_JMS, disableJms); thinStore.setValue(ThinClientPreferenceConstants.P_DISABLE_JMS,
disableJms);
thinStore.setValue(ThinClientPreferenceConstants.P_USE_PROXIES,
useProxy);
IPersistentPreferenceStore localStore = LocalizationManager
.getInstance().getLocalizationStore();
localStore.setValue( localStore.setValue(
LocalizationConstants.P_LOCALIZATION_PROMPT_ON_STARTUP, LocalizationConstants.P_LOCALIZATION_PROMPT_ON_STARTUP,
alwaysPrompt); alwaysPrompt);
if (useProxy) { if (useProxy) {
store.setValue(ThinClientPreferenceConstants.P_USE_PROXIES, thinStore.setValue(ThinClientPreferenceConstants.P_PROXY_ADDRESS,
useProxy);
store.setValue(ThinClientPreferenceConstants.P_PROXY_ADDRESS,
proxyAddress); proxyAddress);
String proxyServerOptions = ServerRemembrance.formatServerOptions(
proxyAddress, thinStore,
ThinClientPreferenceConstants.P_PROXY_SERVER_OPTIONS);
thinStore.setValue(
ThinClientPreferenceConstants.P_PROXY_SERVER_OPTIONS,
proxyServerOptions);
if (getAlertVizServer() != null) { if (getAlertVizServer() != null) {
localStore.setValue(LocalizationConstants.P_ALERT_SERVER, localStore.setValue(LocalizationConstants.P_ALERT_SERVER,
@ -256,13 +270,6 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
} }
LocalizationManager.getInstance().setCurrentSite(getSite()); LocalizationManager.getInstance().setCurrentSite(getSite());
try {
store.save();
} catch (IOException e) {
statusHandler.handle(Priority.SIGNIFICANT,
"Unable to persist thinclient localization preference store",
e);
}
try { try {
localStore.save(); localStore.save();
} catch (IOException e) { } catch (IOException e) {
@ -273,6 +280,19 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
super.applySettings(); super.applySettings();
} }
/*
* Have to store the thin client preferences either way to remember the
* JMS and proxy checkboxes correctly
*/
try {
thinStore.save();
} catch (IOException e) {
statusHandler
.handle(Priority.SIGNIFICANT,
"Unable to persist thinclient localization preference store",
e);
}
} }
@Override @Override
@ -287,9 +307,9 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
details = null; details = null;
// validate proxy // validate proxy
if (proxyText != null && !proxyText.isDisposed() if (proxySrv != null && !proxySrv.widget.isDisposed()
&& proxyText.isEnabled()) { && proxySrv.widget.isEnabled()) {
proxyAddress = proxyText.getText(); proxyAddress = proxySrv.getText();
} }
if (proxyAddress != null && proxyAddress.length() > 0) { if (proxyAddress != null && proxyAddress.length() > 0) {
validateServices(); validateServices();
@ -297,8 +317,9 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
} else { } else {
status = "Please enter a thin client proxy server address"; status = "Please enter a thin client proxy server address";
} }
if (proxyText != null && !proxyText.isDisposed()) { if (proxySrv != null && !proxySrv.widget.isDisposed()) {
proxyText.setBackground(getTextColor(servicesGood && pypiesGood)); proxySrv.widget.setBackground(getTextColor(servicesGood
&& pypiesGood));
} }
validateJms(servicesGood); validateJms(servicesGood);
@ -345,15 +366,15 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog {
private void updateProxyEnabled() { private void updateProxyEnabled() {
useProxy = useProxyCheck.getSelection(); useProxy = useProxyCheck.getSelection();
proxyText.setEnabled(useProxy); proxySrv.widget.setEnabled(useProxy);
super.setLocalizationEnabled(!useProxy); super.setLocalizationEnabled(!useProxy);
if (useProxy) { if (useProxy) {
if (localizationText != null && !localizationText.isDisposed()) { if (localizationSrv != null && !localizationSrv.widget.isDisposed()) {
localizationText.setBackground(getTextColor(true)); localizationSrv.widget.setBackground(getTextColor(true));
} }
} else { } else {
if (proxyText != null && !proxyText.isDisposed()) { if (proxySrv != null && !proxySrv.widget.isDisposed()) {
proxyText.setBackground(getTextColor(true)); proxySrv.widget.setBackground(getTextColor(true));
} }
} }
validate(); validate();