From a49a3bbcc4f0b0109b1f3c0a7fb3748f022a05d7 Mon Sep 17 00:00:00 2001 From: Slav Korolev Date: Mon, 27 Oct 2014 14:53:45 -0400 Subject: [PATCH] Omaha #3667 - Corrected functionality of dialog. Former-commit-id: 45c9b0560a872a6415cfff367c9947b24960c52f [formerly fbb9e62cfc7733ceafd16367867f83fc28b4014b] [formerly 9f0b1a68e6850082576068a3631df3277c016160 [formerly cf354d6ac5668ba502feb188bdf17a0967168b19]] Former-commit-id: 9f0b1a68e6850082576068a3631df3277c016160 Former-commit-id: a3aaf1a7443cf20a0f96e647b31be45b06bea2a3 --- .../dialogs/FogMonitoringAreaConfigDlg.java | 22 ++--- .../ui/dialogs/SSMonitoringAreaConfigDlg.java | 20 ++-- .../dialogs/SnowMonitoringAreaConfigDlg.java | 19 ++-- .../ui/dialogs/MonitoringAreaConfigDlg.java | 93 +++++++++++-------- 4 files changed, 83 insertions(+), 71 deletions(-) diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java index f2beeb0cd3..fec8226307 100644 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java @@ -48,8 +48,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Apr 28, 2014 3086 skorolev Updated getConfigManager. * Sep 04, 2014 3220 skorolev Added fireConfigUpdateEvent method. Updated handler. * Sep 19, 2014 2757 skorolev Updated handlers for dialog buttons. - * Oct 16, 2014 3220 skorolev Corrected getInstance() method. - * + * Oct 16, 2014 3220 skorolev Corrected getInstance() method. + * Oct 27, 2014 3667 skorolev Cleaned code. * * * @@ -81,22 +81,18 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { @Override protected void handleOkBtnSelection() { if (dataIsChanged()) { - int choice = showMessage(shell, SWT.OK | SWT.CANCEL, - "Fog Monitor Confirm Changes", - "Want to Update Fog Monitor's Setup files?"); - if (choice == SWT.OK) { - // Save the configuration xml file - getValues(); - resetStatus(); - configMgr.saveConfigXml(); - configMgr.saveAdjacentAreaConfigXml(); - + int choice = showMessage(shell, SWT.YES | SWT.NO, + "Fog Monitor Confirm Changes", "Save changes?"); + if (choice == SWT.YES) { + // Save the config xml file. + resetAndSave(); /** * DR#11279: re-initialize threshold manager and the monitor * using new monitor area configuration */ FogThresholdMgr.reInitialize(); fireConfigUpdateEvent(); + // Open Threshold Dialog if zones/stations are added. if ((!configMgr.getAddedZones().isEmpty()) || (!configMgr.getAddedStations().isEmpty())) { if (editDialog() == SWT.YES) { @@ -118,6 +114,8 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { configMgr.getAddedZones().clear(); configMgr.getAddedStations().clear(); } + } else { // Return back to continue edit. + return; } } if ((fogMonitorDlg == null) || fogMonitorDlg.isDisposed()) { diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java index 228bb04f85..9ae677f9a4 100644 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java @@ -49,6 +49,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Sep 04, 2014 3220 skorolev Added fireConfigUpdateEvent method. Updated handler. * Sep 19, 2014 2757 skorolev Updated handlers for dialog buttons. * Oct 16, 2014 3220 skorolev Corrected getInstance() method. + * Oct 27, 2014 3667 skorolev Cleaned code. * * * @@ -75,19 +76,14 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { @Override protected void handleOkBtnSelection() { if (dataIsChanged()) { - int choice = showMessage(shell, SWT.OK | SWT.CANCEL, - "SAFESEAS Monitor Confirm Changes", - "Want to update the SAFESEAS setup files?"); - if (choice == SWT.OK) { - // Save the config xml file - getValues(); - resetStatus(); - configMgr.saveConfigXml(); - configMgr.saveAdjacentAreaConfigXml(); - + int choice = showMessage(shell, SWT.YES | SWT.NO, + "SAFESEAS Monitor Confirm Changes", "Save changes?"); + if (choice == SWT.YES) { + // Save the config xml file. + resetAndSave(); SSThresholdMgr.reInitialize(); fireConfigUpdateEvent(); - + // Open Threshold Dialog if zones/stations are added. if ((!configMgr.getAddedZones().isEmpty()) || (!configMgr.getAddedStations().isEmpty())) { if (editDialog() == SWT.YES) { @@ -110,6 +106,8 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { configMgr.getAddedZones().clear(); configMgr.getAddedStations().clear(); } + } else { // Return back to continue edit. + return; } } if ((ssMonitorDlg == null) || ssMonitorDlg.isDisposed()) { diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java index ce4a560ef8..9cebab2fb8 100644 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java @@ -49,6 +49,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Sep 04, 2014 3220 skorolev Added fireConfigUpdateEvent method. Updated handler. * Sep 19, 2014 2757 skorolev Updated handlers for dialog buttons. * Oct 16, 2014 3220 skorolev Corrected getInstance() method. + * Oct 27, 2014 3667 skorolev Cleaned code. * * * @@ -80,18 +81,14 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { @Override protected void handleOkBtnSelection() { if (dataIsChanged()) { - int choice = showMessage(shell, SWT.OK | SWT.CANCEL, - "SNOW Monitor Confirm Changes", - "Want to update the SNOW setup files?"); - if (choice == SWT.OK) { - // Save the config xml file - getValues(); - resetStatus(); - configMgr.saveConfigXml(); - configMgr.saveAdjacentAreaConfigXml(); - + int choice = showMessage(shell, SWT.YES | SWT.NO, + "SNOW Monitor Confirm Changes", "Save changes?"); + if (choice == SWT.YES) { + // Save the config xml file. + resetAndSave(); SnowThresholdMgr.reInitialize(); fireConfigUpdateEvent(); + // Open Threshold Dialog if zones/stations are added. if ((!configMgr.getAddedZones().isEmpty()) || (!configMgr.getAddedStations().isEmpty())) { if (editDialog() == SWT.YES) { @@ -118,6 +115,8 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { configMgr.getAddedZones().clear(); configMgr.getAddedStations().clear(); } + } else { // Return back to continue edit. + return; } } if ((snowMonitorDlg == null) || snowMonitorDlg.isDisposed()) { diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java index 41830e4328..a672f8c7b4 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java @@ -71,9 +71,10 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Jan 29, 2014 2757 skorolev Added status variables. * Apr 23, 2014 3054 skorolev Fixed issue with removing from list a new zone and a new station. * Apr 28, 2014 3086 skorolev Updated getConfigManager method. - * * Sep 16, 2014 2757 skorolev Updated createBottomButtons method. * Sep 24, 2014 2757 skorolev Fixed problem with adding and removing zones. + * Oct 27, 2014 3667 skorolev Corrected functionality of dialog. Cleaned code. + * * * * @author lvenable @@ -1043,40 +1044,49 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements if (additionalList.getSelectionCount() == 0) { if (mode == Mode.Zone) { showMessage(shell, SWT.ERROR, "Selection Needed", - "You must select a station first"); + "You must select an additional zone to add."); } else { showMessage(shell, SWT.ERROR, "Selection Needed", - "You must select a zone first"); + "You must select an additional station to add."); } return; } - String entry = additionalList.getItem(additionalList - .getSelectionIndex()); - additionalList.remove(additionalList.getSelectionIndex()); if (mode == Mode.Zone) { - maZones.add(entry); + String zone = additionalList.getItem(additionalList + .getSelectionIndex()); + additionalList.remove(additionalList.getSelectionIndex()); + maZones.add(zone); Collections.sort(maZones); monitorAreaList .setItems(maZones.toArray(new String[maZones.size()])); - monitorAreaList.setSelection(maZones.indexOf(entry)); + monitorAreaList.setSelection(maZones.indexOf(zone)); handleMonitorAreaListSelection(); - additionalZones.remove(entry); - configMgr.addArea(entry, entry.charAt(2) == 'Z' ? ZoneType.MARITIME + additionalZones.remove(zone); + configMgr.addArea(zone, zone.charAt(2) == 'Z' ? ZoneType.MARITIME : ZoneType.REGULAR); - if (!configMgr.getAddedZones().contains(entry)) { - configMgr.getAddedZones().add(entry); + if (!configMgr.getAddedZones().contains(zone)) { + configMgr.getAddedZones().add(zone); } - configMgr.removeAdjArea(entry); + configMgr.removeAdjArea(zone); } else { // Station mode - maStations.add(entry); + if (associatedList.getSelectionCount() == 0) { + showMessage(shell, SWT.ERROR, "Selection Needed", + "You must select an associated zone first."); + return; + } + String stn = additionalList.getItem(additionalList + .getSelectionIndex()); + additionalList.remove(additionalList.getSelectionIndex()); + maStations.add(stn); Collections.sort(maStations); monitorAreaList.setItems(maStations.toArray(new String[maStations .size()])); - monitorAreaList.setSelection(maStations.indexOf(entry)); - additionalStns.remove(entry); - String zone = associatedList.getItem(associatedList.getSelectionIndex()); - String stnId = entry.substring(0, entry.indexOf('#')); - String stnType = entry.substring(entry.indexOf('#') + 1); + monitorAreaList.setSelection(maStations.indexOf(stn)); + additionalStns.remove(stn); + String zone = associatedList.getItem(associatedList + .getSelectionIndex()); + String stnId = stn.substring(0, stn.indexOf('#')); + String stnType = stn.substring(stn.indexOf('#') + 1); configMgr.addStation(zone, stnId, stnType, configMgr .getAddedStations().contains(stnId)); handleMonitorAreaListSelection(); @@ -1090,10 +1100,10 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements if (monitorAreaList.getSelectionCount() == 0) { if (mode == Mode.Zone) { showMessage(shell, SWT.ERROR, "Selection Needed", - "You must select a station first"); + "You must select a monitor area zone to remove."); } else { showMessage(shell, SWT.ERROR, "Selection Needed", - "You must select a zone first"); + "You must select a monitor area station to remove."); } return; } @@ -1114,9 +1124,10 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements if (configMgr.getAddedZones().contains(entry)) { configMgr.getAddedZones().remove(entry); } - - configMgr.addAdjArea(entry,entry.charAt(2) == 'Z' ? ZoneType.MARITIME - : ZoneType.REGULAR); + + configMgr.addAdjArea(entry, + entry.charAt(2) == 'Z' ? ZoneType.MARITIME + : ZoneType.REGULAR); } else { // Station mode additionalStns.add(entry); Collections.sort(additionalStns); @@ -1135,21 +1146,23 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements if (monitorAreaList.getSelectionCount() == 0) { if (mode == Mode.Zone) { showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a zone"); + "You must select a monitor area zone to add."); monitorAreaList.select(0); } else { - showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a station"); + if (additionalList.getSelectionCount() == 0) { + showMessage(shell, SWT.ERROR, "Select Needed", + "You must select a monitor area station to add."); + } } return; } if (maRegionalList.getSelectionCount() == 0) { if (mode == Mode.Zone) { showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a station"); + "You must select a station to add into Associated Stations."); } else { showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a zone"); + "You must select a zone to add into Associated Zones."); associatedList.select(0); } return; @@ -1218,10 +1231,10 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements if (associatedList.getSelectionCount() == 0) { if (mode == Mode.Zone) { showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a station"); + "You must select an associated station to remove."); } else { showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a zone"); + "You must select an associated zone to remove."); } return; } @@ -1293,12 +1306,22 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements /** * Called when the cancel. */ - private void closeWithoutSave() { + protected void closeWithoutSave() { resetStatus(); setReturnValue(true); close(); } + /** + * Reset and Saving configuration parameters. + */ + protected void resetAndSave() { + getValues(); + resetStatus(); + configMgr.saveConfigXml(); + configMgr.saveAdjacentAreaConfigXml(); + } + /** * Sets algorithm text. */ @@ -1458,12 +1481,6 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements * @return */ protected int editDialog() { - showMessage(shell, SWT.ICON_INFORMATION | SWT.OK, appName - + " Config Change", "You're updating the " + appName - + " monitoring settings." + "\n\nIf " + appName - + " is running anywhere within " - + "the office, please clear it.\n"); - String message = "New zones have been added, and their monitoring thresholds " + "have been set to default values; would you like to modify " + "their threshold values now?";