diff --git a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java index 81a397b09e..dca22bfe46 100644 --- a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java +++ b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java @@ -77,6 +77,7 @@ import com.raytheon.viz.ui.personalities.awips.CAVE; * Jun 26, 2015 4474 bsteffen Register the PathManager as an OSGi service. * Dec 04, 2015 5169 bsteffen Allow ProductAlertObserver to send messages * to the AutoUpdater + * Feb 08, 2016, 5281 tjensen Combined Data and Menu Refresh Intervals * * * @@ -93,13 +94,6 @@ public class ThinClientComponent extends CAVE implements IThinClientComponent { private StatsJob statsJob; - /* - * (non-Javadoc) - * - * @see - * com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent#startInternal - * (java.lang.String) - */ @Override protected void startInternal(String componentName) throws Exception { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); @@ -111,7 +105,7 @@ public class ThinClientComponent extends CAVE implements IThinClientComponent { // Initialize the timed menu time refresher store.addPropertyChangeListener(new TimedRefresher( new MenuTimeRefreshTask(), - ThinClientPreferenceConstants.P_MENU_TIME_REFRESH_INTERVAL)); + ThinClientPreferenceConstants.P_DATA_REFRESH_INTERVAL)); // Start network statistics statsJob = new StatsJob("HTTP Network Statistics", HttpClient @@ -163,12 +157,6 @@ public class ThinClientComponent extends CAVE implements IThinClientComponent { .getUnderlyingFactory())); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent# - * initializeLocalization() - */ @Override protected void initializeLocalization() throws Exception { /* @@ -197,23 +185,11 @@ public class ThinClientComponent extends CAVE implements IThinClientComponent { PathManagerFactory.getPathManager(), null); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.personalities.awips.AbstractAWIPSComponent# - * createAWIPSWorkbenchAdvisor() - */ @Override protected AWIPSWorkbenchAdvisor createAWIPSWorkbenchAdvisor() { return new ThinClientWorkbenchAdvisor(); } - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent# - * initializeObservers() - */ @Override protected void initializeObservers() { ThinClientNotificationManagerJob.getInstance(); diff --git a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/preferences/ThinClientConnectionPreferences.java b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/preferences/ThinClientConnectionPreferences.java index 3f9e857614..c4c4ada054 100644 --- a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/preferences/ThinClientConnectionPreferences.java +++ b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/preferences/ThinClientConnectionPreferences.java @@ -23,6 +23,7 @@ package com.raytheon.uf.viz.thinclient.cave.preferences; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.ComboFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.RadioGroupFieldEditor; import org.eclipse.jface.util.PropertyChangeEvent; import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore; @@ -39,6 +40,8 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Nov 8, 2011 mschenke Initial creation + * Feb 08, 2016, 5281 tjensen Replaced disableJms checkbox with radio buttons + * and combined Data and Menu Refresh Intervals * * * @@ -47,12 +50,10 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; */ public class ThinClientConnectionPreferences extends FieldEditorPreferencePage { - private BooleanFieldEditor disableJMS; + private RadioGroupFieldEditor dataRefreshMethod; private BooleanFieldEditor disableMenuTimes; - private ComboFieldEditor menuTimeInterval; - private ComboFieldEditor dataUpdateInterval; /** @@ -65,49 +66,35 @@ public class ThinClientConnectionPreferences extends FieldEditorPreferencePage { setDescription("Thin Client Connections"); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors - * () - */ @Override protected void createFieldEditors() { - disableJMS = new BooleanFieldEditor( - ThinClientPreferenceConstants.P_DISABLE_JMS, "Disable &JMS", + dataRefreshMethod = new RadioGroupFieldEditor( + ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD, + "Data Refresh: ", + 2, + new String[][] { + { + "&Automatic Push", + ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_PUSH }, + { + "&Timed Poll", + ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_POLL } }, getFieldEditorParent()); - addField(disableJMS); + addField(dataRefreshMethod); disableMenuTimes = new BooleanFieldEditor( ThinClientPreferenceConstants.P_DISABLE_MENU_TIMES, - "Disable Menu &Times", getFieldEditorParent()); + "Disable &Menu Times", getFieldEditorParent()); addField(disableMenuTimes); HierarchicalPreferenceStore uiStore = Activator.getDefault() .getUiPreferenceStore(); - float[] intervals = uiStore - .getFloatArray(ThinClientPreferenceConstants.P_MENU_TIME_UPDATE_INTERVALS); - String[][] values = new String[intervals.length + 1][2]; - values[0] = new String[] { "Off", "0" }; - for (int i = 0; i < intervals.length; ++i) { - String val = Integer.toString((int) intervals[i]); - values[i + 1] = new String[] { val, val }; - } - - menuTimeInterval = new ComboFieldEditor( - ThinClientPreferenceConstants.P_MENU_TIME_REFRESH_INTERVAL, - "&Menu Time Update Interval (min)", values, - getFieldEditorParent()); - - // TODO: Hook in periodic menu time updating (URICatalog?) - addField(menuTimeInterval); // Add data update options - intervals = uiStore + float[] intervals = uiStore .getFloatArray(ThinClientPreferenceConstants.P_DATA_UPDATE_INTERVALS); - values = new String[intervals.length + 1][2]; + String[][] values = new String[intervals.length + 1][2]; values[0] = new String[] { "Off", "0" }; for (int i = 0; i < intervals.length; ++i) { String val = Integer.toString((int) intervals[i]); @@ -119,30 +106,25 @@ public class ThinClientConnectionPreferences extends FieldEditorPreferencePage { "&Data Update Interval (min)", values, getFieldEditorParent()); addField(dataUpdateInterval); - boolean disableJMS = getPreferenceStore().getBoolean( - ThinClientPreferenceConstants.P_DISABLE_JMS); - menuTimeInterval.setEnabled(disableJMS, getFieldEditorParent()); + boolean disableJMS = ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_POLL + .equals(getPreferenceStore().getString( + ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD)); dataUpdateInterval.setEnabled(disableJMS, getFieldEditorParent()); } @Override public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); - this.updateEnabledFields(); + if (event.getSource() == dataRefreshMethod) { + this.updateEnabledFields((String) event.getNewValue()); + } + ; } - @Override - protected void checkState() { - super.checkState(); - this.updateEnabledFields(); - } - - private void updateEnabledFields() { - boolean disableMenuTimes = this.disableMenuTimes.getBooleanValue(); - boolean disableJMS = this.disableJMS.getBooleanValue(); + private void updateEnabledFields(String refreshMethod) { + boolean disableJMS = ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_POLL + .equals(refreshMethod); dataUpdateInterval.setEnabled(disableJMS, getFieldEditorParent()); - menuTimeInterval.setEnabled(!disableMenuTimes && disableJMS, - getFieldEditorParent()); } } 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 c8aa01fd84..10efa97156 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 @@ -20,9 +20,7 @@ package com.raytheon.uf.viz.thinclient.cave.preferences; -import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -55,6 +53,7 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; * 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 * Oct 08, 2015 4891 njensen Added tooltip to useProxies + * Feb 09, 2016 5281 tjensen Remove option for Use Proxy Server * * * @@ -63,8 +62,6 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; */ public class ThinClientServerPreferences extends FieldEditorPreferencePage { - private BooleanFieldEditor useProxies; - private TextOrComboEditor proxyServer; private Button connectivityButton; @@ -79,23 +76,8 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage { setDescription("Thin Client Servers (changes require a restart)"); } - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors - * () - */ @Override protected void createFieldEditors() { - useProxies = new BooleanFieldEditor( - ThinClientPreferenceConstants.P_USE_PROXIES, - "&Use Proxy Servers", getFieldEditorParent()); - useProxies - .getDescriptionControl(getFieldEditorParent()) - .setToolTipText( - "Connect to a remote proxy server configured to support thin clients"); - addField(useProxies); proxyServer = new TextOrComboEditor(getFieldEditorParent(), this.getPreferenceStore(), @@ -182,22 +164,4 @@ public class ThinClientServerPreferences extends FieldEditorPreferencePage { } } - @Override - public void propertyChange(PropertyChangeEvent event) { - super.propertyChange(event); - this.updateEnabledFields(); - } - - @Override - protected void checkState() { - super.checkState(); - this.updateEnabledFields(); - } - - private void updateEnabledFields() { - boolean useProxies = this.useProxies.getBooleanValue(); - proxyServer.setEnabled(useProxies, connectivityButton.getParent()); - connectivityButton.setEnabled(useProxies); - } - } diff --git a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/DataRefreshTask.java b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/DataRefreshTask.java index f3ca4f41aa..d43ac33183 100644 --- a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/DataRefreshTask.java +++ b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/DataRefreshTask.java @@ -45,6 +45,7 @@ import com.raytheon.viz.alerts.observers.ProductAlertObserver; * Feb 21, 2014 16744 dfriedman Update all alert observers * Dec 04, 2015 5169 bsteffen Allow ProductAlertObserver to send messages * to the AutoUpdater + * Feb 08, 2016 5281 tjensen Replaced disableJms with dataRefreshMethod * * * @@ -54,15 +55,12 @@ import com.raytheon.viz.alerts.observers.ProductAlertObserver; public class DataRefreshTask implements RefreshTimerTask { - /* - * (non-Javadoc) - * - * @see java.util.TimerTask#run() - */ @Override public void run() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - if (store.getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS)) { + if (ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_POLL + .equals(store + .getString(ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD))) { Collection alerts = ThinClientDataUpdateTree .getInstance().updateAllData(); @@ -75,25 +73,11 @@ public class DataRefreshTask implements RefreshTimerTask { } } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.thinclient.refresh.TimedRefresher.RefreshTimerTask - * #scheduled() - */ @Override public void scheduled() { } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.thinclient.refresh.TimedRefresher.RefreshTimerTask - * #stopped() - */ @Override public void stopped() { diff --git a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/MenuTimeRefreshTask.java b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/MenuTimeRefreshTask.java index 2675424050..c4240f3fc2 100644 --- a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/MenuTimeRefreshTask.java +++ b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/refresh/MenuTimeRefreshTask.java @@ -24,7 +24,6 @@ import org.eclipse.jface.preference.IPreferenceStore; import com.raytheon.uf.viz.thinclient.Activator; import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; import com.raytheon.uf.viz.thinclient.refresh.TimedRefresher.RefreshTimerTask; -import com.raytheon.viz.alerts.jobs.MenuUpdater; /** * Timer task that is responsible for requerying menu times @@ -36,6 +35,7 @@ import com.raytheon.viz.alerts.jobs.MenuUpdater; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Nov 10, 2011 mschenke Initial creation + * Feb 08, 2016 5281 tjensen Replaced disableJms with dataRefreshMethod * * * @@ -45,42 +45,23 @@ import com.raytheon.viz.alerts.jobs.MenuUpdater; public class MenuTimeRefreshTask implements RefreshTimerTask { - private MenuUpdater menuUpdater = new MenuUpdater(); - - /* - * (non-Javadoc) - * - * @see java.util.TimerTask#run() - */ @Override public void run() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - if (!store.getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS)) { + if (ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_PUSH + .equals(store + .getString(ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD))) { return; } ThinClientURICatalog.getInstance().requeryAllMenuTimes(); } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.thinclient.refresh.TimedRefresher.RefreshTimerTask - * #scheduled() - */ @Override public void scheduled() { } - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.thinclient.refresh.TimedRefresher.RefreshTimerTask - * #stopped() - */ @Override public void stopped() { diff --git a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ThinClientNotificationManagerJob.java b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ThinClientNotificationManagerJob.java index 7e058551c6..0b427b0aa5 100644 --- a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ThinClientNotificationManagerJob.java +++ b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/ThinClientNotificationManagerJob.java @@ -36,8 +36,8 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; /** * Listens to changes to the "Disable JMS" option in the Thin Client - * Preferences. Will automatically connect to and disconnect from the - * JMS Server as the option is updated. + * Preferences. Will automatically connect to and disconnect from the JMS Server + * as the option is updated. * *
  * 
@@ -48,6 +48,7 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
  * Nov 29, 2011            bsteffen     Initial creation
  * Aug 27, 2013 2295       bkowal       The entire jms connection string is now
  *                                      provided by EDEX.
+ * Feb 08, 2016 5281       tjensen      Replaced disableJms with dataRefreshMethod
  * 
  * 
* @@ -62,7 +63,7 @@ public class ThinClientNotificationManagerJob extends NotificationManagerJob private static ThinClientNotificationManagerJob instance; - private Boolean disableJMS; + private String dataRefreshMethod; public static synchronized ThinClientNotificationManagerJob getInstance() { if (instance == null) { @@ -75,17 +76,20 @@ public class ThinClientNotificationManagerJob extends NotificationManagerJob public ThinClientNotificationManagerJob() { super(); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - disableJMS = store - .getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS); + dataRefreshMethod = store + .getString(ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD); + store.addPropertyChangeListener(this); - if (!disableJMS) { + if (ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_PUSH + .equals(dataRefreshMethod)) { connect(true); } } @Override protected void connect(boolean notifyError) { - if (disableJMS == null || disableJMS) { + if (ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_POLL + .equals(dataRefreshMethod)) { return; } else { super.connect(notifyError); @@ -94,10 +98,12 @@ public class ThinClientNotificationManagerJob extends NotificationManagerJob @Override public void propertyChange(PropertyChangeEvent event) { - if (ThinClientPreferenceConstants.P_DISABLE_JMS.equals(event + if (ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD.equals(event .getProperty())) { - disableJMS = Boolean.valueOf(String.valueOf(event.getNewValue())); - if (disableJMS) { + dataRefreshMethod = String.valueOf(event.getNewValue()); + + if (ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_POLL + .equals(dataRefreshMethod)) { disconnect(true); } else { if (VizApp.getJmsConnectionString() == null) { diff --git a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/localization/ThinClientLocalizationInitializer.java b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/localization/ThinClientLocalizationInitializer.java index ea3bdc74aa..df07ba6e9e 100644 --- a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/localization/ThinClientLocalizationInitializer.java +++ b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/localization/ThinClientLocalizationInitializer.java @@ -64,6 +64,7 @@ import com.raytheon.uf.viz.thinclient.ui.ThinClientConnectivityDialog; * Sep 05, 2014 3570 bclement HTTP client API changes * Jan 26, 2015 3952 njensen gzip handled by default * Jul 06, 2015 4614 njensen explicitly enable gzip + * Feb 08, 2016 5281 tjensen Replaced disableJms with dataRefreshMethod * * * @@ -100,8 +101,8 @@ public class ThinClientLocalizationInitializer extends LocalizationInitializer { } IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - boolean disableJMS = store - .getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS); + String dataRefreshMethod = store + .getString(ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD); if (store.getBoolean(ThinClientPreferenceConstants.P_USE_PROXIES)) { String proxyAddr = store @@ -129,12 +130,11 @@ public class ThinClientLocalizationInitializer extends LocalizationInitializer { false); VizApp.setHttpServer(servicesProxy); - if (!disableJMS) { + if (ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_PUSH + .equals(dataRefreshMethod)) { GetServersResponse resp = ConnectivityManager .checkLocalizationServer(servicesProxy, false); - if (!disableJMS) { - VizApp.setJmsConnectionString(resp.getJmsConnectionString()); - } + VizApp.setJmsConnectionString(resp.getJmsConnectionString()); } String pypiesProxy = ThinClientUriUtil.getPypiesAddress(proxyAddr); @@ -146,7 +146,8 @@ public class ThinClientLocalizationInitializer extends LocalizationInitializer { VizServers.getInstance().setServerLocations(serversMap); } else { processGetServers(); - if (disableJMS) { + if (ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_POLL + .equals(dataRefreshMethod)) { VizApp.setJmsConnectionString(null); } } diff --git a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/PreferenceInitializer.java b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/PreferenceInitializer.java index 25647c5e00..c6dcee086a 100644 --- a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/PreferenceInitializer.java +++ b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/PreferenceInitializer.java @@ -38,6 +38,8 @@ import com.raytheon.uf.viz.thinclient.Activator; * ------------ ---------- ----------- -------------------------- * Oct 21, 2011 mschenke Initial creation * Oct 08, 2015 4891 njensen Default data update interval to 5 + * Feb 08, 2016 5281 tjensen Replaced disableJms with dataRefreshMethod, + * combined Data and Menu Refresh Intervals * * * @@ -61,8 +63,12 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { false); store.setDefault(ThinClientPreferenceConstants.P_CACHE_MAPS, true); - // By default keep jms enabled - store.setDefault(ThinClientPreferenceConstants.P_DISABLE_JMS, false); + /* + * By default, use automatic data push. If unavailable, timed poll + * method will be used. + */ + store.setDefault(ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD, + ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_PUSH); store.setDefault( ThinClientPreferenceConstants.P_ENABLE_REQUEST_COMPRESSION, @@ -71,9 +77,6 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { // Menu times will be enabled by default store.setDefault(ThinClientPreferenceConstants.P_DISABLE_MENU_TIMES, false); - // Default menu refresh interval - store.setDefault( - ThinClientPreferenceConstants.P_MENU_TIME_REFRESH_INTERVAL, 5); // Default data refresh rate store.setDefault(ThinClientPreferenceConstants.P_DATA_REFRESH_INTERVAL, diff --git a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/ThinClientPreferenceConstants.java b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/ThinClientPreferenceConstants.java index f8b93b6299..c17b54df73 100644 --- a/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/ThinClientPreferenceConstants.java +++ b/cave/com.raytheon.uf.viz.thinclient/src/com/raytheon/uf/viz/thinclient/preferences/ThinClientPreferenceConstants.java @@ -35,7 +35,8 @@ import org.eclipse.jface.preference.IPreferenceStore; * Feb 04, 2014 2704 njensen Consolidate services and pypies proxy addresses * Jun 24, 2014 3236 njensen Added proxy address options * May 29, 2015 4532 bsteffen Add sync localization option. - * + * Feb 08, 2016 5281 tjensen Replaced disableJms with dataRefreshMethod, + * combined Data and Menu Refresh Intervals * * * @@ -49,12 +50,8 @@ public class ThinClientPreferenceConstants { public static String P_DATA_REFRESH_INTERVAL = "dataRefreshRate"; - public static String P_MENU_TIME_REFRESH_INTERVAL = "menuRefreshInterval"; - public static String P_USE_PROXIES = "useHttpProxy"; - public static String P_MENU_TIME_UPDATE_INTERVALS = "menuTimeUpdateInterval"; - public static String P_DATA_UPDATE_INTERVALS = "dataUpdateInterval"; public static String P_CACHE_WEATHER = "cachePypies"; @@ -80,7 +77,11 @@ public class ThinClientPreferenceConstants { public static String P_DISABLE_MENU_TIMES = "disableMenuTimes"; - public static String P_DISABLE_JMS = "disableJms"; + public static String P_DATA_REFRESH_METHOD = "dataRefreshMethod"; + + public static String P_DATA_REFRESH_METHOD_PUSH = "push"; + + public static String P_DATA_REFRESH_METHOD_POLL = "poll"; public static String P_ENABLE_REQUEST_COMPRESSION = "enableRequestCompression"; 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 9e4e6a8c79..2f35597750 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,11 +26,11 @@ 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; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import com.raytheon.uf.common.localization.msgs.GetServersResponse; @@ -45,7 +45,6 @@ import com.raytheon.uf.viz.core.localization.ConnectivityPreferenceDialog; import com.raytheon.uf.viz.core.localization.LocalizationConstants; 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.ThinClientUriUtil; import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; @@ -69,6 +68,7 @@ import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants; * Jun 03, 2014 3217 bsteffen Add option to always open startup dialog. * Jun 24, 2014 3236 njensen Add ability to remember multiple servers * Oct 08, 2015 4891 njensen Added tooltip to useProxyCheck + * Feb 08, 2016, 5281 tjensen Reworked interface to simply options * * * @@ -127,113 +127,96 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { private IConnectivityCallback pypiesCallback = new PypiesCallback(); - private Button useProxyCheck; - - private boolean useProxy = false; - - private Button disableJmsCheck; + private boolean useProxy = true; private Button alwaysPromptCheck; - private boolean disableJms = false; + private String dataRefreshMethod; private boolean jmsGood = false; private boolean alwaysPrompt; - private Label jmsErrorLabel; - private IConnectivityCallback jmsCallback = new JmsCallback(); - private TextOrCombo proxySrv; - private String proxyAddress; + private Button autoPullBtn; + + private Button timedPollBtn; + + private final String dataRefreshTooltip = "Automatic Push: Data pushed as soon as available\n" + + "Timed Poll: Poll for new data at scheduled intervals"; + + private final String unableConnectJMS = "\n\nUnable to connect to JMS: Automatic Push disabled"; + + private Group dataRefreshGroup; + public ThinClientConnectivityDialog(boolean checkAlertViz) { super(checkAlertViz, "Thin Client Connectivity Preferences"); IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - useProxy = store - .getBoolean(ThinClientPreferenceConstants.P_USE_PROXIES); - disableJms = store - .getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS); + dataRefreshMethod = store + .getString(ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD); proxyAddress = store .getString(ThinClientPreferenceConstants.P_PROXY_ADDRESS); } + @Override + protected String[] getServerOptions() { + IPreferenceStore thinPrefs = Activator.getDefault() + .getPreferenceStore(); + return ServerRemembrance.getServerOptions(thinPrefs, + ThinClientPreferenceConstants.P_PROXY_SERVER_OPTIONS); + } + @Override protected void createTextBoxes(Composite textBoxComp) { super.createTextBoxes(textBoxComp); - Label label = new Label(textBoxComp, SWT.RIGHT); - label.setText("Use Proxy Server:"); - GridData gd = new GridData(SWT.RIGHT, SWT.CENTER, false, true); - gd.horizontalIndent = 20; - label.setLayoutData(gd); + // Reuse the localization stuff for proxy + localizationLabel.setText("Proxy Server:"); + localizationSrv.setText(proxyAddress == null ? "" : proxyAddress); - Composite proxyComp = new Composite(textBoxComp, SWT.NONE); + new Label(textBoxComp, SWT.NONE); + Composite drComp = new Composite(textBoxComp, SWT.NONE); GridLayout gl = new GridLayout(2, false); gl.marginHeight = 0; gl.marginWidth = 0; - proxyComp.setLayout(gl); - gd = new GridData(SWT.FILL, SWT.CENTER, true, false); - proxyComp.setLayoutData(gd); + drComp.setLayout(gl); + GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); + drComp.setLayoutData(gd); - useProxyCheck = new Button(proxyComp, SWT.CHECK | SWT.LEFT); - useProxyCheck.setSelection(useProxy); - useProxyCheck.addSelectionListener(new SelectionAdapter() { + dataRefreshGroup = new Group(drComp, SWT.BORDER_SOLID); + dataRefreshGroup.setText("Data Refresh:"); + gl = new GridLayout(2, true); + gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL + | GridData.GRAB_HORIZONTAL); + dataRefreshGroup.setLayout(gl); + dataRefreshGroup.setLayoutData(gd); + autoPullBtn = new Button(dataRefreshGroup, SWT.RADIO); + autoPullBtn.setText("Automatic Push"); + if (ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_PUSH + .equals(dataRefreshMethod)) { + autoPullBtn.setSelection(true); + } + timedPollBtn = new Button(dataRefreshGroup, SWT.RADIO); + timedPollBtn.setText("Timed Poll"); + if (ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_POLL + .equals(dataRefreshMethod)) { + timedPollBtn.setSelection(true); + } + timedPollBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - updateProxyEnabled(); - } - }); - useProxyCheck - .setToolTipText("Connect to a remote proxy server configured to support thin clients"); - - 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); - 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); - - Composite jmsComp = new Composite(textBoxComp, SWT.NONE); - gl = new GridLayout(2, false); - gl.marginHeight = 0; - gl.marginWidth = 0; - jmsComp.setLayout(gl); - - disableJmsCheck = new Button(jmsComp, SWT.CHECK | SWT.LEFT); - disableJmsCheck.setSelection(disableJms); - disableJmsCheck.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - disableJms = disableJmsCheck.getSelection(); + if (timedPollBtn.getSelection()) { + dataRefreshMethod = ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_POLL; + } else { + dataRefreshMethod = ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD_PUSH; + } validate(); } }); - disableJmsCheck.setText("Disable JMS"); - jmsErrorLabel = new Label(jmsComp, SWT.LEFT); - jmsErrorLabel.setText("Error connecting to JMS"); - jmsErrorLabel.setForeground(display.getSystemColor(SWT.COLOR_RED)); - jmsErrorLabel.setVisible(true); + dataRefreshGroup.setToolTipText(dataRefreshTooltip); new Label(textBoxComp, SWT.NONE); alwaysPrompt = LocalizationManager @@ -252,16 +235,14 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { } }); - - updateProxyEnabled(); } @Override protected void applySettings() { IPersistentPreferenceStore thinStore = Activator.getDefault() .getPreferenceStore(); - thinStore.setValue(ThinClientPreferenceConstants.P_DISABLE_JMS, - disableJms); + thinStore.setValue(ThinClientPreferenceConstants.P_DATA_REFRESH_METHOD, + dataRefreshMethod); thinStore.setValue(ThinClientPreferenceConstants.P_USE_PROXIES, useProxy); @@ -271,30 +252,26 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { LocalizationConstants.P_LOCALIZATION_PROMPT_ON_STARTUP, alwaysPrompt); - if (useProxy) { - thinStore.setValue(ThinClientPreferenceConstants.P_PROXY_ADDRESS, - proxyAddress); - String proxyServerOptions = ServerRemembrance.formatServerOptions( - proxyAddress, thinStore, - ThinClientPreferenceConstants.P_PROXY_SERVER_OPTIONS); - thinStore.setValue( - ThinClientPreferenceConstants.P_PROXY_SERVER_OPTIONS, - proxyServerOptions); + thinStore.setValue(ThinClientPreferenceConstants.P_PROXY_ADDRESS, + proxyAddress); + String proxyServerOptions = ServerRemembrance.formatServerOptions( + proxyAddress, thinStore, + ThinClientPreferenceConstants.P_PROXY_SERVER_OPTIONS); + thinStore.setValue( + ThinClientPreferenceConstants.P_PROXY_SERVER_OPTIONS, + proxyServerOptions); - if (getAlertVizServer() != null) { - localStore.setValue(LocalizationConstants.P_ALERT_SERVER, - getAlertVizServer()); - } - LocalizationManager.getInstance().setCurrentSite(getSite()); + if (getAlertVizServer() != null) { + localStore.setValue(LocalizationConstants.P_ALERT_SERVER, + getAlertVizServer()); + } + LocalizationManager.getInstance().setCurrentSite(getSite()); - try { - localStore.save(); - } catch (IOException e) { - statusHandler.handle(Priority.SIGNIFICANT, - "Unable to persist localization preference store", e); - } - } else { - super.applySettings(); + try { + localStore.save(); + } catch (IOException e) { + statusHandler.handle(Priority.SIGNIFICANT, + "Unable to persist localization preference store", e); } /* @@ -314,28 +291,24 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { @Override public boolean validate() { - if (!useProxy) { - boolean superResult = super.validate(); - validateJms(superResult); - return superResult && jmsGood; - } status = null; details = null; // validate proxy - if (proxySrv != null && !proxySrv.widget.isDisposed() - && proxySrv.widget.isEnabled()) { - proxyAddress = proxySrv.getText(); - } + proxyAddress = localizationSrv.getText(); + if (proxyAddress != null && proxyAddress.length() > 0) { validateServices(); validatePypies(); } else { + servicesGood = false; + pypiesGood = false; status = "Please enter a thin client proxy server address"; } - if (proxySrv != null && !proxySrv.widget.isDisposed()) { - proxySrv.widget.setBackground(getTextColor(servicesGood + + if (localizationSrv != null && !localizationSrv.widget.isDisposed()) { + localizationSrv.widget.setBackground(getTextColor(servicesGood && pypiesGood)); } @@ -381,22 +354,6 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { pypiesCallback); } - private void updateProxyEnabled() { - useProxy = useProxyCheck.getSelection(); - proxySrv.widget.setEnabled(useProxy); - super.setLocalizationEnabled(!useProxy); - if (useProxy) { - if (localizationSrv != null && !localizationSrv.widget.isDisposed()) { - localizationSrv.widget.setBackground(getTextColor(true)); - } - } else { - if (proxySrv != null && !proxySrv.widget.isDisposed()) { - proxySrv.widget.setBackground(getTextColor(true)); - } - } - validate(); - } - /** * Validates that a connection to JMS works. * @@ -404,36 +361,41 @@ public class ThinClientConnectivityDialog extends ConnectivityPreferenceDialog { * if we've successfully connected to edex */ private void validateJms(boolean hasEdexConnection) { - // only check Jms if it's enabled and we can connect to the services - if (!disableJms) { - if (hasEdexConnection) { - try { - String server = useProxy ? ThinClientUriUtil - .getServicesAddress(proxyAddress) - : getLocalization(); - GetServersResponse response = ConnectivityManager - .checkLocalizationServer(server, false); - ConnectivityManager.checkJmsServer( - response.getJmsConnectionString(), jmsCallback); - } catch (VizException e) { - if (status == null) { - status = "Error connecting to JMS"; - } - appendDetails(buildDetails(new ConnectivityResult(false, - null, e))); - jmsGood = false; - } - } else { - // JMS can't be good if we're not connected to edex cause - // then we don't even know where to connect to + if (hasEdexConnection) { + try { + String server = ThinClientUriUtil + .getServicesAddress(proxyAddress); + GetServersResponse response = ConnectivityManager + .checkLocalizationServer(server, false); + ConnectivityManager.checkJmsServer( + response.getJmsConnectionString(), jmsCallback); + } catch (VizException e) { + appendDetails(buildDetails(new ConnectivityResult(false, null, + e))); jmsGood = false; } - } - jmsGood = (jmsGood || disableJms); - if (jmsErrorLabel != null && !jmsErrorLabel.isDisposed()) { - jmsErrorLabel.setVisible(!jmsGood); + } else { + // JMS can't be good if we're not connected to edex cause + // then we don't even know where to connect to + jmsGood = false; } + // If display items are not disposed, update them as needed. + if (!autoPullBtn.isDisposed() && !timedPollBtn.isDisposed() + && !dataRefreshGroup.isDisposed()) { + if (jmsGood && !autoPullBtn.isEnabled()) { + autoPullBtn.setEnabled(true); + autoPullBtn.setSelection(true); + timedPollBtn.setSelection(false); + dataRefreshGroup.setToolTipText(dataRefreshTooltip); + } else if (!jmsGood && autoPullBtn.isEnabled()) { + autoPullBtn.setEnabled(false); + autoPullBtn.setSelection(false); + timedPollBtn.setSelection(true); + dataRefreshGroup.setToolTipText(dataRefreshTooltip + + unableConnectJMS); + } + } } }