Merge "Issue #2757. Fixed issues in Area Configuration Dialogs." into development

Former-commit-id: 39021a203a [formerly 72a4a12e89] [formerly 19b883a407] [formerly 39021a203a [formerly 72a4a12e89] [formerly 19b883a407] [formerly c44b120176 [formerly 19b883a407 [formerly ecb833d823cf072f4e02b312fe320c2ade5162a2]]]]
Former-commit-id: c44b120176
Former-commit-id: 803102f8b3 [formerly 3e3805e1a7] [formerly d7c9c51cbb759b4283d0b5b2756b8b47c1ba7581 [formerly 15f94a61b5]]
Former-commit-id: 0a393f43928fc43da068f439b074fcfb4f402dcd [formerly e65a289e97]
Former-commit-id: c483877308
This commit is contained in:
Lee Venable 2014-02-03 14:31:28 -06:00 committed by Gerrit Code Review
commit 94705e9533
7 changed files with 408 additions and 354 deletions

View file

@ -39,14 +39,14 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogMonitor;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 15, 2009 #3963 lvenable Initial creation * Dec 15, 2009 #3963 lvenable Initial creation
* Feb 03, 2014 #2757 skorolev Fixed reInitialize()
* *
* </pre> * </pre>
* *
* @author lvenable * @author lvenable
* @version 1.0 * @version 1.0
*/ */
public class FogThresholdMgr extends AbstractThresholdMgr public class FogThresholdMgr extends AbstractThresholdMgr {
{
/** /**
* Class instance. * Class instance.
*/ */
@ -55,11 +55,9 @@ public class FogThresholdMgr extends AbstractThresholdMgr
/** /**
* Private constructor. * Private constructor.
*/ */
private FogThresholdMgr() private FogThresholdMgr() {
{
super("DefaultFogDisplayThresholds.xml", super("DefaultFogDisplayThresholds.xml",
"DefaultFogMonitorThresholds.xml", "DefaultFogMonitorThresholds.xml", "fog");
"fog");
areaConfigMgr = getAreaConfigMgr(); areaConfigMgr = getAreaConfigMgr();
init(); // call init() after areaConfigMgr is set init(); // call init() after areaConfigMgr is set
@ -67,12 +65,11 @@ public class FogThresholdMgr extends AbstractThresholdMgr
/** /**
* Get an instance of the manager class. * Get an instance of the manager class.
*
* @return Class instance. * @return Class instance.
*/ */
public static FogThresholdMgr getInstance() public static FogThresholdMgr getInstance() {
{ if (classInstance == null) {
if (classInstance == null)
{
classInstance = new FogThresholdMgr(); classInstance = new FogThresholdMgr();
} }
@ -80,34 +77,29 @@ public class FogThresholdMgr extends AbstractThresholdMgr
} }
/** /**
* DR#11279: * DR#11279: When monitor area configuration is changed, threshold manager
* When monitor area configuration is changed, * needs to be re-initialized using the new monitor area configuration
* threshold manager needs to be re-initialized
* using the new monitor area configuration
*/ */
public static void reInitialize() { public static void reInitialize() {
if ( classInstance != null ) { if (classInstance != null) {
classInstance = null; classInstance = null;
classInstance = new FogThresholdMgr();
} }
classInstance = new FogThresholdMgr();
// Update threshold file.
classInstance.loadDefaultMonitorThreshold();
classInstance.saveMonitorThresholds();
} }
@Override @Override
protected ArrayList<String> getThresholdKeys(DataUsageKey dataUsage) protected ArrayList<String> getThresholdKeys(DataUsageKey dataUsage) {
{
ArrayList<String> threshKeys = new ArrayList<String>(); ArrayList<String> threshKeys = new ArrayList<String>();
if (dataUsage == DataUsageKey.DISPLAY) if (dataUsage == DataUsageKey.DISPLAY) {
{ for (FogDisplay fogDisp : FogDisplay.values()) {
for (FogDisplay fogDisp : FogDisplay.values())
{
threshKeys.add(fogDisp.getXmlKey()); threshKeys.add(fogDisp.getXmlKey());
} }
} } else if (dataUsage == DataUsageKey.MONITOR) {
else if (dataUsage == DataUsageKey.MONITOR) for (FogMonitor fogMon : FogMonitor.values()) {
{
for (FogMonitor fogMon : FogMonitor.values())
{
threshKeys.add(fogMon.getXmlKey()); threshKeys.add(fogMon.getXmlKey());
} }
} }

View file

@ -40,6 +40,7 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 5, 2010 mpduff Initial creation * Jan 5, 2010 mpduff Initial creation
* Nov 27, 2012 1351 skorolev Changes for non-blocking dialog. * Nov 27, 2012 1351 skorolev Changes for non-blocking dialog.
* Jan 29, 2014 2757 skorolev Changed OK button handler.
* *
* </pre> * </pre>
* *
@ -53,6 +54,9 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
readConfigData(); readConfigData();
} }
private FogMonitorConfigurationManager configManager = FogMonitorConfigurationManager
.getInstance();
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -61,19 +65,23 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/ */
@Override @Override
protected void handleOkBtnSelection() { protected void handleOkBtnSelection() {
FogMonitorConfigurationManager configManager = FogMonitorConfigurationManager
.getInstance();
// Check for changes in the data // Check for changes in the data
if (!configManager.getAddedZones().isEmpty() if (!configManager.getAddedZones().isEmpty()
|| !configManager.getAddedZones().isEmpty()) { || !configManager.getAddedStations().isEmpty()
|| this.timeWindowChanged || this.shipDistanceChanged
|| this.fogChkChanged || this.maZonesRemoved) {
int choice = showMessage(shell, SWT.OK | SWT.CANCEL, int choice = showMessage(shell, SWT.OK | SWT.CANCEL,
"Fog Monitor Confirm Changes", "Fog Monitor Confirm Changes",
"Want to Update Fog Monitor's Setup files?"); "Want to Update Fog Monitor's Setup files?");
if (choice == SWT.OK) { if (choice == SWT.OK) {
// Save the config xml file // Save the config xml file
configManager.setShipDistance(distanceScale.getSelection()); configManager.setTimeWindow(timeWindow.getSelection());
configManager.setTimeWindow(timeScale.getSelection()); this.timeWindowChanged = false;
configManager.setShipDistance(shipDistance.getSelection());
this.shipDistanceChanged = false;
configManager.setUseAlgorithms(fogChk.getSelection()); configManager.setUseAlgorithms(fogChk.getSelection());
this.fogChkChanged = false;
this.maZonesRemoved = false;
configManager.saveConfigData(); configManager.saveConfigData();
/** /**
* DR#11279: re-initialize threshold manager and the monitor * DR#11279: re-initialize threshold manager and the monitor
@ -82,6 +90,8 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
FogThresholdMgr.reInitialize(); FogThresholdMgr.reInitialize();
FogMonitor.reInitialize(); FogMonitor.reInitialize();
if ((!configManager.getAddedZones().isEmpty())
|| (!configManager.getAddedStations().isEmpty())) {
String message = "New zones have been added, the display " String message = "New zones have been added, the display "
+ "thresholds for the new zones are set to " + "thresholds for the new zones are set to "
+ "default values, you may edit them with the display " + "default values, you may edit them with the display "
@ -92,8 +102,6 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
showMessage(shell, SWT.ICON_INFORMATION | SWT.OK, showMessage(shell, SWT.ICON_INFORMATION | SWT.OK,
"Fog Monitor Confirm Changes", message); "Fog Monitor Confirm Changes", message);
if ((!configManager.getAddedZones().isEmpty())
|| (!configManager.getAddedZones().isEmpty())) {
String message2 = "New zones have been added, and their monitoring thresholds " String message2 = "New zones have been added, and their monitoring thresholds "
+ "have been set to default values; would you like to modify " + "have been set to default values; would you like to modify "
+ "their threshold values now?"; + "their threshold values now?";
@ -105,6 +113,8 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
DataUsageKey.MONITOR); DataUsageKey.MONITOR);
fogMonitorDlg.open(); fogMonitorDlg.open();
} }
configManager.getAddedZones().clear();
configManager.getAddedStations().clear();
} }
} }
} else { } else {
@ -114,10 +124,10 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
if (yesno == SWT.NO) { if (yesno == SWT.NO) {
return; return;
} }
}
setReturnValue(true); setReturnValue(true);
close(); close();
} }
}
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -140,8 +150,22 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/ */
@Override @Override
protected void readConfigData() { protected void readConfigData() {
FogMonitorConfigurationManager configManager = FogMonitorConfigurationManager
.getInstance();
configManager.readConfigXml(currentSite); configManager.readConfigXml(currentSite);
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg#setValues
* ()
*/
@Override
protected void setValues() {
timeWindow.setSelection(configManager.getTimeWindow());
setTimeScaleLabel();
shipDistance.setSelection(configManager.getShipDistance());
setShipDistScaleLabel();
fogChk.setSelection(configManager.isUseAlgorithms());
}
} }

View file

@ -39,30 +39,26 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SafeSeasMonitor;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 27, 2009 #3963 lvenable Initial creation * Dec 27, 2009 #3963 lvenable Initial creation
* Feb 03, 2014 #2757 skorolev Fixed reInitialize()
* *
* </pre> * </pre>
* *
* @author lvenable * @author lvenable
* @version 1.0 * @version 1.0
*/ */
public class SSThresholdMgr extends AbstractThresholdMgr public class SSThresholdMgr extends AbstractThresholdMgr {
{
private static SSThresholdMgr classInstance; private static SSThresholdMgr classInstance;
private SSThresholdMgr() private SSThresholdMgr() {
{
super("DefaultSSDisplayThresholds.xml", super("DefaultSSDisplayThresholds.xml",
"DefaultSSMonitorThresholds.xml", "DefaultSSMonitorThresholds.xml", "safeseas");
"safeseas");
areaConfigMgr = getAreaConfigMgr(); areaConfigMgr = getAreaConfigMgr();
init(); // call init() after areaConfigMgr is set init(); // call init() after areaConfigMgr is set
} }
public static SSThresholdMgr getInstance() public static SSThresholdMgr getInstance() {
{ if (classInstance == null) {
if (classInstance == null)
{
classInstance = new SSThresholdMgr(); classInstance = new SSThresholdMgr();
} }
@ -70,34 +66,29 @@ public class SSThresholdMgr extends AbstractThresholdMgr
} }
/** /**
* DR#11279: * DR#11279: When monitor area configuration is changed, threshold manager
* When monitor area configuration is changed, * needs to be re-initialized using the new monitor area configuration
* threshold manager needs to be re-initialized
* using the new monitor area configuration
*/ */
public static void reInitialize() { public static void reInitialize() {
if ( classInstance != null ) { if (classInstance != null) {
classInstance = null; classInstance = null;
classInstance = new SSThresholdMgr();
} }
// Update threshold file.
classInstance = new SSThresholdMgr();
classInstance.loadDefaultMonitorThreshold();
classInstance.saveMonitorThresholds();
} }
@Override @Override
protected ArrayList<String> getThresholdKeys(DataUsageKey dataUsage) protected ArrayList<String> getThresholdKeys(DataUsageKey dataUsage) {
{
ArrayList<String> threshKeys = new ArrayList<String>(); ArrayList<String> threshKeys = new ArrayList<String>();
if (dataUsage == DataUsageKey.DISPLAY) if (dataUsage == DataUsageKey.DISPLAY) {
{ for (SafeSeasDisplay ssDisp : SafeSeasDisplay.values()) {
for (SafeSeasDisplay ssDisp : SafeSeasDisplay.values())
{
threshKeys.add(ssDisp.getXmlKey()); threshKeys.add(ssDisp.getXmlKey());
} }
} } else if (dataUsage == DataUsageKey.MONITOR) {
else if (dataUsage == DataUsageKey.MONITOR) for (SafeSeasMonitor ssMon : SafeSeasMonitor.values()) {
{
for (SafeSeasMonitor ssMon : SafeSeasMonitor.values())
{
threshKeys.add(ssMon.getXmlKey()); threshKeys.add(ssMon.getXmlKey());
} }
} }
@ -117,56 +108,56 @@ public class SSThresholdMgr extends AbstractThresholdMgr
return areaConfigMgr; return areaConfigMgr;
} }
// /** // /**
// * Get the path where the display thresholds XML files are contained. // * Get the path where the display thresholds XML files are contained.
// * @return File path. // * @return File path.
// */ // */
// @Override // @Override
// public String getDisplayThresholdPath() // public String getDisplayThresholdPath()
// { // {
// String fs = String.valueOf(File.separatorChar); // String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
// //
// sb.append("safeseas").append(fs); // sb.append("safeseas").append(fs);
// sb.append("threshold").append(fs); // sb.append("threshold").append(fs);
// sb.append("display").append(fs); // sb.append("display").append(fs);
// //
// return sb.toString(); // return sb.toString();
// } // }
// //
// /** // /**
// * Get the path where the monitor thresholds XML files are contained. // * Get the path where the monitor thresholds XML files are contained.
// * @return File path. // * @return File path.
// */ // */
// @Override // @Override
// public String getMonitorThresholdPath() // public String getMonitorThresholdPath()
// { // {
// String fs = String.valueOf(File.separatorChar); // String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
// //
// sb.append("safeseas").append(fs); // sb.append("safeseas").append(fs);
// sb.append("threshold").append(fs); // sb.append("threshold").append(fs);
// sb.append("monitor").append(fs); // sb.append("monitor").append(fs);
// //
// return sb.toString(); // return sb.toString();
// } // }
// //
// /** // /**
// * Get the path where the XML file containing the user selected // * Get the path where the XML file containing the user selected
// * default file is located. // * default file is located.
// * @return The path of the user selected default file XML. // * @return The path of the user selected default file XML.
// */ // */
// @Override // @Override
// public String getDefaultThresholdFilePath() // public String getDefaultThresholdFilePath()
// { // {
// String fs = String.valueOf(File.separatorChar); // String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
// //
// sb.append("safeseas").append(fs); // sb.append("safeseas").append(fs);
// sb.append("threshold").append(fs); // sb.append("threshold").append(fs);
// sb.append("display").append(fs); // sb.append("display").append(fs);
// sb.append("defaultThresh").append(fs); // sb.append("defaultThresh").append(fs);
// //
// return sb.toString(); // return sb.toString();
// } // }
} }

View file

@ -31,7 +31,7 @@ import com.raytheon.uf.viz.monitor.safeseas.threshold.SSThresholdMgr;
import com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg; import com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg;
/** /**
* TODO Add Description * SAFESEAS area configuration dialog.
* *
* <pre> * <pre>
* *
@ -40,6 +40,7 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 5, 2010 mpduff Initial creation * Jan 5, 2010 mpduff Initial creation
* Nov 27, 2012 1351 skorolev Changes for non-blocking dialog. * Nov 27, 2012 1351 skorolev Changes for non-blocking dialog.
* Jan 29, 2014 2757 skorolev Changed OK button handler.
* *
* </pre> * </pre>
* *
@ -60,6 +61,9 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
readConfigData(); readConfigData();
} }
private SSMonitorConfigurationManager configManager = SSMonitorConfigurationManager
.getInstance();
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -68,19 +72,23 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/ */
@Override @Override
protected void handleOkBtnSelection() { protected void handleOkBtnSelection() {
SSMonitorConfigurationManager configManager = SSMonitorConfigurationManager
.getInstance();
// Check for changes in the data // Check for changes in the data
if (!configManager.getAddedZones().isEmpty() if (!configManager.getAddedZones().isEmpty()
|| !configManager.getAddedZones().isEmpty()) { || !configManager.getAddedStations().isEmpty()
|| this.timeWindowChanged || this.shipDistanceChanged
|| this.fogChkChanged || this.maZonesRemoved) {
int choice = showMessage(shell, SWT.OK | SWT.CANCEL, int choice = showMessage(shell, SWT.OK | SWT.CANCEL,
"SAFESEAS Monitor Confirm Changes", "SAFESEAS Monitor Confirm Changes",
"Want to update the SAFESEAS setup files?"); "Want to update the SAFESEAS setup files?");
if (choice == SWT.OK) { if (choice == SWT.OK) {
// Save the config xml file // Save the config xml file
configManager.setShipDistance(distanceScale.getSelection()); configManager.setTimeWindow(timeWindow.getSelection());
configManager.setTimeWindow(timeScale.getSelection()); this.timeWindowChanged = false;
configManager.setShipDistance(shipDistance.getSelection());
this.shipDistanceChanged = false;
configManager.setUseAlgorithms(fogChk.getSelection()); configManager.setUseAlgorithms(fogChk.getSelection());
this.fogChkChanged = false;
this.maZonesRemoved = false;
configManager.saveConfigData(); configManager.saveConfigData();
/** /**
* DR#11279: re-initialize threshold manager and the monitor * DR#11279: re-initialize threshold manager and the monitor
@ -88,13 +96,20 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/ */
SSThresholdMgr.reInitialize(); SSThresholdMgr.reInitialize();
SafeSeasMonitor.reInitialize(); SafeSeasMonitor.reInitialize();
showMessage(shell, SWT.OK, "SAFESEAS Config Change", if ((!configManager.getAddedZones().isEmpty())
"You're updating the SAFESEAS monitoring settings." || (!configManager.getAddedStations().isEmpty())) {
String message = "You're updating the SAFESEAS monitoring settings."
+ "\n\nIf SAFESEAS is running anywhere within " + "\n\nIf SAFESEAS is running anywhere within "
+ "the office, please clear it.\n"); + "the office, please clear it.\n";
showMessage(shell, SWT.OK, "SAFESEAS Config Change",
message);
String message2 = "New zones have been added, and their monitoring thresholds " String message2 = "New zones have been added, and their monitoring thresholds "
+ "have been set to default values; would you like to modify " + "have been set to default values; would you like to modify "
+ "their threshold values now?"; + "their threshold values now?";
int yesno = showMessage(shell, SWT.ICON_QUESTION | SWT.YES int yesno = showMessage(shell, SWT.ICON_QUESTION | SWT.YES
| SWT.NO, "Edit Thresholds Now?", message2); | SWT.NO, "Edit Thresholds Now?", message2);
if (yesno == SWT.YES) { if (yesno == SWT.YES) {
@ -103,6 +118,9 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
DataUsageKey.MONITOR); DataUsageKey.MONITOR);
ssMonitorDlg.open(); ssMonitorDlg.open();
} }
configManager.getAddedZones().clear();
configManager.getAddedStations().clear();
}
} }
} else { } else {
String message3 = "No changes made.\nDo you want to exit?"; String message3 = "No changes made.\nDo you want to exit?";
@ -111,10 +129,10 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
if (yesno == SWT.NO) { if (yesno == SWT.NO) {
return; return;
} }
}
setReturnValue(true); setReturnValue(true);
close(); close();
} }
}
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -137,8 +155,22 @@ public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/ */
@Override @Override
protected void readConfigData() { protected void readConfigData() {
SSMonitorConfigurationManager configManager = SSMonitorConfigurationManager
.getInstance();
configManager.readConfigXml(currentSite); configManager.readConfigXml(currentSite);
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg#setValues
* ()
*/
@Override
protected void setValues() {
timeWindow.setSelection(configManager.getTimeWindow());
setTimeScaleLabel();
shipDistance.setSelection(configManager.getShipDistance());
setShipDistScaleLabel();
fogChk.setSelection(configManager.isUseAlgorithms());
}
} }

View file

@ -29,7 +29,6 @@ import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr;
import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowDisplay; import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowDisplay;
import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowMonitor; import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowMonitor;
/** /**
* This class manages the Snow thresholds for display and monitor. * This class manages the Snow thresholds for display and monitor.
* *
@ -40,30 +39,26 @@ import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.SnowMonitor;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Dec 27, 2009 #3963 lvenable Initial creation * Dec 27, 2009 #3963 lvenable Initial creation
* Feb 03, 2014 #2757 skorolev Fixed reInitialize()
* *
* </pre> * </pre>
* *
* @author lvenable * @author lvenable
* @version 1.0 * @version 1.0
*/ */
public class SnowThresholdMgr extends AbstractThresholdMgr public class SnowThresholdMgr extends AbstractThresholdMgr {
{ private static SnowThresholdMgr classInstance;
private static SnowThresholdMgr classInstance;
private SnowThresholdMgr() private SnowThresholdMgr() {
{
super("DefaultSnowDisplayThresholds.xml", super("DefaultSnowDisplayThresholds.xml",
"DefaultSnowMonitorThresholds.xml", "DefaultSnowMonitorThresholds.xml", "snow");
"snow");
areaConfigMgr = getAreaConfigMgr(); areaConfigMgr = getAreaConfigMgr();
init(); // call init() after areaConfigMgr is set init(); // call init() after areaConfigMgr is set
} }
public static SnowThresholdMgr getInstance() public static SnowThresholdMgr getInstance() {
{ if (classInstance == null) {
if (classInstance == null)
{
classInstance = new SnowThresholdMgr(); classInstance = new SnowThresholdMgr();
} }
@ -71,34 +66,29 @@ private static SnowThresholdMgr classInstance;
} }
/** /**
* DR#11279: * DR#11279: When monitor area configuration is changed, threshold manager
* When monitor area configuration is changed, * needs to be re-initialized using the new monitor area configuration
* threshold manager needs to be re-initialized
* using the new monitor area configuration
*/ */
public static void reInitialize() { public static void reInitialize() {
if ( classInstance != null ) { if (classInstance != null) {
classInstance = null; classInstance = null;
classInstance = new SnowThresholdMgr();
} }
// Update threshold file.
classInstance = new SnowThresholdMgr();
classInstance.loadDefaultMonitorThreshold();
classInstance.saveMonitorThresholds();
} }
@Override @Override
protected ArrayList<String> getThresholdKeys(DataUsageKey dataUsage) protected ArrayList<String> getThresholdKeys(DataUsageKey dataUsage) {
{
ArrayList<String> threshKeys = new ArrayList<String>(); ArrayList<String> threshKeys = new ArrayList<String>();
if (dataUsage == DataUsageKey.DISPLAY) if (dataUsage == DataUsageKey.DISPLAY) {
{ for (SnowDisplay snowDisp : SnowDisplay.values()) {
for (SnowDisplay snowDisp : SnowDisplay.values())
{
threshKeys.add(snowDisp.getXmlKey()); threshKeys.add(snowDisp.getXmlKey());
} }
} } else if (dataUsage == DataUsageKey.MONITOR) {
else if (dataUsage == DataUsageKey.MONITOR) for (SnowMonitor snowMon : SnowMonitor.values()) {
{
for (SnowMonitor snowMon : SnowMonitor.values())
{
threshKeys.add(snowMon.getXmlKey()); threshKeys.add(snowMon.getXmlKey());
} }
} }
@ -118,56 +108,56 @@ private static SnowThresholdMgr classInstance;
return areaConfigMgr; return areaConfigMgr;
} }
// /** // /**
// * Get the path where the display thresholds XML files are contained. // * Get the path where the display thresholds XML files are contained.
// * @return File path. // * @return File path.
// */ // */
// @Override // @Override
// public String getDisplayThresholdPath() // public String getDisplayThresholdPath()
// { // {
// String fs = String.valueOf(File.separatorChar); // String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
// //
// sb.append("snow").append(fs); // sb.append("snow").append(fs);
// sb.append("threshold").append(fs); // sb.append("threshold").append(fs);
// sb.append("display").append(fs); // sb.append("display").append(fs);
// //
// return sb.toString(); // return sb.toString();
// } // }
// //
// /** // /**
// * Get the path where the monitor thresholds XML files are contained. // * Get the path where the monitor thresholds XML files are contained.
// * @return File path. // * @return File path.
// */ // */
// @Override // @Override
// public String getMonitorThresholdPath() // public String getMonitorThresholdPath()
// { // {
// String fs = String.valueOf(File.separatorChar); // String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
// //
// sb.append("snow").append(fs); // sb.append("snow").append(fs);
// sb.append("threshold").append(fs); // sb.append("threshold").append(fs);
// sb.append("monitor").append(fs); // sb.append("monitor").append(fs);
// //
// return sb.toString(); // return sb.toString();
// } // }
// //
// /** // /**
// * Get the path where the XML file containing the user selected // * Get the path where the XML file containing the user selected
// * default file is located. // * default file is located.
// * @return The path of the user selected default file XML. // * @return The path of the user selected default file XML.
// */ // */
// @Override // @Override
// public String getDefaultThresholdFilePath() // public String getDefaultThresholdFilePath()
// { // {
// String fs = String.valueOf(File.separatorChar); // String fs = String.valueOf(File.separatorChar);
// StringBuilder sb = new StringBuilder(); // StringBuilder sb = new StringBuilder();
// //
// sb.append("snow").append(fs); // sb.append("snow").append(fs);
// sb.append("threshold").append(fs); // sb.append("threshold").append(fs);
// sb.append("display").append(fs); // sb.append("display").append(fs);
// sb.append("defaultThresh").append(fs); // sb.append("defaultThresh").append(fs);
// //
// return sb.toString(); // return sb.toString();
// } // }
} }

View file

@ -40,6 +40,7 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 5, 2010 mpduff Initial creation * Jan 5, 2010 mpduff Initial creation
* Nov 27, 2012 1351 skorolev Changes for non-blocking dialog. * Nov 27, 2012 1351 skorolev Changes for non-blocking dialog.
* Jan 29, 2014 2757 skorolev Changed OK button handler.
* *
* </pre> * </pre>
* *
@ -54,6 +55,9 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
readConfigData(); readConfigData();
} }
private SnowMonitorConfigurationManager configManager = SnowMonitorConfigurationManager
.getInstance();
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -62,17 +66,18 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/ */
@Override @Override
protected void handleOkBtnSelection() { protected void handleOkBtnSelection() {
SnowMonitorConfigurationManager configManager = SnowMonitorConfigurationManager
.getInstance();
// Check for changes in the data // Check for changes in the data
if (!configManager.getAddedZones().isEmpty() if (!configManager.getAddedZones().isEmpty()
|| !configManager.getAddedZones().isEmpty()) { || !configManager.getAddedStations().isEmpty()
|| this.timeWindowChanged || this.maZonesRemoved) {
int choice = showMessage(shell, SWT.OK | SWT.CANCEL, int choice = showMessage(shell, SWT.OK | SWT.CANCEL,
"SNOW Monitor Confirm Changes", "SNOW Monitor Confirm Changes",
"Want to update the SNOW setup files?"); "Want to update the SNOW setup files?");
if (choice == SWT.OK) { if (choice == SWT.OK) {
// Save the config xml file // Save the config xml file
configManager.setTimeWindow(timeScale.getSelection()); configManager.setTimeWindow(timeWindow.getSelection());
this.timeWindowChanged = false;
this.maZonesRemoved = false;
configManager.saveConfigData(); configManager.saveConfigData();
/** /**
* DR#11279: re-initialize threshold manager and the monitor * DR#11279: re-initialize threshold manager and the monitor
@ -80,6 +85,9 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/ */
SnowThresholdMgr.reInitialize(); SnowThresholdMgr.reInitialize();
SnowMonitor.reInitialize(); SnowMonitor.reInitialize();
if ((!configManager.getAddedZones().isEmpty())
|| (!configManager.getAddedStations().isEmpty())) {
showMessage(shell, SWT.ICON_INFORMATION | SWT.OK, showMessage(shell, SWT.ICON_INFORMATION | SWT.OK,
"SNOW Config Change", "SNOW Config Change",
"You're updating the SNOW monitoring settings." "You're updating the SNOW monitoring settings."
@ -98,6 +106,9 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
snowMonitorDlg.open(); snowMonitorDlg.open();
} }
} }
configManager.getAddedZones().clear();
configManager.getAddedStations().clear();
}
} else { } else {
String message3 = "No changes made.\nDo you want to exit?"; String message3 = "No changes made.\nDo you want to exit?";
int yesno = showMessage(shell, int yesno = showMessage(shell,
@ -105,10 +116,10 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
if (yesno == SWT.NO) { if (yesno == SWT.NO) {
return; return;
} }
}
setReturnValue(true); setReturnValue(true);
close(); close();
} }
}
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -130,9 +141,20 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg {
*/ */
@Override @Override
protected void readConfigData() { protected void readConfigData() {
SnowMonitorConfigurationManager configManager = SnowMonitorConfigurationManager
.getInstance();
configManager.readConfigXml(currentSite); configManager.readConfigXml(currentSite);
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg#setValues
* ()
*/
@Override
protected void setValues() {
timeWindow.setSelection(configManager.getTimeWindow());
setTimeScaleLabel();
}
} }

View file

@ -71,7 +71,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Nov 16, 2012 1297 skorolev Changes for non-blocking dialog. * Nov 16, 2012 1297 skorolev Changes for non-blocking dialog.
* Feb 06, 2013 1578 skorolev Fixed a cursor problem for checkboxes. * Feb 06, 2013 1578 skorolev Fixed a cursor problem for checkboxes.
* Oct 07, 2013 #2443 lvenable Fixed image memory leak. * Oct 07, 2013 #2443 lvenable Fixed image memory leak.
* * Jan 29, 2014 2757 skorolev Added status variables.
* </pre> * </pre>
* *
* @author lvenable * @author lvenable
@ -125,17 +125,25 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
/** Edit/Delete button. **/ /** Edit/Delete button. **/
private Button editDeleteBtn; private Button editDeleteBtn;
/** Time scale control. **/ /** Time window control. **/
protected Scale timeScale; protected Scale timeWindow;
/** Time window status. */
protected boolean timeWindowChanged = false;
/** Time scale label to display the value set by the time scale. **/ /** Time scale label to display the value set by the time scale. **/
private Label timeScaleLbl; private Label timeWindowLbl;
/** Distance scale. **/ /** Ship Distance scale. **/
protected Scale distanceScale; protected Scale shipDistance;
/** Distance scale label to display the value set by the distance scale. **/ /** Ship Distance status. */
private Label distanceScaleLBl; protected boolean shipDistanceChanged = false;
/**
* Ship Distance scale label to display the value set by the distance scale.
**/
private Label shipDistanceLBl;
/** Monitor area Add button. **/ /** Monitor area Add button. **/
private Button monAreaAddBtn; private Button monAreaAddBtn;
@ -158,6 +166,9 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
/** Fog check button. **/ /** Fog check button. **/
protected Button fogChk; protected Button fogChk;
/** Fog check button status. */
protected boolean fogChkChanged = false;
/** Control font. **/ /** Control font. **/
private Font controlFont; private Font controlFont;
@ -170,6 +181,9 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
/** monitor area zones **/ /** monitor area zones **/
private java.util.List<String> maZones = null; private java.util.List<String> maZones = null;
/** monitor area zones status. */
protected boolean maZonesRemoved = false;
/** monitor area stations **/ /** monitor area stations **/
private java.util.List<String> maStations = null; private java.util.List<String> maStations = null;
@ -457,6 +471,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
@Override @Override
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
removeZoneStn(); removeZoneStn();
maZonesRemoved = true;
} }
}); });
@ -646,22 +661,23 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
int defaultVal = (int) Math.round((2.00 - 0.25) / .05); int defaultVal = (int) Math.round((2.00 - 0.25) / .05);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
timeScale = new Scale(scaleComp, SWT.HORIZONTAL); timeWindow = new Scale(scaleComp, SWT.HORIZONTAL);
timeScale.setMinimum(0); timeWindow.setMinimum(0);
timeScale.setMaximum(max); timeWindow.setMaximum(max);
timeScale.setSelection(defaultVal); timeWindow.setSelection(defaultVal);
timeScale.setLayoutData(gd); timeWindow.setLayoutData(gd);
timeScale.addSelectionListener(new SelectionAdapter() { timeWindow.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
setTimeScaleLabel(); setTimeScaleLabel();
timeWindowChanged = true;
} }
}); });
gd = new GridData(50, SWT.DEFAULT); gd = new GridData(50, SWT.DEFAULT);
timeScaleLbl = new Label(scaleComp, SWT.NONE); timeWindowLbl = new Label(scaleComp, SWT.NONE);
timeScaleLbl.setFont(controlFont); timeWindowLbl.setFont(controlFont);
timeScaleLbl.setLayoutData(gd); timeWindowLbl.setLayoutData(gd);
setTimeScaleLabel(); setTimeScaleLabel();
@ -682,22 +698,23 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
distanceLbl.setLayoutData(gd); distanceLbl.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
distanceScale = new Scale(scaleComp, SWT.HORIZONTAL); shipDistance = new Scale(scaleComp, SWT.HORIZONTAL);
distanceScale.setMinimum(0); shipDistance.setMinimum(0);
distanceScale.setMaximum(200); shipDistance.setMaximum(200);
distanceScale.setSelection(100); shipDistance.setSelection(100);
distanceScale.setLayoutData(gd); shipDistance.setLayoutData(gd);
distanceScale.addSelectionListener(new SelectionAdapter() { shipDistance.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
setShipDistScaleLabel(); setShipDistScaleLabel();
shipDistanceChanged = true;
} }
}); });
gd = new GridData(50, SWT.DEFAULT); gd = new GridData(50, SWT.DEFAULT);
distanceScaleLBl = new Label(scaleComp, SWT.NONE); shipDistanceLBl = new Label(scaleComp, SWT.NONE);
distanceScaleLBl.setFont(controlFont); shipDistanceLBl.setFont(controlFont);
distanceScaleLBl.setLayoutData(gd); shipDistanceLBl.setLayoutData(gd);
setShipDistScaleLabel(); setShipDistScaleLabel();
@ -709,6 +726,12 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
gd = new GridData(); gd = new GridData();
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
fogChk = new Button(scaleComp, SWT.CHECK); fogChk = new Button(scaleComp, SWT.CHECK);
fogChk.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fogChkChanged = true;
}
});
setAlgorithmText(); setAlgorithmText();
} }
@ -784,18 +807,18 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
/** /**
* Set the time scale label. * Set the time scale label.
*/ */
private void setTimeScaleLabel() { protected void setTimeScaleLabel() {
double val = timeScale.getSelection() * .05 + .25; double val = timeWindow.getSelection() * .05 + .25;
val = roundToHundredths(val); val = roundToHundredths(val);
timeScaleLbl.setText(String.format("%5.2f", val)); timeWindowLbl.setText(String.format("%5.2f", val));
} }
/** /**
* Set the ship distance scale label. * Set the ship distance scale label.
*/ */
private void setShipDistScaleLabel() { protected void setShipDistScaleLabel() {
distanceScaleLBl.setText(String.format("%5d", shipDistanceLBl.setText(String.format("%5d",
distanceScale.getSelection())); shipDistance.getSelection()));
} }
/** /**
@ -958,27 +981,7 @@ public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements
/** /**
* Set the slider values and the check box. * Set the slider values and the check box.
*/ */
private void setValues() { protected abstract void setValues();
MonitorConfigurationManager configManager = getConfigManager();
if (appName == AppName.SAFESEAS) {
fogChk.setSelection(((SSMonitorConfigurationManager) configManager)
.isUseAlgorithms());
distanceScale
.setSelection(((SSMonitorConfigurationManager) configManager)
.getShipDistance());
setShipDistScaleLabel();
} else if (appName == AppName.FOG) {
fogChk.setSelection(((FogMonitorConfigurationManager) configManager)
.isUseAlgorithms());
distanceScale
.setSelection(((FogMonitorConfigurationManager) configManager)
.getShipDistance());
setShipDistScaleLabel();
}
timeScale.setSelection(configManager.getTimeWindow());
setTimeScaleLabel();
}
/** /**
* Show a dialog message. * Show a dialog message.