diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObHourReports.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObHourReports.java old mode 100755 new mode 100644 index d4a4ff156f..83d84ad0d1 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObHourReports.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/ObHourReports.java @@ -24,7 +24,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.CopyOnWriteArrayList; import com.raytheon.uf.common.monitor.data.CommonConfig; import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; @@ -47,6 +46,7 @@ import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr; * Oct.29, 2012 1297 skorolev Changed HashMap to Map * Oct.31 2012 1297 skorolev Cleaned code. * Sep 04 2014 3220 skorolev Added updateZones method. + * Dec 18 2014 3841 skorolev Corrected updateZones method. * * * @@ -219,28 +219,23 @@ public class ObHourReports { public void updateZones() { Map> zoneStationMap = MonitoringArea .getPlatformMap(); - // remove zones or stations - List hourZones = new CopyOnWriteArrayList( - hourReports.keySet()); - for (String zone : hourZones) { - if (hourReports.keySet().contains(zone)) { - List stations = new CopyOnWriteArrayList( - hourReports.get(zone).getZoneHourReports().keySet()); - for (String stn : stations) { - if (!zoneStationMap.get(zone).contains(stn)) { - hourReports.get(zone).getZoneHourReports().remove(stn); - } - } - if (!zoneStationMap.keySet().contains(zone)) { - hourReports.remove(zone); - } + // Updated list of zones + Set updtZones = zoneStationMap.keySet(); + // add zones + for (String zone : updtZones) { + if (!hourReports.keySet().contains(zone)) { + hourReports.put(zone, new ObZoneHourReports(nominalTime, zone, + appName, thresholdMgr)); } } - // add zones - for (String zone : zoneStationMap.keySet()) { - List stations = new CopyOnWriteArrayList( - zoneStationMap.get(zone)); - for (String stn : stations) { + // remove zones + hourReports.keySet().retainAll(updtZones); + // add and(or) remove stations + for (String zone : updtZones) { + // Updated list of stations in this zone + List updtStns = zoneStationMap.get(zone); + // add stations + for (String stn : updtStns) { if (!hourReports.get(zone).getZoneHourReports() .containsKey(stn)) { hourReports @@ -251,10 +246,9 @@ public class ObHourReports { stn, appName, thresholdMgr)); } } - if (!hourReports.containsKey(zone)) { - hourReports.put(zone, new ObZoneHourReports(nominalTime, zone, - appName, thresholdMgr)); - } + // remove stations + hourReports.get(zone).getZoneHourReports().keySet() + .retainAll(updtStns); } } } 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 cd63a81cbd..1a2750ff53 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 @@ -79,6 +79,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Oct 27, 2014 3667 skorolev Corrected functionality of dialog. Cleaned code. * Nov 12, 2014 3650 skorolev Added confirmation box for unsaved changes in the dialog. * Nov 21, 2014 3841 skorolev Added formIsValid method. + * Dec 18, 2014 3841 skorolev Corrected addZoneStn method. * * * @@ -1091,13 +1092,13 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements monitorAreaList .setItems(maZones.toArray(new String[maZones.size()])); monitorAreaList.setSelection(maZones.indexOf(zone)); - handleMonitorAreaListSelection(); additionalZones.remove(zone); configMgr.addArea(zoneXML); if (!configMgr.getAddedZones().contains(zone)) { configMgr.getAddedZones().add(zone); } configMgr.removeAdjArea(zone); + handleMonitorAreaListSelection(); } else { // Station mode if (associatedList.getSelectionCount() == 0) { showMessage(shell, SWT.ERROR, "Selection Needed",