Omaha #3841 - Corrected dialogs for adding and editing the new zones and stations.
Former-commit-id: 640a7d9e6bfcd25248a36b5babb527cca4baeb7a
This commit is contained in:
parent
567285cfd5
commit
3379aa3316
27 changed files with 820 additions and 520 deletions
|
@ -91,7 +91,7 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
* Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea.
|
||||
* Sep 23, 2014 3356 njensen Remove unnecessary import
|
||||
* Mar 09, 2014 3888 dhladky Stopped processing when dialogs are null or disposed.
|
||||
*
|
||||
* Sep 03, 2015 3841 skorolev Corrected getInstance for FSSObsMonitorConfigurationManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -162,7 +162,7 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener {
|
|||
*/
|
||||
private FogMonitor() {
|
||||
pluginPatterns.add(fogPattern);
|
||||
fogConfig = new FSSObsMonitorConfigurationManager(MonName.fog.name());
|
||||
fogConfig = FSSObsMonitorConfigurationManager.getInstance(MonName.fog);
|
||||
updateMonitoringArea();
|
||||
initObserver(OBS, this);
|
||||
obData = new ObMultiHrsReports(CommonConfig.AppName.FOG);
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogMonitor;
|
|||
* Feb 03, 2014 #2757 skorolev Fixed reInitialize()
|
||||
* May 20, 2014 3086 skorolev Cleaned code.
|
||||
* Sep 04, 2014 3220 skorolev Removed "site".
|
||||
* Sep 03, 2015 3841 skorolev Corrected getInstance for FSSObsMonitorConfigurationManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,8 +62,8 @@ public class FogThresholdMgr extends AbstractThresholdMgr {
|
|||
super("DefaultFogDisplayThresholds.xml",
|
||||
"DefaultFogMonitorThresholds.xml", AppName.FOG.name()
|
||||
.toLowerCase());
|
||||
areaConfigMgr = new FSSObsMonitorConfigurationManager(
|
||||
MonName.fog.name());
|
||||
areaConfigMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.fog);
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -128,8 +129,8 @@ public class FogThresholdMgr extends AbstractThresholdMgr {
|
|||
@Override
|
||||
protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() {
|
||||
if (areaConfigMgr == null) {
|
||||
areaConfigMgr = new FSSObsMonitorConfigurationManager(
|
||||
MonName.fog.name());
|
||||
areaConfigMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.fog);
|
||||
}
|
||||
return areaConfigMgr;
|
||||
}
|
||||
|
|
|
@ -19,15 +19,19 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.monitor.fog.ui.dialogs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent;
|
||||
import com.raytheon.uf.viz.monitor.fog.FogMonitor;
|
||||
import com.raytheon.uf.viz.monitor.fog.threshold.FogThresholdMgr;
|
||||
|
@ -51,6 +55,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* Sep 19, 2014 2757 skorolev Updated handlers for dialog buttons.
|
||||
* Oct 27, 2014 3667 skorolev Cleaned code.
|
||||
* Feb 10, 2015 3886 skorolev Changed confirmation message.
|
||||
* Aug 17, 2015 3841 skorolev Corrected handleOkBtnSelection.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -80,19 +85,15 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
|
|||
* handleOkBtnSelection()
|
||||
*/
|
||||
@Override
|
||||
protected void handleOkBtnSelection() {
|
||||
protected void handleOkBtnSelection() throws LocalizationException,
|
||||
SerializationException, IOException {
|
||||
if (dataIsChanged()) {
|
||||
int choice = showMessage(shell, SWT.YES | SWT.NO,
|
||||
"Confirm Cofiguration Changes", "Save changes?");
|
||||
"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
|
||||
*/
|
||||
saveConfigs();
|
||||
FogThresholdMgr.reInitialize();
|
||||
fireConfigUpdateEvent();
|
||||
// Open Threshold Dialog if zones/stations are added.
|
||||
if ((!configMgr.getAddedZones().isEmpty())
|
||||
|| (!configMgr.getAddedStations().isEmpty())) {
|
||||
|
@ -102,19 +103,19 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
|
|||
fogMonitorDlg.setCloseCallback(new ICloseCallback() {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
// Clean added zones and stations. Close dialog.
|
||||
configMgr.getAddedZones().clear();
|
||||
configMgr.getAddedStations().clear();
|
||||
setReturnValue(true);
|
||||
close();
|
||||
}
|
||||
});
|
||||
fogMonitorDlg.open();
|
||||
}
|
||||
// Clean added zones and stations.
|
||||
configMgr.getAddedZones().clear();
|
||||
configMgr.getAddedStations().clear();
|
||||
}
|
||||
/**
|
||||
* DR#11279: re-initialize threshold manager and the monitor
|
||||
* using new monitor area configuration
|
||||
*/
|
||||
fireConfigUpdateEvent();
|
||||
resetStatus();
|
||||
} else { // Return back to continue edit.
|
||||
return;
|
||||
}
|
||||
|
@ -150,8 +151,8 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
|
|||
@Override
|
||||
protected FSSObsMonitorConfigurationManager getInstance() {
|
||||
if (configMgr == null) {
|
||||
configMgr = new FSSObsMonitorConfigurationManager(
|
||||
MonName.fog.name());
|
||||
configMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.fog);
|
||||
}
|
||||
return configMgr;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg;
|
|||
* Dec 7, 2012 1351 skorolev Changes for non-blocking dialogs.
|
||||
* Apr 28, 2014 3086 skorolev Updated getConfigMgr method.
|
||||
* Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose.
|
||||
* Aug 26, 2015 3841 skorolev Corrected getMonitorAreaConfigInstance().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -219,6 +220,7 @@ public class FogZoneTableDlg extends ZoneTableDlg {
|
|||
@Override
|
||||
public void fireDialogShutdown(IMonitorListener iml) {
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Iterator<IMonitor> iter = getMonitorControlListeners()
|
||||
.iterator();
|
||||
|
@ -239,6 +241,7 @@ public class FogZoneTableDlg extends ZoneTableDlg {
|
|||
@Override
|
||||
public void fireKillMonitor() {
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Iterator<IMonitor> iter = getMonitorControlListeners()
|
||||
.iterator();
|
||||
|
@ -304,8 +307,9 @@ public class FogZoneTableDlg extends ZoneTableDlg {
|
|||
@Override
|
||||
protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() {
|
||||
if (configMgr == null || configMgr.isPopulated()) {
|
||||
configMgr = new FSSObsMonitorConfigurationManager(
|
||||
MonName.fog.name());
|
||||
configMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.fog);
|
||||
configMgr.setPopulated(false);
|
||||
}
|
||||
return configMgr;
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
* Feb 15, 2013 1638 mschenke Changed code to reference DataURI.SEPARATOR instead of URIFilter
|
||||
* Apr 28, 2014 3086 skorolev Removed local getMonitorAreaConfig method.
|
||||
* Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea.
|
||||
* Sep 03, 2015 3841 skorolev Corrected getInstance for FSSObsMonitorConfigurationManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -161,7 +162,8 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener {
|
|||
*/
|
||||
private SafeSeasMonitor() {
|
||||
pluginPatterns.add(ssPattern);
|
||||
ssAreaConfig = new FSSObsMonitorConfigurationManager(MonName.ss.name());
|
||||
ssAreaConfig = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.ss);
|
||||
updateMonitoringArea();
|
||||
initObserver(OBS, this);
|
||||
obData = new ObMultiHrsReports(CommonConfig.AppName.SAFESEAS);
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasMonitor;
|
|||
* Feb 03, 2014 #2757 skorolev Fixed reInitialize().
|
||||
* Apr 28, 2014 3086 skorolev Removed local getMonitorAreaConfig method.
|
||||
* Sep 04, 2014 3220 skorolev Removed "site".
|
||||
* Sep 03, 2015 3841 skorolev Corrected getInstance for FSSObsMonitorConfigurationManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -59,7 +60,8 @@ public class SSThresholdMgr extends AbstractThresholdMgr {
|
|||
super("DefaultSSDisplayThresholds.xml",
|
||||
"DefaultSSMonitorThresholds.xml", AppName.SAFESEAS.name()
|
||||
.toLowerCase());
|
||||
areaConfigMgr = new FSSObsMonitorConfigurationManager(MonName.ss.name());
|
||||
areaConfigMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.ss);
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -123,8 +125,8 @@ public class SSThresholdMgr extends AbstractThresholdMgr {
|
|||
@Override
|
||||
protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() {
|
||||
if (areaConfigMgr == null) {
|
||||
areaConfigMgr = new FSSObsMonitorConfigurationManager(
|
||||
MonName.ss.name());
|
||||
areaConfigMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.ss);
|
||||
}
|
||||
return areaConfigMgr;
|
||||
}
|
||||
|
|
|
@ -19,15 +19,19 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.monitor.safeseas.ui.dialogs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent;
|
||||
import com.raytheon.uf.viz.monitor.safeseas.SafeSeasMonitor;
|
||||
import com.raytheon.uf.viz.monitor.safeseas.threshold.SSThresholdMgr;
|
||||
|
@ -50,7 +54,8 @@ 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 27, 2014 3667 skorolev Cleaned code.
|
||||
* Feb 10, 2015 3886 skorolev Changed confirmation message.
|
||||
* Feb 10, 2015 3886 skorolev Changed confirmation message.
|
||||
* Aug 17, 2015 3841 skorolev Corrected handleOkBtnSelection.
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -75,18 +80,18 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void handleOkBtnSelection() {
|
||||
protected void handleOkBtnSelection() throws LocalizationException,
|
||||
SerializationException, IOException {
|
||||
if (dataIsChanged()) {
|
||||
int choice = showMessage(shell, SWT.YES | SWT.NO,
|
||||
"Confirm Cofiguration Changes", "Save changes?");
|
||||
"SAFESEAS Monitor Confirm Changes", "Save changes?");
|
||||
if (choice == SWT.YES) {
|
||||
// Save the config xml file.
|
||||
resetAndSave();
|
||||
saveConfigs();
|
||||
SSThresholdMgr.reInitialize();
|
||||
fireConfigUpdateEvent();
|
||||
// Open Threshold Dialog if zones/stations are added.
|
||||
if ((!configMgr.getAddedZones().isEmpty())
|
||||
|| (!configMgr.getAddedStations().isEmpty())) {
|
||||
// Open Threshold Dialog if zones/stations are added.
|
||||
if (editDialog() == SWT.YES) {
|
||||
ssMonitorDlg = new SSDispMonThreshDlg(shell,
|
||||
CommonConfig.AppName.SAFESEAS,
|
||||
|
@ -94,19 +99,15 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
|
|||
ssMonitorDlg.setCloseCallback(new ICloseCallback() {
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
// Clean added zones and stations. Close dialog.
|
||||
configMgr.getAddedZones().clear();
|
||||
configMgr.getAddedStations().clear();
|
||||
setReturnValue(true);
|
||||
close();
|
||||
}
|
||||
});
|
||||
ssMonitorDlg.open();
|
||||
}
|
||||
// Clean added zones and stations.
|
||||
configMgr.getAddedZones().clear();
|
||||
configMgr.getAddedStations().clear();
|
||||
}
|
||||
fireConfigUpdateEvent();
|
||||
resetStatus();
|
||||
} else { // Return back to continue edit.
|
||||
return;
|
||||
}
|
||||
|
@ -142,7 +143,8 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
|
|||
@Override
|
||||
public FSSObsMonitorConfigurationManager getInstance() {
|
||||
if (configMgr == null) {
|
||||
configMgr = new FSSObsMonitorConfigurationManager(MonName.ss.name());
|
||||
configMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.ss);
|
||||
}
|
||||
return configMgr;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants;
|
|||
* Dec 7, 2012 #1351 skorolev Changes for non-blocking dialogs.
|
||||
* Apr 28, 2014 3086 skorolev Updated getConfigMgr method.
|
||||
* Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose.
|
||||
* Aug 26, 2015 3841 skorolev Corrected getMonitorAreaConfigInstance().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -70,7 +71,8 @@ public class SSZoneTableDlg extends ZoneTableDlg {
|
|||
private SSDispMonThreshDlg ssThreshDlg;
|
||||
|
||||
/** Swell column names in the zone and station table. **/
|
||||
private String[] ssSwellCols = { "SSZT_SwellPeriod", "SSZT_Swell2Period" };
|
||||
private final String[] ssSwellCols = { "SSZT_SwellPeriod",
|
||||
"SSZT_Swell2Period" };
|
||||
|
||||
/**
|
||||
* Constructor (Dec 30, 2009, zhao)
|
||||
|
@ -329,7 +331,9 @@ public class SSZoneTableDlg extends ZoneTableDlg {
|
|||
@Override
|
||||
protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() {
|
||||
if (configMgr == null || configMgr.isPopulated()) {
|
||||
configMgr = new FSSObsMonitorConfigurationManager(MonName.ss.name());
|
||||
configMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.ss);
|
||||
configMgr.setPopulated(false);
|
||||
}
|
||||
return configMgr;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* Feb 15, 2013 1638 mschenke Changed code to reference DataURI.SEPARATOR instead of URIFilter
|
||||
* Apr 28, 2014 3086 skorolev Removed local getMonitorAreaConfig method.
|
||||
* Sep 04, 2014 3220 skorolev Updated configUpdate method and added updateMonitoringArea.
|
||||
* Sep 03, 2015 3841 skorolev Corrected getInstance for FSSObsMonitorConfigurationManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -103,7 +104,7 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
|
|||
* This object contains all observation data necessary for the table dialogs
|
||||
* and trending plots
|
||||
*/
|
||||
private ObMultiHrsReports obData;
|
||||
private final ObMultiHrsReports obData;
|
||||
|
||||
/** All SNOW datauri start with this */
|
||||
private final String OBS = "fssobs";
|
||||
|
@ -128,7 +129,8 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
|
|||
*/
|
||||
private SnowMonitor() {
|
||||
pluginPatterns.add(snowPattern);
|
||||
snowConfig = new FSSObsMonitorConfigurationManager(MonName.snow.name());
|
||||
snowConfig = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.snow);
|
||||
updateMonitoringArea();
|
||||
initObserver(OBS, this);
|
||||
obData = new ObMultiHrsReports(CommonConfig.AppName.SNOW);
|
||||
|
@ -382,6 +384,7 @@ public class SnowMonitor extends ObsMonitor implements ISnowResourceListener {
|
|||
*
|
||||
* @param dialogTime
|
||||
*/
|
||||
@Override
|
||||
public void updateDialogTime(Date dialogTime) {
|
||||
this.dialogTime = dialogTime;
|
||||
fireMonitorEvent(this);
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowMonitor;
|
|||
* Feb 03, 2014 #2757 skorolev Fixed reInitialize()
|
||||
* May 21, 2014 3086 skorolev Cleaned code.
|
||||
* Sep 04, 2014 3220 skorolev Removed "site".
|
||||
* Sep 03, 2015 3841 skorolev Corrected getInstance for FSSObsMonitorConfigurationManager.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -59,8 +60,8 @@ public class SnowThresholdMgr extends AbstractThresholdMgr {
|
|||
"DefaultSnowMonitorThresholds.xml", AppName.SNOW.name()
|
||||
.toLowerCase());
|
||||
|
||||
areaConfigMgr = new FSSObsMonitorConfigurationManager(
|
||||
MonName.snow.name());
|
||||
areaConfigMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.snow);
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -124,8 +125,8 @@ public class SnowThresholdMgr extends AbstractThresholdMgr {
|
|||
@Override
|
||||
protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() {
|
||||
if (areaConfigMgr == null) {
|
||||
areaConfigMgr = new FSSObsMonitorConfigurationManager(
|
||||
MonName.snow.name());
|
||||
areaConfigMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.snow);
|
||||
}
|
||||
return areaConfigMgr;
|
||||
}
|
||||
|
|
|
@ -19,15 +19,19 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.monitor.snow.ui.dialogs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.viz.monitor.events.IMonitorConfigurationEvent;
|
||||
import com.raytheon.uf.viz.monitor.snow.SnowMonitor;
|
||||
import com.raytheon.uf.viz.monitor.snow.threshold.SnowThresholdMgr;
|
||||
|
@ -51,6 +55,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* Sep 19, 2014 2757 skorolev Updated handlers for dialog buttons.
|
||||
* Oct 27, 2014 3667 skorolev Cleaned code.
|
||||
* Feb 10, 2015 3886 skorolev Changed confirmation message.
|
||||
* Aug 17, 2015 3841 skorolev Corrected handleOkBtnSelection.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -79,15 +84,15 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
|
|||
* handleApplyBtnSelection()
|
||||
*/
|
||||
@Override
|
||||
protected void handleOkBtnSelection() {
|
||||
protected void handleOkBtnSelection() throws LocalizationException,
|
||||
SerializationException, IOException {
|
||||
if (dataIsChanged()) {
|
||||
int choice = showMessage(shell, SWT.YES | SWT.NO,
|
||||
"Confirm Cofiguration Changes", "Save changes?");
|
||||
"SNOW Monitor Confirm Changes", "Save changes?");
|
||||
if (choice == SWT.YES) {
|
||||
// Save the config xml file.
|
||||
resetAndSave();
|
||||
saveConfigs();
|
||||
SnowThresholdMgr.reInitialize();
|
||||
fireConfigUpdateEvent();
|
||||
// Open Threshold Dialog if zones/stations are added.
|
||||
if ((!configMgr.getAddedZones().isEmpty())
|
||||
|| (!configMgr.getAddedStations().isEmpty())) {
|
||||
|
@ -102,19 +107,15 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
|
|||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
// Clean added zones and stations. Close dialog.
|
||||
configMgr.getAddedZones().clear();
|
||||
configMgr.getAddedStations().clear();
|
||||
setReturnValue(true);
|
||||
close();
|
||||
}
|
||||
});
|
||||
snowMonitorDlg.open();
|
||||
}
|
||||
// Clean added zones and stations.
|
||||
configMgr.getAddedZones().clear();
|
||||
configMgr.getAddedStations().clear();
|
||||
}
|
||||
fireConfigUpdateEvent();
|
||||
resetStatus();
|
||||
} else { // Return back to continue edit.
|
||||
return;
|
||||
}
|
||||
|
@ -135,8 +136,8 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
|
|||
@Override
|
||||
protected FSSObsMonitorConfigurationManager getInstance() {
|
||||
if (configMgr == null) {
|
||||
configMgr = new FSSObsMonitorConfigurationManager(
|
||||
MonName.snow.name());
|
||||
configMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.snow);
|
||||
}
|
||||
return configMgr;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.ZoneTableDlg;
|
|||
* Dec 7, 2012 1351 skorolev Changes for non-blocking dialogs
|
||||
* Apr 28, 2014 3086 skorolev Updated getConfigMgr method.
|
||||
* Sep 04, 2014 3220 skorolev Removed "site". Added check on dispose.
|
||||
* Aug 26, 2015 3841 skorolev Corrected getMonitorAreaConfigInstance().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -265,8 +266,9 @@ public class SnowZoneTableDlg extends ZoneTableDlg {
|
|||
@Override
|
||||
protected FSSObsMonitorConfigurationManager getMonitorAreaConfigInstance() {
|
||||
if (configMgr == null || configMgr.isPopulated()) {
|
||||
configMgr = new FSSObsMonitorConfigurationManager(
|
||||
MonName.snow.name());
|
||||
configMgr = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.snow);
|
||||
configMgr.setPopulated(false);
|
||||
}
|
||||
return configMgr;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr;
|
|||
* Oct.31 2012 1297 skorolev Cleaned code.
|
||||
* Sep 04 2014 3220 skorolev Added updateZones method.
|
||||
* Mar 17 2015 3888 dhladky check for nulls
|
||||
* Sep 03, 2015 3841 skorolev Made final appName, hourReports and thresholdMgr.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,19 +62,19 @@ public class ObHourReports {
|
|||
/**
|
||||
* the nominal time of this ObHourReports object
|
||||
*/
|
||||
private Date nominalTime;
|
||||
private final Date nominalTime;
|
||||
|
||||
/**
|
||||
* application name (SNOW, FOG, SAFESEAS)
|
||||
*/
|
||||
private CommonConfig.AppName appName;
|
||||
private final CommonConfig.AppName appName;
|
||||
|
||||
/**
|
||||
* key is zone id, value is ObZoneHourReports object
|
||||
*/
|
||||
private Map<String, ObZoneHourReports> hourReports;
|
||||
private final Map<String, ObZoneHourReports> hourReports;
|
||||
|
||||
private AbstractThresholdMgr thresholdMgr;
|
||||
private final AbstractThresholdMgr thresholdMgr;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
|
|
|
@ -25,10 +25,13 @@ import java.util.Date;
|
|||
import com.raytheon.uf.common.geospatial.ISpatialQuery;
|
||||
import com.raytheon.uf.common.geospatial.SpatialQueryFactory;
|
||||
import com.raytheon.uf.common.monitor.MonitorAreaUtils;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager.MonName;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.data.ObConst;
|
||||
import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
||||
import com.raytheon.uf.viz.monitor.config.CommonTableConfig;
|
||||
import com.raytheon.uf.viz.monitor.config.CommonTableConfig.CellType;
|
||||
import com.raytheon.uf.viz.monitor.config.CommonTableConfig.ObsHistType;
|
||||
|
@ -50,6 +53,7 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants;
|
|||
* May 23, 2012 14410 zhao Modified getCellTypeForBlizWarn and getCellTypeForHsnowWarn modules
|
||||
* Feb 28, 2013 14410 zhao Modified getCellTypeForBlizWarn
|
||||
* May 23, 2014 3086 skorolev Corrected ObsHistType. Cleaned code.
|
||||
* Aug 17, 2015 3841 skorolev Added coordinates in the hover text for a newly added zones.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -112,7 +116,11 @@ public final class TableUtil {
|
|||
|
||||
String hoverText = null;
|
||||
if (isZone) {
|
||||
hoverText = getZoneHoverText(areaId);
|
||||
AreaIdXML zoneXML = FSSObsMonitorConfigurationManager
|
||||
.getObsManager(MonName.fog).getAreaXml(zone);
|
||||
if (zoneXML != null) {
|
||||
hoverText = getZoneHoverText(zoneXML);
|
||||
}
|
||||
} else {
|
||||
hoverText = getStationHoverText(areaId);
|
||||
}
|
||||
|
@ -320,7 +328,8 @@ public final class TableUtil {
|
|||
* dialog)
|
||||
* @param zone
|
||||
* @param report
|
||||
* @param tm Abstract Threshold Manager
|
||||
* @param tm
|
||||
* Abstract Threshold Manager
|
||||
* @param fogCellType
|
||||
* @return
|
||||
*/
|
||||
|
@ -338,7 +347,11 @@ public final class TableUtil {
|
|||
|
||||
String hoverText = null;
|
||||
if (isZone) {
|
||||
hoverText = getZoneHoverText(areaId);
|
||||
AreaIdXML zoneXML = FSSObsMonitorConfigurationManager
|
||||
.getObsManager(MonName.ss).getAreaXml(zone);
|
||||
if (zoneXML != null) {
|
||||
hoverText = getZoneHoverText(zoneXML);
|
||||
}
|
||||
} else {
|
||||
hoverText = getStationHoverText(areaId);
|
||||
}
|
||||
|
@ -639,7 +652,11 @@ public final class TableUtil {
|
|||
|
||||
String hoverText = null;
|
||||
if (isZone) {
|
||||
hoverText = getZoneHoverText(areaId);
|
||||
AreaIdXML zoneXML = FSSObsMonitorConfigurationManager
|
||||
.getObsManager(MonName.snow).getAreaXml(zone);
|
||||
if (zoneXML != null) {
|
||||
hoverText = getZoneHoverText(zoneXML);
|
||||
}
|
||||
} else {
|
||||
hoverText = getStationHoverText(areaId);
|
||||
}
|
||||
|
@ -881,11 +898,12 @@ public final class TableUtil {
|
|||
/**
|
||||
* Gets Zone Hover Text.
|
||||
*
|
||||
* @param zone
|
||||
* @param zoneXML
|
||||
* @return
|
||||
*/
|
||||
private static String getZoneHoverText(String zone) {
|
||||
private static String getZoneHoverText(AreaIdXML zoneXML) {
|
||||
|
||||
String zone = zoneXML.getAreaId();
|
||||
ISpatialQuery sq = null;
|
||||
String sql = null;
|
||||
String hoverText = zone.substring(0, 2) + ", ";
|
||||
|
@ -908,11 +926,13 @@ public final class TableUtil {
|
|||
sq = SpatialQueryFactory.create();
|
||||
Object[] results = sq.dbRequest(sql, "maps");
|
||||
if (results.length > 0) {
|
||||
if (results[0] instanceof Object[]) {
|
||||
Object[] res = (Object[]) results[0];
|
||||
hoverText += (String) res[0];
|
||||
} else {
|
||||
hoverText += (String) results[0].toString();
|
||||
if (results[0] instanceof String) {
|
||||
hoverText += (String) results[0];
|
||||
}
|
||||
} else {
|
||||
if (zoneXML.getCLat() != null) {
|
||||
hoverText += "(" + zoneXML.getCLat() + ", "
|
||||
+ zoneXML.getCLon() + ")";
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -976,7 +996,7 @@ public final class TableUtil {
|
|||
*/
|
||||
public static CellType getCellTypeForSCA(String zone, ObReport report,
|
||||
AbstractThresholdMgr tm) {
|
||||
// TODO:
|
||||
|
||||
float windSpd = report.getWindSpeed();
|
||||
float windGust = report.getWindGust();
|
||||
float waveHgt = report.getHighResWaveHeight();
|
||||
|
@ -1027,7 +1047,7 @@ public final class TableUtil {
|
|||
*/
|
||||
public static CellType getCellTypeForGaleWarn(String zone, ObReport report,
|
||||
AbstractThresholdMgr tm) {
|
||||
// TODO:
|
||||
|
||||
CellType type = CellType.NotAvailable;
|
||||
CellType windSpeedType = tm
|
||||
.getThresholdValueCellType(
|
||||
|
@ -1064,7 +1084,7 @@ public final class TableUtil {
|
|||
*/
|
||||
public static CellType getCellTypeForStormWarn(String zone,
|
||||
ObReport report, AbstractThresholdMgr tm) {
|
||||
// TODO:
|
||||
|
||||
CellType type = CellType.NotAvailable;
|
||||
CellType windSpeedType = tm
|
||||
.getThresholdValueCellType(
|
||||
|
@ -1101,7 +1121,7 @@ public final class TableUtil {
|
|||
*/
|
||||
public static CellType getCellTypeForHFWW(String zone, ObReport report,
|
||||
AbstractThresholdMgr tm) {
|
||||
// TODO:
|
||||
|
||||
CellType type = CellType.NotAvailable;
|
||||
CellType windSpeedType = tm
|
||||
.getThresholdValueCellType(
|
||||
|
@ -1138,7 +1158,7 @@ public final class TableUtil {
|
|||
*/
|
||||
public static CellType getCellTypeForFog(String zone, ObReport report,
|
||||
AbstractThresholdMgr tm) {
|
||||
// TODO:
|
||||
|
||||
float visValue = report.getVisibility();// in miles
|
||||
if (visValue == ObConst.MISSING) {
|
||||
return CellType.NotAvailable;
|
||||
|
|
16
cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewStationDlg.java
Normal file → Executable file
16
cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewStationDlg.java
Normal file → Executable file
|
@ -34,6 +34,7 @@ import org.eclipse.swt.widgets.Text;
|
|||
|
||||
import com.raytheon.uf.common.geospatial.ISpatialQuery;
|
||||
import com.raytheon.uf.common.geospatial.SpatialQueryFactory;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.xml.StationIdXML;
|
||||
|
@ -56,6 +57,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Nov 20, 2012 1297 skorolev Changes for non-blocking dialog.
|
||||
* Apr 23, 2014 3054 skorolev Added MESONET handling.
|
||||
* Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method.
|
||||
* Aug 17, 2015 3841 skorolev Corrected handleAddNewStation method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -67,7 +69,7 @@ public class AddNewStationDlg extends CaveSWTDialog {
|
|||
.getHandler(AddNewStationDlg.class);
|
||||
|
||||
/** Application name. */
|
||||
private AppName appName;
|
||||
private final AppName appName;
|
||||
|
||||
/** METAR radio button. */
|
||||
private Button metarRdo;
|
||||
|
@ -85,10 +87,12 @@ public class AddNewStationDlg extends CaveSWTDialog {
|
|||
private Text stationTF;
|
||||
|
||||
/** Zone */
|
||||
private String area;
|
||||
private final String area;
|
||||
|
||||
/** Call back interface */
|
||||
private MonitoringAreaConfigDlg macDlg;
|
||||
private final MonitoringAreaConfigDlg macDlg;
|
||||
|
||||
private final FSSObsMonitorConfigurationManager cfgMgr;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -106,6 +110,7 @@ public class AddNewStationDlg extends CaveSWTDialog {
|
|||
this.appName = appName;
|
||||
this.area = area;
|
||||
this.macDlg = macDlg;
|
||||
cfgMgr = macDlg.getInstance();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -260,9 +265,10 @@ public class AddNewStationDlg extends CaveSWTDialog {
|
|||
+ "' is already in your Monitoring Area or among your Additional Stations.");
|
||||
return;
|
||||
}
|
||||
|
||||
macDlg.addNewStationAction(stn);
|
||||
macDlg.getInstance().addStation(area, stn, type, false);
|
||||
macDlg.getInstance().getStations().add(stn);
|
||||
cfgMgr.addNewStation(area, stn, type, true);
|
||||
cfgMgr.getStations().add(stn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
95
cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewZoneDlg.java
Normal file → Executable file
95
cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewZoneDlg.java
Normal file → Executable file
|
@ -28,7 +28,6 @@ import org.eclipse.swt.widgets.Button;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
|
@ -50,6 +49,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Apr 23, 2014 3054 skorolev Deleted unnecessary parameter in addArea method.
|
||||
* Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method.
|
||||
* Feb 10, 2015 3886 skorolev Added fixed width for dialog.
|
||||
* Aug 17, 2015 3841 skorolev Corrected handleAddNewAction method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -59,7 +59,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
public class AddNewZoneDlg extends CaveSWTDialog {
|
||||
|
||||
/** Application name. */
|
||||
private AppName appName;
|
||||
private final AppName appName;
|
||||
|
||||
/** Marine zone radio button. */
|
||||
private Button marineZoneRdo;
|
||||
|
@ -77,7 +77,7 @@ public class AddNewZoneDlg extends CaveSWTDialog {
|
|||
private Text centroidLonTF;
|
||||
|
||||
/** Monitoring Area Configuration Dialog. */
|
||||
private MonitoringAreaConfigDlg macDlg;
|
||||
private final MonitoringAreaConfigDlg macDlg;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -144,13 +144,15 @@ public class AddNewZoneDlg extends CaveSWTDialog {
|
|||
/*
|
||||
* Add the radio controls.
|
||||
*/
|
||||
Composite radioComp = new Composite(topComp, SWT.NONE);
|
||||
radioComp.setLayout(new GridLayout(1, false));
|
||||
marineZoneRdo = new Button(radioComp, SWT.RADIO);
|
||||
marineZoneRdo.setText("Marine Zone");
|
||||
marineZoneRdo.setSelection(true);
|
||||
countyRdo = new Button(radioComp, SWT.RADIO);
|
||||
countyRdo.setText("County");
|
||||
if (appName != AppName.SNOW) {
|
||||
Composite radioComp = new Composite(topComp, SWT.NONE);
|
||||
radioComp.setLayout(new GridLayout(1, false));
|
||||
marineZoneRdo = new Button(radioComp, SWT.RADIO);
|
||||
marineZoneRdo.setText("Marine Zone");
|
||||
marineZoneRdo.setSelection(true);
|
||||
countyRdo = new Button(radioComp, SWT.RADIO);
|
||||
countyRdo.setText("County");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,9 +238,13 @@ public class AddNewZoneDlg extends CaveSWTDialog {
|
|||
addBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
String areaId = idTF.getText().toUpperCase();
|
||||
idTF.setText(areaId);
|
||||
String latString = centroidLatTF.getText();
|
||||
String lonString = centroidLonTF.getText();
|
||||
handleAddNewAction(latString, lonString);
|
||||
if (macDlg.formIsValid(areaId, latString, lonString)) {
|
||||
handleAddNewAction(areaId, latString, lonString);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -261,58 +267,35 @@ public class AddNewZoneDlg extends CaveSWTDialog {
|
|||
* @param latString
|
||||
* @param lonString
|
||||
*/
|
||||
private void handleAddNewAction(String latString, String lonString) {
|
||||
String areaId = idTF.getText();
|
||||
if (areaId.equals("") || areaId.length() != 6
|
||||
|| (areaId.charAt(2) != 'C' && areaId.charAt(2) != 'Z')) {
|
||||
displayInputErrorMsg("Invalid Area ID = '" + areaId
|
||||
+ "' entered. Please enter a correctly formatted Area ID.");
|
||||
return;
|
||||
}
|
||||
private void handleAddNewAction(String areaId, String latString,
|
||||
String lonString) throws NumberFormatException {
|
||||
if (macDlg.isExistingZone(areaId)) {
|
||||
displayInputErrorMsg("The Area ID, "
|
||||
macDlg.displayInputErrorMsg("The Area ID, "
|
||||
+ areaId
|
||||
+ ", is already in your Monitoring Area or among your Additional Zones.");
|
||||
return;
|
||||
}
|
||||
if (latString == null || latString.isEmpty() || lonString == null
|
||||
|| lonString.isEmpty()) {
|
||||
macDlg.latLonErrorMsg(latString, lonString);
|
||||
return;
|
||||
double lat = Double.parseDouble(latString.trim());
|
||||
double lon = Double.parseDouble(lonString.trim());
|
||||
ZoneType type = ZoneType.REGULAR;
|
||||
if (appName != AppName.SNOW) {
|
||||
if (marineZoneRdo.getSelection() || idTF.getText().charAt(2) == 'Z') {
|
||||
type = ZoneType.MARITIME;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
double lat = Double.parseDouble(latString.trim());
|
||||
double lon = Double.parseDouble(lonString.trim());
|
||||
ZoneType type = ZoneType.REGULAR;
|
||||
if (appName != AppName.SNOW) {
|
||||
if (marineZoneRdo.getSelection()) {
|
||||
type = ZoneType.MARITIME;
|
||||
}
|
||||
}
|
||||
if (lat > 90.0 || lat < -90.0 || lon > 180.0 || lon < -180.0) {
|
||||
macDlg.latLonErrorMsg(latString, lonString);
|
||||
return;
|
||||
}
|
||||
macDlg.configMgr.addArea(areaId, lat, lon, type);
|
||||
macDlg.addNewZoneAction(areaId, centroidLatTF.getText(),
|
||||
centroidLonTF.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
macDlg.latLonErrorMsg(latString, lonString);
|
||||
return;
|
||||
// Correct third character for METARs
|
||||
char chr = idTF.getText().charAt(2);
|
||||
if (chr != 'C') {
|
||||
String c = idTF.getText().substring(2).replace(chr, 'C');
|
||||
idTF.setText(idTF.getText().substring(0, 2) + c);
|
||||
areaId = idTF.getText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays Input Error Message
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
private void displayInputErrorMsg(String msg) {
|
||||
MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION
|
||||
| SWT.OK);
|
||||
messageBox.setText("Invalid input");
|
||||
messageBox.setMessage(msg);
|
||||
messageBox.open();
|
||||
if (lat > 90.0 || lat < -90.0 || lon > 180.0 || lon < -180.0) {
|
||||
macDlg.latLonErrorMsg(latString, lonString);
|
||||
return;
|
||||
}
|
||||
macDlg.configMgr.addNewArea(areaId, lat, lon, type);
|
||||
macDlg.addZoneToMA(areaId);
|
||||
}
|
||||
}
|
||||
|
|
35
cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/DeleteStationDlg.java
Normal file → Executable file
35
cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/DeleteStationDlg.java
Normal file → Executable file
|
@ -19,6 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.monitor.ui.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
|
@ -35,6 +37,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
|
@ -50,6 +53,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Nov 20, 2012 1297 skorolev Changes for non-blocking dialog.
|
||||
* Apr 23, 2014 3054 skorolev Fixed issue with deleting a new station.
|
||||
* Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method.
|
||||
* Aug 17, 2015 3841 skorolev Corrected deleteSelected method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -64,11 +68,12 @@ public class DeleteStationDlg extends CaveSWTDialog {
|
|||
/** Control font. */
|
||||
private Font controlFont;
|
||||
|
||||
/** Area configuration manager. */
|
||||
private FSSObsMonitorConfigurationManager configMgr;
|
||||
|
||||
/** Monitoring Area Configuration Dialog */
|
||||
private MonitoringAreaConfigDlg macDlg;
|
||||
private final MonitoringAreaConfigDlg macDlg;
|
||||
|
||||
private final FSSObsMonitorConfigurationManager cfgMgr;
|
||||
|
||||
private final java.util.List<String> newAddedStns = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -77,13 +82,15 @@ public class DeleteStationDlg extends CaveSWTDialog {
|
|||
* Parent shell.
|
||||
* @param appName
|
||||
* Application name.
|
||||
* @param area
|
||||
* @param macDlg
|
||||
*/
|
||||
public DeleteStationDlg(Shell parent, AppName appName,
|
||||
MonitoringAreaConfigDlg macDlg) {
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText(appName.toString() + ": Delete a Newly Entered Station");
|
||||
this.macDlg = macDlg;
|
||||
configMgr = macDlg.getInstance();
|
||||
cfgMgr = macDlg.getInstance();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -114,6 +121,10 @@ public class DeleteStationDlg extends CaveSWTDialog {
|
|||
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||
createListControl();
|
||||
createBottomButtons();
|
||||
java.util.List<AreaIdXML> areaList = cfgMgr.getConfigXml().getAreaIds();
|
||||
newAddedStns.addAll(cfgMgr.getNewlyAddedStations(areaList));
|
||||
areaList = cfgMgr.getAdjAreaConfigXml().getAreaIds();
|
||||
newAddedStns.addAll(cfgMgr.getNewlyAddedStations(areaList));
|
||||
populate();
|
||||
}
|
||||
|
||||
|
@ -175,8 +186,7 @@ public class DeleteStationDlg extends CaveSWTDialog {
|
|||
* Populate list of added stations.
|
||||
*/
|
||||
private void populate() {
|
||||
java.util.List<String> addedStations = configMgr.getAddedStations();
|
||||
stationList.setItems(addedStations.toArray(new String[addedStations
|
||||
stationList.setItems(newAddedStns.toArray(new String[newAddedStns
|
||||
.size()]));
|
||||
}
|
||||
|
||||
|
@ -184,15 +194,20 @@ public class DeleteStationDlg extends CaveSWTDialog {
|
|||
* Delete stations from the list.
|
||||
*/
|
||||
private String deleteSelected() {
|
||||
String retval = null;
|
||||
String retval = "";
|
||||
if (stationList.getItemCount() != 0) {
|
||||
if (stationList.getSelectionIndex() != -1) {
|
||||
int idx = stationList.getSelectionIndex();
|
||||
String selection = stationList.getItem(idx);
|
||||
retval = configMgr.getAddedStations().get(idx);
|
||||
configMgr.getAddedStations().remove(idx);
|
||||
stationList.remove(selection);
|
||||
java.util.List<AreaIdXML> areaXmlList = cfgMgr.getConfigXml()
|
||||
.getAreaIds();
|
||||
cfgMgr.removeStation(selection.split("#")[0], areaXmlList);
|
||||
areaXmlList = cfgMgr.getAdjAreaConfigXml().getAreaIds();
|
||||
cfgMgr.removeStation(selection.split("#")[0], areaXmlList);
|
||||
newAddedStns.remove(selection);
|
||||
populate();
|
||||
macDlg.maStationsRemoved = true;
|
||||
} else {
|
||||
MessageBox messageBox = new MessageBox(shell,
|
||||
SWT.ICON_INFORMATION | SWT.NONE);
|
||||
|
|
205
cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/EditNewZoneDlg.java
Normal file → Executable file
205
cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/EditNewZoneDlg.java
Normal file → Executable file
|
@ -19,6 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.monitor.ui.dialogs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
|
@ -34,9 +36,11 @@ import org.eclipse.swt.widgets.MessageBox;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML.ZoneType;
|
||||
import com.raytheon.uf.common.monitor.xml.StationIdXML;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
|
@ -53,6 +57,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Apr 23, 2014 3054 skorolev Fixed issues with removing a new zone from list.
|
||||
* Apr 28, 2014 3086 skorolev Removed local getAreaConfigMgr method.
|
||||
* Nov 10, 2014 3741 skorolev Fixed configXML issue.
|
||||
* Aug 17, 2015 3841 skorolev Made editable a content of ID field.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -62,7 +67,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
public class EditNewZoneDlg extends CaveSWTDialog {
|
||||
|
||||
/** Call back interface. */
|
||||
private MonitoringAreaConfigDlg macDlg;
|
||||
private final MonitoringAreaConfigDlg macDlg;
|
||||
|
||||
/** Zone list control. */
|
||||
private List zoneList;
|
||||
|
@ -85,17 +90,13 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
/** Control font. */
|
||||
private Font controlFont;
|
||||
|
||||
/** Marine station radio button. */
|
||||
private Button marineRdo;
|
||||
|
||||
/** None Marine station radio button. */
|
||||
private Button nonMarineRdo;
|
||||
|
||||
/** Bottom label */
|
||||
private Label bottomLbl;
|
||||
|
||||
/** Deleted zone */
|
||||
private String delZone;
|
||||
private boolean delZone = false;
|
||||
|
||||
private final FSSObsMonitorConfigurationManager cfgMgr;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -111,6 +112,7 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText(appName.toString() + ": Edit a Newly Added Zone");
|
||||
this.macDlg = macDlg;
|
||||
cfgMgr = macDlg.getInstance();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -142,7 +144,7 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
createListAndTextControls();
|
||||
createBottomLabel();
|
||||
createCloseButton();
|
||||
populate();
|
||||
populate("");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,21 +229,6 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
lonTF = new Text(textButtonComp, SWT.BORDER);
|
||||
lonTF.setLayoutData(gd);
|
||||
|
||||
gd = new GridData();
|
||||
gd.horizontalSpan = 2;
|
||||
gd.verticalIndent = 15;
|
||||
marineRdo = new Button(textButtonComp, SWT.RADIO);
|
||||
marineRdo.setLayoutData(gd);
|
||||
marineRdo.setSelection(false);
|
||||
marineRdo.setText("Marine Station");
|
||||
|
||||
gd = new GridData();
|
||||
gd.horizontalSpan = 2;
|
||||
nonMarineRdo = new Button(textButtonComp, SWT.RADIO);
|
||||
nonMarineRdo.setLayoutData(gd);
|
||||
nonMarineRdo.setSelection(true);
|
||||
nonMarineRdo.setText("Non-Marine Station");
|
||||
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, true);
|
||||
gd.widthHint = 80;
|
||||
gd.verticalIndent = 5;
|
||||
|
@ -251,7 +238,17 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
saveBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
saveSelected();
|
||||
if (zoneList.getItemCount() != 0) {
|
||||
String area = zoneList.getItem(zoneList.getSelectionIndex());
|
||||
String areaStr = idTF.getText().toUpperCase();
|
||||
String latStr = latTF.getText();
|
||||
String lonStr = lonTF.getText();
|
||||
if (macDlg.formIsValid(areaStr, latStr, lonStr)) {
|
||||
saveSelected(area, areaStr, latStr, lonStr);
|
||||
}
|
||||
} else {
|
||||
bottomLbl.setText("No zones have been edited.");
|
||||
}
|
||||
}
|
||||
});
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, true);
|
||||
|
@ -309,9 +306,24 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
/**
|
||||
* Populate list of added zones.
|
||||
*/
|
||||
private void populate() {
|
||||
java.util.List<String> newList = macDlg.configMgr.getAddedZones();
|
||||
private void populate(String selected) {
|
||||
java.util.List<String> newList = new ArrayList<String>();
|
||||
java.util.List<AreaIdXML> maList = cfgMgr.getConfigXml().getAreaIds();
|
||||
for (AreaIdXML maZone : maList) {
|
||||
if (maZone.getCLat() != null) {
|
||||
newList.add(maZone.getAreaId());
|
||||
}
|
||||
}
|
||||
java.util.List<AreaIdXML> adtnlList = cfgMgr.getAdjAreaConfigXml()
|
||||
.getAreaIds();
|
||||
for (AreaIdXML aZone : adtnlList) {
|
||||
if (aZone.getCLat() != null) {
|
||||
newList.add(aZone.getAreaId());
|
||||
}
|
||||
}
|
||||
zoneList.removeAll();
|
||||
zoneList.setItems(newList.toArray(new String[newList.size()]));
|
||||
macDlg.populateLeftLists(selected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -319,27 +331,23 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
*/
|
||||
private void handleZoneSelection() {
|
||||
String zone = zoneList.getItem(zoneList.getSelectionIndex());
|
||||
AreaIdXML areaXml = macDlg.configMgr.getAreaXml(zone);
|
||||
// DR #7343: a null areaXml causes an "Unhandled event loop exception"
|
||||
AreaIdXML areaXml = cfgMgr.getAreaXml(zone);
|
||||
AreaIdXML adjAreaXml = cfgMgr.getAdjAreaXML(zone);
|
||||
if (areaXml != null) {
|
||||
idTF.setText(areaXml.getAreaId());
|
||||
idTF.setEnabled(false);
|
||||
latTF.setText(String.valueOf(areaXml.getCLat()));
|
||||
lonTF.setText(String.valueOf(areaXml.getCLon()));
|
||||
if (areaXml.getType() == ZoneType.REGULAR) {
|
||||
nonMarineRdo.setSelection(true);
|
||||
marineRdo.setSelection(false);
|
||||
} else {
|
||||
nonMarineRdo.setSelection(false);
|
||||
marineRdo.setSelection(true);
|
||||
}
|
||||
} else if (adjAreaXml != null) {
|
||||
idTF.setText(adjAreaXml.getAreaId());
|
||||
latTF.setText(String.valueOf(adjAreaXml.getCLat()));
|
||||
lonTF.setText(String.valueOf(adjAreaXml.getCLon()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete selected zones.
|
||||
*/
|
||||
private String deleteSelected() {
|
||||
private Boolean deleteSelected() {
|
||||
if (zoneList.getItemCount() != 0) {
|
||||
if (zoneList.getSelectionIndex() == -1) {
|
||||
MessageBox messageBox = new MessageBox(shell,
|
||||
|
@ -348,62 +356,97 @@ public class EditNewZoneDlg extends CaveSWTDialog {
|
|||
messageBox.setMessage("Please select zone to be deleted.");
|
||||
messageBox.open();
|
||||
zoneList.select(0);
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
String area = zoneList.getItem(zoneList.getSelectionIndex());
|
||||
AreaIdXML zoneXML = null;
|
||||
if (cfgMgr.getConfigXml().containsArea(area)) {
|
||||
zoneXML = cfgMgr.getAreaXml(area);
|
||||
} else if (cfgMgr.getAdjAreaConfigXml().containsArea(area)) {
|
||||
zoneXML = cfgMgr.getAdjAreaXML(area);
|
||||
}
|
||||
zoneList.remove(zoneList.getSelectionIndex());
|
||||
macDlg.configMgr.removeArea(area);
|
||||
idTF.setText("");
|
||||
latTF.setText("");
|
||||
lonTF.setText("");
|
||||
return area;
|
||||
zoneList.select(0);
|
||||
if (zoneList.getItemCount() != 0) {
|
||||
handleZoneSelection();
|
||||
} else {
|
||||
idTF.setText("");
|
||||
latTF.setText("");
|
||||
lonTF.setText("");
|
||||
}
|
||||
if (zoneXML != null && macDlg.getMaZones().contains(area)) {
|
||||
macDlg.getMaZones().remove(area);
|
||||
cfgMgr.removeArea(zoneXML);
|
||||
}
|
||||
if (zoneXML != null && macDlg.getAdditionalZones().contains(area)) {
|
||||
macDlg.getAdditionalZones().remove(area);
|
||||
cfgMgr.removeAdjArea(zoneXML);
|
||||
}
|
||||
macDlg.populateLeftLists("");
|
||||
macDlg.maZonesRemoved = true;
|
||||
return true;
|
||||
} else {
|
||||
bottomLbl.setText("No zones have been deleted.");
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save selected zones.
|
||||
*
|
||||
* @param area
|
||||
* Original zone ID
|
||||
* @param areaStr
|
||||
* New zone ID
|
||||
* @param latStr
|
||||
* Latitude
|
||||
* @param lonStr
|
||||
* Longitude
|
||||
* @throws NumberFormatException
|
||||
*/
|
||||
private void saveSelected() {
|
||||
|
||||
if (zoneList.getItemCount() != 0) {
|
||||
String area = zoneList.getItem(zoneList.getSelectionIndex());
|
||||
String latStr = latTF.getText();
|
||||
String lontStr = lonTF.getText();
|
||||
if (latStr == null || latStr.isEmpty() || lontStr == null
|
||||
|| lontStr.isEmpty()) {
|
||||
macDlg.latLonErrorMsg(latStr, lontStr);
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
double lat = Double.parseDouble(latStr);
|
||||
double lon = Double.parseDouble(lontStr);
|
||||
if (lat > 90.0 || lat < -90.0 || lon > 180.0
|
||||
|| lon < -180.0) {
|
||||
macDlg.latLonErrorMsg(latStr, lontStr);
|
||||
return;
|
||||
}
|
||||
ZoneType type = ZoneType.REGULAR;
|
||||
if (marineRdo.getSelection()) {
|
||||
type = ZoneType.MARITIME;
|
||||
}
|
||||
// Replace previously added zone
|
||||
macDlg.configMgr.removeArea(area);
|
||||
macDlg.configMgr.removeAddedArea(area);
|
||||
macDlg.configMgr.addArea(area, lat, lon, type);
|
||||
populate();
|
||||
// Return cursor to the top of the list.
|
||||
zoneList.select(0);
|
||||
} catch (NumberFormatException e) {
|
||||
macDlg.latLonErrorMsg(latStr, lontStr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
private void saveSelected(String area, String areaStr, String latStr,
|
||||
String lonStr) throws NumberFormatException {
|
||||
java.util.List<StationIdXML> stationIds;
|
||||
if (macDlg.getMaZones().contains(area)) {
|
||||
stationIds = cfgMgr.getAreaXml(area).getStationIds();
|
||||
} else if (macDlg.getAdditionalZones().contains(area)) {
|
||||
stationIds = cfgMgr.getAdjAreaXML(area).getStationIds();
|
||||
} else {
|
||||
bottomLbl.setText("No zones have been edited.");
|
||||
return;
|
||||
}
|
||||
double lat = Double.parseDouble(latStr);
|
||||
double lon = Double.parseDouble(lonStr);
|
||||
if (lat > 90.0 || lat < -90.0 || lon > 180.0 || lon < -180.0) {
|
||||
macDlg.latLonErrorMsg(latStr, lonStr);
|
||||
return;
|
||||
}
|
||||
ZoneType type = ZoneType.REGULAR;
|
||||
if (areaStr.charAt(2) != 'C') {
|
||||
type = (ZoneType.MARITIME);
|
||||
}
|
||||
AreaIdXML areaXML = new AreaIdXML();
|
||||
areaXML.setAreaId(areaStr);
|
||||
areaXML.setCLat(lat);
|
||||
areaXML.setCLon(lon);
|
||||
areaXML.setType(type);
|
||||
areaXML.setStationIds(stationIds);
|
||||
// Replace previously added zone
|
||||
if (cfgMgr.getAreaList().contains(area)) {
|
||||
if (macDlg.getMaZones().contains(area)) {
|
||||
int idx = macDlg.getMaZones().indexOf(area);
|
||||
macDlg.getMaZones().set(idx, areaXML.getAreaId());
|
||||
}
|
||||
cfgMgr.replaceArea(cfgMgr.getAreaXml(area), areaXML);
|
||||
} else if (macDlg.getAdditionalZones().contains(area)) {
|
||||
if (macDlg.getAdditionalZones().contains(area)) {
|
||||
int idx = macDlg.getAdditionalZones().indexOf(area);
|
||||
macDlg.getAdditionalZones().set(idx, areaXML.getAreaId());
|
||||
}
|
||||
cfgMgr.replaceAdjArea(cfgMgr.getAdjAreaXML(area), areaXML);
|
||||
}
|
||||
populate(areaStr);
|
||||
// Return cursor to the list.
|
||||
zoneList.select(zoneList.indexOf(areaStr));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
211
cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java
Normal file → Executable file
211
cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java
Normal file → Executable file
|
@ -19,8 +19,11 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.monitor.ui.dialogs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -42,10 +45,12 @@ import org.eclipse.swt.widgets.Scale;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.monitor.config.FSSObsMonitorConfigurationManager;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig;
|
||||
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML.ZoneType;
|
||||
import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -79,6 +84,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.
|
||||
* Mar 08, 2015 3888 dhladky Restored threshold pop-up when adding new stations/zones.
|
||||
* Aug 17, 2015 3841 skorolev Added formIsValid method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -181,7 +187,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
private Font controlFont;
|
||||
|
||||
/** Application name. **/
|
||||
private CommonConfig.AppName appName;
|
||||
private final CommonConfig.AppName appName;
|
||||
|
||||
/** The current site. **/
|
||||
protected static String currentSite = null;
|
||||
|
@ -329,7 +335,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
// initialize zone/station lists
|
||||
initZoneStationLists();
|
||||
// Populate the dialog
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
setValues();
|
||||
shell.addShellListener(new ShellAdapter() {
|
||||
@Override
|
||||
|
@ -401,7 +407,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
|
||||
mode = Mode.Zone;
|
||||
changeZoneStationControls();
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
if (!getShell().isDisposed()) {
|
||||
getShell().setCursor(null);
|
||||
}
|
||||
|
@ -417,7 +423,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
|
||||
mode = Mode.Station;
|
||||
changeZoneStationControls();
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
if (!getShell().isDisposed()) {
|
||||
getShell().setCursor(null);
|
||||
}
|
||||
|
@ -782,7 +788,15 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
okBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
handleOkBtnSelection();
|
||||
try {
|
||||
handleOkBtnSelection();
|
||||
} catch (LocalizationException | SerializationException
|
||||
| IOException e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"There is a problem with configuration XML file",
|
||||
e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -878,6 +892,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
* Handles the Add New button click.
|
||||
*/
|
||||
private void handleAddNewAction() {
|
||||
// Zone configure
|
||||
if (zoneRdo.getSelection() == true) {
|
||||
if (addNewZoneDlg == null) {
|
||||
addNewZoneDlg = new AddNewZoneDlg(shell, appName, this);
|
||||
|
@ -886,16 +901,16 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
public void dialogClosed(Object returnValue) {
|
||||
if ((Boolean) returnValue) {
|
||||
// Update the dialog
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
}
|
||||
addNewZoneDlg = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
addNewZoneDlg.open();
|
||||
} else {
|
||||
if (associatedList.getSelectionIndex() != -1) {
|
||||
String area = associatedList.getItem(associatedList
|
||||
} else { // Station configure
|
||||
if (maRegionalList.getSelectionIndex() != -1) {
|
||||
String area = maRegionalList.getItem(maRegionalList
|
||||
.getSelectionIndex());
|
||||
if (addNewStnDlg == null) {
|
||||
addNewStnDlg = new AddNewStationDlg(shell, appName, area,
|
||||
|
@ -905,7 +920,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
public void dialogClosed(Object returnValue) {
|
||||
if ((Boolean) returnValue) {
|
||||
// Update the dialog
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
}
|
||||
addNewStnDlg = null;
|
||||
}
|
||||
|
@ -916,9 +931,9 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
MessageBox messageBox = new MessageBox(shell,
|
||||
SWT.ICON_INFORMATION | SWT.NONE);
|
||||
messageBox.setText("Selection error.");
|
||||
messageBox.setMessage("Please select associated zone.");
|
||||
messageBox.setMessage("Please select a monitoring zone.");
|
||||
messageBox.open();
|
||||
associatedList.select(0);
|
||||
maRegionalList.select(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -937,7 +952,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
// Update the edit dialog
|
||||
String selectedZone = returnValue.toString();
|
||||
maZones.remove(selectedZone);
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
}
|
||||
editDlg = null;
|
||||
}
|
||||
|
@ -951,10 +966,9 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
// Update the delete dialog
|
||||
String selectedStn = returnValue.toString();
|
||||
maStations.remove(selectedStn);
|
||||
populateLeftLists();
|
||||
String station = returnValue.toString();
|
||||
maStations.remove(station);
|
||||
populateLeftLists("");
|
||||
}
|
||||
deleteStnDlg = null;
|
||||
}
|
||||
|
@ -985,13 +999,14 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
maRegionalList.setItems(additionalZones
|
||||
.toArray(new String[additionalZones.size()]));
|
||||
}
|
||||
maRegionalList.select(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the zone list boxes.
|
||||
*/
|
||||
private void populateLeftLists() {
|
||||
protected void populateLeftLists(String selected) {
|
||||
if (mode == Mode.Zone) {
|
||||
/** Zone Mode */
|
||||
Collections.sort(maZones);
|
||||
|
@ -1011,7 +1026,11 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
}
|
||||
if (monitorAreaList.getItemCount() > 0) {
|
||||
// select top of the list
|
||||
monitorAreaList.setSelection(0);
|
||||
if (selected.equals("")) {
|
||||
monitorAreaList.setSelection(0);
|
||||
} else {
|
||||
monitorAreaList.setSelection(monitorAreaList.indexOf(selected));
|
||||
}
|
||||
handleMonitorAreaListSelection();
|
||||
}
|
||||
}
|
||||
|
@ -1090,20 +1109,20 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
if (mode == Mode.Zone) {
|
||||
String zone = additionalList.getItem(additionalList
|
||||
.getSelectionIndex());
|
||||
AreaIdXML zoneXML = configMgr.getAdjAreaXML(zone);
|
||||
additionalList.remove(additionalList.getSelectionIndex());
|
||||
maZones.add(zone);
|
||||
Collections.sort(maZones);
|
||||
monitorAreaList
|
||||
.setItems(maZones.toArray(new String[maZones.size()]));
|
||||
monitorAreaList.setSelection(maZones.indexOf(zone));
|
||||
handleMonitorAreaListSelection();
|
||||
additionalZones.remove(zone);
|
||||
configMgr.addArea(zone, zone.charAt(2) == 'Z' ? ZoneType.MARITIME
|
||||
: ZoneType.REGULAR);
|
||||
configMgr.addArea(zoneXML);
|
||||
handleMonitorAreaListSelection();
|
||||
if (!configMgr.getAddedZones().contains(zone)) {
|
||||
configMgr.getAddedZones().add(zone);
|
||||
}
|
||||
configMgr.removeAdjArea(zone);
|
||||
configMgr.removeAdjArea(zoneXML);
|
||||
} else { // Station mode
|
||||
if (associatedList.getSelectionCount() == 0) {
|
||||
showMessage(shell, SWT.ERROR, "Selection Needed",
|
||||
|
@ -1123,7 +1142,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
.getSelectionIndex());
|
||||
String stnId = stn.substring(0, stn.indexOf('#'));
|
||||
String stnType = stn.substring(stn.indexOf('#') + 1);
|
||||
configMgr.addStation(zone, stnId, stnType, configMgr
|
||||
configMgr.addNewStation(zone, stnId, stnType, configMgr
|
||||
.getAddedStations().contains(stnId));
|
||||
handleMonitorAreaListSelection();
|
||||
}
|
||||
|
@ -1145,9 +1164,11 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
}
|
||||
String entry = monitorAreaList.getItem(monitorAreaList
|
||||
.getSelectionIndex());
|
||||
monitorAreaList.remove(monitorAreaList.getSelectionIndex());
|
||||
associatedList.removeAll();
|
||||
|
||||
if (mode == Mode.Zone) {
|
||||
monitorAreaList.remove(monitorAreaList.getSelectionIndex());
|
||||
// entry is a zone to remove.
|
||||
AreaIdXML zoneXML = configMgr.getAreaXml(entry);
|
||||
if (!additionalZones.contains(entry)) {
|
||||
additionalZones.add(entry);
|
||||
}
|
||||
|
@ -1156,22 +1177,30 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
.toArray(new String[additionalZones.size()]));
|
||||
additionalList.setSelection(additionalZones.indexOf(entry));
|
||||
maZones.remove(entry);
|
||||
configMgr.removeArea(entry);
|
||||
configMgr.removeArea(zoneXML);
|
||||
if (configMgr.getAddedZones().contains(entry)) {
|
||||
configMgr.getAddedZones().remove(entry);
|
||||
}
|
||||
|
||||
configMgr.addAdjArea(entry,
|
||||
entry.charAt(2) == 'Z' ? ZoneType.MARITIME
|
||||
: ZoneType.REGULAR);
|
||||
} else { // Station mode
|
||||
configMgr.addAdjArea(zoneXML);
|
||||
associatedList.removeAll();
|
||||
} else { // Station mode. entry is name#type of station.
|
||||
if (associatedList.getItemCount() >= 1
|
||||
&& associatedList.getSelectionIndex() < 0) {
|
||||
showMessage(shell, SWT.ERROR, "Selection Needed",
|
||||
"You must select a assopciated area zone to remove.");
|
||||
return;
|
||||
}
|
||||
monitorAreaList.remove(monitorAreaList.getSelectionIndex());
|
||||
String stnZone = associatedList.getSelection()[0];
|
||||
additionalStns.add(entry);
|
||||
Collections.sort(additionalStns);
|
||||
additionalList.setItems(additionalStns
|
||||
.toArray(new String[additionalStns.size()]));
|
||||
additionalList.setSelection(additionalStns.indexOf(entry));
|
||||
maStations.remove(entry);
|
||||
configMgr.removeStation(entry.substring(0, entry.indexOf('#')));
|
||||
// station removes from configuration XML files
|
||||
configMgr.removeStationFromArea(stnZone,
|
||||
entry.substring(0, entry.indexOf('#')));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1205,11 +1234,8 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
}
|
||||
String entry = maRegionalList.getItem(maRegionalList
|
||||
.getSelectionIndex());
|
||||
String[] items = associatedList.getItems();
|
||||
ArrayList<String> itemList = new ArrayList<String>();
|
||||
for (String item : items) {
|
||||
itemList.add(item);
|
||||
}
|
||||
java.util.List<String> itemList = new LinkedList<String>(
|
||||
Arrays.asList(associatedList.getItems()));
|
||||
if (itemList.contains(entry)) {
|
||||
/**
|
||||
* if selected entry is already in associated list: highlight the
|
||||
|
@ -1238,24 +1264,24 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
.getSelectionIndex());
|
||||
String stnId = entry.substring(0, entry.indexOf('#'));
|
||||
String stnType = entry.substring(entry.indexOf('#') + 1);
|
||||
configMgr.addStation(zone, stnId, stnType, configMgr
|
||||
|
||||
configMgr.addNewStation(zone, stnId, stnType, configMgr
|
||||
.getAddedStations().contains(stnId));
|
||||
} else { // Station mode
|
||||
if (regionalRdo.getSelection()) {
|
||||
// entry is a zone selected from additional zones
|
||||
AreaIdXML zoneXML = configMgr.getAdjAreaXML(entry);
|
||||
maZones.add(entry);
|
||||
Collections.sort(maZones);
|
||||
additionalZones.remove(entry);
|
||||
maRegionalList.remove(maRegionalList.getSelectionIndex());
|
||||
configMgr.addArea(entry,
|
||||
entry.charAt(2) == 'Z' ? ZoneType.MARITIME
|
||||
: ZoneType.REGULAR);
|
||||
configMgr.addArea(zoneXML);
|
||||
}
|
||||
String stn = monitorAreaList.getItem(monitorAreaList
|
||||
.getSelectionIndex());
|
||||
String stnId = stn.substring(0, stn.indexOf('#'));
|
||||
String stnType = stn.substring(stn.indexOf('#') + 1);
|
||||
configMgr.addStation(entry, stnId, stnType, configMgr
|
||||
configMgr.addNewStation(entry, stnId, stnType, configMgr
|
||||
.getAddedStations().contains(stnId));
|
||||
}
|
||||
}
|
||||
|
@ -1280,10 +1306,10 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
if (mode == Mode.Zone) {
|
||||
String zone = monitorAreaList.getItem(monitorAreaList
|
||||
.getSelectionIndex());
|
||||
configMgr.removeStation(zone, entry);
|
||||
configMgr.removeStationFromArea(zone, entry);
|
||||
java.util.List<String> zones = configMgr.getAreaByStationId(entry
|
||||
.substring(0, entry.indexOf('#')));
|
||||
if (zones.size() == 0) {
|
||||
if (zones.isEmpty()) {
|
||||
// entry is no longer an MA station
|
||||
maStations.remove(entry);
|
||||
additionalStns.add(entry);
|
||||
|
@ -1299,7 +1325,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
} else { // Station mode
|
||||
String stn = monitorAreaList.getItem(monitorAreaList
|
||||
.getSelectionIndex());
|
||||
configMgr.removeStation(entry, stn);
|
||||
configMgr.removeStationFromArea(entry, stn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1343,13 +1369,18 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Reset and Saving configuration parameters.
|
||||
* Save configuration parameters.
|
||||
*
|
||||
* @throws SerializationException
|
||||
* @throws LocalizationException
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void resetAndSave() {
|
||||
protected void saveConfigs() throws LocalizationException,
|
||||
SerializationException, IOException {
|
||||
getValues();
|
||||
resetStatus();
|
||||
configMgr.saveConfigXml();
|
||||
configMgr.saveAdjacentAreaConfigXml();
|
||||
configMgr.setPopulated(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1363,8 +1394,13 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
/**
|
||||
* Handles OK button. Save changes and close the dialog (or just close if
|
||||
* there are no changes).
|
||||
*
|
||||
* @throws SerializationException
|
||||
* @throws LocalizationException
|
||||
* @throws IOException
|
||||
*/
|
||||
protected abstract void handleOkBtnSelection();
|
||||
protected abstract void handleOkBtnSelection()
|
||||
throws LocalizationException, SerializationException, IOException;
|
||||
|
||||
/**
|
||||
* Adds a new zone to monitor area and refresh GUI
|
||||
|
@ -1374,7 +1410,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
public void addZoneToMA(String zone) {
|
||||
maZones.add(zone);
|
||||
Collections.sort(maZones);
|
||||
populateLeftLists();
|
||||
populateLeftLists(zone);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1386,7 +1422,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
public void addStationToMA(String stnWithType) {
|
||||
maStations.add(stnWithType);
|
||||
Collections.sort(maStations);
|
||||
populateLeftLists();
|
||||
populateLeftLists("");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1416,6 +1452,58 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Input test.
|
||||
*
|
||||
* @param area
|
||||
* @param latString
|
||||
* @param lonString
|
||||
* @return
|
||||
*/
|
||||
public boolean formIsValid(String area, String latString, String lonString) {
|
||||
boolean retVal = true;
|
||||
String msg = "";
|
||||
if (area.equals("") || area.length() != 6
|
||||
|| !Character.isDigit(area.charAt(3))) {
|
||||
msg = "Invalid Area ID = '"
|
||||
+ area
|
||||
+ "' entered.\n"
|
||||
+ "Please enter a correctly formatted Area ID:\n"
|
||||
+ "Zone ID must have six characters. 3 letters and 3 digits.\n"
|
||||
+ "Use only capital characters.\n";
|
||||
retVal = false;
|
||||
}
|
||||
if (appName != AppName.SNOW
|
||||
&& (area.charAt(2) != 'C' && area.charAt(2) != 'Z')) {
|
||||
msg = msg
|
||||
+ "A third character should be C for county and Z for marine zone.\n";
|
||||
retVal = false;
|
||||
}
|
||||
if (!msg.isEmpty()) {
|
||||
displayInputErrorMsg(msg);
|
||||
retVal = false;
|
||||
}
|
||||
if (latString == null || latString.isEmpty() || lonString == null
|
||||
|| lonString.isEmpty()) {
|
||||
latLonErrorMsg(latString, lonString);
|
||||
retVal = false;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays Input Error Message
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void displayInputErrorMsg(String msg) {
|
||||
MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION
|
||||
| SWT.OK);
|
||||
messageBox.setText("Invalid input");
|
||||
messageBox.setMessage(msg);
|
||||
messageBox.open();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -1462,6 +1550,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
* @see
|
||||
* com.raytheon.uf.viz.monitor.ui.dialogs.INewZoneStnAction#latLonErrorMsg()
|
||||
*/
|
||||
@Override
|
||||
public void latLonErrorMsg(String latStr, String lonStr) {
|
||||
MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION
|
||||
| SWT.OK);
|
||||
|
@ -1538,6 +1627,22 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
|
|||
return state;
|
||||
}
|
||||
|
||||
public java.util.List<String> getMaZones() {
|
||||
return maZones;
|
||||
}
|
||||
|
||||
public java.util.List<String> getMaStations() {
|
||||
return maStations;
|
||||
}
|
||||
|
||||
public java.util.List<String> getAdditionalZones() {
|
||||
return additionalZones;
|
||||
}
|
||||
|
||||
public java.util.List<String> getAdditionalStns() {
|
||||
return additionalStns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Configuration manager.
|
||||
*
|
||||
|
|
|
@ -96,6 +96,7 @@ import com.vividsolutions.jts.io.ParseException;
|
|||
* May 15, 2014 3086 skorolev Replaced MonitorConfigurationManager with FSSObsMonitorConfigurationManager.
|
||||
* Sep 15, 2014 3220 skorolev Added refreshZoneTableData method.
|
||||
* Nov 03, 2014 3741 skorolev Updated zoom procedures.
|
||||
* Aug 26, 2015 3841 skorolev Corrected zoomToZone procedure.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -225,7 +226,7 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
|
|||
protected abstract void shellDisposeAction();
|
||||
|
||||
/** List of opened plots. **/
|
||||
private Map<String, CaveSWTDialog> openedDlgs = new HashMap<String, CaveSWTDialog>();
|
||||
private final Map<String, CaveSWTDialog> openedDlgs = new HashMap<String, CaveSWTDialog>();
|
||||
|
||||
/** row index in the station table. **/
|
||||
public int rowIndex;
|
||||
|
@ -242,7 +243,7 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
|
|||
/** current site **/
|
||||
protected String site;
|
||||
|
||||
protected FSSObsMonitorConfigurationManager configMgr;
|
||||
protected FSSObsMonitorConfigurationManager configMgr = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -788,6 +789,7 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements
|
|||
private void zoomToZone(String zone) throws Exception {
|
||||
Coordinate zoneCenter = MonitorAreaUtils.getZoneCenter(zone);
|
||||
if (zoneCenter == null) { // Test a newly added zone.
|
||||
configMgr = getMonitorAreaConfigInstance();
|
||||
AreaIdXML zoneXML = configMgr.getAreaXml(zone);
|
||||
if (zoneXML != null // Coordinates do not the null values.
|
||||
&& (zoneXML.getCLon() != null || zoneXML.getCLat() != null)) {
|
||||
|
|
|
@ -20,9 +20,13 @@
|
|||
package com.raytheon.uf.common.monitor.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
|
@ -34,6 +38,8 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel
|
|||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.SaveableOutputStream;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.monitor.MonitorAreaUtils;
|
||||
import com.raytheon.uf.common.monitor.data.AdjacentWfoMgr;
|
||||
import com.raytheon.uf.common.monitor.events.MonitorConfigEvent;
|
||||
|
@ -42,6 +48,7 @@ import com.raytheon.uf.common.monitor.xml.AreaIdXML;
|
|||
import com.raytheon.uf.common.monitor.xml.AreaIdXML.ZoneType;
|
||||
import com.raytheon.uf.common.monitor.xml.MonAreaConfigXML;
|
||||
import com.raytheon.uf.common.monitor.xml.StationIdXML;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
||||
import com.raytheon.uf.common.site.SiteMap;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
|
@ -68,6 +75,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* May 15 2014 3086 skorolev Renamed from MonitorConfigurationManager. Replaces three separate area configuration managers with one.
|
||||
* Sep 04 2014 3220 skorolev Added fileUpdated method.
|
||||
* Feb 24 2015 3220 dhladky Made sure config file is read in on change.
|
||||
* Aug 17 2015 3841 skorolev Corrected getInstance, addArea, addAdjArea and added getAdjAreaConfigXml.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -108,9 +116,6 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
/** Name of plugin */
|
||||
private static String pluginName = null;
|
||||
|
||||
/** Monitor name */
|
||||
private static String monitorName = null;
|
||||
|
||||
/** Name of area configuration file */
|
||||
private String configFileName = null;
|
||||
|
||||
|
@ -128,28 +133,31 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
ss, fog, snow
|
||||
};
|
||||
|
||||
/** Default value for Timewindow in hours */
|
||||
private static final double DEFAULT_TIME = 2;
|
||||
|
||||
/** Localization Area Configuration File. */
|
||||
private LocalizationFile lacf = null;
|
||||
|
||||
/** Configuration XML is updated and saved */
|
||||
protected boolean isPopulated;
|
||||
|
||||
/** Singleton instance of this class */
|
||||
private static FSSObsMonitorConfigurationManager instance = null;
|
||||
/** Map for current configuration managers. */
|
||||
private final static Map<MonName, FSSObsMonitorConfigurationManager> instanceMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Private Constructor
|
||||
*
|
||||
* @param monitorName
|
||||
*/
|
||||
public FSSObsMonitorConfigurationManager(String monitorName) {
|
||||
setMonitorName(monitorName);
|
||||
setPopulated(false);
|
||||
private FSSObsMonitorConfigurationManager(MonName monitorName) {
|
||||
// setMonitorName(monitorName);
|
||||
|
||||
// Avoid confusion in file path
|
||||
if (monitorName == MonName.ss.name()) {
|
||||
if (monitorName == MonName.ss) {
|
||||
pluginName = "safeseas";
|
||||
} else {
|
||||
pluginName = monitorName;
|
||||
pluginName = monitorName.name();
|
||||
}
|
||||
/** Path to Monitoring Area Configuration XML. */
|
||||
setConfigFileName(pluginName + File.separatorChar + "monitoringArea"
|
||||
|
@ -162,19 +170,21 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
configXml = new MonAreaConfigXML();
|
||||
adjAreaConfigXml = new MonAreaConfigXML();
|
||||
readConfigXml();
|
||||
setPopulated(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of Configuration manager for FSSObs monitors.
|
||||
* Returns instance of current monitor.
|
||||
*
|
||||
* @param monitor
|
||||
* Name of monitor
|
||||
* @return Instance of manager
|
||||
* @return
|
||||
*/
|
||||
public static synchronized FSSObsMonitorConfigurationManager getInstance(
|
||||
String monitor) {
|
||||
MonName monitor) {
|
||||
FSSObsMonitorConfigurationManager instance = instanceMap.get(monitor);
|
||||
if (instance == null) {
|
||||
instance = new FSSObsMonitorConfigurationManager(monitor);
|
||||
instanceMap.put(monitor, instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
@ -188,17 +198,16 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
public void readConfigXml() {
|
||||
boolean monitorAreaFileExists = true;
|
||||
boolean adjacentAreaFileExists = true;
|
||||
// Read area configuration XML file.
|
||||
try {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pm.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
|
||||
this.currentSite = lc.getContextName();
|
||||
lacf = pm.getLocalizationFile(lc, configFileName);
|
||||
String monitorAreaFilePath = lacf.getFile().getAbsolutePath();
|
||||
MonAreaConfigXML configXmltmp = jaxb
|
||||
.unmarshalFromXmlFile(monitorAreaFilePath.toString());
|
||||
configXml = configXmltmp;
|
||||
setPopulated(true);
|
||||
InputStream inStrm = lacf.openInputStream();
|
||||
configXml = (MonAreaConfigXML) jaxb
|
||||
.unmarshalFromInputStream(inStrm);
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.handle(Priority.WARN,
|
||||
|
@ -208,7 +217,7 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
+ "");
|
||||
monitorAreaFileExists = false;
|
||||
}
|
||||
|
||||
// Read adjacent area configuration XML file.
|
||||
try {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
String adjacentAreaFilePath = pm.getFile(
|
||||
|
@ -218,7 +227,6 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
MonAreaConfigXML configXmltmp = jaxb
|
||||
.unmarshalFromXmlFile(adjacentAreaFilePath.toString());
|
||||
adjAreaConfigXml = configXmltmp;
|
||||
|
||||
} catch (Exception e) {
|
||||
statusHandler
|
||||
.handle(Priority.WARN,
|
||||
|
@ -276,9 +284,7 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
configXml.addAreaId(zoneXml);
|
||||
}
|
||||
}
|
||||
// Default value for Timewindow.
|
||||
int defaultVal = 2;
|
||||
configXml.setTimeWindow(defaultVal);
|
||||
configXml.setTimeWindow(DEFAULT_TIME);
|
||||
saveConfigXml();
|
||||
}
|
||||
// Check for an adjacent area config file, if one does not exist,
|
||||
|
@ -311,26 +317,26 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
/**
|
||||
* Saves the monitor area XML configuration data to the current XML file
|
||||
* name.
|
||||
*
|
||||
* @throws LocalizationException
|
||||
* @throws SerializationException
|
||||
*/
|
||||
public void saveConfigXml() {
|
||||
public void saveConfigXml() throws LocalizationException,
|
||||
SerializationException {
|
||||
// Save the xml object to disk
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE);
|
||||
LocalizationFile newXmlFile = pm.getLocalizationFile(lc,
|
||||
getConfigFileName());
|
||||
if (newXmlFile.getFile().getParentFile().exists() == false) {
|
||||
newXmlFile.getFile().getParentFile().mkdirs();
|
||||
}
|
||||
try {
|
||||
jaxb.marshalToXmlFile(configXml, newXmlFile.getFile()
|
||||
.getAbsolutePath());
|
||||
newXmlFile.save();
|
||||
lacf = newXmlFile;
|
||||
lacf.addFileUpdatedObserver(this);
|
||||
setPopulated(true);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.ERROR, e.getMessage());
|
||||
SaveableOutputStream outStrm = newXmlFile.openOutputStream();
|
||||
jaxb.marshalToStream(configXml, outStrm);
|
||||
outStrm.save();
|
||||
} catch (IOException e) {
|
||||
statusHandler.handle(Priority.ERROR,
|
||||
"There is a problem to save configuration XML file: "
|
||||
+ getConfigFileName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,53 +345,40 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
* name.
|
||||
*
|
||||
* @param filename
|
||||
* adjacentAreaConfig.xml
|
||||
* adjacentAreaConfig.xml adjAreaConfigXml
|
||||
* @throws SerializationException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void saveAdjacentAreaConfigXml() {
|
||||
public void saveAdjacentAreaConfigXml() throws SerializationException,
|
||||
LocalizationException, IOException {
|
||||
// Save the xml object to disk
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE);
|
||||
LocalizationFile newXmlFile = pm.getLocalizationFile(lc,
|
||||
getAdjAreaConfigFileName());
|
||||
if (newXmlFile.getFile().getParentFile().exists() == false) {
|
||||
newXmlFile.getFile().getParentFile().mkdirs();
|
||||
}
|
||||
try {
|
||||
jaxb.marshalToXmlFile(adjAreaConfigXml, newXmlFile.getFile()
|
||||
.getAbsolutePath());
|
||||
newXmlFile.save();
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.ERROR, e.getMessage());
|
||||
SaveableOutputStream outStrm = newXmlFile.openOutputStream();
|
||||
jaxb.marshalToStream(adjAreaConfigXml, outStrm);
|
||||
outStrm.save();
|
||||
} catch (LocalizationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"There is a problem to save configuration XML file: "
|
||||
+ getAdjAreaConfigFileName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new Area to the configuration. This method only adds the area, the
|
||||
* other info will need to be added to the area via the other methods in
|
||||
* this class.
|
||||
* Adds Area XML.
|
||||
*
|
||||
* @param areaId
|
||||
* @param type
|
||||
* Type of zone
|
||||
* @param areaXML
|
||||
*/
|
||||
public void addArea(String areaId, ZoneType type) {
|
||||
public void addArea(AreaIdXML areaXML) {
|
||||
List<AreaIdXML> areaXmlList = configXml.getAreaIds();
|
||||
boolean areaExists = false;
|
||||
for (AreaIdXML area : areaXmlList) {
|
||||
if (area.getAreaId().equals(areaId)) {
|
||||
area.setType(type);
|
||||
areaExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (areaExists == false) {
|
||||
AreaIdXML area = new AreaIdXML();
|
||||
area.setAreaId(areaId);
|
||||
area.setType(type);
|
||||
configXml.addAreaId(area);
|
||||
if (!addedZones.contains(areaId)) {
|
||||
addedZones.add(areaId);
|
||||
if (!areaXmlList.contains(areaXML)) {
|
||||
configXml.addAreaId(areaXML);
|
||||
if (!addedZones.contains(areaXML.getAreaId())) {
|
||||
addedZones.add(areaXML.getAreaId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -404,7 +397,7 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
* @param type
|
||||
* The area type
|
||||
*/
|
||||
public void addArea(String areaId, double lat, double lon, ZoneType type) {
|
||||
public void addNewArea(String areaId, double lat, double lon, ZoneType type) {
|
||||
List<AreaIdXML> areaXmlList = configXml.getAreaIds();
|
||||
boolean areaExists = false;
|
||||
for (AreaIdXML area : areaXmlList) {
|
||||
|
@ -440,12 +433,15 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
* The station id
|
||||
* @param type
|
||||
* The station type
|
||||
* @param existingStation
|
||||
* Does the station already exist
|
||||
* @param added
|
||||
* Station has been added (true | false)
|
||||
*/
|
||||
public void addStation(String areaId, String stationId, String type,
|
||||
boolean existingStation) {
|
||||
public void addNewStation(String areaId, String stationId, String type,
|
||||
boolean added) {
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
if (!configXml.containsArea(areaId)) {
|
||||
areaList = adjAreaConfigXml.getAreaIds();
|
||||
}
|
||||
if (stationId.contains("#")) {
|
||||
stationId = stationId.substring(0, stationId.indexOf("#"));
|
||||
}
|
||||
|
@ -454,8 +450,13 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
StationIdXML stationXml = new StationIdXML();
|
||||
stationXml.setName(stationId);
|
||||
stationXml.setType(type);
|
||||
if (added) {
|
||||
stationXml.setAdded(added);
|
||||
}
|
||||
area.addStationIdXml(stationXml);
|
||||
addedStations.add(stationId + "#" + type);
|
||||
if (!addedStations.contains(stationId)) {
|
||||
addedStations.add(stationId + "#" + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -553,9 +554,11 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
for (AreaIdXML area : areaList) {
|
||||
List<StationIdXML> stationList = area.getStationIds();
|
||||
for (StationIdXML station : stationList) {
|
||||
if (station.getName().equals(stationId)) {
|
||||
results.add(area.getAreaId());
|
||||
if (!stationList.isEmpty()) {
|
||||
for (StationIdXML station : stationList) {
|
||||
if (station.getName().equals(stationId)) {
|
||||
results.add(area.getAreaId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -565,7 +568,7 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
/**
|
||||
* Gets all the stations associated with the areas.
|
||||
*
|
||||
* @return List of stations
|
||||
* @return List of stations with type
|
||||
*/
|
||||
public List<String> getStations() {
|
||||
List<AreaIdXML> areaXml = configXml.getAreaIds();
|
||||
|
@ -590,13 +593,31 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
Set<String> stations = new HashSet<String>();
|
||||
for (AreaIdXML area : areaXml) {
|
||||
List<StationIdXML> stationList = area.getStationIds();
|
||||
for (StationIdXML station : stationList) {
|
||||
stations.add(station.getName());
|
||||
if (!stationList.isEmpty()) {
|
||||
for (StationIdXML station : stationList) {
|
||||
stations.add(station.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return stations;
|
||||
}
|
||||
|
||||
public List<String> getNewlyAddedStations(List<AreaIdXML> areaXml) {
|
||||
ArrayList<String> retVal = new ArrayList<String>();
|
||||
for (AreaIdXML area : areaXml) {
|
||||
List<StationIdXML> stationList = area.getStationIds();
|
||||
if (!stationList.isEmpty()) {
|
||||
for (StationIdXML stn : stationList) {
|
||||
if (stn.isAdded()) {
|
||||
retVal.add(stn.getName() + "#" + stn.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all monitoring areas.
|
||||
*
|
||||
|
@ -633,37 +654,41 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
* @param station
|
||||
* Station to remove from the area
|
||||
*/
|
||||
public void removeStation(String area, String station) {
|
||||
station = station.substring(0, station.indexOf("#"));
|
||||
public void removeStationFromArea(String area, String station) {
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
for (AreaIdXML areaXml : areaList) {
|
||||
if (areaXml.getAreaId().equals(area)) {
|
||||
List<StationIdXML> stationList = areaXml.getStationIds();
|
||||
for (int i = 0; i < stationList.size(); i++) {
|
||||
if (stationList.get(i).getName().equals(station)) {
|
||||
stationList.remove(i);
|
||||
areaXml.getStationIds();
|
||||
if (!stationList.isEmpty()) {
|
||||
for (int i = 0; i < stationList.size(); i++) {
|
||||
StationIdXML stationXml = stationList.get(i);
|
||||
if (stationXml.getName().equals(station.split("#")[0])) {
|
||||
stationList.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a station from the monitoring area.
|
||||
* Removes a station from all monitoring areas.
|
||||
*
|
||||
* @param station
|
||||
* The station to remove
|
||||
*/
|
||||
public void removeStation(String station) {
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
for (AreaIdXML areaXml : areaList) {
|
||||
List<StationIdXML> stationList = areaXml.getStationIds();
|
||||
for (int i = 0; i < stationList.size(); i++) {
|
||||
StationIdXML stationXml = stationList.get(i);
|
||||
if (stationXml.getName().equals(station)) {
|
||||
stationList.remove(i);
|
||||
i--;
|
||||
public void removeStation(String station, List<AreaIdXML> areaListXML) {
|
||||
for (AreaIdXML areaXML : areaListXML) {
|
||||
List<StationIdXML> stationList = areaXML.getStationIds();
|
||||
if (!stationList.isEmpty()) {
|
||||
for (int i = 0; i < stationList.size(); i++) {
|
||||
StationIdXML stationXml = stationList.get(i);
|
||||
if (stationXml.getName().equals(station)) {
|
||||
stationList.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -687,39 +712,69 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes an area from the monitoring area.
|
||||
* Gets an AdjAreaXml.
|
||||
*
|
||||
* @param zone
|
||||
* from additional list
|
||||
* @return
|
||||
*/
|
||||
public AreaIdXML getAdjAreaXML(String zone) {
|
||||
List<AreaIdXML> areaList = adjAreaConfigXml.getAreaIds();
|
||||
for (AreaIdXML adjAreaXml : areaList) {
|
||||
if (adjAreaXml.getAreaId().equals(zone)) {
|
||||
return adjAreaXml;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an area XML from the area configuration.
|
||||
*
|
||||
* @param area
|
||||
* The area to remove
|
||||
*/
|
||||
public void removeArea(String area) {
|
||||
public void removeArea(AreaIdXML area) {
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
for (int i = 0; i < areaList.size(); i++) {
|
||||
if (areaList.get(i).getAreaId().equals(area)) {
|
||||
areaList.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < addedZones.size(); i++) {
|
||||
if (addedZones.get(i).equals(area)) {
|
||||
addedZones.remove(i);
|
||||
break;
|
||||
if (areaList.contains(area)) {
|
||||
areaList.remove(area);
|
||||
if (addedZones.contains(area.getAreaId())) {
|
||||
addedZones.remove(area.getAreaId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an added area.
|
||||
* Replaces existing area XML in the area configuration.
|
||||
*
|
||||
* @param area
|
||||
* The area to remove
|
||||
* @param areaOld
|
||||
* @param areaNew
|
||||
*/
|
||||
public void removeAddedArea(String area) {
|
||||
for (int i = 0; i < addedZones.size(); i++) {
|
||||
if (addedZones.get(i).equals(area)) {
|
||||
addedZones.remove(i);
|
||||
break;
|
||||
}
|
||||
public void replaceArea(AreaIdXML areaOld, AreaIdXML areaNew) {
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
int idx = areaList.indexOf(areaOld);
|
||||
areaList.set(idx, areaNew);
|
||||
if (addedZones.contains(areaOld)) {
|
||||
addedZones.set(addedZones.indexOf(areaOld), areaNew.getAreaId());
|
||||
} else {
|
||||
addedZones.add(areaNew.getAreaId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces existing area XML in the adjusted area configuration
|
||||
*
|
||||
* @param areaOld
|
||||
* @param areaNew
|
||||
*/
|
||||
public void replaceAdjArea(AreaIdXML areaOld, AreaIdXML areaNew) {
|
||||
List<AreaIdXML> areaList = adjAreaConfigXml.getAreaIds();
|
||||
int idx = areaList.indexOf(areaOld);
|
||||
areaList.set(idx, areaNew);
|
||||
if (addedZones.contains(areaOld)) {
|
||||
addedZones.set(addedZones.indexOf(areaOld), areaNew.getAreaId());
|
||||
} else {
|
||||
addedZones.add(areaNew.getAreaId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -789,6 +844,15 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
return configXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Adjacent Configuration Xml
|
||||
*
|
||||
* @return the adjAreaConfigXml
|
||||
*/
|
||||
public MonAreaConfigXML getAdjAreaConfigXml() {
|
||||
return adjAreaConfigXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Added Zones
|
||||
*
|
||||
|
@ -839,13 +903,15 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
String result = null;
|
||||
List<AreaIdXML> areaList = configXml.getAreaIds();
|
||||
for (AreaIdXML area : areaList) {
|
||||
if (area.getAreaId().equals(theZone)) {
|
||||
if (area.getAreaId().equals(theZone)
|
||||
&& area.containsStation(theStation)) {
|
||||
List<StationIdXML> stationList = area.getStationIds();
|
||||
for (StationIdXML station : stationList) {
|
||||
if (station.getName().equals(theStation)) {
|
||||
return station.getType();
|
||||
result = station.getType();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -937,24 +1003,6 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Monitor Name.
|
||||
*
|
||||
* @return monitor name
|
||||
*/
|
||||
public String getMonitorName() {
|
||||
return monitorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Monitor Name.
|
||||
*
|
||||
* @param monitorName
|
||||
*/
|
||||
public void setMonitorName(String monitorName) {
|
||||
FSSObsMonitorConfigurationManager.monitorName = monitorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag is true if config file updated and saved.
|
||||
*
|
||||
|
@ -974,41 +1022,42 @@ public class FSSObsMonitorConfigurationManager implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Remove Adjacent Area.
|
||||
* Remove Adjacent Area XML.
|
||||
*
|
||||
* @param zone
|
||||
*/
|
||||
public void removeAdjArea(String zone) {
|
||||
public void removeAdjArea(AreaIdXML zone) {
|
||||
List<AreaIdXML> adjAreaList = adjAreaConfigXml.getAreaIds();
|
||||
for (int i = 0; i < adjAreaList.size(); i++) {
|
||||
if (adjAreaList.get(i).getAreaId().equals(zone)) {
|
||||
adjAreaList.remove(i);
|
||||
break;
|
||||
if (adjAreaList.contains(zone)) {
|
||||
adjAreaList.remove(zone);
|
||||
if (addedZones.contains(zone.getAreaId())) {
|
||||
addedZones.remove(zone.getAreaId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Adjacent Area.
|
||||
* Add Adjacent Area XML.
|
||||
*
|
||||
* @param areaId
|
||||
* @param type
|
||||
* @param areaXML
|
||||
*/
|
||||
public void addAdjArea(String areaId, ZoneType type) {
|
||||
public void addAdjArea(AreaIdXML areaXML) {
|
||||
List<AreaIdXML> adjAreaList = adjAreaConfigXml.getAreaIds();
|
||||
boolean areaExists = false;
|
||||
for (AreaIdXML area : adjAreaList) {
|
||||
if (area.getAreaId().equals(areaId)) {
|
||||
area.setType(type);
|
||||
areaExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (areaExists == false) {
|
||||
AreaIdXML area = new AreaIdXML();
|
||||
area.setAreaId(areaId);
|
||||
area.setType(type);
|
||||
adjAreaConfigXml.addAreaId(area);
|
||||
if (!adjAreaList.contains(areaXML)) {
|
||||
adjAreaConfigXml.addAreaId(areaXML);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets configuration manager for monitor.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static FSSObsMonitorConfigurationManager getObsManager(
|
||||
MonName monitor) {
|
||||
FSSObsMonitorConfigurationManager instance = getInstance(monitor);
|
||||
instance.readConfigXml();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
package com.raytheon.uf.common.monitor.xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
|
@ -36,6 +38,7 @@ import javax.xml.bind.annotation.XmlElements;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 21, 2009 lvenable Initial creation
|
||||
* Sep 03, 2015 3841 skorolev Added containsStation method
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -46,7 +49,7 @@ import javax.xml.bind.annotation.XmlElements;
|
|||
public class AreaIdXML {
|
||||
|
||||
@XmlElements({ @XmlElement(name = "StationID", type = StationIdXML.class) })
|
||||
private ArrayList<StationIdXML> stationIds = new ArrayList<StationIdXML>();
|
||||
private List<StationIdXML> stationIds = new ArrayList<StationIdXML>();
|
||||
|
||||
@XmlAttribute(name = "id")
|
||||
private String areaId;
|
||||
|
@ -67,11 +70,11 @@ public class AreaIdXML {
|
|||
public AreaIdXML() {
|
||||
}
|
||||
|
||||
public ArrayList<StationIdXML> getStationIds() {
|
||||
public List<StationIdXML> getStationIds() {
|
||||
return stationIds;
|
||||
}
|
||||
|
||||
public void setStationIds(ArrayList<StationIdXML> stationIds) {
|
||||
public void setStationIds(List<StationIdXML> stationIds) {
|
||||
this.stationIds = stationIds;
|
||||
}
|
||||
|
||||
|
@ -138,4 +141,21 @@ public class AreaIdXML {
|
|||
public void setCLon(Double lon) {
|
||||
cLon = lon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param station
|
||||
* @return
|
||||
*/
|
||||
public boolean containsStation(String station) {
|
||||
if (!stationIds.isEmpty()) {
|
||||
Iterator<StationIdXML> itr = getStationIds().iterator();
|
||||
while (itr.hasNext()) {
|
||||
if (itr.next().getName().equals(station)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
package com.raytheon.uf.common.monitor.xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
|
@ -37,6 +39,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 21, 2009 lvenable Initial creation
|
||||
* May 15, 2014 3086 skorolev Changed type for timeWindow element.
|
||||
* Sep 03, 2015 3841 skorolev Added containsArea method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -48,7 +51,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
public class MonAreaConfigXML {
|
||||
|
||||
@XmlElements({ @XmlElement(name = "AreaID", type = AreaIdXML.class) })
|
||||
private ArrayList<AreaIdXML> areaIds = new ArrayList<AreaIdXML>();
|
||||
private List<AreaIdXML> areaIds = new ArrayList<AreaIdXML>();
|
||||
|
||||
/**
|
||||
* Time period in minutes during which stations are monitoring.
|
||||
|
@ -71,7 +74,7 @@ public class MonAreaConfigXML {
|
|||
public MonAreaConfigXML() {
|
||||
}
|
||||
|
||||
public ArrayList<AreaIdXML> getAreaIds() {
|
||||
public List<AreaIdXML> getAreaIds() {
|
||||
return areaIds;
|
||||
}
|
||||
|
||||
|
@ -130,4 +133,21 @@ public class MonAreaConfigXML {
|
|||
public void addAreaId(AreaIdXML areaXml) {
|
||||
areaIds.add(areaXml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if areaXML exist for area ID.
|
||||
*
|
||||
* @param area
|
||||
* area ID
|
||||
* @return areaXML
|
||||
*/
|
||||
public boolean containsArea(String areaId) {
|
||||
Iterator<AreaIdXML> itr = getAreaIds().iterator();
|
||||
while (itr.hasNext()) {
|
||||
if (itr.next().getAreaId().equals(areaId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@ import javax.xml.bind.annotation.XmlAttribute;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 21, 2009 lvenable Initial creation
|
||||
* Dec 21, 2009 lvenable Initial creation
|
||||
* Aug 25, 2015 3481 skorolev Added attribute "added"
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,6 +48,9 @@ public class StationIdXML {
|
|||
@XmlAttribute(name = "name")
|
||||
private String name;
|
||||
|
||||
@XmlAttribute(name = "added", required = false)
|
||||
private boolean added;
|
||||
|
||||
public static final String MARITIME = "MARITIME";
|
||||
|
||||
public static final String METAR = "METAR";
|
||||
|
@ -79,4 +83,12 @@ public class StationIdXML {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isAdded() {
|
||||
return added;
|
||||
}
|
||||
|
||||
public void setAdded(boolean added) {
|
||||
this.added = added;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ import com.raytheon.uf.edex.menus.AbstractMenuUtil;
|
|||
* Configuration Manager has not read a
|
||||
* FFMPRunConfig.xml file.
|
||||
* Sep 04, 2014 3220 skorolev Updated menu creation for Fog, Safeseas and Snow monitors.
|
||||
* Sep 03, 2015 3841 skorolev Corrected getInstance for Fog, Safeseas and Snow monitors.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -483,26 +484,26 @@ public class DatMenuUtil extends AbstractMenuUtil {
|
|||
*/
|
||||
private void createSafeseasMenu() {
|
||||
FSSObsMonitorConfigurationManager ssConfig = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.ss.name());
|
||||
Set<String> ssStns = ssConfig.getStationIDs();
|
||||
StringBuilder stations = new StringBuilder();
|
||||
for (String s : ssStns) {
|
||||
if (stations.length() > 0) {
|
||||
stations.append(",");
|
||||
}
|
||||
stations.append(s);
|
||||
.getInstance(MonName.ss);
|
||||
Set<String> ssStns = ssConfig.getStationIDs();
|
||||
StringBuilder stations = new StringBuilder();
|
||||
for (String s : ssStns) {
|
||||
if (stations.length() > 0) {
|
||||
stations.append(",");
|
||||
}
|
||||
String ssStations = stations.toString();
|
||||
CommonMenuContributionFile safeMenuContributionFile = new CommonMenuContributionFile();
|
||||
safeMenuContributionFile.contribution = new CommonIncludeMenuItem[1];
|
||||
safeMenuContributionFile.contribution[0] = new CommonIncludeMenuItem();
|
||||
safeMenuContributionFile.contribution[0] = processOtherContribution(
|
||||
ssStations, "menus/safeseas/baseSafeSeas.xml",
|
||||
"menu:obs?before=EndOfMaritime", "SAFESEAS",
|
||||
safeMenuContributionFile.contribution[0]);
|
||||
toXml(safeMenuContributionFile, "menus" + File.separator
|
||||
+ "safeseas" + File.separator + "index.xml");
|
||||
ssConfig = null;
|
||||
stations.append(s);
|
||||
}
|
||||
String ssStations = stations.toString();
|
||||
CommonMenuContributionFile safeMenuContributionFile = new CommonMenuContributionFile();
|
||||
safeMenuContributionFile.contribution = new CommonIncludeMenuItem[1];
|
||||
safeMenuContributionFile.contribution[0] = new CommonIncludeMenuItem();
|
||||
safeMenuContributionFile.contribution[0] = processOtherContribution(
|
||||
ssStations, "menus/safeseas/baseSafeSeas.xml",
|
||||
"menu:obs?before=EndOfMaritime", "SAFESEAS",
|
||||
safeMenuContributionFile.contribution[0]);
|
||||
toXml(safeMenuContributionFile, "menus" + File.separator + "safeseas"
|
||||
+ File.separator + "index.xml");
|
||||
ssConfig = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -510,26 +511,26 @@ public class DatMenuUtil extends AbstractMenuUtil {
|
|||
*/
|
||||
private void createFogMenu() {
|
||||
FSSObsMonitorConfigurationManager fogConfig = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.fog.name());
|
||||
Set<String> fogStns = fogConfig.getStationIDs();
|
||||
StringBuilder stations = new StringBuilder();
|
||||
for (String s : fogStns) {
|
||||
if (stations.length() > 0) {
|
||||
stations.append(",");
|
||||
}
|
||||
stations.append(s);
|
||||
.getInstance(MonName.fog);
|
||||
Set<String> fogStns = fogConfig.getStationIDs();
|
||||
StringBuilder stations = new StringBuilder();
|
||||
for (String s : fogStns) {
|
||||
if (stations.length() > 0) {
|
||||
stations.append(",");
|
||||
}
|
||||
String fogStations = stations.toString();
|
||||
CommonMenuContributionFile fogMenuContributionFile = new CommonMenuContributionFile();
|
||||
fogMenuContributionFile.contribution = new CommonIncludeMenuItem[1];
|
||||
fogMenuContributionFile.contribution[0] = new CommonIncludeMenuItem();
|
||||
fogMenuContributionFile.contribution[0] = processOtherContribution(
|
||||
fogStations, "menus/fog/baseFog.xml",
|
||||
"menu:obs?after=FOGPLACEHOLDER", "Fog Monitor",
|
||||
fogMenuContributionFile.contribution[0]);
|
||||
toXml(fogMenuContributionFile, "menus" + File.separator + "fog"
|
||||
+ File.separator + "index.xml");
|
||||
fogConfig = null;
|
||||
stations.append(s);
|
||||
}
|
||||
String fogStations = stations.toString();
|
||||
CommonMenuContributionFile fogMenuContributionFile = new CommonMenuContributionFile();
|
||||
fogMenuContributionFile.contribution = new CommonIncludeMenuItem[1];
|
||||
fogMenuContributionFile.contribution[0] = new CommonIncludeMenuItem();
|
||||
fogMenuContributionFile.contribution[0] = processOtherContribution(
|
||||
fogStations, "menus/fog/baseFog.xml",
|
||||
"menu:obs?after=FOGPLACEHOLDER", "Fog Monitor",
|
||||
fogMenuContributionFile.contribution[0]);
|
||||
toXml(fogMenuContributionFile, "menus" + File.separator + "fog"
|
||||
+ File.separator + "index.xml");
|
||||
fogConfig = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -537,26 +538,26 @@ public class DatMenuUtil extends AbstractMenuUtil {
|
|||
*/
|
||||
private void createSnowMenu() {
|
||||
FSSObsMonitorConfigurationManager snowConfig = FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.snow.name());
|
||||
Set<String> snowStns = snowConfig.getStationIDs();
|
||||
StringBuilder stations = new StringBuilder();
|
||||
for (String s : snowStns) {
|
||||
if (stations.length() > 0) {
|
||||
stations.append(",");
|
||||
}
|
||||
stations.append(s);
|
||||
.getInstance(MonName.snow);
|
||||
Set<String> snowStns = snowConfig.getStationIDs();
|
||||
StringBuilder stations = new StringBuilder();
|
||||
for (String s : snowStns) {
|
||||
if (stations.length() > 0) {
|
||||
stations.append(",");
|
||||
}
|
||||
String snowStations = stations.toString();
|
||||
CommonMenuContributionFile snowMenuContributionFile = new CommonMenuContributionFile();
|
||||
snowMenuContributionFile.contribution = new CommonIncludeMenuItem[1];
|
||||
snowMenuContributionFile.contribution[0] = new CommonIncludeMenuItem();
|
||||
snowMenuContributionFile.contribution[0] = processOtherContribution(
|
||||
snowStations, "menus/snow/baseSnow.xml",
|
||||
"menu:obs?after=SNOWPLACEHOLDER", "SNOW",
|
||||
snowMenuContributionFile.contribution[0]);
|
||||
toXml(snowMenuContributionFile, "menus" + File.separator + "snow"
|
||||
+ File.separator + "index.xml");
|
||||
snowConfig = null;
|
||||
stations.append(s);
|
||||
}
|
||||
String snowStations = stations.toString();
|
||||
CommonMenuContributionFile snowMenuContributionFile = new CommonMenuContributionFile();
|
||||
snowMenuContributionFile.contribution = new CommonIncludeMenuItem[1];
|
||||
snowMenuContributionFile.contribution[0] = new CommonIncludeMenuItem();
|
||||
snowMenuContributionFile.contribution[0] = processOtherContribution(
|
||||
snowStations, "menus/snow/baseSnow.xml",
|
||||
"menu:obs?after=SNOWPLACEHOLDER", "SNOW",
|
||||
snowMenuContributionFile.contribution[0]);
|
||||
toXml(snowMenuContributionFile, "menus" + File.separator + "snow"
|
||||
+ File.separator + "index.xml");
|
||||
snowConfig = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,6 +51,7 @@ import com.raytheon.uf.edex.plugin.fssobs.common.FSSObsConfig;
|
|||
* May 23, 2014 3086 skorolev Cleaned code.
|
||||
* Aug 18, 2014 3530 bclement removed constructDataURI() call
|
||||
* Sep 04, 2014 3220 skorolev Replaced 3 URI filters with one.
|
||||
* Sep 03, 2015 3841 skorolev Corrected getInstance.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -141,7 +142,7 @@ public class FSSObsGenerator extends CompositeProductGenerator implements
|
|||
allStations = new HashSet<String>();
|
||||
|
||||
for (MonName mname : MonName.values()) {
|
||||
currManager = new FSSObsMonitorConfigurationManager(mname.name());
|
||||
currManager = FSSObsMonitorConfigurationManager.getInstance(mname);
|
||||
currManager.addListener(this);
|
||||
allStations.addAll(currManager.getStations());
|
||||
currManager = null;
|
||||
|
|
|
@ -56,6 +56,7 @@ import com.raytheon.uf.edex.plugin.loctables.util.store.ObStationStoreStrategy;
|
|||
* Mar 06, 2014 2876 mpduff New NDM plugin.
|
||||
* Apr 28, 2014 3086 skorolev Updated setupLocalFiles method
|
||||
* Sep 04, 2014 3220 skorolev Removed parameter currentSite from FSSObs configuration managers.
|
||||
* Sep 03, 2015 3841 skorolev Corrected getInstance for FSSObs monitors.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -128,12 +129,10 @@ public class LocationTablesIngest implements INationalDatasetSubscriber {
|
|||
private void setupLocalFiles() {
|
||||
List<FSSObsMonitorConfigurationManager> monitors = new ArrayList<FSSObsMonitorConfigurationManager>();
|
||||
|
||||
monitors.add(FSSObsMonitorConfigurationManager.getInstance(MonName.fog
|
||||
.name()));
|
||||
monitors.add(FSSObsMonitorConfigurationManager.getInstance(MonName.ss
|
||||
.name()));
|
||||
monitors.add(FSSObsMonitorConfigurationManager.getInstance(MonName.snow
|
||||
.name()));
|
||||
monitors.add(FSSObsMonitorConfigurationManager.getInstance(MonName.fog));
|
||||
monitors.add(FSSObsMonitorConfigurationManager.getInstance(MonName.ss));
|
||||
monitors.add(FSSObsMonitorConfigurationManager
|
||||
.getInstance(MonName.snow));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue