From 32f192134d46ed70bf3092f30ccdd6f033ca696a Mon Sep 17 00:00:00 2001 From: Slav Korolev Date: Wed, 21 Nov 2012 13:10:16 -0500 Subject: [PATCH] Issue #1351. Changes for non-blocking MonitoringAreaConfigDlg according to reviewer's comments. Changes for History Tables. Change-Id: Ic68f4afd44a3039707cb80ee71a935aa2f00a6a2 Former-commit-id: af101861e431a8487b40f941c7b1dcdf67c16e5d [formerly 5e4bbc03a4809825b8358083db2a54a6d397f55b [formerly 82dc81aa3cbdfcfcd0b3f5f6566bfce0b6fddd22]] Former-commit-id: 5e4bbc03a4809825b8358083db2a54a6d397f55b Former-commit-id: 153af1673a9d1de82da510c725400905592b85c2 --- .../uf/viz/monitor/fog/FogMonitor.java | 16 +- .../monitor/fog/test/FogTestDriverDlg.java | 496 --- .../fog/ui/actions/FogAreaConfigAction.java | 28 +- .../fog/ui/dialogs/FogMonitorMeteoTab.java | 208 +- .../dialogs/FogMonitoringAreaConfigDlg.java | 79 +- .../fog/ui/dialogs/FogObsHistTableDlg.java | 40 - .../viz/monitor/safeseas/SafeSeasMonitor.java | 14 +- .../monitor/safeseas/test/DataGenerator.java | 293 -- .../safeseas/test/SSTestDriverDlg.java | 266 -- .../ui/actions/SafeseasAreaConfigAction.java | 28 +- .../ui/dialogs/SSMonitoringAreaConfigDlg.java | 84 +- .../ui/dialogs/SSObsHistTableDlg.java | 40 - .../scan/commondialogs/UnwarnedInfoDlg.java | 174 -- .../monitor/scan/test/TimeHeightMainDlg.java | 65 - .../scan/test/TrendGraphWindowDlg.java | 212 -- .../uf/viz/monitor/snow/SnowMonitor.java | 14 +- .../monitor/snow/test/SnowTestDriverDlg.java | 266 -- .../snow/ui/actions/SnowAreaConfigAction.java | 27 +- .../dialogs/SnowMonitoringAreaConfigDlg.java | 77 +- .../snow/ui/dialogs/SnowObsHistTableDlg.java | 40 - .../thresholds/AbstractThresholdMgr.java | 107 +- .../viz/monitor/thresholds/ThresholdMgr.java | 74 +- .../monitor/ui/dialogs/AddNewStationDlg.java | 416 ++- .../viz/monitor/ui/dialogs/AddNewZoneDlg.java | 359 +-- .../monitor/ui/dialogs/DeleteStationDlg.java | 218 +- .../monitor/ui/dialogs/EditNewZoneDlg.java | 382 +-- .../ui/dialogs/MonitoringAreaConfigDlg.java | 2702 ++++++++--------- .../monitor/ui/dialogs/ObsHistTableDlg.java | 81 +- .../viz/monitor/ui/dialogs/ZoneTableDlg.java | 93 +- .../config/MonitorConfigurationManager.java | 531 ++-- .../edex/plugin/fssobs/FSSObsURIFilter.java | 174 +- .../uf/edex/plugin/fssobs/FSSObsUtils.java | 136 +- 32 files changed, 3015 insertions(+), 4725 deletions(-) delete mode 100644 cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/test/FogTestDriverDlg.java delete mode 100644 cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogObsHistTableDlg.java delete mode 100644 cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/test/DataGenerator.java delete mode 100644 cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/test/SSTestDriverDlg.java delete mode 100644 cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSObsHistTableDlg.java delete mode 100644 cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/UnwarnedInfoDlg.java delete mode 100644 cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/test/TimeHeightMainDlg.java delete mode 100644 cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/test/TrendGraphWindowDlg.java delete mode 100644 cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/test/SnowTestDriverDlg.java delete mode 100644 cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowObsHistTableDlg.java diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java index f5b359411d..d43d5a4dbc 100644 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/FogMonitor.java @@ -122,7 +122,7 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { private FogZoneTableDlg zoneDialog; /** zone table dialog **/ - private MonitoringAreaConfigDlg areaDialog = null; + private MonitoringAreaConfigDlg areaDialog; /** area config manager **/ private FogMonitorConfigurationManager fogConfig = null; @@ -260,7 +260,7 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { FogMonitorConfigurationManager areaConfig = getMonitorAreaConfig(); for (String zone : areaConfig.getAreaList()) { // add the unique - ArrayList stations = areaConfig.getAreaStations(zone); + List stations = areaConfig.getAreaStations(zone); zones.put(zone, stations); } } catch (Exception ve) { @@ -377,24 +377,20 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { * @param shell */ public void launchDialog(String type, Shell shell) { - if (type.equals("zone")) { - if (zoneDialog == null || zoneDialog.getShell() == null - || zoneDialog.isDisposed()) { + if (zoneDialog == null) { zoneDialog = new FogZoneTableDlg(shell, obData); addMonitorListener(zoneDialog); zoneDialog.addMonitorControlListener(this); fireMonitorEvent(zoneDialog.getClass().getName()); - zoneDialog.open(); - } else { - zoneDialog.bringToTop(); } + zoneDialog.open(); } else if (type.equals("area")) { if (areaDialog == null) { areaDialog = new FogMonitoringAreaConfigDlg(shell, "Fog Monitor Area Configuration"); - areaDialog.open(); } + areaDialog.open(); } } @@ -562,7 +558,7 @@ public class FogMonitor extends ObsMonitor implements IFogResourceListener { } if (areaDialog != null) { - areaDialog.shellDisposeDialog(); + areaDialog.close(); areaDialog = null; } } diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/test/FogTestDriverDlg.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/test/FogTestDriverDlg.java deleted file mode 100644 index b025028fac..0000000000 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/test/FogTestDriverDlg.java +++ /dev/null @@ -1,496 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.monitor.fog.test; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.monitor.data.CommonTableConfig.CellType; -import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; -import com.raytheon.uf.viz.monitor.fog.threshold.FogAlgorithmMgr; -import com.raytheon.uf.viz.monitor.fog.threshold.FogThresholdMgr; -import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogMonThreshSetupDlg; -import com.raytheon.uf.viz.monitor.fog.xml.FogMonitorAlgorithmXML; -import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr.ThresholdKey; -import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg; -import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg.DialogType; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogDisplay; - -public class FogTestDriverDlg extends Dialog { - private Display display; - - private Shell shell; - - private Font lblFont; - - public FogTestDriverDlg(Shell parentShell) { - super(parentShell, 0); - } - - public Object open() { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - shell.setText("FOG Driver"); - - GridLayout gl = new GridLayout(1, false); - gl.horizontalSpacing = 0; - shell.setLayout(gl); - - shell.setSize(600, 600); - - lblFont = new Font(shell.getDisplay(), "Monospace", 14, SWT.NORMAL); - - initComponents(); - - shell.open(); - - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } - - lblFont.dispose(); - - return null; - } - - private void initComponents() { - Label lbl = new Label(shell, SWT.NONE); - lbl.setText("FOG"); - lbl.setFont(lblFont); - - Button printFogDisplayThresh = new Button(shell, SWT.PUSH); - printFogDisplayThresh.setText("Print FOG Display Threshold Data"); - printFogDisplayThresh.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - printFogDisplayThresholdData(); - } - }); - - Button printCopyFogDisplayThresh = new Button(shell, SWT.PUSH); - printCopyFogDisplayThresh - .setText("**** Print FOG Display Threshold Data COPY"); - printCopyFogDisplayThresh.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - printCopyFogDisplayThresholdData(); - } - }); - - Button changeThresh = new Button(shell, SWT.PUSH); - changeThresh.setText("Change Threshold Data"); - changeThresh.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - changeThresholdData(); - } - }); - - Button loadThreshDlg = new Button(shell, SWT.PUSH); - loadThreshDlg.setText("Load Dialog"); - loadThreshDlg.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - displayLoadDialog(); - } - }); - - Button saveAsThreshDlg = new Button(shell, SWT.PUSH); - saveAsThreshDlg.setText("Save As Dialog"); - saveAsThreshDlg.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - displaySaveDialog(); - } - }); - - Button printDefaultFileNameBtn = new Button(shell, SWT.PUSH); - printDefaultFileNameBtn.setText("Print Default Threshold File Name"); - printDefaultFileNameBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - displayDefaultThreshFileName(); - } - }); - - Button selectDefaultFileNameBtn = new Button(shell, SWT.PUSH); - selectDefaultFileNameBtn.setText("Select Default Threshold File Name"); - selectDefaultFileNameBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - selectDefaultThreshFileName(); - } - }); - - Button loadDefaultFileNameBtn = new Button(shell, SWT.PUSH); - loadDefaultFileNameBtn.setText("Load Default Threshold"); - loadDefaultFileNameBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - loadDefaultThresholds(); - } - }); - - Button cellTypeBtn = new Button(shell, SWT.PUSH); - cellTypeBtn.setText("Print CellType"); - cellTypeBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - printCellType(); - } - }); - - /* - * ************************************************************************ - */ - addSeparator(shell); - - lbl = new Label(shell, SWT.NONE); - lbl.setText("FOG ALGORITHM"); - lbl.setFont(lblFont); - - Button fogAlgorithmBtn = new Button(shell, SWT.PUSH); - fogAlgorithmBtn.setText("Print FOG Algorithm Data"); - fogAlgorithmBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - printFogAlgorithmData(); - } - }); - - Button fogAlgorithmChangeBtn = new Button(shell, SWT.PUSH); - fogAlgorithmChangeBtn.setText("Change FOG Algorithm Data"); - fogAlgorithmChangeBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - changeFogAlgorithmData(); - } - }); - - Button saveAsAlgorithmBtn = new Button(shell, SWT.PUSH); - saveAsAlgorithmBtn.setText("Algorithm Save As Dialog"); - saveAsAlgorithmBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - algorithmSaveDialog(); - } - }); - - Button loadAlgorithmBtn = new Button(shell, SWT.PUSH); - loadAlgorithmBtn.setText("Algorithm Load Dialog"); - loadAlgorithmBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - algorithmLoadDialog(); - } - }); - - Button selectAlgorithmFileNameBtn = new Button(shell, SWT.PUSH); - selectAlgorithmFileNameBtn - .setText("Select Default Algorithm File Name"); - selectAlgorithmFileNameBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - selectDefaultAlgorithmFileName(); - } - }); - - Button displayFogAlgDailogBtn = new Button(shell, SWT.PUSH); - displayFogAlgDailogBtn.setText("Display Fog Algorithm Dialog"); - displayFogAlgDailogBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - displayFogAlgDialog(); - } - }); - } - - private void addSeparator(Composite parentComp) { - GridLayout gl = (GridLayout) parentComp.getLayout(); - - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = gl.numColumns; - Label sepLbl = new Label(parentComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - } - - private void printFogDisplayThresholdData() { - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - ftm.printDisplayThresholds(); - } - - private void printCopyFogDisplayThresholdData() { - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - ftm.printDisplayThresholdsXMLCopy(); - } - - private void changeThresholdData() { - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - ftm.setThresholdValue(DataUsageKey.DISPLAY, ThresholdKey.RED, "NE093", - MonitorConfigConstants.FogDisplay.FOG_DISP_METEO_TEMP - .getXmlKey(), 111); - } - - private void displayLoadDialog() { - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.OPEN, ftm.getDisplayThresholdPath(), ftm - .getDefaultFileName(DataUsageKey.DISPLAY)); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - ftm.loadDisplayThreashold(fileName.getFile().getName()); - } - - private void displaySaveDialog() { - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.SAVE_AS, ftm.getDisplayThresholdPath(), ftm - .getDefaultFileName(DataUsageKey.DISPLAY)); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - ftm.saveAsDisplayThresholds(fileName.getFile().getName()); - } - - private void displayDefaultThreshFileName() { - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - - System.out.println(">" + ftm.getDefDisplayThreshFileName() + "<"); - } - - private void selectDefaultThreshFileName() { - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.SELECT_DEFAULT, ftm.getDisplayThresholdPath(), ftm - .getDefaultFileName(DataUsageKey.DISPLAY)); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - ftm.setDefaultDisplayFileName(fileName.getFile().getName()); - } - - private void loadDefaultThresholds() { - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - - ftm.loadDefaultDisplayThreshold(); - } - - private void printCellType() { - CellType ct; - String key; - double value = Double.NaN; - - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - - /* - * Ceiling - */ - - // ----------------------------- - key = FogDisplay.FOG_DISP_METEO_CEILING.getXmlKey(); - value = 3.0; - ct = ftm.getThresholdValueCellType(DataUsageKey.DISPLAY, "NE093", key, - value); - System.out.println("key = " + key + "\t value = " + value - + "\tCellType = " + ct.name()); - - // ----------------------------- - value = 7.0; - ct = ftm.getThresholdValueCellType(DataUsageKey.DISPLAY, "NE093", key, - value); - System.out.println("key = " + key + "\t value = " + value - + "\tCellType = " + ct.name()); - - // ----------------------------- - value = 12.0; - ct = ftm.getThresholdValueCellType(DataUsageKey.DISPLAY, "NE093", key, - value); - System.out.println("key = " + key + "\t value = " + value - + "\tCellType = " + ct.name()); - - /* - * Temp - */ - - // ----------------------------- - key = FogDisplay.FOG_DISP_METEO_TEMP.getXmlKey(); - value = 100.0; - ct = ftm.getThresholdValueCellType(DataUsageKey.DISPLAY, "NE093", key, - value); - System.out.println("key = " + key + "\t value = " + value - + "\tCellType = " + ct.name()); - - // ----------------------------- - key = FogDisplay.FOG_DISP_METEO_TEMP.getXmlKey(); - value = 85.0; - ct = ftm.getThresholdValueCellType(DataUsageKey.DISPLAY, "NE093", key, - value); - System.out.println("key = " + key + "\t value = " + value - + "\tCellType = " + ct.name()); - - // ----------------------------- - key = FogDisplay.FOG_DISP_METEO_TEMP.getXmlKey(); - value = 75.0; - ct = ftm.getThresholdValueCellType(DataUsageKey.DISPLAY, "NE093", key, - value); - System.out.println("key = " + key + "\t value = " + value - + "\tCellType = " + ct.name()); - } - - private void printFogAlgorithmData() { - FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance(); - - FogMonitorAlgorithmXML algXML = fam.getAlgorithmXML(); - - System.out.println(algXML.getFogProductYLo()); - System.out.println(algXML.getFogProductRLo()); - System.out.println(algXML.getFogProductRHi()); - System.out.println(algXML.getFogProductYHi()); - System.out.println(algXML.getVisYLo()); - System.out.println(algXML.getVisRLo()); - System.out.println(algXML.getVisRHi()); - System.out.println(algXML.getVisYHi()); - System.out.println(algXML.getMaxCloudTemp()); - System.out.println(algXML.getIceSnowVsFog()); - System.out.println(algXML.getCoolFogVsWarmSurface()); - System.out.println(algXML.getDaytimeSmoothThresh()); - System.out.println(algXML.getAdjacencyThresh()); - System.out.println(algXML.getTwilightAngle()); - System.out.println(algXML.getFractalDimension()); - } - - private void changeFogAlgorithmData() { - FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance(); - fam.getAlgorithmXML().setFractalDimension(1.7); - } - - private void algorithmSaveDialog() { - FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.SAVE_AS, fam.getAlgorithmThresholdPath(), fam - .getDefaultAlgorithmFileName()); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - fam.saveAlgorithmXmlAs(fileName.getFile().getName()); - } - - private void algorithmLoadDialog() { - FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.OPEN, fam.getAlgorithmThresholdPath(), fam - .getDefaultAlgorithmFileName()); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - fam.loadAlgorithmThreashold(fileName.getFile().getName()); - } - - private void selectDefaultAlgorithmFileName() { - FogAlgorithmMgr fam = FogAlgorithmMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.SELECT_DEFAULT, fam.getDefaultFileNamePath(), fam - .getDefaultAlgorithmFileName()); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - fam.setDefaultAlgorithmFileName(fileName.getFile().getName()); - } - - private void displayFogAlgDialog() { - FogMonThreshSetupDlg fogThreshSetup = new FogMonThreshSetupDlg(shell); - fogThreshSetup.open(); - } -} diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAreaConfigAction.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAreaConfigAction.java index 3a0b2c8b83..f0f0c7c5ed 100644 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAreaConfigAction.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/actions/FogAreaConfigAction.java @@ -25,6 +25,8 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogMonitoringAreaConfigDlg; /** @@ -36,7 +38,8 @@ import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogMonitoringAreaConfigDlg; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 19 2009 3963 dhladky Initial creation. - * Jul 14 2010 6567 zhao Launch AreaConfigDlg w/o monitor + * Jul 14 2010 6567 zhao Launch AreaConfigDlg w/o monitor + * Nov.27, 2012 1297 skorolev Cleanup code for non-blocking dialog. * * * @@ -46,19 +49,22 @@ import com.raytheon.uf.viz.monitor.fog.ui.dialogs.FogMonitoringAreaConfigDlg; public class FogAreaConfigAction extends AbstractHandler { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(FogAreaConfigAction.class); + + private FogMonitoringAreaConfigDlg areaDialog; + @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - - System.out.println("Activating/Action the FOG Area Config..."); - //FogMonitor fog = FogMonitor.getInstance(); - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - //fog.launchDialog("area", shell); - - FogMonitoringAreaConfigDlg areaDialog = new FogMonitoringAreaConfigDlg(shell, "Fog Monitor Area Configuration"); + + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + if (areaDialog == null || areaDialog.getShell() == null + || areaDialog.isDisposed()) { + areaDialog = new FogMonitoringAreaConfigDlg(shell, + "Fog Monitor Area Configuration"); + } areaDialog.open(); - return null; } - } - diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java index db7467d968..13f0869a89 100644 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitorMeteoTab.java @@ -21,6 +21,7 @@ package com.raytheon.uf.viz.monitor.fog.ui.dialogs; import java.util.ArrayList; import java.util.Collections; +import java.util.List; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -39,219 +40,204 @@ import com.raytheon.uf.viz.monitor.fog.threshold.FogThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.TabItemComp; import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants.FogMonitor; -public class FogMonitorMeteoTab extends TabItemComp implements IUpdateMonitorMeteo -{ - private MonitorConfigurationManager areaConfigMgr = null; +public class FogMonitorMeteoTab extends TabItemComp implements + IUpdateMonitorMeteo { + private MonitorConfigurationManager areaConfigMgr = null; private FogMonitorMeteoEditDlg fogMeteoEditDlg; - + private ArrayList areaIDArray; - + private ArrayList fogDataArray; - - public FogMonitorMeteoTab(TabFolder parent, DataUsageKey duKey) - { + + public FogMonitorMeteoTab(TabFolder parent, DataUsageKey duKey) { super(parent, duKey); } - @Override - protected void createListHeader(Composite parentComp) - { + @Override + protected void createListHeader(Composite parentComp) { Composite lblComp = new Composite(parentComp, SWT.NONE); GridLayout gl = new GridLayout(5, false); - gl.horizontalSpacing = 0; + gl.horizontalSpacing = 0; gl.marginHeight = 0; gl.marginWidth = 0; lblComp.setLayout(gl); - + /* * Create filler label. */ GridData gd = new GridData(71, SWT.DEFAULT); Label fillerLbl = new Label(lblComp, SWT.CENTER); fillerLbl.setLayoutData(gd); - + /* * Meteo */ Composite meteoComp = createGroupComposite(lblComp, 10, null); createLabelComp(meteoComp, "Vis(mi)", "", true); - } - + } + @Override - protected void populateList() - { - if (fogDataArray == null) - { + protected void populateList() { + if (fogDataArray == null) { createDataArray(); } - + boolean update = false; - if (dataList.getItemCount() > 0) - { + if (dataList.getItemCount() > 0) { update = true; } - + RangesUtil rangeUtil = RangesUtil.getInstance(); - + areaIDArray = new ArrayList(); - + String tmpVisStr; String currentAreaID; - + double visVal = 0.0; - - StringBuilder sb = null; + + StringBuilder sb = null; FogMonitorMeteoData fmmd = null; - - for (int i = 0; i < fogDataArray.size(); i++) - { + + for (int i = 0; i < fogDataArray.size(); i++) { sb = new StringBuilder(); - + fmmd = fogDataArray.get(i); - + currentAreaID = fmmd.getAreaID(); areaIDArray.add(currentAreaID); - + sb.append(String.format(areaIdFmt, currentAreaID)); - + /* * Visibility - */ - visVal = fmmd.getMeteoVisR(); - tmpVisStr = rangeUtil.getVisString((int)visVal); + */ + visVal = fmmd.getMeteoVisR(); + tmpVisStr = rangeUtil.getVisString((int) visVal); sb.append(String.format(dataFmt, tmpVisStr)); - - visVal = fmmd.getMeteoVisY(); - tmpVisStr = rangeUtil.getVisString((int)visVal); + + visVal = fmmd.getMeteoVisY(); + tmpVisStr = rangeUtil.getVisString((int) visVal); sb.append(String.format(dataFmt, tmpVisStr)); - + sb.append(" "); - - if (update == true) - { + + if (update == true) { dataList.setItem(i, sb.toString()); - } - else - { + } else { dataList.add(sb.toString()); - } + } } - + packListControls(); } - - private void createDataArray() - { + + private void createDataArray() { fogDataArray = new ArrayList(); - - FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - + + FogThresholdMgr ftm = FogThresholdMgr.getInstance(); + areaConfigMgr = getAreaConfigMgr(); - - ArrayList areas = areaConfigMgr.getAreaList(); + + List areas = areaConfigMgr.getAreaList(); Collections.sort(areas); - - for (String area : areas ) { - + + for (String area : areas) { + FogMonitorMeteoData fmmd = new FogMonitorMeteoData(); - + fmmd.setAreaID(area); /* * Visibility */ String xmlKey = FogMonitor.FOG_MONITOR_METEO_VIS.getXmlKey(); - fmmd.setMeteoVisR(ftm.getThresholdValue(duKey, threshKeyR, area, xmlKey)); - fmmd.setMeteoVisY(ftm.getThresholdValue(duKey, threshKeyY, area, xmlKey)); - + fmmd.setMeteoVisR(ftm.getThresholdValue(duKey, threshKeyR, area, + xmlKey)); + fmmd.setMeteoVisY(ftm.getThresholdValue(duKey, threshKeyY, area, + xmlKey)); + fogDataArray.add(fmmd); } } - - private FogMonitorMeteoData getDataAtFirstSelection() - { - + + private FogMonitorMeteoData getDataAtFirstSelection() { + int index = dataList.getSelectionIndex(); - + return fogDataArray.get(index); - - } - - private void updateFogDataArray(FogMonitorMeteoData fmmd) - { - int[] dataListIndexes = dataList.getSelectionIndices(); - int currentIndex = 0; - - for (int i = 0; i < dataListIndexes.length; i++) - { - currentIndex = dataListIndexes[i]; - - fogDataArray.get(currentIndex).updateData(fmmd); - } + } - + + private void updateFogDataArray(FogMonitorMeteoData fmmd) { + int[] dataListIndexes = dataList.getSelectionIndices(); + int currentIndex = 0; + + for (int i = 0; i < dataListIndexes.length; i++) { + currentIndex = dataListIndexes[i]; + + fogDataArray.get(currentIndex).updateData(fmmd); + } + } + @Override - public void commitDataToXML() - { + public void commitDataToXML() { FogThresholdMgr ftm = FogThresholdMgr.getInstance(); - + String xmlKey; String areaID; - - for (FogMonitorMeteoData fdmd : fogDataArray) - { + + for (FogMonitorMeteoData fdmd : fogDataArray) { areaID = fdmd.getAreaID(); - + /* * Visibility */ xmlKey = FogMonitor.FOG_MONITOR_METEO_VIS.getXmlKey(); - ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, fdmd.getMeteoVisR()); - ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, fdmd.getMeteoVisY()); + ftm.setThresholdValue(duKey, threshKeyR, areaID, xmlKey, + fdmd.getMeteoVisR()); + ftm.setThresholdValue(duKey, threshKeyY, areaID, xmlKey, + fdmd.getMeteoVisY()); } } - + @Override - public void reloadData() - { + public void reloadData() { dataList.removeAll(); fogDataArray.clear(); fogDataArray = null; - + populateList(); } @Override - protected void editDataAction() - { + protected void editDataAction() { FogMonitorMeteoData fdmd = getDataAtFirstSelection(); - - if (fogMeteoEditDlg == null) - { - fogMeteoEditDlg = new FogMonitorMeteoEditDlg(getParent().getShell(), fdmd, this); + + if (fogMeteoEditDlg == null) { + fogMeteoEditDlg = new FogMonitorMeteoEditDlg( + getParent().getShell(), fdmd, this); fogMeteoEditDlg.open(); fogMeteoEditDlg = null; } } @Override - public void updateThresholdData(FogMonitorMeteoData fmmd) - { + public void updateThresholdData(FogMonitorMeteoData fmmd) { updateFogDataArray(fmmd); - populateList(); + populateList(); } private MonitorConfigurationManager getAreaConfigMgr() { if (areaConfigMgr == null) { LocalizationManager mgr = LocalizationManager.getInstance(); String siteScope = mgr.getCurrentSite(); - + areaConfigMgr = FogMonitorConfigurationManager.getInstance(); areaConfigMgr.readConfigXml(siteScope); } return areaConfigMgr; - } + } } - diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java index 088a26f42e..679e678cc6 100644 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogMonitoringAreaConfigDlg.java @@ -31,14 +31,15 @@ import com.raytheon.uf.viz.monitor.fog.threshold.FogThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg; /** - * TODO Add Description + * Fog Monitor area configuration dialog. * *
  * 
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Jan 5, 2010            mpduff     Initial creation
+ * Jan  5, 2010            mpduff       Initial creation
+ * Nov 27, 2012 1351       skorolev     Changes for non-blocking dialog.
  * 
  * 
* @@ -52,31 +53,35 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { readConfigData(); } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg# + * handleOkBtnSelection() + */ @Override protected void handleOkBtnSelection() { FogMonitorConfigurationManager configManager = FogMonitorConfigurationManager .getInstance(); // Check for changes in the data - int choice = showMessage(shell, SWT.OK | SWT.CANCEL, - "Fog Monitor Confirm Changes", - "Want to Update Fog Monitor's Setup files?"); + if (!configManager.getAddedZones().isEmpty() + || !configManager.getAddedZones().isEmpty()) { + int choice = showMessage(shell, SWT.OK | SWT.CANCEL, + "Fog Monitor Confirm Changes", + "Want to Update Fog Monitor's Setup files?"); + if (choice == SWT.OK) { + // Save the config xml file + configManager.setShipDistance(distanceScale.getSelection()); + configManager.setTimeWindow(timeScale.getSelection()); + configManager.setUseAlgorithms(fogChk.getSelection()); + configManager.saveConfigData(); + /** + * DR#11279: re-initialize threshold manager and the monitor + * using new monitor area configuration + */ + FogThresholdMgr.reInitialize(); + FogMonitor.reInitialize(); - if (choice == SWT.OK) { - // Save the config xml file - configManager.setShipDistance(distanceScale.getSelection()); - configManager.setTimeWindow(timeScale.getSelection()); - configManager.setUseAlgorithms(fogChk.getSelection()); - configManager.saveConfigData(); - - /** - * DR#11279: - * re-initialize threshold manager and the monitor - * using new monitor area configuration - */ - FogThresholdMgr.reInitialize(); - FogMonitor.reInitialize(); - - if ( configManager.getAddedZones().size() > 0 || addedZones.size() > 0 ) { String message = "New zones have been added, the display " + "thresholds for the new zones are set to " + "default values, you may edit them with the display " @@ -87,8 +92,8 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { showMessage(shell, SWT.ICON_INFORMATION | SWT.OK, "Fog Monitor Confirm Changes", message); - if ((configManager.getAddedZones().size() > 0) - || (addedZones.size() > 0)) { + if ((!configManager.getAddedZones().isEmpty()) + || (!configManager.getAddedZones().isEmpty())) { String message2 = "New zones have been added, and their monitoring thresholds " + "have been set to default values; would you like to modify " + "their threshold values now?"; @@ -102,17 +107,37 @@ public class FogMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { } } } - shell.dispose(); + } else { + String message3 = "No changes made.\nDo you want to exit?"; + int yesno = showMessage(shell, + SWT.ICON_QUESTION | SWT.YES | SWT.NO, "Exit", message3); + if (yesno == SWT.NO) { + return; + } } + setReturnValue(true); + close(); } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg# + * setAlgorithmText() + */ @Override protected void setAlgorithmText() { - fogChk - .setText("Fog Monitor algorithms' threat level is considered when determining\n" - + "the guardian icon color."); + fogChk.setText("Fog Monitor algorithms' threat level is considered when determining\n" + + "the guardian icon color."); } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg#readConfigData + * () + */ @Override protected void readConfigData() { FogMonitorConfigurationManager configManager = FogMonitorConfigurationManager diff --git a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogObsHistTableDlg.java b/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogObsHistTableDlg.java deleted file mode 100644 index 610ef3b974..0000000000 --- a/cave/com.raytheon.uf.viz.monitor.fog/src/com/raytheon/uf/viz/monitor/fog/ui/dialogs/FogObsHistTableDlg.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.monitor.fog.ui.dialogs; - -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; -import com.raytheon.uf.common.monitor.data.CommonTableConfig.ObsHistType; -import com.raytheon.uf.viz.monitor.data.TableData; -import com.raytheon.uf.viz.monitor.ui.dialogs.ObsHistTableDlg; - -public class FogObsHistTableDlg extends ObsHistTableDlg { - public FogObsHistTableDlg(Shell parent, TableData tableData, - String stationID, double lat, double lon, AppName appName, - ObsHistType obsType) { - super(parent, tableData, stationID, lat, lon, appName, obsType); - // TODO Auto-generated constructor stub - } - - protected void configAction() { - System.out.println("FOG Config Action"); - } -} diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java index cad03d29e1..e2a305d068 100644 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/SafeSeasMonitor.java @@ -207,24 +207,20 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { * @param shell */ public void launchDialog(String type, Shell shell) { - if (type.equals("zone")) { - if (zoneDialog == null || zoneDialog.getShell() == null - || zoneDialog.isDisposed()) { + if (zoneDialog == null) { zoneDialog = new SSZoneTableDlg(shell, obData); addMonitorListener(zoneDialog); zoneDialog.addMonitorControlListener(this); fireMonitorEvent(zoneDialog.getClass().getName()); - zoneDialog.open(); - } else { - zoneDialog.bringToTop(); } + zoneDialog.open(); } else if (type.equals("area")) { if (areaDialog == null) { areaDialog = new SSMonitoringAreaConfigDlg(shell, "Safe Seas Monitor Area Configuration"); - areaDialog.open(); } + areaDialog.open(); } } @@ -465,7 +461,7 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { zoneDialog = null; } if (areaDialog != null) { - areaDialog.shellDisposeDialog(); + areaDialog.close(); areaDialog = null; } } @@ -492,7 +488,7 @@ public class SafeSeasMonitor extends ObsMonitor implements ISSResourceListener { */ public Map getMonitoringAreaGeometries() { if (zoneGeometries == null) { - ArrayList zones = getMonitorAreaConfig().getAreaList(); + List zones = getMonitorAreaConfig().getAreaList(); zoneGeometries = new HashMap(); for (String zone : zones) { try { diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/test/DataGenerator.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/test/DataGenerator.java deleted file mode 100644 index 41df4d3c13..0000000000 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/test/DataGenerator.java +++ /dev/null @@ -1,293 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.monitor.safeseas.test; - -import java.util.Date; - -import com.raytheon.uf.common.monitor.data.CommonConfig; -import com.raytheon.uf.common.monitor.data.CommonTableConfig; -import com.raytheon.uf.common.monitor.data.CommonTableConfig.CellType; -import com.raytheon.uf.viz.monitor.data.TableCellData; -import com.raytheon.uf.viz.monitor.data.TableData; -import com.raytheon.uf.viz.monitor.data.TableRowData; - -public class DataGenerator -{ - private CommonTableConfig ctc; - - public DataGenerator() - { - ctc = CommonTableConfig.getInstance(); - } - - public TableData generateData(CommonConfig.AppName appName) - { - TableData tData = new TableData(appName); - - System.out.println("Creating data for: " + appName.name()); - - if (appName == CommonConfig.AppName.SAFESEAS) - { - for (int i = 0; i < 2; i++) - { - safeseasRow1(i,tData); - safeseasRow1(i,tData); - } - } - else if (appName == CommonConfig.AppName.SNOW) - { - for (int i = 0; i < 2; i++) - { - snowRow1(i,tData); - snowRow2(i,tData); - } - } - else if (appName == CommonConfig.AppName.FOG) - { - for (int i = 0; i < 2000; i++) - { - fogRow1(i,tData); - fogRow2(i,tData); - fogRow3(i,tData); - fogRow4(i,tData); - } - } - - return tData; - } - - private void fogRow1(int num, TableData tData) - { - TableRowData trd = new TableRowData(ctc.getTableColumnKeys(CommonConfig.AppName.FOG).length); - - trd.setTableCellData(0, new TableCellData("NJC00" + num, "Hover Text", CellType.AreaId, false)); - trd.setTableCellData(1, new TableCellData("3", CellType.G, true)); - trd.setTableCellData(2, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(3, new TableCellData("4", CellType.R, true)); - trd.setTableCellData(4, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(5, new TableCellData(4, CellType.G, true)); - trd.setTableCellData(6, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(7, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(8, new TableCellData(70, CellType.G, true)); - trd.setTableCellData(9, new TableCellData(66, CellType.G, true)); - trd.setTableCellData(10, new TableCellData(4, CellType.R, true)); - trd.setTableCellData(11, new TableCellData(88, CellType.R, true)); - trd.setTableCellData(12, new TableCellData("", CellType.R, true)); - - tData.addReplaceDataRow(trd); - } - - private void fogRow2(int num, TableData tData) - { - TableRowData trd = new TableRowData(ctc.getTableColumnKeys(CommonConfig.AppName.FOG).length); - - trd.setTableCellData(0, new TableCellData("ANZ45" + num, "Hover Text", CellType.AreaId, false)); - trd.setTableCellData(1, new TableCellData("1 1/2", CellType.R, true)); - trd.setTableCellData(2, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(3, new TableCellData("50", CellType.Y, true)); - trd.setTableCellData(4, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(5, new TableCellData(80, CellType.R, true)); - trd.setTableCellData(6, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(7, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(8, new TableCellData(84, CellType.Y, true)); - trd.setTableCellData(9, new TableCellData(63, CellType.G, true)); - trd.setTableCellData(10, new TableCellData(6, CellType.Y, true)); - trd.setTableCellData(11, new TableCellData(48, CellType.G, true)); - trd.setTableCellData(12, new TableCellData("", CellType.NotDetermined, true)); - - tData.addReplaceDataRow(trd); - } - - private void fogRow3(int num, TableData tData) - { - TableRowData trd = new TableRowData(ctc.getTableColumnKeys(CommonConfig.AppName.FOG).length); - - trd.setTableCellData(0, new TableCellData("VAC84" + num, "Hover Text", CellType.AreaId, false)); - trd.setTableCellData(1, new TableCellData("2 1/2", CellType.Y, true)); - trd.setTableCellData(2, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(3, new TableCellData("CLR", CellType.G, true)); - trd.setTableCellData(4, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(5, new TableCellData(45, CellType.Y, true)); - trd.setTableCellData(6, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(7, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(8, new TableCellData(95, CellType.R, true)); - trd.setTableCellData(9, new TableCellData(75, CellType.Y, true)); - trd.setTableCellData(10, new TableCellData(15, CellType.G, true)); - trd.setTableCellData(11, new TableCellData(66, CellType.Y, true)); - trd.setTableCellData(12, new TableCellData("", CellType.G, true)); - - tData.addReplaceDataRow(trd); - } - - private void fogRow4(int num, TableData tData) - { - TableRowData trd = new TableRowData(ctc.getTableColumnKeys(CommonConfig.AppName.FOG).length); - - trd.setTableCellData(0, new TableCellData("VEC84" + num, "Hover Text", CellType.AreaId, false)); - trd.setTableCellData(1, new TableCellData("1 7/8", CellType.Y, true)); - trd.setTableCellData(2, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(3, new TableCellData("CLR", CellType.G, true)); - trd.setTableCellData(4, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(5, new TableCellData(46, CellType.Y, true)); - trd.setTableCellData(6, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(7, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(8, new TableCellData(93, CellType.R, true)); - trd.setTableCellData(9, new TableCellData(76, CellType.Y, true)); - trd.setTableCellData(10, new TableCellData(14, CellType.G, true)); - trd.setTableCellData(11, new TableCellData(60, CellType.Y, true)); - trd.setTableCellData(12, new TableCellData("", CellType.G, true)); - - tData.addReplaceDataRow(trd); - } - - private void snowRow1(int num, TableData tData) - { - TableRowData trd = new TableRowData(ctc.getTableColumnKeys(CommonConfig.AppName.SNOW).length); - - trd.setTableCellData(0, new TableCellData("PAC00" + num, "Hover Text", CellType.AreaId, false)); - trd.setTableCellData(1, new TableCellData("", CellType.G, true)); - trd.setTableCellData(2, new TableCellData("", CellType.Y, true)); - trd.setTableCellData(3, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(4, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(5, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(6, new TableCellData(11, CellType.G, true)); - trd.setTableCellData(7, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(8, new TableCellData(16, CellType.G, true)); - trd.setTableCellData(9, new TableCellData(36, CellType.Y, true)); - trd.setTableCellData(10, new TableCellData(28, CellType.R, true)); - trd.setTableCellData(11, new TableCellData("9", CellType.G, true)); - trd.setTableCellData(12, new TableCellData(1015, CellType.G, true)); - trd.setTableCellData(13, new TableCellData(27, CellType.G, true)); - trd.setTableCellData(14, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(15, new TableCellData(0.025, CellType.Y, true)); - trd.setTableCellData(16, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(17, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(18, new TableCellData(0, CellType.NotAvailable, true)); - - tData.addReplaceDataRow(trd); - } - - private void snowRow2(int num, TableData tData) - { - TableRowData trd = new TableRowData(ctc.getTableColumnKeys(CommonConfig.AppName.SNOW).length); - - trd.setTableCellData(0, new TableCellData("ANZ00" + num, "Hover Text", CellType.AreaId, false)); - trd.setTableCellData(1, new TableCellData("", CellType.Y, true)); - trd.setTableCellData(2, new TableCellData("", CellType.R, true)); - trd.setTableCellData(3, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(4, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(5, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(6, new TableCellData(45, CellType.Y, true)); - trd.setTableCellData(7, new TableCellData(24, CellType.G, true)); - trd.setTableCellData(8, new TableCellData(25, CellType.Y, true)); - trd.setTableCellData(9, new TableCellData(28, CellType.R, true)); - trd.setTableCellData(10, new TableCellData(45, CellType.G, true)); - trd.setTableCellData(11, new TableCellData("2 1/2", CellType.G, true)); - trd.setTableCellData(12, new TableCellData(900, CellType.G, true)); - trd.setTableCellData(13, new TableCellData(16, CellType.Y, true)); - trd.setTableCellData(14, new TableCellData(25, CellType.R, true)); - trd.setTableCellData(15, new TableCellData(1.02566, CellType.R, true)); - trd.setTableCellData(16, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(17, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(18, new TableCellData(0, CellType.NotAvailable, true)); - - tData.addReplaceDataRow(trd); - } - - private void safeseasRow1(int num, TableData tData) - { - TableRowData trd = new TableRowData(ctc.getTableColumnKeys(CommonConfig.AppName.SAFESEAS).length); - - trd.setTableCellData(0, new TableCellData("ANZ00" + num, "Hover Text", CellType.AreaId, false)); - trd.setTableCellData(1, new TableCellData("", CellType.R, true)); - trd.setTableCellData(2, new TableCellData("", CellType.G, true)); - trd.setTableCellData(3, new TableCellData("", CellType.G, true)); - trd.setTableCellData(4, new TableCellData("", CellType.G, true)); - trd.setTableCellData(5, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(6, new TableCellData(15, CellType.Y, true)); - trd.setTableCellData(7, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(8, new TableCellData(19, CellType.R, true)); - trd.setTableCellData(9, new TableCellData("8", CellType.G, true)); - trd.setTableCellData(10, new TableCellData(61, CellType.G, true)); - trd.setTableCellData(11, new TableCellData(43, CellType.G, true)); - trd.setTableCellData(12, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(13, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(14, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(15, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(16, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(17, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(18, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(19, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(20, new TableCellData(0, CellType.NotAvailable, true)); - trd.setTableCellData(21, new TableCellData(0, CellType.NotMonitored, true)); - trd.setTableCellData(22, new TableCellData("", CellType.G, true)); - - tData.addReplaceDataRow(trd); - } - - //******************************************************************************************* - //******************************************************************************************* - //******************************************************************************************* - //******************************************************************************************* - //******************************************************************************************* - - public TableData generateObsHistData(CommonConfig.AppName appName, CommonTableConfig.ObsHistType obsType) - { - TableData tData = new TableData(appName); - - System.out.println("Creating data for: " + appName.name() + " and " + obsType.name()); - - if (appName == CommonConfig.AppName.SAFESEAS) - { - // Create Safeseas Data - } - else if (appName == CommonConfig.AppName.SNOW) - { - if (obsType == CommonTableConfig.ObsHistType.METAR) - { - obsSnowMetarRow1(0, tData); - } - } - else if (appName == CommonConfig.AppName.FOG) - { - // Create Fog Data - } - - return tData; - } - - private void obsSnowMetarRow1(int num, TableData tData) - { -// TableRowData trd = new TableRowData(ctc.getZoneStnColumnKeys(CommonConfig.AppName.SNOW).length); - - int numCols = ctc.getObsHistColumnKeys(CommonConfig.AppName.SNOW, - CommonTableConfig.ObsHistType.METAR).length; - TableRowData trd = new TableRowData(numCols); - - trd.setTableCellData(0, new TableCellData(new Date(), CellType.ObsHist)); - trd.setTableCellData(1, new TableCellData(300, CellType.ObsHist, false)); - trd.setTableCellData(2, new TableCellData(7, CellType.ObsHist, false)); - trd.setTableCellData(3, new TableCellData(20, CellType.ObsHist, false)); - trd.setTableCellData(4, new TableCellData(1023, CellType.ObsHist, false)); - trd.setTableCellData(5, new TableCellData(-.02, CellType.ObsHist, false)); - - tData.addReplaceDataRow(trd); - } -} diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/test/SSTestDriverDlg.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/test/SSTestDriverDlg.java deleted file mode 100644 index 03c2b48a8f..0000000000 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/test/SSTestDriverDlg.java +++ /dev/null @@ -1,266 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.monitor.safeseas.test; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.monitor.data.CommonTableConfig.CellType; -import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; -import com.raytheon.uf.viz.monitor.safeseas.threshold.SSThresholdMgr; -import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr.ThresholdKey; -import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg; -import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg.DialogType; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; - -public class SSTestDriverDlg extends Dialog { - private Display display; - - private Shell shell; - - private Font lblFont; - - public SSTestDriverDlg(Shell parentShell) { - super(parentShell, 0); - } - - public Object open() { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - shell.setText("SAFESEAS Driver"); - - GridLayout gl = new GridLayout(1, false); - gl.horizontalSpacing = 0; - shell.setLayout(gl); - - shell.setSize(600, 600); - - lblFont = new Font(shell.getDisplay(), "Monospace", 14, SWT.NORMAL); - - initComponents(); - - shell.open(); - - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } - - lblFont.dispose(); - - return null; - } - - private void initComponents() { - Label lbl = new Label(shell, SWT.NONE); - lbl.setText("SAFESEAS"); - lbl.setFont(lblFont); - - Button printDisplayThresh = new Button(shell, SWT.PUSH); - printDisplayThresh.setText("Print Display Threshold Data"); - printDisplayThresh.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - printDisplayThresholdData(); - } - }); - - Button changeThresh = new Button(shell, SWT.PUSH); - changeThresh.setText("Change Threshold Data"); - changeThresh.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - changeThresholdData(); - } - }); - - Button loadThreshDlg = new Button(shell, SWT.PUSH); - loadThreshDlg.setText("Load Dialog"); - loadThreshDlg.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - displayLoadDialog(); - } - }); - - Button saveAsThreshDlg = new Button(shell, SWT.PUSH); - saveAsThreshDlg.setText("Save As Dialog"); - saveAsThreshDlg.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - displaySaveDialog(); - } - }); - - Button printDefaultFileNameBtn = new Button(shell, SWT.PUSH); - printDefaultFileNameBtn.setText("Print Default Threshold File Name"); - printDefaultFileNameBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - displayDefaultThreshFileName(); - } - }); - - Button selectDefaultFileNameBtn = new Button(shell, SWT.PUSH); - selectDefaultFileNameBtn.setText("Select Default Threshold File Name"); - selectDefaultFileNameBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - selectDefaultThreshFileName(); - } - }); - - Button loadDefaultFileNameBtn = new Button(shell, SWT.PUSH); - loadDefaultFileNameBtn.setText("Load Default Threshold"); - loadDefaultFileNameBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - loadDefaultThresholds(); - } - }); - - Button cellTypeBtn = new Button(shell, SWT.PUSH); - cellTypeBtn.setText("Print CellType"); - cellTypeBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - printCellType(); - } - }); - } - - private void addSeparator(Composite parentComp) { - GridLayout gl = (GridLayout) parentComp.getLayout(); - - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = gl.numColumns; - Label sepLbl = new Label(parentComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - } - - private void printDisplayThresholdData() { - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - sstm.printDisplayThresholds(); - } - - private void changeThresholdData() { - System.out.println("NOT WORKING..."); - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - sstm.setThresholdValue(DataUsageKey.DISPLAY, ThresholdKey.RED, "NE093", - MonitorConfigConstants.SafeSeasDisplay.SS_DISP_METEO_TEMP - .getXmlKey(), 111); - } - - private void displayLoadDialog() { - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.OPEN, sstm.getDisplayThresholdPath(), sstm - .getDefaultFileName(DataUsageKey.DISPLAY)); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - sstm.loadDisplayThreashold(fileName.getFile().getName()); - } - - private void displaySaveDialog() { - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.SAVE_AS, sstm.getDisplayThresholdPath(), sstm - .getDefaultFileName(DataUsageKey.DISPLAY)); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - sstm.saveAsDisplayThresholds(fileName.getFile().getName()); - } - - private void displayDefaultThreshFileName() { - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - - System.out.println(">" + sstm.getDefDisplayThreshFileName() + "<"); - } - - private void selectDefaultThreshFileName() { - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.SELECT_DEFAULT, sstm.getDisplayThresholdPath(), sstm - .getDefaultFileName(DataUsageKey.DISPLAY)); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - sstm.setDefaultDisplayFileName(fileName.getFile().getName()); - } - - private void loadDefaultThresholds() { - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - - sstm.loadDefaultDisplayThreshold(); - } - - private void printCellType() { - CellType ct; - String key; - double value = Double.NaN; - - SSThresholdMgr sstm = SSThresholdMgr.getInstance(); - - } -} diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/actions/SafeseasAreaConfigAction.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/actions/SafeseasAreaConfigAction.java index 8aee553fb7..ebcbe4a060 100644 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/actions/SafeseasAreaConfigAction.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/actions/SafeseasAreaConfigAction.java @@ -25,7 +25,8 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; -import com.raytheon.uf.viz.monitor.safeseas.SafeSeasMonitor; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.monitor.safeseas.ui.dialogs.SSMonitoringAreaConfigDlg; /** @@ -37,7 +38,8 @@ import com.raytheon.uf.viz.monitor.safeseas.ui.dialogs.SSMonitoringAreaConfigDlg * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 28, 2009 3963 dhladky Initial creation. - * March 5, 2012 14413 zhao Launch AreaConfigDlg w/o monitor + * March 5, 2012 14413 zhao Launch AreaConfigDlg w/o monitor + * Nov.27, 2012 1297 skorolev Cleanup code for non-blocking dialog * * * @@ -47,19 +49,21 @@ import com.raytheon.uf.viz.monitor.safeseas.ui.dialogs.SSMonitoringAreaConfigDlg public class SafeseasAreaConfigAction extends AbstractHandler { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(SafeseasAreaConfigAction.class); + + private SSMonitoringAreaConfigDlg configDlg; + @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - - System.out.println("Activating/Action the Safeseas Area Config..."); - - //SafeSeasMonitor monitor = SafeSeasMonitor.getInstance(); - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - //monitor.launchDialog("area", shell); - - SSMonitoringAreaConfigDlg configDlg= new SSMonitoringAreaConfigDlg(shell, "Safe Seas Monitor Area Configuration"); + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + if (configDlg == null || configDlg.getShell() == null + || configDlg.isDisposed()) { + configDlg = new SSMonitoringAreaConfigDlg(shell, + "SAFESEAS Monitor Area Configuration"); + } configDlg.open(); - return null; } - } diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java index d0c2db19b1..67f87ea8ca 100644 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSMonitoringAreaConfigDlg.java @@ -38,7 +38,8 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jan 5, 2010 mpduff Initial creation + * Jan 5, 2010 mpduff Initial creation + * Nov 27, 2012 1351 skorolev Changes for non-blocking dialog. * * * @@ -48,63 +49,92 @@ import com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg; public class SSMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { + /** + * Constructor + * + * @param parent + * @param title + */ public SSMonitoringAreaConfigDlg(Shell parent, String title) { super(parent, title, AppName.SAFESEAS); readConfigData(); } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg# + * handleOkBtnSelection() + */ @Override protected void handleOkBtnSelection() { SSMonitorConfigurationManager configManager = SSMonitorConfigurationManager .getInstance(); // Check for changes in the data - int choice = showMessage(shell, SWT.OK | SWT.CANCEL, - "SAFESEAS Monitor Confirm Changes", - "Want to update the SAFESEAS setup files?"); - - if (choice == SWT.OK) { - // Save the config xml file - configManager.setShipDistance(distanceScale.getSelection()); - configManager.setTimeWindow(timeScale.getSelection()); - configManager.setUseAlgorithms(fogChk.getSelection()); - configManager.saveConfigData(); - - /** - * DR#11279: re-initialize threshold manager and the monitor using - * new monitor area configuration - */ - SSThresholdMgr.reInitialize(); - SafeSeasMonitor.reInitialize(); - - showMessage(shell, SWT.OK, "SAFESEAS Config Change", - "You're updating the SAFESEAS monitoring settings." - + "\n\nIf SAFESEAS is running anywhere within " - + "the office, please clear it.\n"); - if (configManager.getAddedZones().size() > 0 - || addedZones.size() > 0) { + if (!configManager.getAddedZones().isEmpty() + || !configManager.getAddedZones().isEmpty()) { + int choice = showMessage(shell, SWT.OK | SWT.CANCEL, + "SAFESEAS Monitor Confirm Changes", + "Want to update the SAFESEAS setup files?"); + if (choice == SWT.OK) { + // Save the config xml file + configManager.setShipDistance(distanceScale.getSelection()); + configManager.setTimeWindow(timeScale.getSelection()); + configManager.setUseAlgorithms(fogChk.getSelection()); + configManager.saveConfigData(); + /** + * DR#11279: re-initialize threshold manager and the monitor + * using new monitor area configuration + */ + SSThresholdMgr.reInitialize(); + SafeSeasMonitor.reInitialize(); + showMessage(shell, SWT.OK, "SAFESEAS Config Change", + "You're updating the SAFESEAS monitoring settings." + + "\n\nIf SAFESEAS is running anywhere within " + + "the office, please clear it.\n"); String message2 = "New zones have been added, and their monitoring thresholds " + "have been set to default values; would you like to modify " + "their threshold values now?"; int yesno = showMessage(shell, SWT.ICON_QUESTION | SWT.YES | SWT.NO, "Edit Thresholds Now?", message2); if (yesno == SWT.YES) { - SSDispMonThreshDlg ssMonitorDlg = new SSDispMonThreshDlg( shell, CommonConfig.AppName.SAFESEAS, DataUsageKey.MONITOR); ssMonitorDlg.open(); } } - shell.dispose(); + } else { + String message3 = "No changes made.\nDo you want to exit?"; + int yesno = showMessage(shell, + SWT.ICON_QUESTION | SWT.YES | SWT.NO, "Exit", message3); + if (yesno == SWT.NO) { + return; + } } + setReturnValue(true); + close(); } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg# + * setAlgorithmText() + */ @Override protected void setAlgorithmText() { fogChk.setText("The Fog Monitor overall threat level is " + "considered when determining the anchor color."); } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg#readConfigData + * () + */ @Override protected void readConfigData() { SSMonitorConfigurationManager configManager = SSMonitorConfigurationManager diff --git a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSObsHistTableDlg.java b/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSObsHistTableDlg.java deleted file mode 100644 index c59db27c28..0000000000 --- a/cave/com.raytheon.uf.viz.monitor.safeseas/src/com/raytheon/uf/viz/monitor/safeseas/ui/dialogs/SSObsHistTableDlg.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.monitor.safeseas.ui.dialogs; - -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; -import com.raytheon.uf.common.monitor.data.CommonTableConfig.ObsHistType; -import com.raytheon.uf.viz.monitor.data.TableData; -import com.raytheon.uf.viz.monitor.ui.dialogs.ObsHistTableDlg; - -public class SSObsHistTableDlg extends ObsHistTableDlg { - public SSObsHistTableDlg(Shell parent, TableData tableData, - String stationID, double lat, double lon, AppName appName, - ObsHistType obsType) { - super(parent, tableData, stationID, lat, lon, appName, obsType); - // TODO Auto-generated constructor stub - } - - protected void configAction() { - System.out.println("SAFESEAS Config Action"); - } -} diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/UnwarnedInfoDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/UnwarnedInfoDlg.java deleted file mode 100644 index 4a902f9ab8..0000000000 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/commondialogs/UnwarnedInfoDlg.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.monitor.scan.commondialogs; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -/** - * Displays a dialog that contains information about using the unwarned functionality. - * - *
- *
- * SOFTWARE HISTORY
- *
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Oct 25, 2009 3039       lvenable     Initial creation
- *
- * 
- * - * @author lvenable - * @version 1.0 - */ -public class UnwarnedInfoDlg extends Dialog -{ - /** - * Dialog shell. - */ - private Shell shell; - - /** - * The display control. - */ - private Display display; - - /** - * Text control. - */ - private StringBuilder infoText; - - /** - * Constructor. - * @param parent Parent shell. - */ - public UnwarnedInfoDlg(Shell parent) - { - super(parent, 0); - } - - /** - * Open method. - * @return Null. - */ - public Object open() - { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - - // Create the main layout for the shell. - GridLayout mainLayout = new GridLayout(1, false); - mainLayout.marginHeight = 0; - mainLayout.marginWidth = 0; - shell.setLayout(mainLayout); - shell.setText("Unwarned Alarm Information"); - - // Initialize all of the controls and layouts - initializeComponents(); - - shell.pack(); - shell.open(); - - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - - return null; - } - - /** - * Initialize the components. - */ - private void initializeComponents() - { - createInfoString(); - - createControls(); - } - - /** - * Create the text control and the close button. - */ - private void createControls() - { - Composite controlComp = new Composite(shell, SWT.NONE); - controlComp.setLayout(new GridLayout(1, false)); - - GridData gd = new GridData(400, 300); - StyledText stText = new StyledText(controlComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); - stText.setWordWrap(true); - stText.setText(infoText.toString()); - stText.setLayoutData(gd); - - gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.widthHint = 80; - Button closeBtn = new Button(controlComp, SWT.PUSH); - closeBtn.setText("Close"); - closeBtn.setLayoutData(gd); - closeBtn.addSelectionListener(new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - shell.dispose(); - } - }); - } - - /** - * Create the information text. - */ - private void createInfoString() - { - infoText = new StringBuilder(); - - infoText.append("SCAN identifies those storm cells that contain a "); - infoText.append("Tornado Vortex Signature (TVS) and to some extent "); - infoText.append("severe weather (based on various storm cell parameters). "); - infoText.append("Now SCAN can determine which storm cells currently have "); - infoText.append("an active TOR or SVR warning and which do not. For "); - infoText.append("those that do not, the SCAN user can set various storm "); - infoText.append("cell parameter thresholds (see below). If these thresholds "); - infoText.append("are met or exceeded and no TOR and/or SVR is in effect "); - infoText.append("in the polygon where the cell is located, an Unwarned Storm "); - infoText.append("Alarm will be issued.\n\n"); - infoText.append("To turn this functionality on for TOR and/or SVR warnings, "); - infoText.append("simply click the toggle below on and then check and specify "); - infoText.append("the thresholds you would like be used in order to issue a TOR "); - infoText.append("and/or SVR Unwarned Storm Cell Alarm. You will know that "); - infoText.append("an Unwarned Storm Alarm has been issued when the storm "); - infoText.append("cell identifier in the Storm Cell Table changes color to "); - infoText.append("magenta for TOR warnings and yellow for SVR warnings."); - } -} diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/test/TimeHeightMainDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/test/TimeHeightMainDlg.java deleted file mode 100644 index 366415ccbf..0000000000 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/test/TimeHeightMainDlg.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.raytheon.uf.viz.monitor.scan.test; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.viz.monitor.scan.commondialogs.TimeHeightDlg; - -public class TimeHeightMainDlg -{ - private Display display; - private Shell shell; - - public TimeHeightMainDlg() - { - display = new Display(); - shell = new Shell(display); - } - - public void run() - { - GridLayout gl = new GridLayout(1, false); - gl.horizontalSpacing = 0; - shell.setLayout(gl); - - shell.setSize(600, 300); - - createButtons(); - -// shell.pack(); - shell.open(); - - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) display.sleep(); - } - - display.dispose(); - } - - private void createButtons() - { - Button timeHeightBtn = new Button(shell, SWT.PUSH); - timeHeightBtn.setText("Time-Height Graph Dialog"); - timeHeightBtn.addSelectionListener(new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { -// TimeHeightDlg thd = new TimeHeightDlg(shell); -// thd.open(); - } - }); - } - - public static void main(String[] args) - { - TimeHeightMainDlg mwd = new TimeHeightMainDlg(); - mwd.run(); - } -} diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/test/TrendGraphWindowDlg.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/test/TrendGraphWindowDlg.java deleted file mode 100644 index a105bfb394..0000000000 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/test/TrendGraphWindowDlg.java +++ /dev/null @@ -1,212 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.monitor.scan.test; - -import java.util.Calendar; -import java.util.Date; -import java.util.LinkedHashMap; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.common.monitor.scan.config.SCANConfig; -import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.CELLTable; -import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables; -import com.raytheon.uf.viz.monitor.scan.TrendGraphData; -import com.raytheon.uf.viz.monitor.scan.commondialogs.TrendGraphCanvas; - -public class TrendGraphWindowDlg extends Dialog -{ - private Display display; - private Shell shell; - - /* - * Canvas information - */ - private TrendGraphCanvas trendCanvas; - - private Shell parentShell; - - private TrendGraphData trendGraphData; - - private Combo trendsCbo; - - private Calendar cal; - - private Date startTime; - - public TrendGraphWindowDlg(Shell parentShell) - { - super(parentShell, 0); - } - - public Object open() - { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - shell.setText("Trend Sample"); - - GridLayout gl = new GridLayout(1, false); - gl.horizontalSpacing = 0; - shell.setLayout(gl); - - shell.setSize(600, 300); - - initComponents(); - - shell.open(); - - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) display.sleep(); - } - - return null; - } - - private void initComponents() - { - cal = Calendar.getInstance(); - startTime = cal.getTime(); - trendGraphData = new TrendGraphData(); - - setupPoshData(); -// setupAzmData(); - - createCanvas(); - createComboControls(); - - handleComboAction(); - } - - private void createCanvas() - { - trendCanvas = new TrendGraphCanvas(shell, trendGraphData, startTime, ScanTables.CELL, - CELLTable.POSH.getColName(),null,null,null); - - } - - private void createComboControls() - { - trendsCbo = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY); - trendsCbo.addSelectionListener(new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent e) - { - handleComboAction(); - } - }); - - SCANConfig scanCfg = SCANConfig.getInstance(); - - String[] attrs = scanCfg.getTrendAttributes(ScanTables.CELL); - - for (String str : attrs) - { - trendsCbo.add(str); - } - - int idx = trendsCbo.indexOf("posh"); - - trendsCbo.select(idx); - } - - private void handleComboAction() - { - - String attrName = trendsCbo.getItem(trendsCbo.getSelectionIndex()); - - trendCanvas.updateAttribute(attrName, trendGraphData, startTime); - } - -// private void setupAzmData() -// { -// Date d = null; -// -// d = cal.getTime(); -// dataMap.put(d, 222.0); -// -// cal.add(Calendar.MINUTE, -5); -// d = cal.getTime(); -// dataMap.put(d, 200.0); -// -// cal.add(Calendar.MINUTE, -5); -// d = cal.getTime(); -// dataMap.put(d, 150.0); -// -// cal.add(Calendar.MINUTE, -5); -// d = cal.getTime(); -// dataMap.put(d, 170.0); -// -// cal.add(Calendar.MINUTE, -5); -// d = cal.getTime(); -// dataMap.put(d, 210.0); -// -// cal.add(Calendar.MINUTE, -5); -// d = cal.getTime(); -// dataMap.put(d, 123.0); -// -// cal.add(Calendar.MINUTE, -5); -// d = cal.getTime(); -// dataMap.put(d, 192.0); -// } - - private void setupPoshData() - { - Date d = null; - LinkedHashMap dataMap = new LinkedHashMap(); - d = cal.getTime(); - dataMap.put(d, 90.0); - - cal.add(Calendar.MINUTE, -5); - d = cal.getTime(); - dataMap.put(d, 30.0); - - cal.add(Calendar.MINUTE, -5); - d = cal.getTime(); - dataMap.put(d, 10.0); - - cal.add(Calendar.MINUTE, -5); - d = cal.getTime(); - dataMap.put(d, 50.0); - - cal.add(Calendar.MINUTE, -5); - d = cal.getTime(); - dataMap.put(d, 25.0); - - cal.add(Calendar.MINUTE, -5); - d = cal.getTime(); - dataMap.put(d, 63.0); - - cal.add(Calendar.MINUTE, -5); - d = cal.getTime(); - dataMap.put(d, 40.0); - - trendGraphData.setGraphData(dataMap); - } -} diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java index 9255b4d559..0d299be156 100644 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/SnowMonitor.java @@ -169,24 +169,20 @@ public class SnowMonitor extends ObsMonitor { * @param shell */ public void launchDialog(String type, Shell shell) { - if (type.equals("zone")) { - if (zoneDialog == null || zoneDialog.getShell() == null - || zoneDialog.isDisposed()) { + if (zoneDialog == null) { zoneDialog = new SnowZoneTableDlg(shell, obData); addMonitorListener(zoneDialog); zoneDialog.addMonitorControlListener(this); fireMonitorEvent(zoneDialog.getClass().getName()); - zoneDialog.open(); - } else { - zoneDialog.bringToTop(); } + zoneDialog.open(); } else if (type.equals("area")) { if (areaDialog == null) { areaDialog = new SnowMonitoringAreaConfigDlg(shell, "SNOW Monitor Area Configuration"); - areaDialog.open(); } + areaDialog.open(); } } @@ -263,7 +259,7 @@ public class SnowMonitor extends ObsMonitor { try { SnowMonitorConfigurationManager areaConfig = getMonitorAreaConfig(); for (String zone : areaConfig.getAreaList()) { - ArrayList stations = areaConfig.getAreaStations(zone); + List stations = areaConfig.getAreaStations(zone); zones.put(zone, stations); } } catch (Exception e) { @@ -408,7 +404,7 @@ public class SnowMonitor extends ObsMonitor { zoneDialog = null; } if (areaDialog != null) { - areaDialog.shellDisposeDialog(); + areaDialog.close(); areaDialog = null; } } diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/test/SnowTestDriverDlg.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/test/SnowTestDriverDlg.java deleted file mode 100644 index 5503aab1bf..0000000000 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/test/SnowTestDriverDlg.java +++ /dev/null @@ -1,266 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.monitor.snow.test; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.monitor.data.CommonTableConfig.CellType; -import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; -import com.raytheon.uf.viz.monitor.snow.threshold.SnowThresholdMgr; -import com.raytheon.uf.viz.monitor.thresholds.AbstractThresholdMgr.ThresholdKey; -import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg; -import com.raytheon.uf.viz.monitor.ui.dialogs.LoadSaveDeleteSelectDlg.DialogType; -import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; - -public class SnowTestDriverDlg extends Dialog { - private Display display; - - private Shell shell; - - private Font lblFont; - - public SnowTestDriverDlg(Shell parentShell) { - super(parentShell, 0); - } - - public Object open() { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - shell.setText("SNOW Driver"); - - GridLayout gl = new GridLayout(1, false); - gl.horizontalSpacing = 0; - shell.setLayout(gl); - - shell.setSize(600, 600); - - lblFont = new Font(shell.getDisplay(), "Monospace", 14, SWT.NORMAL); - - initComponents(); - - shell.open(); - - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) - display.sleep(); - } - - lblFont.dispose(); - - return null; - } - - private void initComponents() { - Label lbl = new Label(shell, SWT.NONE); - lbl.setText("SNOW"); - lbl.setFont(lblFont); - - Button printDisplayThresh = new Button(shell, SWT.PUSH); - printDisplayThresh.setText("Print Display Threshold Data"); - printDisplayThresh.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - printDisplayThresholdData(); - } - }); - - Button changeThresh = new Button(shell, SWT.PUSH); - changeThresh.setText("Change Threshold Data"); - changeThresh.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - changeThresholdData(); - } - }); - - Button loadThreshDlg = new Button(shell, SWT.PUSH); - loadThreshDlg.setText("Load Dialog"); - loadThreshDlg.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - displayLoadDialog(); - } - }); - - Button saveAsThreshDlg = new Button(shell, SWT.PUSH); - saveAsThreshDlg.setText("Save As Dialog"); - saveAsThreshDlg.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - displaySaveDialog(); - } - }); - - Button printDefaultFileNameBtn = new Button(shell, SWT.PUSH); - printDefaultFileNameBtn.setText("Print Default Threshold File Name"); - printDefaultFileNameBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - displayDefaultThreshFileName(); - } - }); - - Button selectDefaultFileNameBtn = new Button(shell, SWT.PUSH); - selectDefaultFileNameBtn.setText("Select Default Threshold File Name"); - selectDefaultFileNameBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - selectDefaultThreshFileName(); - } - }); - - Button loadDefaultFileNameBtn = new Button(shell, SWT.PUSH); - loadDefaultFileNameBtn.setText("Load Default Threshold"); - loadDefaultFileNameBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - loadDefaultThresholds(); - } - }); - - Button cellTypeBtn = new Button(shell, SWT.PUSH); - cellTypeBtn.setText("Print CellType"); - cellTypeBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - printCellType(); - } - }); - } - - private void addSeparator(Composite parentComp) { - GridLayout gl = (GridLayout) parentComp.getLayout(); - - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = gl.numColumns; - Label sepLbl = new Label(parentComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - } - - private void printDisplayThresholdData() { - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - stm.printDisplayThresholds(); - } - - private void changeThresholdData() { - System.out.println("NOT WORKING..."); - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - stm.setThresholdValue(DataUsageKey.DISPLAY, ThresholdKey.RED, "NE093", - MonitorConfigConstants.SnowDisplay.SNOW_DISP_METEO_TEMP - .getXmlKey(), 111); - } - - private void displayLoadDialog() { - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.OPEN, stm.getDisplayThresholdPath(), stm - .getDefaultFileName(DataUsageKey.DISPLAY)); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - stm.loadDisplayThreashold(fileName.getFile().getName()); - } - - private void displaySaveDialog() { - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.SAVE_AS, stm.getDisplayThresholdPath(), stm - .getDefaultFileName(DataUsageKey.DISPLAY)); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - stm.saveAsDisplayThresholds(fileName.getFile().getName()); - } - - private void displayDefaultThreshFileName() { - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - - System.out.println(">" + stm.getDefDisplayThreshFileName() + "<"); - } - - private void selectDefaultThreshFileName() { - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - - LoadSaveDeleteSelectDlg lsDlg = new LoadSaveDeleteSelectDlg(shell, - DialogType.SELECT_DEFAULT, stm.getDisplayThresholdPath(), stm - .getDefaultFileName(DataUsageKey.DISPLAY)); - LocalizationFile fileName = (LocalizationFile) lsDlg.open(); - - if (fileName == null) { - System.out.println("FileName is null..."); - return; - } - - System.out.println("Selected file absolute path= " - + fileName.getFile().getAbsolutePath()); - System.out.println("Selected file name = " - + fileName.getFile().getName()); - - stm.setDefaultDisplayFileName(fileName.getFile().getName()); - } - - private void loadDefaultThresholds() { - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - - stm.loadDefaultDisplayThreshold(); - } - - private void printCellType() { - CellType ct; - String key; - double value = Double.NaN; - - SnowThresholdMgr stm = SnowThresholdMgr.getInstance(); - - } -} diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/actions/SnowAreaConfigAction.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/actions/SnowAreaConfigAction.java index 3433571204..9613aeaa4d 100644 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/actions/SnowAreaConfigAction.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/actions/SnowAreaConfigAction.java @@ -25,7 +25,8 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; -import com.raytheon.uf.viz.monitor.snow.SnowMonitor; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.monitor.snow.ui.dialogs.SnowMonitoringAreaConfigDlg; /** @@ -38,6 +39,7 @@ import com.raytheon.uf.viz.monitor.snow.ui.dialogs.SnowMonitoringAreaConfigDlg; * ------------ ---------- ----------- -------------------------- * Dec 28, 2009 3963 dhladky Initial creation. * March 5, 2012 14413 zhao Launch AreaConfigDlg w/o monitor + * Nov.27, 2012 1297 skorolev Cleanup code for non-blocking dialog * * * @@ -47,19 +49,22 @@ import com.raytheon.uf.viz.monitor.snow.ui.dialogs.SnowMonitoringAreaConfigDlg; public class SnowAreaConfigAction extends AbstractHandler { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(SnowAreaConfigAction.class); + + private SnowMonitoringAreaConfigDlg configDlg; + @Override public Object execute(ExecutionEvent arg0) throws ExecutionException { - - System.out.println("Activating/Action the Snow Area Config..."); - - //SnowMonitor monitor = SnowMonitor.getInstance(); - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - //monitor.launchDialog("area", shell); - - SnowMonitoringAreaConfigDlg configDlg= new SnowMonitoringAreaConfigDlg(shell, "SNOW Monitor Area Configuration"); + + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + if (configDlg == null || configDlg.getShell() == null + || configDlg.isDisposed()) { + configDlg = new SnowMonitoringAreaConfigDlg(shell, + "SNOW Monitor Area Configuration"); + } configDlg.open(); - return null; } - } \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java index c7d17305d7..e40ce21bc8 100644 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowMonitoringAreaConfigDlg.java @@ -31,14 +31,15 @@ import com.raytheon.uf.viz.monitor.snow.threshold.SnowThresholdMgr; import com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg; /** - * TODO Add Description + * SNOW Monitor area configuration dialog. * *
  * 
  * SOFTWARE HISTORY
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Jan 5, 2010            mpduff     Initial creation
+ * Jan  5, 2010            mpduff      Initial creation
+ * Nov 27, 2012 1351       skorolev    Changes for non-blocking dialog.
  * 
  * 
* @@ -53,35 +54,38 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { readConfigData(); } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg# + * handleOkBtnSelection() + */ @Override protected void handleOkBtnSelection() { SnowMonitorConfigurationManager configManager = SnowMonitorConfigurationManager .getInstance(); // Check for changes in the data - int choice = showMessage(shell, SWT.OK | SWT.CANCEL, - "SNOW Monitor Confirm Changes", - "Want to update the SNOW setup files?"); + if (!configManager.getAddedZones().isEmpty() + || !configManager.getAddedZones().isEmpty()) { + int choice = showMessage(shell, SWT.OK | SWT.CANCEL, + "SNOW Monitor Confirm Changes", + "Want to update the SNOW setup files?"); + if (choice == SWT.OK) { + // Save the config xml file + configManager.setTimeWindow(timeScale.getSelection()); + configManager.saveConfigData(); + /** + * DR#11279: re-initialize threshold manager and the monitor + * using new monitor area configuration + */ + SnowThresholdMgr.reInitialize(); + SnowMonitor.reInitialize(); + showMessage(shell, SWT.ICON_INFORMATION | SWT.OK, + "SNOW Config Change", + "You're updating the SNOW monitoring settings." + + "\n\nIf SNOW is running anywhere within " + + "the office, please clear it.\n"); - if (choice == SWT.OK) { - // Save the config xml file - configManager.setTimeWindow(timeScale.getSelection()); - configManager.saveConfigData(); - - /** - * DR#11279: re-initialize threshold manager and the monitor using - * new monitor area configuration - */ - SnowThresholdMgr.reInitialize(); - SnowMonitor.reInitialize(); - - showMessage(shell, SWT.ICON_INFORMATION | SWT.OK, - "SNOW Config Change", - "You're updating the SNOW monitoring settings." - + "\n\nIf SNOW is running anywhere within " - + "the office, please clear it.\n"); - - if (configManager.getAddedZones().size() > 0 - || addedZones.size() > 0) { String message2 = "New zones have been added, and their monitoring thresholds " + "have been set to default values; would you like to modify " + "their threshold values now?"; @@ -94,15 +98,36 @@ public class SnowMonitoringAreaConfigDlg extends MonitoringAreaConfigDlg { snowMonitorDlg.open(); } } - shell.dispose(); + } else { + String message3 = "No changes made.\nDo you want to exit?"; + int yesno = showMessage(shell, + SWT.ICON_QUESTION | SWT.YES | SWT.NO, "Exit", message3); + if (yesno == SWT.NO) { + return; + } } + setReturnValue(true); + close(); } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg# + * setAlgorithmText() + */ @Override protected void setAlgorithmText() { // Not used for SNOW } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.monitor.ui.dialogs.MonitoringAreaConfigDlg#readConfigData + * () + */ @Override protected void readConfigData() { SnowMonitorConfigurationManager configManager = SnowMonitorConfigurationManager diff --git a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowObsHistTableDlg.java b/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowObsHistTableDlg.java deleted file mode 100644 index 452d5acb58..0000000000 --- a/cave/com.raytheon.uf.viz.monitor.snow/src/com/raytheon/uf/viz/monitor/snow/ui/dialogs/SnowObsHistTableDlg.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.uf.viz.monitor.snow.ui.dialogs; - -import org.eclipse.swt.widgets.Shell; - -import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; -import com.raytheon.uf.common.monitor.data.CommonTableConfig.ObsHistType; -import com.raytheon.uf.viz.monitor.data.TableData; -import com.raytheon.uf.viz.monitor.ui.dialogs.ObsHistTableDlg; - -public class SnowObsHistTableDlg extends ObsHistTableDlg { - public SnowObsHistTableDlg(Shell parent, TableData tableData, - String stationID, double lat, double lon, AppName appName, - ObsHistType obsType) { - super(parent, tableData, stationID, lat, lon, appName, obsType); - - } - - protected void configAction() { - System.out.println("Snow Config Action"); - } -} diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java index e4ed5cb1ae..91aa4a8c89 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/AbstractThresholdMgr.java @@ -22,16 +22,17 @@ package com.raytheon.uf.viz.monitor.thresholds; import java.io.File; import java.util.ArrayList; import java.util.Collections; +import java.util.List; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.localization.PathManagerFactory; 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.monitor.config.MonitorConfigurationManager; -import com.raytheon.uf.common.monitor.data.ObConst; import com.raytheon.uf.common.monitor.data.CommonTableConfig.CellType; +import com.raytheon.uf.common.monitor.data.ObConst; import com.raytheon.uf.common.monitor.data.ObConst.DataUsageKey; import com.raytheon.uf.viz.monitor.filename.DefaultFilenameMgr; import com.raytheon.uf.viz.monitor.util.MonitorConfigConstants; @@ -58,6 +59,7 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; */ public abstract class AbstractThresholdMgr { protected MonitorConfigurationManager areaConfigMgr = null; + /** * Default file name for the FOG display thresholds. */ @@ -149,13 +151,13 @@ public abstract class AbstractThresholdMgr { loadDefaultDisplayThreshold(); } else { currFullDisplayXmlFileName = getDisplayThresholdPath() - + defaultFileNameMgr.getDefaultThresholdFilename(); + + defaultFileNameMgr.getDefaultThresholdFilename(); displayThreshMgr = new ThresholdMgr(currFullDisplayXmlFileName); displayThreshMgr.readThresholdXml(); } } else { currFullDisplayXmlFileName = getDisplayThresholdPath() - + defDisplayThreshName; + + defDisplayThreshName; displayThreshMgr = new ThresholdMgr(currFullDisplayXmlFileName); loadDefaultDisplayThreshold(); } @@ -164,7 +166,7 @@ public abstract class AbstractThresholdMgr { * Setup the Fog monitor threshold manager */ currFullMonitorXmlFileName = getMonitorThresholdPath() - + defMonitorThreshName; + + defMonitorThreshName; monitorThreshMgr = new ThresholdMgr(currFullMonitorXmlFileName); if (validateFileName(currFullMonitorXmlFileName) == true) { @@ -281,18 +283,21 @@ public abstract class AbstractThresholdMgr { return CellType.NotMonitored; } - + /** - * Determines Table Cell Type for a directional variable such as - * Wind Direction or Swell Direction + * Determines Table Cell Type for a directional variable such as Wind + * Direction or Swell Direction + * * @param dataUsage * @param areaID * @param keyFrom * @param keyTo * @param value - * @return Cell Type + * @return Cell Type */ - public CellType getDirectionalThresholdValueCellType(DataUsageKey dataUsage, String areaID, String keyFrom, String keyTo, double value) { + public CellType getDirectionalThresholdValueCellType( + DataUsageKey dataUsage, String areaID, String keyFrom, + String keyTo, double value) { if (hasArea(areaID, dataUsage) == false) { return CellType.NotMonitored; } @@ -315,44 +320,47 @@ public abstract class AbstractThresholdMgr { redTo = displayThreshMgr.getRedValue(areaID, keyTo); yellowFrom = displayThreshMgr.getYellowValue(areaID, keyFrom); yellowTo = displayThreshMgr.getYellowValue(areaID, keyTo); - return calcDirectionalCellType(redFrom, redTo, yellowFrom, yellowTo, value); + return calcDirectionalCellType(redFrom, redTo, yellowFrom, + yellowTo, value); } else if (dataUsage == DataUsageKey.MONITOR) { redFrom = monitorThreshMgr.getRedValue(areaID, keyFrom); redTo = monitorThreshMgr.getRedValue(areaID, keyTo); yellowFrom = monitorThreshMgr.getYellowValue(areaID, keyFrom); yellowTo = monitorThreshMgr.getYellowValue(areaID, keyTo); - return calcDirectionalCellType(redFrom, redTo, yellowFrom, yellowTo, value); + return calcDirectionalCellType(redFrom, redTo, yellowFrom, + yellowTo, value); } return CellType.NotMonitored; } - - private CellType calcDirectionalCellType(double redFrom, double redTo, double yellowFrom, double yellowTo, double value) { - if ( redFrom < redTo ) { - if ( value > redFrom && value < redTo ) { - return CellType.R; - } - } - - if ( redFrom > redTo ) { - if ( value > redFrom || value < redTo ) { - return CellType.R; - } - } - - if ( yellowFrom < yellowTo ) { - if ( value > yellowFrom && value < yellowTo ) { - return CellType.Y; - } - } - - if ( yellowFrom > yellowTo ) { - if ( value > yellowFrom || value < yellowTo ) { - return CellType.Y; - } - } - + private CellType calcDirectionalCellType(double redFrom, double redTo, + double yellowFrom, double yellowTo, double value) { + + if (redFrom < redTo) { + if (value > redFrom && value < redTo) { + return CellType.R; + } + } + + if (redFrom > redTo) { + if (value > redFrom || value < redTo) { + return CellType.R; + } + } + + if (yellowFrom < yellowTo) { + if (value > yellowFrom && value < yellowTo) { + return CellType.Y; + } + } + + if (yellowFrom > yellowTo) { + if (value > yellowFrom || value < yellowTo) { + return CellType.Y; + } + } + return CellType.G; } @@ -360,11 +368,12 @@ public abstract class AbstractThresholdMgr { double value) { Boolean redIsHigher = MonitorConfigConstants.rValueIsHigher(key, appName); - // SK. Take integer part of data for threshold comparison to avoid color confusion. - // To be consistent with table display for which Math.round() is used, + // SK. Take integer part of data for threshold comparison to avoid color + // confusion. + // To be consistent with table display for which Math.round() is used, // [zhao 10/06/2011] - value = Math.round( new Float(value) ); - + value = Math.round(new Float(value)); + if (redIsHigher == null) { if (red <= yellow) { if (value <= red) { @@ -403,7 +412,7 @@ public abstract class AbstractThresholdMgr { return CellType.NotMonitored; } - + /** * Set the default display threshold file name. * @@ -414,7 +423,7 @@ public abstract class AbstractThresholdMgr { if (fileName == null) { defaultFileNameMgr.setDefaultThresholdFilename(""); currFullDisplayXmlFileName = getDisplayThresholdPath() - + defDisplayThreshName; + + defDisplayThreshName; return; } @@ -455,9 +464,9 @@ public abstract class AbstractThresholdMgr { if (filename == null || filename.trim().length() == 0) { currFullDisplayXmlFileName = getDisplayThresholdPath() - + defDisplayThreshName; + + defDisplayThreshName; - ArrayList areaIDs = null; + List areaIDs = null; try { areaIDs = areaConfigMgr.getAreaList(); @@ -484,9 +493,9 @@ public abstract class AbstractThresholdMgr { public void loadDefaultMonitorThreshold() { currFullMonitorXmlFileName = getMonitorThresholdPath() - + defMonitorThreshName; + + defMonitorThreshName; - ArrayList areaIDs = null; + List areaIDs = null; try { areaIDs = areaConfigMgr.getAreaList(); diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/ThresholdMgr.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/ThresholdMgr.java index f645094f43..09b94134d1 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/ThresholdMgr.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/thresholds/ThresholdMgr.java @@ -21,6 +21,7 @@ package com.raytheon.uf.viz.monitor.thresholds; import java.io.File; import java.util.ArrayList; +import java.util.List; import javax.xml.bind.JAXB; @@ -30,6 +31,9 @@ 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.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.monitor.xml.AreaThresholdXML; import com.raytheon.uf.viz.monitor.xml.AreaXML; import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; @@ -45,6 +49,7 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 15, 2009 #3963 lvenable Initial creation + * Dec 4, 2012 #1351 skorolev Cleaned code * * * @@ -52,6 +57,10 @@ import com.raytheon.uf.viz.monitor.xml.ThresholdsXML; * @version 1.0 */ public class ThresholdMgr { + + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(ThresholdMgr.class); + /** * Threshold XML data. */ @@ -80,12 +89,9 @@ public class ThresholdMgr { cfgXML = null; IPathManager pm = PathManagerFactory.getPathManager(); File path = pm.getStaticFile(currFullPathAndFileName); - - System.out.println("**** path = " + path); - cfgXML = JAXB.unmarshal(path, ThresholdsXML.class); } catch (Exception e) { - e.printStackTrace(); + statusHandler.handle(Priority.ERROR, e.getMessage()); } } @@ -98,22 +104,14 @@ public class ThresholdMgr { LocalizationType.CAVE_STATIC, LocalizationLevel.SITE); LocalizationFile locFile = pm.getLocalizationFile(context, currFullPathAndFileName); - if (locFile.getFile().getParentFile().exists() == false) { - System.out.println("Creating new directory"); - - if (locFile.getFile().getParentFile().mkdirs() == false) { - System.out.println("Could not create new directory..."); - } + locFile.getFile().getParentFile().mkdirs(); } - try { - System.out.println("Saving -- " - + locFile.getFile().getAbsolutePath()); JAXB.marshal(cfgXML, locFile.getFile()); locFile.save(); } catch (Exception e) { - e.printStackTrace(); + statusHandler.handle(Priority.ERROR, e.getMessage()); } } @@ -139,22 +137,17 @@ public class ThresholdMgr { * @return True if the configuration XML was successfully created. */ public boolean createConfigFromDefaults(String fullDefaultPathName, - ArrayList areaIDs, ArrayList keys) { + List areaIDs, ArrayList keys) { try { IPathManager pm = PathManagerFactory.getPathManager(); File path = pm.getStaticFile(fullDefaultPathName); - - System.out.println("*** create from defaults path = " + path); - ThresholdsXML cfgXmlDefaults = JAXB.unmarshal(path, ThresholdsXML.class); - createXmlFromDefaults(cfgXmlDefaults, areaIDs, keys); } catch (Exception e) { - e.printStackTrace(); + statusHandler.handle(Priority.ERROR, e.getMessage()); return false; } - return true; } @@ -170,25 +163,27 @@ public class ThresholdMgr { * values. */ private void createXmlFromDefaults(ThresholdsXML cfgXmlDefaults, - ArrayList areaIDs, ArrayList keys) { + List areaIDs, ArrayList keys) { cfgXML = new ThresholdsXML(); - createAreas(cfgXmlDefaults, areaIDs, keys); } + /** + * Creates Areas. + * + * @param defaultThreshXML + * @param areaIDs + * @param keys + */ private void createAreas(ThresholdsXML defaultThreshXML, - ArrayList areaIDs, ArrayList keys) { + List areaIDs, ArrayList keys) { ArrayList areas = new ArrayList(); - for (String areaID : areaIDs) { AreaXML area = new AreaXML(); area.setAreaId(areaID); - createAreaThreshold(area, defaultThreshXML, keys); - areas.add(area); } - cfgXML.setAreas(areas); } @@ -206,7 +201,6 @@ public class ThresholdMgr { private void createAreaThreshold(AreaXML area, ThresholdsXML defaultThreshXML, ArrayList keys) { ArrayList areaThreshArray = new ArrayList(); - for (String key : keys) { AreaThresholdXML areaThresh = new AreaThresholdXML(); areaThresh.setKey(key); @@ -214,10 +208,8 @@ public class ThresholdMgr { .getRedValue(key)); areaThresh.setYellow(defaultThreshXML.getAreas().get(0) .getYellowValue(key)); - areaThreshArray.add(areaThresh); } - area.setAreaThresholds(areaThreshArray); } @@ -294,41 +286,41 @@ public class ThresholdMgr { return this.cfgXML; } + /** + * Sets the threshold XML. + * + * @param newCfgXML + */ public void setThresholdXML(ThresholdsXML newCfgXML) { this.cfgXML = newCfgXML; } + /** + * Gets Thresholds Xml Copy. + * + * @return newThreshXML + */ public ThresholdsXML getThresholdsXmlCopy() { ThresholdsXML newThreshXML = new ThresholdsXML(); - ArrayList currAreas = cfgXML.getAreas(); ArrayList newAreas = new ArrayList(); - for (AreaXML currAreaXML : currAreas) { AreaXML newAreaXML = new AreaXML(); newAreaXML.setAreaId(currAreaXML.getAreaId()); - ArrayList currAreaThreshholds = currAreaXML .getAreaThresholds(); ArrayList newAreaThreshholds = new ArrayList(); - for (AreaThresholdXML currAreaThreshXML : currAreaThreshholds) { AreaThresholdXML newAreaThreshXML = new AreaThresholdXML(); newAreaThreshXML.setKey(currAreaThreshXML.getKey()); newAreaThreshXML.setRed(currAreaThreshXML.getRed()); newAreaThreshXML.setYellow(currAreaThreshXML.getYellow()); - newAreaThreshholds.add(newAreaThreshXML); } - newAreaXML.setAreaThresholds(newAreaThreshholds); - newAreas.add(newAreaXML); - } - newThreshXML.setAreas(newAreas); - return newThreshXML; } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewStationDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewStationDlg.java index fd7195ea75..459e5c428a 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewStationDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewStationDlg.java @@ -26,9 +26,8 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; 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; @@ -36,360 +35,355 @@ 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.FogMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.MonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.SSMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.SnowMonitorConfigurationManager; 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; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.viz.ui.dialogs.CaveSWTDialog; /** * * Add New Station dialog. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Apr 2, 2009            lvenable     Initial creation
- *
+ * Nov 20, 2012 1297      skorolev     Changes for non-blocking dialog.
+ * 
  * 
- * + * * @author lvenable * @version 1.0 */ -public class AddNewStationDlg extends Dialog -{ - /** - * Dialog shell. - */ - private Shell shell; - - /** - * The display control. - */ - private Display display; - - /** - * Return value when the shell is disposed. - */ - private Boolean returnValue = false; - +public class AddNewStationDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(AddNewStationDlg.class); + /** * Application name. */ - private CommonConfig.AppName appName; - + private AppName appName; + /** * METAR radio button. */ private Button metarRdo; - + /** * Maritime button. */ private Button maritimeRdo; - + /** * Mesonet button; */ private Button mesonetRdo; - + /** * Station label. */ private Label stationLbl; - + /** * Station text control. */ private Text stationTF; - + + /** + * Zone + */ private String area; - - private INewZoneStnAction macDlg; - + + /** + * Call back interface + */ + private INewZoneStnAction macDlg; + + /** + * Area configuration manager. + */ + private MonitorConfigurationManager configManager; + /** * Constructor. - * @param parent Parent shell. - * @param appName Application name. + * + * @param parent + * Parent shell. + * @param appName + * @param area + * @param macDlg */ - public AddNewStationDlg(Shell parent, CommonConfig.AppName appName, String area, INewZoneStnAction macDlg) - { - super(parent, 0); - - this.appName = appName; + public AddNewStationDlg(Shell parent, CommonConfig.AppName appName, + String area, INewZoneStnAction macDlg) { + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); + setText(appName.toString() + ": Add a New Stn to Monitor Area"); + this.appName = appName; this.area = area; this.macDlg = macDlg; + configManager = getConfigManager(appName); } - - /** - * Open method used to display the dialog. - * @return True/False. + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() */ - public Object open() - { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - shell.setText(appName.toString() + ": Add a New Station"); - - // Create the main layout for the shell. + @Override + protected Layout constructShellLayout() { GridLayout mainLayout = new GridLayout(1, false); mainLayout.marginHeight = 2; mainLayout.marginWidth = 2; mainLayout.verticalSpacing = 2; - shell.setLayout(mainLayout); - - // Initialize all of the controls and layouts - initializeComponents(); - - shell.pack(); - - shell.open(); - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - - return returnValue; + return mainLayout; } - - /** - * Initialize the components on the display. + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) */ - private void initializeComponents() - { + @Override + protected void initializeComponents(Shell shell) { + setReturnValue(false); createTopLabelRadioControls(); - createTextControls(); - createBottomButtons(); - setStationLabel(); } - + /** - * Create the top radio controls. + * Creates the top radio controls. */ - private void createTopLabelRadioControls() - { + private void createTopLabelRadioControls() { Composite topComp = new Composite(shell, SWT.NONE); topComp.setLayout(new GridLayout(2, true)); topComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - /* * Add the label. */ Label topLbl = new Label(topComp, SWT.RIGHT); topLbl.setText("Please type in a new: "); topLbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true)); - /* * Add the radio controls. */ Composite radioComp = new Composite(topComp, SWT.NONE); radioComp.setLayout(new GridLayout(1, false)); - metarRdo = new Button(radioComp, SWT.RADIO); metarRdo.setText("Metar"); metarRdo.setSelection(true); - metarRdo.addSelectionListener(new SelectionAdapter() - { + metarRdo.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { + public void widgetSelected(SelectionEvent event) { + setStationLabel(); + } + }); + // TODO: Disable if area has no marine zones. + maritimeRdo = new Button(radioComp, SWT.RADIO); + maritimeRdo.setText("Maritime"); + maritimeRdo.setEnabled(appName != CommonConfig.AppName.SNOW); + maritimeRdo.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { setStationLabel(); } }); - - if (appName != CommonConfig.AppName.SNOW) - { - maritimeRdo = new Button(radioComp, SWT.RADIO); - maritimeRdo.setText("Maritime"); - maritimeRdo.addSelectionListener(new SelectionAdapter() - { - @Override - public void widgetSelected(SelectionEvent event) - { - setStationLabel(); - } - }); - } - mesonetRdo = new Button(radioComp, SWT.RADIO); mesonetRdo.setText("Mesonet"); - mesonetRdo.addSelectionListener(new SelectionAdapter() - { + mesonetRdo.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { + public void widgetSelected(SelectionEvent event) { setStationLabel(); } }); } - + /** * Create the text controls. */ - private void createTextControls() - { + private void createTextControls() { Composite textComp = new Composite(shell, SWT.NONE); textComp.setLayout(new GridLayout(1, true)); textComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - stationLbl = new Label(textComp, SWT.NONE); - stationLbl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - + stationLbl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, + false)); stationTF = new Text(textComp, SWT.BORDER); stationTF.setLayoutData(new GridData(250, SWT.DEFAULT)); } - + /** - * Create the bottom buttons. + * Creates the bottom buttons. */ - private void createBottomButtons() - { + private void createBottomButtons() { GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); Composite mainButtonComp = new Composite(shell, SWT.NONE); mainButtonComp.setLayout(new GridLayout(1, false)); mainButtonComp.setLayoutData(gd); - // Add a separator label. Label sepLbl = new Label(mainButtonComp, SWT.SEPARATOR | SWT.HORIZONTAL); sepLbl.setLayoutData(gd); - + gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false); Composite buttonComp = new Composite(shell, SWT.NONE); buttonComp.setLayout(new GridLayout(2, false)); buttonComp.setLayoutData(gd); - + gd = new GridData(100, SWT.DEFAULT); Button addBtn = new Button(buttonComp, SWT.PUSH); addBtn.setText("Add"); addBtn.setLayoutData(gd); - addBtn.addSelectionListener(new SelectionAdapter() - { + addBtn.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { + public void widgetSelected(SelectionEvent event) { String stationType = StationIdXML.METAR; - FogMonitorConfigurationManager configManager = FogMonitorConfigurationManager.getInstance(); if (metarRdo.getSelection()) { stationType = StationIdXML.METAR; } else if (mesonetRdo.getSelection()) { String s = stationTF.getText(); - s.substring(s.indexOf("#"), s.length() - 1); + s = s.substring(s.indexOf("#") + 1, s.length()); stationType = s.toUpperCase(); - // TODO need to verifyu the stationType exists. + // TODO need to verify the stationType exists. // was in SSmesonetStationInfo.txt in AWIPS1. } else { stationType = StationIdXML.MARITIME; } - - configManager.addStation(area, stationTF.getText(), stationType, false); - - /** - * for DR #7854: add new station to Monitor Area Config GUI - */ - handleAddNewStation(); - - //shell.dispose(); + if (!stationTF.getText().isEmpty()) { + configManager.addStation(area, stationTF.getText(), + stationType, false); + /** + * for DR #7854: add new station to Monitor Area Config GUI + */ + handleAddNewStation(); + } else { + displayInputErrorMsg("Invalid Station ID entered: Please enter a valid Station ID for the selected Station Type"); + } } }); - + gd = new GridData(100, SWT.DEFAULT); Button closeBtn = new Button(buttonComp, SWT.PUSH); closeBtn.setText("Close"); closeBtn.setLayoutData(gd); - closeBtn.addSelectionListener(new SelectionAdapter() - { + closeBtn.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { - shell.dispose(); + public void widgetSelected(SelectionEvent event) { + setReturnValue(true); + close(); } }); } - + /** * Set the station label. */ - private void setStationLabel() - { - if (mesonetRdo.getSelection() == true) - { + private void setStationLabel() { + if (mesonetRdo.getSelection() == true) { stationLbl.setText("StationID#Provider:"); - } - else - { + } else { stationLbl.setText("StationID:"); } } - private void handleAddNewStation() { - - if ( !isValidStation() ) { - displayInputErrorMsg("Invalid Station ID entered: Please enter a valid Station ID for the selected Station Type"); - return; - } - String stn = stationTF.getText(); - if ( metarRdo.getSelection() ) { - stn = stn + "#METAR"; - } else if ( maritimeRdo.getSelection() ) { - stn = stn + "#MARITIME"; - } else { - //Mesonet - } - if ( macDlg.isExistingStation(stn) ) { - displayInputErrorMsg("The Station, " + stn + ", is already in your Monitoring Area or among your Additional Stations"); - return; - } - macDlg.addNewStationAction(stn); - } - - private boolean isValidStation() { - - String stnId = stationTF.getText(); - if ( stnId.contains("#") && !mesonetRdo.getSelection() ) { - return false; - } - String catalogtypePhrase = ""; - if ( metarRdo.getSelection() ) { - catalogtypePhrase = "catalogtype = 1"; // METAR - } else if ( maritimeRdo.getSelection() ) { - catalogtypePhrase = "catalogtype = 33 or catalogtype = 32"; // MARITIME - } else { - //TODO need code for handling Mesonet - } - try { - String sql = "select stationid, catalogtype from common_obs_spatial where ( " + catalogtypePhrase + " ) and stationid = '" + stnId + "'"; - ISpatialQuery sq = SpatialQueryFactory.create(); - Object[] results = sq.dbRequest(sql, "metadata"); - if ( results == null ) { - return false; - } - if ( results.length != 2 ) { - return false; - } - return true; - - /** - * TODO: need to add code for handling Mesonet station type - */ - - } catch ( Exception e ) { - e.printStackTrace(); - } - - return false; - } - - private void displayInputErrorMsg(String msg) { - MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK); + /** + * Adds a new station. + */ + private void handleAddNewStation() { + if (!isValidStation()) { + displayInputErrorMsg("Invalid Station ID entered: Please enter a valid Station ID for the selected Station Type"); + return; + } + String stn = stationTF.getText(); + if (metarRdo.getSelection()) { + stn = stn + "#METAR"; + } else if (maritimeRdo.getSelection()) { + stn = stn + "#MARITIME"; + } else { + // TODO: Mesonet + } + if (macDlg.isExistingStation(stn)) { + displayInputErrorMsg("The Station, " + + stn + + ", is already in your Monitoring Area or among your Additional Stations"); + return; + } + macDlg.addNewStationAction(stn); + + } + + /** + * Checks if station is valid. + * + * @return boolean value + */ + private boolean isValidStation() { + String stnId = stationTF.getText(); + if (stnId.contains("#") && !mesonetRdo.getSelection()) { + return false; + } + String catalogtypePhrase = ""; + if (metarRdo.getSelection()) { + catalogtypePhrase = "catalogtype = 1"; // METAR + } else if (maritimeRdo.isEnabled() && maritimeRdo.getSelection()) { + catalogtypePhrase = "catalogtype = 33 or catalogtype = 32"; // MARITIME + } else { + catalogtypePhrase = "catalogtype = 1000"; // MESONET + stnId = stnId.substring(0, stnId.indexOf("#")); + } + try { + String sql = "select stationid, catalogtype from common_obs_spatial where ( " + + catalogtypePhrase + " ) and stationid = '" + stnId + "'"; + ISpatialQuery sq = SpatialQueryFactory.create(); + Object[] results = sq.dbRequest(sql, "metadata"); + if (results == null) { + return false; + } + if (results.length != 2) { + return false; + } + return true; + /** + * TODO: need to add code for handling Mesonet station type + */ + } catch (Exception e) { + statusHandler.handle(Priority.ERROR, e.getMessage()); + } + return false; + } + + /** + * Displays input error. + * + * @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(); - } + } + + private MonitorConfigurationManager getConfigManager(AppName app) { + MonitorConfigurationManager mngr = null; + if (app == AppName.FOG) { + mngr = FogMonitorConfigurationManager.getInstance(); + } else if (app == AppName.SAFESEAS) { + mngr = SSMonitorConfigurationManager.getInstance(); + } else if (app == AppName.SNOW) { + mngr = SnowMonitorConfigurationManager.getInstance(); + } + return mngr; + } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewZoneDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewZoneDlg.java index 1ea7c8b880..d85858a9c0 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewZoneDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/AddNewZoneDlg.java @@ -26,9 +26,8 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; 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; @@ -37,236 +36,189 @@ import com.raytheon.uf.common.monitor.config.FogMonitorConfigurationManager; import com.raytheon.uf.common.monitor.config.MonitorConfigurationManager; import com.raytheon.uf.common.monitor.config.SSMonitorConfigurationManager; import com.raytheon.uf.common.monitor.config.SnowMonitorConfigurationManager; -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.viz.ui.dialogs.CaveSWTDialog; /** * Dialog to display the control for adding a new zone. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Apr 2, 2009            lvenable     Initial creation
- *
+ * Nov 20, 2012 1297      skorolev     Changes for non-blocking dialog.
+ * 
  * 
- * + * * @author lvenable * @version 1.0 */ -public class AddNewZoneDlg extends Dialog -{ - /** - * Dialog shell. - */ - private Shell shell; - - /** - * The display control. - */ - private Display display; - - /** - * Return value when the shell is disposed. - */ - private Boolean returnValue = false; - +public class AddNewZoneDlg extends CaveSWTDialog { + /** * Application name. */ - private CommonConfig.AppName appName; - + private AppName appName; + /** * Marine zone radio button. */ private Button marineZoneRdo; - + /** * County radio button. */ private Button countyRdo; - + /** * ID text control. */ private Text idTF; - + /** * Centroid latitude text control. */ private Text centroidLatTF; - + /** * Centroid longitude text control. */ private Text centroidLonTF; - - private Button marineRdo; - - private Button nonMarineRdo; - - private INewZoneStnAction macDlg; - + + /** + * Call back interface. + */ + private INewZoneStnAction macDlg; + + /** + * Area configuration manager. + */ + private MonitorConfigurationManager configMan; + /** * Constructor. - * @param parent Parent shell. - * @param appName Application name. + * + * @param parent + * Parent shell. + * @param appName + * Application name. */ - public AddNewZoneDlg(Shell parent, CommonConfig.AppName appName, INewZoneStnAction macDlg) - { - super(parent, 0); - + public AddNewZoneDlg(Shell parent, AppName appName, INewZoneStnAction macDlg) { + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); + setText(appName.toString() + ": Add a New Zone to Monitor Area."); this.appName = appName; this.macDlg = macDlg; + configMan = getConfigManager(appName); } - - /** - * Open method used to display the dialog. - * @return True/False. + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() */ - public Object open() - { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - shell.setText("Add a New Zone"); - - // Create the main layout for the shell. + @Override + protected Layout constructShellLayout() { GridLayout mainLayout = new GridLayout(1, false); mainLayout.marginHeight = 2; mainLayout.marginWidth = 2; mainLayout.verticalSpacing = 2; - shell.setLayout(mainLayout); - - // Initialize all of the controls and layouts - initializeComponents(); - - shell.pack(); - - shell.open(); - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - - return returnValue; + return mainLayout; } - - /** - * Initialize the components on the display. + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) */ - private void initializeComponents() - { - if (appName != CommonConfig.AppName.SNOW) - { + @Override + protected void initializeComponents(Shell shell) { + setReturnValue(false); + if (appName != AppName.SNOW) { createTopZoneCountyControls(); - } - else - { + } else { createCountyZoneLabels(); } - createTextControls(); createBottomButtons(); } - + /** - * Create the top zone county controls. + * Creates the top zone county controls. */ - private void createTopZoneCountyControls() - { + private void createTopZoneCountyControls() { Composite topComp = new Composite(shell, SWT.NONE); topComp.setLayout(new GridLayout(2, true)); topComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - /* * Add the label. */ Label topLbl = new Label(topComp, SWT.RIGHT); topLbl.setText("Please type in a new: "); topLbl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true)); - /* * 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"); } - + /** - * Create the county zone labels. + * Creates the county zone labels. */ - private void createCountyZoneLabels() - { + private void createCountyZoneLabels() { Composite labelComp = new Composite(shell, SWT.NONE); labelComp.setLayout(new GridLayout(1, false)); - labelComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - + labelComp + .setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); Label topLbl = new Label(labelComp, SWT.CENTER); topLbl.setText("Please type in a new county/zone"); topLbl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); } - + /** - * Create the text controls. + * Creates the text controls. */ - private void createTextControls() - { + private void createTextControls() { Composite textComp = new Composite(shell, SWT.NONE); GridLayout gl = new GridLayout(2, false); gl.verticalSpacing = 10; textComp.setLayout(gl); textComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - + GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, true); Label idLbl = new Label(textComp, SWT.RIGHT); idLbl.setText("Id (e.g. AMZ080):"); idLbl.setLayoutData(gd); - + idTF = new Text(textComp, SWT.BORDER); idTF.setLayoutData(new GridData(120, SWT.DEFAULT)); - + gd = new GridData(SWT.FILL, SWT.CENTER, true, true); Label centroidLatLbl = new Label(textComp, SWT.RIGHT); centroidLatLbl.setText("Centroid Lat (e.g. 29.198):"); centroidLatLbl.setLayoutData(gd); - + centroidLatTF = new Text(textComp, SWT.BORDER); centroidLatTF.setLayoutData(new GridData(120, SWT.DEFAULT)); - + gd = new GridData(SWT.FILL, SWT.CENTER, true, true); Label centroidLonLbl = new Label(textComp, SWT.RIGHT); centroidLonLbl.setText("Centroid Lon (e.g. -71.75):"); centroidLonLbl.setLayoutData(gd); - + centroidLonTF = new Text(textComp, SWT.BORDER); centroidLonTF.setLayoutData(new GridData(120, SWT.DEFAULT)); - - - // gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - // marineRdo = new Button(textComp, SWT.RADIO); - // marineRdo.setLayoutData(gd); - // marineRdo.setSelection(false); - // marineRdo.setText("Marine Station"); - // - // gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - // nonMarineRdo = new Button(textComp, SWT.RADIO); - // nonMarineRdo.setLayoutData(gd); - // nonMarineRdo.setSelection(true); - // nonMarineRdo.setText("Non-Marine Station"); - /* * Create the Use Decimal label. */ @@ -276,113 +228,132 @@ public class AddNewZoneDlg extends Dialog useDecimalLbl.setText("Use Decimal Degrees, West Longitude negative"); useDecimalLbl.setLayoutData(gd); } - + /** - * Create the bottom Add and Close buttons. + * Creates the bottom Add and Close buttons. */ - private void createBottomButtons() - { + private void createBottomButtons() { GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); Composite mainButtonComp = new Composite(shell, SWT.NONE); mainButtonComp.setLayout(new GridLayout(1, false)); mainButtonComp.setLayoutData(gd); - + // Add a separator label. Label sepLbl = new Label(mainButtonComp, SWT.SEPARATOR | SWT.HORIZONTAL); sepLbl.setLayoutData(gd); - + gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false); Composite buttonComp = new Composite(shell, SWT.NONE); buttonComp.setLayout(new GridLayout(2, false)); buttonComp.setLayoutData(gd); - + gd = new GridData(100, SWT.DEFAULT); Button addBtn = new Button(buttonComp, SWT.PUSH); addBtn.setText("Add"); addBtn.setLayoutData(gd); - addBtn.addSelectionListener(new SelectionAdapter() - { + addBtn.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { - String latString = centroidLatTF.getText(); + public void widgetSelected(SelectionEvent event) { + String latString = centroidLatTF.getText(); String lonString = centroidLonTF.getText(); - - if (((latString != null) && (latString.length() > 0)) && - (lonString != null) && (lonString.length() > 0)) { - double lat; - double lon; - try { - lat = Double.parseDouble(latString); - lon = Double.parseDouble(lonString); - - handleAddNewAction(lat, lon); - } catch (NumberFormatException e) { - MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK); - messageBox.setText("Invalid Lat/Lon"); - messageBox.setMessage("Invalid Lat/Lon entered. Please enter correctly formatted Lat/Lon values"); - messageBox.open(); - } - - //shell.dispose(); - } else { - MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK); - messageBox.setText("Invalid Lat/Lon"); - messageBox.setMessage("Invalid Lat/Lon entered. Please enter correctly formatted Lat/Lon values"); - messageBox.open(); - } + handleAddNewAction(latString, lonString); } }); - + gd = new GridData(100, SWT.DEFAULT); Button closeBtn = new Button(buttonComp, SWT.PUSH); closeBtn.setText("Close"); closeBtn.setLayoutData(gd); - closeBtn.addSelectionListener(new SelectionAdapter() - { + closeBtn.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { - shell.dispose(); + public void widgetSelected(SelectionEvent event) { + setReturnValue(true); + close(); } }); } - - private void handleAddNewAction(double lat, double lon) { - String areaId = idTF.getText(); - if ( areaId.length() != 6 || (areaId.charAt(2) != 'C' && areaId.charAt(2) != 'Z') ) { - displayInputErrorMsg("Invalid Area ID entered. Please enter a correctly formatted Area ID"); - return; - } - if ( macDlg.isExistingZone(areaId) ) { - displayInputErrorMsg("The Area ID, " + areaId + ", is already in your Monitoring Area or among your Additional Zones"); - return; - } - - ZoneType type = ZoneType.REGULAR; - if (marineRdo.getSelection()) { - type = ZoneType.MARITIME; - } - MonitorConfigurationManager configManager = null; - if ( appName == CommonConfig.AppName.FOG ) { - configManager = FogMonitorConfigurationManager.getInstance(); - } else if ( appName == CommonConfig.AppName.SAFESEAS ) { - configManager = SSMonitorConfigurationManager.getInstance(); - } else if ( appName == CommonConfig.AppName.SNOW ) { - configManager = SnowMonitorConfigurationManager.getInstance(); - } else { - return; + /** + * Adds a new zone. + * + * @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 entered. Please enter a correctly formatted Area ID"); + return; + } + if (macDlg.isExistingZone(areaId)) { + 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()) { + MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION + | SWT.OK); + messageBox.setText("Invalid Lat/Lon"); + messageBox + .setMessage("Invalid Lat/Lon entered. Please enter correctly formatted Lat and Lon values"); + messageBox.open(); + return; + } 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; + } + } + configMan.addArea(areaId, lat, lon, type, false); + macDlg.addNewZoneAction(areaId, centroidLatTF.getText(), + centroidLonTF.getText()); + } catch (NumberFormatException e) { + MessageBox messageBox = new MessageBox(shell, + SWT.ICON_INFORMATION | SWT.OK); + messageBox.setText("Invalid Lat/Lon"); + messageBox + .setMessage("Invalid Lat/Lon entered. Please enter correctly formatted Lat and Lon values"); + messageBox.open(); + return; + } } - configManager.addArea(areaId, lat, lon, type, false); - macDlg.addNewZoneAction(areaId, centroidLatTF.getText(), centroidLonTF.getText()); - } - private void displayInputErrorMsg(String msg) { - MessageBox messageBox = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK); + /** + * 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(); - } + } + + /** + * Gets Configuration Manager. + * + * @param app + * @return manager + */ + private MonitorConfigurationManager getConfigManager(AppName app) { + MonitorConfigurationManager mngr = null; + if (app == AppName.FOG) { + mngr = FogMonitorConfigurationManager.getInstance(); + } else if (app == AppName.SAFESEAS) { + mngr = SSMonitorConfigurationManager.getInstance(); + } else if (app == AppName.SNOW) { + mngr = SnowMonitorConfigurationManager.getInstance(); + } + return mngr; + } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/DeleteStationDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/DeleteStationDlg.java index 30ea066ed4..380ba8b80c 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/DeleteStationDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/DeleteStationDlg.java @@ -19,8 +19,6 @@ **/ 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; @@ -29,137 +27,105 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.monitor.config.FogMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.config.MonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.SSMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.SnowMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; +import com.raytheon.viz.ui.dialogs.CaveSWTDialog; /** * Dialog for deleting stations. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Apr 2, 2009            lvenable     Initial creation
- *
+ * Nov 20, 2012 1297      skorolev     Changes for non-blocking dialog.
+ * 
  * 
- * + * * @author lvenable * @version 1.0 */ -public class DeleteStationDlg extends Dialog -{ - /** - * Dialog shell. - */ - private Shell shell; - - /** - * The display control. - */ - private Display display; - - /** - * Return value when the shell is disposed. - */ - private Boolean returnValue = false; - - /** - * Dialog title. - */ - private String dialogTitle; - +public class DeleteStationDlg extends CaveSWTDialog { + /** * Station list control. */ private List stationList; - + /** * Control font. */ private Font controlFont; - + + /** + * Area configuration manager. + */ + private MonitorConfigurationManager configMan; + /** * Constructor. - * @param parent Parent shell. - * @param appName Application name. + * + * @param parent + * Parent shell. + * @param appName + * Application name. */ - public DeleteStationDlg(Shell parent, CommonConfig.AppName appName) - { - super(parent, 0); - - dialogTitle = appName.toString() + ": Delete a Newly Entered Station"; + public DeleteStationDlg(Shell parent, AppName appName) { + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); + setText(appName.toString() + ": Delete a Newly Entered Station"); + configMan = getConfigManager(appName); } - - /** - * Open method used to display the dialog. - * @return True/False. + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() */ - public Object open() - { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - shell.setText(dialogTitle); - - // Create the main layout for the shell. + @Override + protected Layout constructShellLayout() { GridLayout mainLayout = new GridLayout(1, false); mainLayout.marginHeight = 2; mainLayout.marginWidth = 2; mainLayout.verticalSpacing = 2; shell.setLayout(mainLayout); - - // Initialize all of the controls and layouts - initializeComponents(); - - populate(); - - shell.pack(); - - shell.open(); - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - - controlFont.dispose(); - - return returnValue; + return mainLayout; } - - /** - * Initialize the components on the display. + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) */ - private void initializeComponents() - { + @Override + protected void initializeComponents(Shell shell) { + setReturnValue(false); controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); - createListControl(); - createBottomButtons(); + populate(); } - + /** * Create the list control. */ - private void createListControl() - { + private void createListControl() { Composite listComp = new Composite(shell, SWT.NONE); listComp.setLayout(new GridLayout(1, false)); - Label stationLbl = new Label(listComp, SWT.NONE); stationLbl.setText("Available Stations to delete:"); - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.widthHint = 350; gd.heightHint = 250; @@ -167,62 +133,92 @@ public class DeleteStationDlg extends Dialog stationList.setFont(controlFont); stationList.setLayoutData(gd); } - + /** * Create the Delete Station and Close buttons. */ - private void createBottomButtons() - { + private void createBottomButtons() { GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); Composite mainButtonComp = new Composite(shell, SWT.NONE); mainButtonComp.setLayout(new GridLayout(1, false)); mainButtonComp.setLayoutData(gd); - + gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false); Composite buttonComp = new Composite(shell, SWT.NONE); buttonComp.setLayout(new GridLayout(2, false)); buttonComp.setLayoutData(gd); - + gd = new GridData(120, SWT.DEFAULT); Button deleteBtn = new Button(buttonComp, SWT.PUSH); deleteBtn.setText("Delete Station"); deleteBtn.setLayoutData(gd); - deleteBtn.addSelectionListener(new SelectionAdapter() - { + deleteBtn.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { + public void widgetSelected(SelectionEvent event) { deleteSelected(); } }); - + gd = new GridData(120, SWT.DEFAULT); Button closeBtn = new Button(buttonComp, SWT.PUSH); closeBtn.setText("Close"); closeBtn.setLayoutData(gd); - closeBtn.addSelectionListener(new SelectionAdapter() - { + closeBtn.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { - shell.dispose(); + public void widgetSelected(SelectionEvent event) { + setReturnValue(true); + close(); } }); } - + + /** + * Populate list of added stations. + */ private void populate() { - FogMonitorConfigurationManager configMan = FogMonitorConfigurationManager.getInstance(); - - ArrayList addedStations = configMan.getAddedStations(); - stationList.setItems(addedStations.toArray(new String[addedStations.size()])); + java.util.List addedStations = configMan.getAddedStations(); + stationList.setItems(addedStations.toArray(new String[addedStations + .size()])); } - + + /** + * Delete stations from the list. + */ private void deleteSelected() { - FogMonitorConfigurationManager configMan = FogMonitorConfigurationManager.getInstance(); - - String selection = stationList.getItem(stationList.getSelectionIndex()); - - configMan.removeStation(selection); - stationList.remove(stationList.getSelectionIndex()); + if (stationList.getItemCount() != 0) { + String selection = stationList.getItem(stationList + .getSelectionIndex()); + configMan.removeStation(selection); + stationList.remove(stationList.getSelectionIndex()); + populate(); + } + } + + /** + * Gets Configuration Manager. + * + * @param app + * @return manager + */ + private MonitorConfigurationManager getConfigManager(AppName app) { + MonitorConfigurationManager mngr = null; + if (app == AppName.FOG) { + mngr = FogMonitorConfigurationManager.getInstance(); + } else if (app == AppName.SAFESEAS) { + mngr = SSMonitorConfigurationManager.getInstance(); + } else if (app == AppName.SNOW) { + mngr = SnowMonitorConfigurationManager.getInstance(); + } + return mngr; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() + */ + @Override + protected void disposed() { + controlFont.dispose(); } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/EditNewZoneDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/EditNewZoneDlg.java index ab18f8b68b..7dbe5dc72a 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/EditNewZoneDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/EditNewZoneDlg.java @@ -19,8 +19,6 @@ **/ 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; @@ -29,189 +27,162 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.monitor.config.FogMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.config.MonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.SSMonitorConfigurationManager; +import com.raytheon.uf.common.monitor.config.SnowMonitorConfigurationManager; +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.viz.ui.dialogs.CaveSWTDialog; /** * Dialog for editing new zones. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Apr 2, 2009            lvenable     Initial creation
- *
+ * Nov 20, 2012 1297      skorolev     Changes for non-blocking dialog.
+ * 
  * 
- * + * * @author lvenable * @version 1.0 */ -public class EditNewZoneDlg extends Dialog -{ - /** - * Dialog shell. - */ - private Shell shell; - - /** - * The display control. - */ - private Display display; - - /** - * Return value when the shell is disposed. - */ - private Boolean returnValue = false; - - /** - * Dialog title. - */ - private String dialogTitle; - +public class EditNewZoneDlg extends CaveSWTDialog { /** * Zone list control. */ private List zoneList; - + /** * ID text control. */ private Text idTF; - + /** * Latitude text control. */ private Text latTF; - + /** * Longitude text control. */ private Text lonTF; - + /** * Save button. */ private Button saveBtn; - + /** * Delete button. */ private Button deleteBtn; - + /** * Control font. */ private Font controlFont; - + + /** + * Marine station radio button. + */ private Button marineRdo; - + + /** + * None Marine station radio button. + */ private Button nonMarineRdo; /** - * Constructor. - * @param parent Parent shell. - * @param appName Application name. + * Area configuration manager. */ - public EditNewZoneDlg(Shell parent, CommonConfig.AppName appName) - { - super(parent, 0); - - dialogTitle = appName.toString() + ": Edit a Newly Added Zone"; - } - + private MonitorConfigurationManager configMan; + /** - * Open method used to display the dialog. - * @return True/False. + * Bottom label */ - public Object open() - { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - shell.setText(dialogTitle); - - // Create the main layout for the shell. + private Label bottomLbl; + + /** + * Constructor. + * + * @param parent + * Parent shell. + * @param appName + * Application name. + */ + public EditNewZoneDlg(Shell parent, AppName appName) { + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); + setText(appName.toString() + ": Edit a Newly Added Zone"); + configMan = this.getConfigManager(appName); + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ + @Override + protected Layout constructShellLayout() { GridLayout mainLayout = new GridLayout(1, false); mainLayout.marginHeight = 2; mainLayout.marginWidth = 2; mainLayout.verticalSpacing = 2; - shell.setLayout(mainLayout); - - // Initialize all of the controls and layouts - initializeComponents(); - - populate(); - - shell.pack(); - - shell.open(); - while (!shell.isDisposed()) - { - if (!display.readAndDispatch()) - { - display.sleep(); - } - } - - controlFont.dispose(); - - return returnValue; + return mainLayout; } - - /** - * Initialize the components on the display. + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) */ - private void initializeComponents() - { + @Override + protected void initializeComponents(Shell shell) { + setReturnValue(false); controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); - createTopLabel(); - createListAndTextControls(); - createBottomLabel(); - createCloseButton(); + populate(); } - + /** * Create the top label. */ - private void createTopLabel() - { + private void createTopLabel() { Composite labelComp = new Composite(shell, SWT.NONE); labelComp.setLayout(new GridLayout(1, false)); - labelComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - + labelComp + .setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); Label topLbl = new Label(labelComp, SWT.CENTER); topLbl.setText("Select Zone from the list box to edit"); topLbl.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); } - + /** * Create the list and text controls. */ - private void createListAndTextControls() - { + private void createListAndTextControls() { Composite mainComp = new Composite(shell, SWT.NONE); GridLayout gl = new GridLayout(2, false); gl.horizontalSpacing = 10; mainComp.setLayout(gl); - - /* - * Add the Zone list control - */ + // Add the Zone list control GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.widthHint = 185; gd.heightHint = 220; @@ -219,60 +190,59 @@ public class EditNewZoneDlg extends Dialog zoneList.setFont(controlFont); zoneList.setLayoutData(gd); zoneList.addSelectionListener(new SelectionAdapter() { - - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) + /* + * (non-Javadoc) + * + * @see + * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse + * .swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent e) { handleZoneSelection(); } - }); - - /* - * Add the text controls and the Save/Delete buttons - */ + // Add the text controls and the Save/Delete buttons Composite textButtonComp = new Composite(mainComp, SWT.NONE); textButtonComp.setLayout(new GridLayout(2, true)); - + int textWidth = 200; - + gd = new GridData(); gd.horizontalSpan = 2; Label idLbl = new Label(textButtonComp, SWT.NONE); idLbl.setText("Id:"); idLbl.setLayoutData(gd); - + gd = new GridData(textWidth, SWT.DEFAULT); gd.horizontalSpan = 2; idTF = new Text(textButtonComp, SWT.BORDER); idTF.setLayoutData(gd); - + gd = new GridData(); gd.horizontalSpan = 2; gd.verticalIndent = 5; Label latLbl = new Label(textButtonComp, SWT.NONE); latLbl.setText("Lat:"); latLbl.setLayoutData(gd); - + gd = new GridData(textWidth, SWT.DEFAULT); gd.horizontalSpan = 2; latTF = new Text(textButtonComp, SWT.BORDER); latTF.setLayoutData(gd); - + gd = new GridData(); gd.horizontalSpan = 2; gd.verticalIndent = 5; Label lonLbl = new Label(textButtonComp, SWT.NONE); lonLbl.setText("Lon:"); lonLbl.setLayoutData(gd); - + gd = new GridData(textWidth, SWT.DEFAULT); gd.horizontalSpan = 2; lonTF = new Text(textButtonComp, SWT.BORDER); lonTF.setLayoutData(gd); - + gd = new GridData(); gd.horizontalSpan = 2; gd.verticalIndent = 15; @@ -280,7 +250,7 @@ public class EditNewZoneDlg extends Dialog marineRdo.setLayoutData(gd); marineRdo.setSelection(false); marineRdo.setText("Marine Station"); - + gd = new GridData(); gd.horizontalSpan = 2; nonMarineRdo = new Button(textButtonComp, SWT.RADIO); @@ -288,136 +258,176 @@ public class EditNewZoneDlg extends Dialog nonMarineRdo.setSelection(true); nonMarineRdo.setText("Non-Marine Station"); - gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, true); gd.widthHint = 80; gd.verticalIndent = 5; saveBtn = new Button(textButtonComp, SWT.PUSH); saveBtn.setText("Save"); saveBtn.setLayoutData(gd); - saveBtn.addSelectionListener(new SelectionAdapter() - { + saveBtn.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { + public void widgetSelected(SelectionEvent event) { saveSelected(); } }); - gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, true); gd.widthHint = 80; gd.verticalIndent = 5; deleteBtn = new Button(textButtonComp, SWT.PUSH); deleteBtn.setText("Delete"); deleteBtn.setLayoutData(gd); - deleteBtn.addSelectionListener(new SelectionAdapter() - { + deleteBtn.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { - deleteSelected(); + public void widgetSelected(SelectionEvent event) { + deleteSelected(); } }); } - + /** * Create the bottom label centroid label. */ - private void createBottomLabel() - { + private void createBottomLabel() { Composite labelComp = new Composite(shell, SWT.NONE); labelComp.setLayout(new GridLayout(1, false)); - labelComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - - Label bottomLbl = new Label(labelComp, SWT.NONE); - bottomLbl.setText("Centriod Lat/Lon use Decimal Degrees, West Longitude negative"); + labelComp + .setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); + bottomLbl = new Label(labelComp, SWT.NONE); + bottomLbl + .setText("Centriod Lat/Lon use Decimal Degrees, West Longitude negative"); } - + /** * Create the Close button. */ - private void createCloseButton() - { + private void createCloseButton() { GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); Composite buttonComp = new Composite(shell, SWT.NONE); buttonComp.setLayout(new GridLayout(1, false)); buttonComp.setLayoutData(gd); - // Add a separator label. Label sepLbl = new Label(buttonComp, SWT.SEPARATOR | SWT.HORIZONTAL); sepLbl.setLayoutData(gd); - gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false); gd.widthHint = 100; Button closeBtn = new Button(buttonComp, SWT.PUSH); closeBtn.setText("Close"); closeBtn.setLayoutData(gd); - closeBtn.addSelectionListener(new SelectionAdapter() - { + closeBtn.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected(SelectionEvent event) - { - shell.dispose(); + public void widgetSelected(SelectionEvent event) { + setReturnValue(true); + close(); } - }); + }); } - + + /** + * Populate list of added zones. + */ private void populate() { - FogMonitorConfigurationManager configMan = FogMonitorConfigurationManager.getInstance(); - - ArrayList newList = configMan.getAddedZones(); + java.util.List newList = configMan.getAddedZones(); zoneList.setItems(newList.toArray(new String[newList.size()])); } - - private void handleZoneSelection() { - FogMonitorConfigurationManager configMan = FogMonitorConfigurationManager.getInstance(); - String zone = zoneList.getItem(zoneList.getSelectionIndex()); + /** + * Zone selection + */ + private void handleZoneSelection() { + String zone = zoneList.getItem(zoneList.getSelectionIndex()); AreaIdXML areaXml = configMan.getAreaXml(zone); - // DR #7343: a null areaXml causes an "Unhandled event loop exception" - if ( areaXml != null ) { + if (areaXml != null) { idTF.setText(areaXml.getAreaId()); 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); - } + } } } - - private void deleteSelected() { - FogMonitorConfigurationManager configMan = FogMonitorConfigurationManager.getInstance(); - String area = zoneList.getItem(zoneList.getSelectionIndex()); - zoneList.remove(zoneList.getSelectionIndex()); - - configMan.removeArea(area); - idTF.setText(""); - latTF.setText(""); - lonTF.setText(""); - } - - private void saveSelected() { - FogMonitorConfigurationManager configMan = FogMonitorConfigurationManager.getInstance(); - String area = zoneList.getItem(zoneList.getSelectionIndex()); - double lat = Double.parseDouble(latTF.getText()); - double lon = Double.parseDouble(lonTF.getText()); - - ZoneType type = ZoneType.REGULAR; - if (marineRdo.getSelection()) { - type = ZoneType.MARITIME; + /** + * Delete selected zones. + */ + // TODO: Delete zone from left list in the Area Configuration dialog. + private void deleteSelected() { + if (zoneList.getItemCount() != 0) { + String area = zoneList.getItem(zoneList.getSelectionIndex()); + zoneList.remove(zoneList.getSelectionIndex()); + configMan.removeArea(area); + idTF.setText(""); + latTF.setText(""); + lonTF.setText(""); + } else { + bottomLbl.setText("No zones have been added."); } - - configMan.removeArea(area); - - configMan.removeAddedArea(area); - - configMan.addArea(idTF.getText(), lat, lon, type, false); } + + /** + * Save selected zones. + */ + private void saveSelected() { + + if (zoneList.getItemCount() != 0) { + String area = zoneList.getItem(zoneList.getSelectionIndex()); + double lat; + if (!latTF.getText().isEmpty()) { + lat = Double.parseDouble(latTF.getText()); + } else { + // wrong value will be filtered when save + lat = 9999.0; + } + double lon; + if (!lonTF.getText().isEmpty()) { + lon = Double.parseDouble(lonTF.getText()); + } else { + // wrong value will be filtered when save + lon = 9999.0; + } + ZoneType type = ZoneType.REGULAR; + if (marineRdo.getSelection()) { + type = ZoneType.MARITIME; + } + configMan.removeArea(area); + configMan.removeAddedArea(area); + configMan.addArea(idTF.getText(), lat, lon, type, false); + populate(); + } else { + bottomLbl.setText("No zones have been added."); + } + } + + /** + * Gets Configuration Manager. + * + * @param app + * @return manager + */ + private MonitorConfigurationManager getConfigManager(AppName app) { + MonitorConfigurationManager mngr = null; + if (app == AppName.FOG) { + mngr = FogMonitorConfigurationManager.getInstance(); + } else if (app == AppName.SAFESEAS) { + mngr = SSMonitorConfigurationManager.getInstance(); + } else if (app == AppName.SNOW) { + mngr = SnowMonitorConfigurationManager.getInstance(); + } + return mngr; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() + */ + @Override + protected void disposed() { + controlFont.dispose(); + } + } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java index 413f94fc65..5b4842ab8f 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/MonitoringAreaConfigDlg.java @@ -26,8 +26,6 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.ShellAdapter; -import org.eclipse.swt.events.ShellEvent; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; @@ -35,27 +33,28 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Dialog; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Scale; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import com.raytheon.uf.common.site.SiteMap; -import com.raytheon.uf.common.monitor.MonitorAreaUtils; + import com.raytheon.uf.common.monitor.config.FogMonitorConfigurationManager; import com.raytheon.uf.common.monitor.config.MonitorConfigurationManager; import com.raytheon.uf.common.monitor.config.SSMonitorConfigurationManager; import com.raytheon.uf.common.monitor.config.SnowMonitorConfigurationManager; -import com.raytheon.uf.common.monitor.data.AdjacentWfoMgr; 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; import com.raytheon.uf.common.monitor.xml.AreaIdXML.ZoneType; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.localization.LocalizationManager; import com.raytheon.uf.viz.monitor.Activator; +import com.raytheon.viz.ui.dialogs.CaveSWTDialog; +import com.raytheon.viz.ui.dialogs.ICloseCallback; /** * Monitoring area configuration dialog. @@ -69,1400 +68,1313 @@ import com.raytheon.uf.viz.monitor.Activator; * Jun 24, 2010 5885/5886 zhao added initZoneStationLists(), * and revised accordingly * Apr 29, 2011 DR#8986 zhao Read in "Counties" instead of "Forecast Zones" - * Feb 22, 2012 14413 zhao modified to reduce calls to database + * Feb 22, 2012 14413 zhao modified to reduce calls to database + * Nov 16, 2012 1297 skorolev Changes for non-blocking dialog. * * * * @author lvenable * @version 1.0 */ -public abstract class MonitoringAreaConfigDlg extends Dialog implements INewZoneStnAction { - /** - * Dialog shell. - */ - protected Shell shell; - - /** - * The display control. - */ - private Display display; - - /** - * Return value when the shell is disposed. - */ - private Boolean returnValue = false; - - /** - * Dialog title. - */ - private String dialogTitle; - - /** - * Zone radio button. - */ - private Button zoneRdo; - - /** - * Station radio button. - */ - private Button stationRdo; - - /** - * Selected Zone text control. - */ - private Text selectedStnZoneTF; - - /** - * Monitor Area label. - */ - private Label montiorAreaLbl; - - /** - * Monitor area list control. - */ - private List monitorAreaList; - - /** - * Associated label. - */ - private Label associatedLbl; - - /** - * Associated list control. - */ - private List associatedList; - - /** - * Additional label. - */ - private Label additionalLbl; - - /** - * Additional list control. - */ - private List additionalList; - - /** - * MA radio button. - */ - private Button maRdo; - - /** - * Regional Stations radio button. - */ - private Button regionalRdo; - - /** - * MA regional list control. - */ - private List maRegionalList; - - /** - * Add New button. - */ - private Button addNewBtn; - - /** - * Edit/Delete button. - */ - private Button editDeleteBtn; - - /** - * Time scale control. - */ - protected Scale timeScale; - - /** - * Time scale label to display the value set by the time scale. - */ - private Label timeScaleLbl; - - /** - * Distance scale. - */ - protected Scale distanceScale; - - /** - * Distance scale label to display the value set by the distance scale. - */ - private Label distanceScaleLBl; - - /** - * Monitor area Add button. - */ - private Button monAreaAddBtn; - - /** - * Monitor area Remove button. - */ - private Button monAreaRemoveBtn; - - /** - * Associated Add button. - */ - private Button assocAddBtn; - - /** - * Associated Remove button. - */ - private Button assocRemoveBtn; - - /** - * Arrow up image. - */ - private Image arrowUpImg; - - /** - * Arrow down image. - */ - private Image arrowDownImg; - - /** - * Fog check button. - */ - protected Button fogChk; - - /** - * Control font. - */ - private Font controlFont; - - /** - * Application name. - */ - private CommonConfig.AppName appName; - - /** - * The current site. - */ - protected String currentSite = null; - - private Cursor waitCursor = null; - - private Cursor arrowCursor = null; - - /** - * monitor area zones/stations; and additional zones/stations in the region - */ - private ArrayList maZones = null; - private ArrayList maStations = null; - private ArrayList additionalZones = null; - private ArrayList additionalStns = null; - - private MonitorConfigurationManager configMgr = null; - - private Mode mode = Mode.Zone; - - protected ArrayList addedZones = new ArrayList(); - - private static enum Mode { - Zone, Station - }; - - /** - * Constructor. - * - * @param parent - * Parent shell. - * @param title - * Dialog title. - * @param appName - * Application name. - */ - public MonitoringAreaConfigDlg(Shell parent, String title, - CommonConfig.AppName appName) { - super(parent, 0); - - dialogTitle = title; - this.appName = appName; - currentSite = LocalizationManager.getInstance().getCurrentSite(); - waitCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT); - arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW); - } - - /** - * Initialize maZones/Stations and additionalZones/Stations - */ - private void initZoneStationLists() { - - /** - * (1) set monitor area zones - */ - maZones = configMgr.getAreaList(); - - Collections.sort(maZones); - - /** - * (2) set monitor area stations - */ - maStations = new ArrayList(); - try { - for (String zone : maZones) { - ArrayList stns = configMgr - .getAreaStationsWithType(zone); - for (String stn : stns) { - if (!maStations.contains(stn)) { - maStations.add(stn); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - - Collections.sort(maStations); - - /** - * (3) set additional zones in the neighborhood of the monitor area - */ - additionalZones = configMgr.getAdjacentAreaList(); //adjMgr.getAdjZones(); - - Collections.sort(additionalZones); - - /** - * (4) set additional stations - */ - additionalStns = new ArrayList(); - try { - for (String zone : additionalZones) { - ArrayList stns = configMgr.getAdjacentAreaStationsWithType(zone); - for (String stn : stns) { - if (!additionalStns.contains(stn)) { - additionalStns.add(stn); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - - Collections.sort(additionalStns); - - } - - /** - * Open method used to display the dialog. - * - * @return True/False. - */ - public Object open() { - Shell parent = getParent(); - display = parent.getDisplay(); - shell = new Shell(parent, SWT.DIALOG_TRIM); - - if (dialogTitle == null) { - shell.setText("Monitoring Area Configuraton"); - } else { - shell.setText(dialogTitle); - } - - // Create the main layout for the shell. - GridLayout mainLayout = new GridLayout(1, false); - mainLayout.marginHeight = 1; - mainLayout.marginWidth = 1; - mainLayout.verticalSpacing = 1; - shell.setLayout(mainLayout); - - // Initialize the font and images - initFontAndImages(); - - // Initialize all of the controls and layouts - initComponents(); - - // set configuration and adjacent managers - configMgr = getConfigManager(); - - // initialize zone/station lists - initZoneStationLists(); - - // Populate the dialog - populateLeftLists(); - // populateRightLists(); // this is called from populateLeftLists() - setValues(); - - shell.addShellListener(new ShellAdapter() { - @Override - public void shellClosed(ShellEvent event) { - closeWithoutSave(); - } - }); - - shell.pack(); - - shell.open(); - - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) { - display.sleep(); - } - } - - controlFont.dispose(); - arrowUpImg.dispose(); - arrowDownImg.dispose(); - - return returnValue; - } - - /** - * Initialize the images and font. - */ - private void initFontAndImages() { - controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); - - ImageDescriptor id = Activator.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, "images/arrowDn.png"); - arrowDownImg = id.createImage(); - - id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, - "images/arrowUp.png"); - arrowUpImg = id.createImage(); - - // arrowUpImg = new Image(display, - // "/home/lvenable/DecisionAidTools/arrowUp.png"); - // arrowDownImg = new Image(display, - // "/home/lvenable/DecisionAidTools/arrowDn.png"); - } - - /** - * Initialize the components on the display. - */ - private void initComponents() { - Composite mainListComp = new Composite(shell, SWT.NONE); - mainListComp.setLayout(new GridLayout(2, false)); - mainListComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, - false)); - - createTopConfigControl(mainListComp); - - createLeftListsAndControls(mainListComp); - createRightListsAndControls(mainListComp); - - createBottomScaleControls(mainListComp); - - createBottomButtons(); - } - - /** - * Create the top configuration controls. - * - * @param parentComp - */ - private void createTopConfigControl(Composite parentComp) { - Composite radioComp = new Composite(parentComp, SWT.NONE); - radioComp.setLayout(new GridLayout(3, false)); - - Label configLbl = new Label(radioComp, SWT.NONE); - configLbl.setText("Configure: "); - - zoneRdo = new Button(radioComp, SWT.RADIO); - zoneRdo.setText("Zone"); - zoneRdo.setSelection(true); - zoneRdo.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - shell.setCursor(waitCursor); - mode = Mode.Zone; - changeZoneStationControls(); - populateLeftLists(); - shell.setCursor(arrowCursor); - } - }); - - stationRdo = new Button(radioComp, SWT.RADIO); - stationRdo.setText("Station"); - stationRdo.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - shell.setCursor(waitCursor); - mode = Mode.Station; - changeZoneStationControls(); - populateLeftLists(); - shell.setCursor(arrowCursor); - } - }); - - /* - * Create the Selected Area Zone/Station text control. - */ - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - selectedStnZoneTF = new Text(parentComp, SWT.BORDER); - selectedStnZoneTF.setEditable(false); - selectedStnZoneTF.setLayoutData(gd); - } - - /** - * Create the Monitor/Additional label and list controls. - * - * @param parentComp - * Parent composite. - */ - private void createLeftListsAndControls(Composite parentComp) { - Composite leftComp = new Composite(parentComp, SWT.NONE); - leftComp.setLayout(new GridLayout(2, true)); - leftComp - .setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - - /* - * Create the Monitor Area label and list control. - */ - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = 2; - montiorAreaLbl = new Label(leftComp, SWT.NONE); - montiorAreaLbl.setText("Monitor Area Zones:"); - montiorAreaLbl.setLayoutData(gd); - - gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.widthHint = 185; - gd.heightHint = 200; - gd.horizontalSpan = 2; - monitorAreaList = new List(leftComp, SWT.BORDER | SWT.SINGLE - | SWT.V_SCROLL); - monitorAreaList.setFont(controlFont); - monitorAreaList.setLayoutData(gd); - monitorAreaList.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - handleMonitorAreaListSelection(); - } - }); - - /* - * Create the Monitor Area Add and Remove buttons. - */ - gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.widthHint = 100; - monAreaAddBtn = new Button(leftComp, SWT.PUSH); - monAreaAddBtn.setText("Add"); - monAreaAddBtn.setImage(arrowUpImg); - monAreaAddBtn.setLayoutData(gd); - monAreaAddBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - addZoneStn(); - } - }); - - gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.widthHint = 100; - monAreaRemoveBtn = new Button(leftComp, SWT.PUSH); - monAreaRemoveBtn.setText("Remove"); - monAreaRemoveBtn.setImage(arrowDownImg); - monAreaRemoveBtn.setLayoutData(gd); - monAreaRemoveBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - removeZoneStn(); - } - }); - - /* - * Create the Additional label and list control. - */ - gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false); - gd.verticalIndent = 5; - gd.heightHint = 20; - gd.horizontalSpan = 2; - additionalLbl = new Label(leftComp, SWT.NONE); - additionalLbl.setText("Additional Zones:"); - additionalLbl.setLayoutData(gd); - - gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.widthHint = 185; - gd.heightHint = 200; - gd.horizontalSpan = 2; - additionalList = new List(leftComp, SWT.BORDER | SWT.SINGLE - | SWT.V_SCROLL); - additionalList.setFont(controlFont); - additionalList.setLayoutData(gd); - - /* - * Create the Add New Zone/Station button. - */ - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = 2; - addNewBtn = new Button(leftComp, SWT.PUSH); - addNewBtn.setText("Add a New Zone to Monitor Area..."); - addNewBtn.setLayoutData(gd); - addNewBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - handleAddNewAction(); - } - }); - } - - /** - * Create the Associated & MA/Regional labels and controls. - * - * @param parentComp - * Parent composite. - */ - private void createRightListsAndControls(Composite parentComp) { - Composite rightComp = new Composite(parentComp, SWT.NONE); - rightComp.setLayout(new GridLayout(2, true)); - rightComp - .setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - - /* - * Create the Associated label and list control. - */ - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = 2; - associatedLbl = new Label(rightComp, SWT.NONE); - associatedLbl.setText("Associated Stations:"); - associatedLbl.setLayoutData(gd); - - gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.widthHint = 185; - gd.heightHint = 200; - gd.horizontalSpan = 2; - associatedList = new List(rightComp, SWT.BORDER | SWT.SINGLE - | SWT.V_SCROLL); - associatedList.setFont(controlFont); - associatedList.setLayoutData(gd); - - /* - * Create the Monitor Area Add and Remove buttons. - */ - gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.widthHint = 100; - assocAddBtn = new Button(rightComp, SWT.PUSH); - assocAddBtn.setText("Add"); - assocAddBtn.setImage(arrowUpImg); - assocAddBtn.setLayoutData(gd); - assocAddBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - addAssociated(); - } - }); - - gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.widthHint = 100; - assocRemoveBtn = new Button(rightComp, SWT.PUSH); - assocRemoveBtn.setText("Remove"); - assocRemoveBtn.setImage(arrowDownImg); - assocRemoveBtn.setLayoutData(gd); - assocRemoveBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - removeAssociated(); - } - }); - - /* - * Create the Additional label and list control. - */ - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false); - gd.verticalIndent = 5; - gd.heightHint = 20; - gd.widthHint = 110; - maRdo = new Button(rightComp, SWT.RADIO); - maRdo.setText("MA Stns"); - maRdo.setSelection(true); - maRdo.setLayoutData(gd); - maRdo.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - shell.setCursor(waitCursor); - populateMaRegionalList(); - shell.setCursor(arrowCursor); - } - }); - - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false); - gd.verticalIndent = 5; - gd.heightHint = 20; - gd.widthHint = 130; - regionalRdo = new Button(rightComp, SWT.RADIO); - regionalRdo.setText("Regional Stns"); - regionalRdo.setLayoutData(gd); - regionalRdo.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - shell.setCursor(waitCursor); - populateMaRegionalList(); - shell.setCursor(arrowCursor); - } - }); - - gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.widthHint = 185; - gd.heightHint = 200; - gd.horizontalSpan = 2; - maRegionalList = new List(rightComp, SWT.BORDER | SWT.SINGLE - | SWT.V_SCROLL); - maRegionalList.setFont(controlFont); - maRegionalList.setLayoutData(gd); - - /* - * Create the Add New Zone/Station button. - */ - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = 2; - editDeleteBtn = new Button(rightComp, SWT.PUSH); - editDeleteBtn.setText("Edit a Newly added Zone..."); - editDeleteBtn.setLayoutData(gd); - editDeleteBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - handleEditDeleteAction(); - } - }); - } - - /** - * Create the bottom scale controls. - * - * @param parentComp - * Parent composite. - */ - private void createBottomScaleControls(Composite parentComp) { - addSeparator(parentComp); - - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = 2; - Composite scaleComp = new Composite(parentComp, SWT.NONE); - scaleComp.setLayout(new GridLayout(2, false)); - scaleComp.setLayoutData(gd); - - /* - * Create the Time Window controls. - */ - gd = new GridData(); - gd.horizontalSpan = 2; - Label timeLbl = new Label(scaleComp, SWT.NONE); - timeLbl.setText("Time window (hrs)"); - timeLbl.setLayoutData(gd); - - int max = (int) Math.round((8.00 - 0.25) / .05); - int defaultVal = (int) Math.round((2.00 - 0.25) / .05); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - timeScale = new Scale(scaleComp, SWT.HORIZONTAL); - timeScale.setMinimum(0); - timeScale.setMaximum(max); - timeScale.setSelection(defaultVal); - timeScale.setLayoutData(gd); - timeScale.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - setTimeScaleLabel(); - } - }); - - gd = new GridData(50, SWT.DEFAULT); - timeScaleLbl = new Label(scaleComp, SWT.NONE); - timeScaleLbl.setFont(controlFont); - timeScaleLbl.setLayoutData(gd); - - setTimeScaleLabel(); - - // If this is a snow dialog then return since we don't need to - // create the Ship Distance scale and Fog check controls. - if (appName == CommonConfig.AppName.SNOW) { - return; - } - - if (appName != AppName.SNOW) { - /* - * Create the Ship Distance controls. - */ - addSeparator(scaleComp); - - gd = new GridData(); - gd.horizontalSpan = 2; - Label distanceLbl = new Label(scaleComp, SWT.NONE); - distanceLbl.setText("Ship Distance (Nautical Miles):"); - distanceLbl.setLayoutData(gd); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - distanceScale = new Scale(scaleComp, SWT.HORIZONTAL); - distanceScale.setMinimum(0); - distanceScale.setMaximum(200); - distanceScale.setSelection(100); - distanceScale.setLayoutData(gd); - distanceScale.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - setShipDistScaleLabel(); - } - }); - - gd = new GridData(50, SWT.DEFAULT); - distanceScaleLBl = new Label(scaleComp, SWT.NONE); - distanceScaleLBl.setFont(controlFont); - distanceScaleLBl.setLayoutData(gd); - - setShipDistScaleLabel(); - - /* - * Create the Fog check box. - */ - addSeparator(scaleComp); - - gd = new GridData(); - gd.horizontalSpan = 2; - fogChk = new Button(scaleComp, SWT.CHECK); - setAlgorithmText(); - } - } - - /** - * Create the bottom OK/Cancel buttons. - */ - private void createBottomButtons() { - addSeparator(shell); - - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - Composite mainButtonComp = new Composite(shell, SWT.NONE); - mainButtonComp.setLayout(new GridLayout(1, false)); - mainButtonComp.setLayoutData(gd); - - gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false); - Composite buttonComp = new Composite(shell, SWT.NONE); - buttonComp.setLayout(new GridLayout(2, false)); - buttonComp.setLayoutData(gd); - - gd = new GridData(100, SWT.DEFAULT); - Button okBtn = new Button(buttonComp, SWT.PUSH); - okBtn.setText("OK"); - okBtn.setLayoutData(gd); - okBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - handleOkBtnSelection(); - } - }); - - gd = new GridData(100, SWT.DEFAULT); - Button cancelBtn = new Button(buttonComp, SWT.PUSH); - cancelBtn.setText("Cancel"); - cancelBtn.setLayoutData(gd); - cancelBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - closeWithoutSave(); - } - }); - } - - /** - * Add a separator bar to the display. - * - * @param parentComp - * Parent composite. - */ - private void addSeparator(Composite parentComp) { - GridLayout gl = (GridLayout) parentComp.getLayout(); - - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = gl.numColumns; - Label sepLbl = new Label(parentComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - } - - /** - * Round a value to the hundredths decimal place. - * - * @param val - * Value. - * @return Rounded value. - */ - private double roundToHundredths(double val) { - double roundedVal = 0.0; - - roundedVal = Math.round(val * 100) / 100.0; - - return roundedVal; - } - - /** - * Set the time scale label. - */ - private void setTimeScaleLabel() { - double val = timeScale.getSelection() * .05 + .25; - val = roundToHundredths(val); - timeScaleLbl.setText(String.format("%5.2f", val)); - } - - /** - * Set the ship distance scale label. - */ - private void setShipDistScaleLabel() { - distanceScaleLBl.setText(String.format("%5d", distanceScale - .getSelection())); - } - - /** - * Change the Zone and Station controls. - */ - private void changeZoneStationControls() { - if (mode == Mode.Zone) { - montiorAreaLbl.setText("Monitor Area Zones:"); - additionalLbl.setText("Additional Zones:"); - addNewBtn.setText("Add a New Zone to Monitor Area..."); - associatedLbl.setText("Associated Stations:"); - maRdo.setText("MA Stns"); - regionalRdo.setText("Regional Stns"); - editDeleteBtn.setText("Edit a Newly added Zone..."); - } else { - montiorAreaLbl.setText("Monitor Area Stations:"); - additionalLbl.setText("Additional Stations:"); - addNewBtn.setText("Add a New Stn to Monitor Area..."); - associatedLbl.setText("Associated Zones:"); - maRdo.setText("MA Zones"); - regionalRdo.setText("Regional Zones"); - editDeleteBtn.setText("Delete a Newly added Station..."); - } - } - - /** - * Handle the Add New button click. - */ - private void handleAddNewAction() { - if (zoneRdo.getSelection() == true) { - AddNewZoneDlg addNewZoneDlg = new AddNewZoneDlg(shell, appName, this); - addNewZoneDlg.open(); - } else { - if (associatedList.getSelectionIndex() == -1) { - associatedList.setSelection(0); - } - String area = associatedList.getItem(associatedList - .getSelectionIndex()); - AddNewStationDlg addNewStnDlg = new AddNewStationDlg(shell, - appName, area, this); - addNewStnDlg.open(); - } - - // Update the dialog - populateLeftLists(); - } - - /** - * Handle the Edit/Delete button click. - */ - private void handleEditDeleteAction() { - if (zoneRdo.getSelection() == true) { - EditNewZoneDlg editDlg = new EditNewZoneDlg(shell, appName); - editDlg.open(); - } else { - DeleteStationDlg deleteStnDlg = new DeleteStationDlg(shell, appName); - deleteStnDlg.open(); - } - - // update the dialog - populateLeftLists(); - } - - /** - * Populate the MA-Regional list box. - */ - private void populateMaRegionalList() { - - maRegionalList.removeAll(); - - if (mode == Mode.Zone) { - - if (maRdo.getSelection()) { - maRegionalList.setItems(maStations - .toArray(new String[maStations.size()])); - } else { - maRegionalList.setItems(additionalStns - .toArray(new String[additionalStns.size()])); - } - - } else { // Station Mode - - if (maRdo.getSelection()) { - maRegionalList.setItems(maZones.toArray(new String[maZones - .size()])); - } else { - maRegionalList.setItems(additionalZones - .toArray(new String[additionalZones.size()])); - } - - } - - } - - /** - * Populate the zone list boxes. - */ - private void populateLeftLists() { - - if (mode == Mode.Zone) { - - /** - * Zone Mode - */ - - Collections.sort(maZones); - monitorAreaList.setItems(maZones - .toArray(new String[maZones.size()])); - - Collections.sort(additionalZones); - additionalList.setItems(additionalZones - .toArray(new String[additionalZones.size()])); - - } else { - - /** - * Station Mode - */ - - Collections.sort(maStations); - monitorAreaList.setItems(maStations.toArray(new String[maStations - .size()])); - - Collections.sort(additionalStns); - additionalList.setItems(additionalStns - .toArray(new String[additionalStns.size()])); - - } - - if (monitorAreaList.getItemCount() > 0) { - - monitorAreaList.setSelection(0); - - handleMonitorAreaListSelection(); - } - } - - /** - * Set the slider values and the check box. - */ - private 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. - * - * @param shell - * The parent shell - * @param style - * The dialog style - * @param title - * The dialog title - * @param msg - * The dialog message - * @return The value representing the button clicked on the dialog - */ - protected int showMessage(Shell shell, int style, String title, String msg) { - MessageBox messageBox = new MessageBox(shell, style); - messageBox.setText(title); - messageBox.setMessage(msg); - return messageBox.open(); - } - - /** - * Add a zone or station to the monitoring area. - */ - private void addZoneStn() { - - if (additionalList.getSelectionCount() == 0) { - if (mode == Mode.Zone) { - showMessage(shell, SWT.ERROR, "Selection Needed", - "You must select a station first"); - } else { - showMessage(shell, SWT.ERROR, "Selection Needed", - "You must select a zone first"); - } - return; - } - - String entry = additionalList.getItem(additionalList - .getSelectionIndex()); - additionalList.remove(additionalList.getSelectionIndex()); - - if (mode == Mode.Zone) { - - maZones.add(entry); - Collections.sort(maZones); - monitorAreaList.setItems(maZones - .toArray(new String[maZones.size()])); - monitorAreaList.setSelection(maZones.indexOf(entry)); - handleMonitorAreaListSelection(); - - additionalZones.remove(entry); - - configMgr.addArea(entry, entry.charAt(2) == 'Z' ? ZoneType.MARITIME - : ZoneType.REGULAR); - - if (!addedZones.contains(entry)) { - addedZones.add(entry); - } - - } else { // Station mode - - maStations.add(entry); - Collections.sort(maStations); - monitorAreaList.setItems(maStations.toArray(new String[maStations - .size()])); - monitorAreaList.setSelection(maStations.indexOf(entry)); - handleMonitorAreaListSelection(); - - additionalStns.remove(entry); - - } - - } - - /** - * Remove a zone or station from the monitoring area. - */ - private void removeZoneStn() { - - if (monitorAreaList.getSelectionCount() == 0) { - if (mode == Mode.Zone) { - showMessage(shell, SWT.ERROR, "Selection Needed", - "You must select a station first"); - } else { - showMessage(shell, SWT.ERROR, "Selection Needed", - "You must select a zone first"); - } - return; - } - - String entry = monitorAreaList.getItem(monitorAreaList - .getSelectionIndex()); - monitorAreaList.remove(monitorAreaList.getSelectionIndex()); - associatedList.removeAll(); - - if (mode == Mode.Zone) { - - additionalZones.add(entry); - Collections.sort(additionalZones); - additionalList.setItems(additionalZones - .toArray(new String[additionalZones.size()])); - additionalList.setSelection(additionalZones.indexOf(entry)); - maZones.remove(entry); - - configMgr.removeArea(entry); - - if (addedZones.contains(entry)) { - addedZones.remove(entry); - } - - } else { // Station mode - - 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('#'))); - - } - - } - - /** - * Add an associated zone or station. - */ - private void addAssociated() { - - if (monitorAreaList.getSelectionCount() == 0) { - if (mode == Mode.Zone) { - showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a zone"); - } else { - showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a station"); - } - return; - } - - if (maRegionalList.getSelectionCount() == 0) { - if (mode == Mode.Zone) { - showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a station"); - } else { - showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a zone"); - } - return; - } - - String entry = maRegionalList.getItem(maRegionalList - .getSelectionIndex()); - String[] items = associatedList.getItems(); - ArrayList itemList = new ArrayList(); - for (String item : items) { - itemList.add(item); - } - - if (itemList.contains(entry)) { - /** - * if selected entry is already in associated list: highlight the - * entry, and no need to do anything else - */ - associatedList.setSelection(itemList.indexOf(entry)); - return; - } - - itemList.add(entry); - Collections.sort(itemList); - associatedList.setItems(itemList.toArray(new String[itemList.size()])); - associatedList.setSelection(itemList.indexOf(entry)); - - /** - * Make changes to the zone/station lists accordingly, if needed, and - * store the changes in Monitor Configuration Manager - */ - - if (mode == Mode.Zone) { - - if (regionalRdo.getSelection()) { - // entry is a station selected from additional stations - maStations.add(entry); - Collections.sort(maStations); - additionalStns.remove(entry); - maRegionalList.remove(maRegionalList.getSelectionIndex()); - } - - String zone = monitorAreaList.getItem(monitorAreaList - .getSelectionIndex()); - String stnId = entry.substring(0, entry.indexOf('#')); - String stnType = entry.substring(entry.indexOf('#') + 1); - configMgr.addStation(zone, stnId, stnType, configMgr - .getAddedStations().contains(stnId)); - - } else { // Station mode - - if (regionalRdo.getSelection()) { - // entry is a zone selected from additional zones - maZones.add(entry); - Collections.sort(maZones); - additionalZones.remove(entry); - maRegionalList.remove(maRegionalList.getSelectionIndex()); - - configMgr.addArea(entry, - entry.charAt(2) == 'Z' ? ZoneType.MARITIME - : ZoneType.REGULAR); - } - - 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 - .getAddedStations().contains(stnId)); - - } - - } - - /** - * Remove an associated zone or station. - */ - private void removeAssociated() { - - if (associatedList.getItemCount() == 0) { - if (mode == Mode.Zone) { - showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a station"); - } else { - showMessage(shell, SWT.ERROR, "Select Needed", - "You must select a zone"); - } - return; - } - - String entry = associatedList.getItem(associatedList - .getSelectionIndex()); - - associatedList.remove(associatedList.getSelectionIndex()); - - if (mode == Mode.Zone) { - - String zone = monitorAreaList.getItem(monitorAreaList - .getSelectionIndex()); - configMgr.removeStation(zone, entry); - - ArrayList zones = configMgr.getAreaByStationId(entry - .substring(0, entry.indexOf('#'))); - if (zones.size() == 0) { - // entry is no longer an MA station - maStations.remove(entry); - additionalStns.add(entry); - Collections.sort(additionalStns); - if (maRdo.getSelection()) { - maRegionalList.setItems(maStations - .toArray(new String[maStations.size()])); - } else { - maRegionalList.setItems(additionalStns - .toArray(new String[additionalStns.size()])); - } - } - - } else { // Station mode - - String stn = monitorAreaList.getItem(monitorAreaList - .getSelectionIndex()); - configMgr.removeStation(entry, stn); - - } - - } - - /** - * Handle the monitor area list selection. - */ - private void handleMonitorAreaListSelection() { - - if (mode == Mode.Zone) { - - String zone = monitorAreaList.getItem(monitorAreaList - .getSelectionIndex()); - selectedStnZoneTF.setText(zone); - - ArrayList stations = configMgr - .getAreaStationsWithType(zone); - if (stations.size() > 1) { - Collections.sort(stations); - } - associatedList.removeAll(); - if (stations.size() > 0) { - associatedList.setItems(stations.toArray(new String[stations - .size()])); - } - - } else { // Station mode - - String station = monitorAreaList.getItem(monitorAreaList - .getSelectionIndex()); - selectedStnZoneTF.setText(station); - - ArrayList zones = configMgr.getAreaByStationId(station - .substring(0, station.indexOf('#'))); - if (zones.size() > 1) { - Collections.sort(zones); - } - associatedList.removeAll(); - if (zones.size() > 0) { - associatedList - .setItems(zones.toArray(new String[zones.size()])); - } - - } - - populateMaRegionalList(); - - } - - /** - * Get the appropriate configuration manager. - * - * @return The correct MonitorConfigurationManager - */ - protected MonitorConfigurationManager getConfigManager() { - MonitorConfigurationManager configManager = null; - - if (appName == AppName.FOG) { - configManager = FogMonitorConfigurationManager.getInstance(); - } else if (appName == AppName.SNOW) { - configManager = SnowMonitorConfigurationManager.getInstance(); - } else if (appName == AppName.SAFESEAS) { - configManager = SSMonitorConfigurationManager.getInstance(); - } - - return configManager; - } - - /** - * Called when the cancel or "X" button is clicked. - */ - private void closeWithoutSave() { - int choice = showMessage(shell, SWT.YES | SWT.NO, "Fog Monitor Exit", - "Are you sure you want to exit?"); - - if (choice == SWT.YES) { - MonitorConfigurationManager configManager = getConfigManager(); - - configManager.setAddedZones(new ArrayList()); - configManager.setAddedStations(new ArrayList()); - shell.dispose(); - } - } - - protected abstract void setAlgorithmText(); - - protected abstract void handleOkBtnSelection(); - - protected abstract void readConfigData(); - - /** - * close GUI dialog - */ - public void shellDisposeDialog() { - shell.dispose(); - } - - /** - * Add a new zone to monitor area and refresh GUI - * @param zone - */ - public void addZoneToMA(String zone) { - maZones.add(zone); - Collections.sort(maZones); - populateLeftLists(); - } - - /** - * Add a new station to monitor area and refresh GUI - * @param stnWithType (String of station ID with type) - */ - public void addStationToMA(String stnWithType) { - maStations.add(stnWithType); - Collections.sort(maStations); - populateLeftLists(); - } - - public void addNewZoneAction(String id, String lat, String log) { - addZoneToMA(id); - } - - public boolean isExistingZone(String zone) { - if ( maZones.contains(zone) || additionalZones.contains(zone) ) { - return true; - } - return false; - } - +public abstract class MonitoringAreaConfigDlg extends CaveSWTDialog implements + INewZoneStnAction { + + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(MonitoringAreaConfigDlg.class); + + /** Zone radio button. **/ + private Button zoneRdo; + + /** Station radio button. **/ + private Button stationRdo; + + /** Selected Zone text control. **/ + private Text selectedStnZoneTF; + + /** Monitor Area label. **/ + private Label montiorAreaLbl; + + /** Monitor area list control. **/ + private List monitorAreaList; + + /** Associated label. **/ + private Label associatedLbl; + + /** Associated list control. **/ + private List associatedList; + + /** Additional label. **/ + private Label additionalLbl; + + /** Additional list control. **/ + private List additionalList; + + /** MA radio button. **/ + private Button maRdo; + + /** Regional Stations radio button. **/ + private Button regionalRdo; + + /** MA regional list control. **/ + private List maRegionalList; + + /** Add New button. **/ + private Button addNewBtn; + + /** Edit/Delete button. **/ + private Button editDeleteBtn; + + /** Time scale control. **/ + protected Scale timeScale; + + /** Time scale label to display the value set by the time scale. **/ + private Label timeScaleLbl; + + /** Distance scale. **/ + protected Scale distanceScale; + + /** Distance scale label to display the value set by the distance scale. **/ + private Label distanceScaleLBl; + + /** Monitor area Add button. **/ + private Button monAreaAddBtn; + + /** Monitor area Remove button. **/ + private Button monAreaRemoveBtn; + + /** Associated Add button. **/ + private Button assocAddBtn; + + /** Associated Remove button. **/ + private Button assocRemoveBtn; + + /** Arrow up image. **/ + private Image arrowUpImg; + + /** Arrow down image. **/ + private Image arrowDownImg; + + /** Fog check button. **/ + protected Button fogChk; + + /** Control font. **/ + private Font controlFont; + + /** Application name. **/ + private CommonConfig.AppName appName; + + /** The current site. **/ + protected String currentSite = null; + + /** Wait Cursor **/ + private Cursor waitCursor = null; + + /** Arrow Cursor **/ + private Cursor arrowCursor = null; + + /** monitor area zones **/ + private java.util.List maZones = null; + + /** monitor area stations **/ + private java.util.List maStations = null; + + /** monitor area additional zones **/ + private java.util.List additionalZones = null; + + /** monitor area additional stations in the region **/ + private java.util.List additionalStns = null; + + /** Monitor Configuration Manager **/ + private MonitorConfigurationManager configMgr = null; + + /** Table mode **/ + private static enum Mode { + Zone, Station + }; + + /** mode by default **/ + private Mode mode = Mode.Zone; + + /** + * Add new Zone dialog. + */ + private AddNewZoneDlg addNewZoneDlg; + + /** + * Add new Station dialog. + */ + private AddNewStationDlg addNewStnDlg; + + /** + * Edit newly added zone dialog. + */ + private EditNewZoneDlg editDlg; + + /** + * Delete a Newly Entered Station dialog + */ + private DeleteStationDlg deleteStnDlg; + + /** + * Constructor. + * + * @param parent + * Parent shell. + * @param title + * Dialog title. + * @param appName + * Application name. + */ + public MonitoringAreaConfigDlg(Shell parent, String title, + CommonConfig.AppName appName) { + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK + | CAVE.INDEPENDENT_SHELL); + setText(title); + this.appName = appName; + currentSite = LocalizationManager.getInstance().getCurrentSite(); + waitCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT); + arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW); + } + + /** + * Initialize maZones/Stations and additionalZones/Stations + */ + private void initZoneStationLists() { + // (1) set monitor area zones + maZones = configMgr.getAreaList(); + Collections.sort(maZones); + // (2) set monitor area stations + maStations = new ArrayList(); + try { + for (String zone : maZones) { + java.util.List stns = configMgr + .getAreaStationsWithType(zone); + for (String stn : stns) { + if (!maStations.contains(stn)) { + maStations.add(stn); + } + } + } + } catch (Exception e) { + statusHandler.handle(Priority.PROBLEM, + " Error initiate Zone/Stations list.", e); + } + Collections.sort(maStations); + // (3) set additional zones in the neighborhood of the monitor area + additionalZones = configMgr.getAdjacentAreaList(); // adjMgr.getAdjZones(); + Collections.sort(additionalZones); + // (4) set additional stations + additionalStns = new ArrayList(); + try { + for (String zone : additionalZones) { + java.util.List stns = configMgr + .getAdjacentAreaStationsWithType(zone); + for (String stn : stns) { + if (!additionalStns.contains(stn)) { + additionalStns.add(stn); + } + } + } + } catch (Exception e) { + statusHandler.handle(Priority.PROBLEM, + " Error initiate Additional Zone/Stations list.", e); + } + Collections.sort(additionalStns); + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ + @Override + protected Layout constructShellLayout() { + // Create the main layout for the shell. + GridLayout mainLayout = new GridLayout(1, false); + mainLayout.marginHeight = 1; + mainLayout.marginWidth = 1; + mainLayout.verticalSpacing = 1; + return mainLayout; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) + */ + @Override + protected void initializeComponents(Shell shell) { + setReturnValue(false); + // Initialize the font and images + initFontAndImages(); + // Initialize all of the controls and layouts + initComponents(); + // set configuration and adjacent managers + configMgr = getConfigManager(); + // initialize zone/station lists + initZoneStationLists(); + // Populate the dialog + populateLeftLists(); + // populateRightLists(); // this is called from populateLeftLists() + setValues(); + } + + /** + * Initialize the images and font. + */ + private void initFontAndImages() { + controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); + ImageDescriptor id = Activator.imageDescriptorFromPlugin( + Activator.PLUGIN_ID, "images/arrowDn.png"); + arrowDownImg = id.createImage(); + id = Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, + "images/arrowUp.png"); + arrowUpImg = id.createImage(); + } + + /** + * Initialize the components on the display. + */ + private void initComponents() { + Composite mainListComp = new Composite(shell, SWT.NONE); + mainListComp.setLayout(new GridLayout(2, false)); + mainListComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, + false)); + createTopConfigControl(mainListComp); + createLeftListsAndControls(mainListComp); + createRightListsAndControls(mainListComp); + createBottomScaleControls(mainListComp); + createBottomButtons(); + } + + /** + * Create the top configuration controls. + * + * @param parentComp + */ + private void createTopConfigControl(Composite parentComp) { + Composite radioComp = new Composite(parentComp, SWT.NONE); + radioComp.setLayout(new GridLayout(3, false)); + + Label configLbl = new Label(radioComp, SWT.NONE); + configLbl.setText("Configure: "); + + zoneRdo = new Button(radioComp, SWT.RADIO); + zoneRdo.setText("Zone"); + zoneRdo.setSelection(true); + zoneRdo.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + shell.setCursor(waitCursor); + mode = Mode.Zone; + changeZoneStationControls(); + populateLeftLists(); + shell.setCursor(arrowCursor); + } + }); + + stationRdo = new Button(radioComp, SWT.RADIO); + stationRdo.setText("Station"); + stationRdo.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + shell.setCursor(waitCursor); + mode = Mode.Station; + changeZoneStationControls(); + populateLeftLists(); + shell.setCursor(arrowCursor); + } + }); + + /* + * Create the Selected Area Zone/Station text control. + */ + GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + selectedStnZoneTF = new Text(parentComp, SWT.BORDER); + selectedStnZoneTF.setEditable(false); + selectedStnZoneTF.setLayoutData(gd); + } + + /** + * Create the Monitor/Additional label and list controls. + * + * @param parentComp + * Parent composite. + */ + private void createLeftListsAndControls(Composite parentComp) { + Composite leftComp = new Composite(parentComp, SWT.NONE); + leftComp.setLayout(new GridLayout(2, true)); + leftComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); + + /* + * Create the Monitor Area label and list control. + */ + GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + gd.horizontalSpan = 2; + montiorAreaLbl = new Label(leftComp, SWT.NONE); + montiorAreaLbl.setText("Monitor Area Zones:"); + montiorAreaLbl.setLayoutData(gd); + + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.widthHint = 185; + gd.heightHint = 200; + gd.horizontalSpan = 2; + monitorAreaList = new List(leftComp, SWT.BORDER | SWT.SINGLE + | SWT.V_SCROLL); + monitorAreaList.setFont(controlFont); + monitorAreaList.setLayoutData(gd); + monitorAreaList.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleMonitorAreaListSelection(); + } + }); + + /* + * Create the Monitor Area Add and Remove buttons. + */ + gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); + gd.widthHint = 100; + monAreaAddBtn = new Button(leftComp, SWT.PUSH); + monAreaAddBtn.setText("Add"); + monAreaAddBtn.setImage(arrowUpImg); + monAreaAddBtn.setLayoutData(gd); + monAreaAddBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + addZoneStn(); + } + }); + + gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); + gd.widthHint = 100; + monAreaRemoveBtn = new Button(leftComp, SWT.PUSH); + monAreaRemoveBtn.setText("Remove"); + monAreaRemoveBtn.setImage(arrowDownImg); + monAreaRemoveBtn.setLayoutData(gd); + monAreaRemoveBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + removeZoneStn(); + } + }); + + /* + * Create the Additional label and list control. + */ + gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false); + gd.verticalIndent = 5; + gd.heightHint = 20; + gd.horizontalSpan = 2; + additionalLbl = new Label(leftComp, SWT.NONE); + additionalLbl.setText("Additional Zones:"); + additionalLbl.setLayoutData(gd); + + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.widthHint = 185; + gd.heightHint = 200; + gd.horizontalSpan = 2; + additionalList = new List(leftComp, SWT.BORDER | SWT.SINGLE + | SWT.V_SCROLL); + additionalList.setFont(controlFont); + additionalList.setLayoutData(gd); + + /* + * Create the Add New Zone/Station button. + */ + gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + gd.horizontalSpan = 2; + addNewBtn = new Button(leftComp, SWT.PUSH); + addNewBtn.setText("Add a New Zone to Monitor Area..."); + addNewBtn.setLayoutData(gd); + addNewBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleAddNewAction(); + } + }); + } + + /** + * Create the Associated & MA/Regional labels and controls. + * + * @param parentComp + * Parent composite. + */ + private void createRightListsAndControls(Composite parentComp) { + Composite rightComp = new Composite(parentComp, SWT.NONE); + rightComp.setLayout(new GridLayout(2, true)); + rightComp + .setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false)); + /* + * Create the Associated label and list control. + */ + GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + gd.horizontalSpan = 2; + associatedLbl = new Label(rightComp, SWT.NONE); + associatedLbl.setText("Associated Stations:"); + associatedLbl.setLayoutData(gd); + + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.widthHint = 185; + gd.heightHint = 200; + gd.horizontalSpan = 2; + associatedList = new List(rightComp, SWT.BORDER | SWT.SINGLE + | SWT.V_SCROLL); + associatedList.setFont(controlFont); + associatedList.setLayoutData(gd); + /* + * Create the Monitor Area Add and Remove buttons. + */ + gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); + gd.widthHint = 100; + assocAddBtn = new Button(rightComp, SWT.PUSH); + assocAddBtn.setText("Add"); + assocAddBtn.setImage(arrowUpImg); + assocAddBtn.setLayoutData(gd); + assocAddBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + addAssociated(); + } + }); + + gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); + gd.widthHint = 100; + assocRemoveBtn = new Button(rightComp, SWT.PUSH); + assocRemoveBtn.setText("Remove"); + assocRemoveBtn.setImage(arrowDownImg); + assocRemoveBtn.setLayoutData(gd); + assocRemoveBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + removeAssociated(); + } + }); + /* + * Create the Additional label and list control. + */ + gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false); + gd.verticalIndent = 5; + gd.heightHint = 20; + gd.widthHint = 110; + maRdo = new Button(rightComp, SWT.RADIO); + maRdo.setText("MA Stns"); + maRdo.setSelection(true); + maRdo.setLayoutData(gd); + maRdo.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + shell.setCursor(waitCursor); + populateMaRegionalList(); + shell.setCursor(arrowCursor); + } + }); + + gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false); + gd.verticalIndent = 5; + gd.heightHint = 20; + gd.widthHint = 130; + regionalRdo = new Button(rightComp, SWT.RADIO); + regionalRdo.setText("Regional Stns"); + regionalRdo.setLayoutData(gd); + regionalRdo.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + shell.setCursor(waitCursor); + populateMaRegionalList(); + shell.setCursor(arrowCursor); + } + }); + + gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.widthHint = 185; + gd.heightHint = 200; + gd.horizontalSpan = 2; + maRegionalList = new List(rightComp, SWT.BORDER | SWT.SINGLE + | SWT.V_SCROLL); + maRegionalList.setFont(controlFont); + maRegionalList.setLayoutData(gd); + /* + * Create the Add New Zone/Station button. + */ + gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + gd.horizontalSpan = 2; + editDeleteBtn = new Button(rightComp, SWT.PUSH); + editDeleteBtn.setText("Edit a Newly added Zone..."); + editDeleteBtn.setLayoutData(gd); + editDeleteBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleEditDeleteAction(); + } + }); + } + + /** + * Create the bottom scale controls. + * + * @param parentComp + * Parent composite. + */ + private void createBottomScaleControls(Composite parentComp) { + addSeparator(parentComp); + + GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + gd.horizontalSpan = 2; + Composite scaleComp = new Composite(parentComp, SWT.NONE); + scaleComp.setLayout(new GridLayout(2, false)); + scaleComp.setLayoutData(gd); + + /* + * Create the Time Window controls. + */ + gd = new GridData(); + gd.horizontalSpan = 2; + Label timeLbl = new Label(scaleComp, SWT.NONE); + timeLbl.setText("Time window (hrs)"); + timeLbl.setLayoutData(gd); + + int max = (int) Math.round((8.00 - 0.25) / .05); + int defaultVal = (int) Math.round((2.00 - 0.25) / .05); + + gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + timeScale = new Scale(scaleComp, SWT.HORIZONTAL); + timeScale.setMinimum(0); + timeScale.setMaximum(max); + timeScale.setSelection(defaultVal); + timeScale.setLayoutData(gd); + timeScale.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + setTimeScaleLabel(); + } + }); + + gd = new GridData(50, SWT.DEFAULT); + timeScaleLbl = new Label(scaleComp, SWT.NONE); + timeScaleLbl.setFont(controlFont); + timeScaleLbl.setLayoutData(gd); + + setTimeScaleLabel(); + + // If this is a snow dialog then return since we don't need to + // create the Ship Distance scale and Fog check controls. + if (appName == AppName.SNOW) { + return; + } + /* + * Create the Ship Distance controls. + */ + addSeparator(scaleComp); + + gd = new GridData(); + gd.horizontalSpan = 2; + Label distanceLbl = new Label(scaleComp, SWT.NONE); + distanceLbl.setText("Ship Distance (Nautical Miles):"); + distanceLbl.setLayoutData(gd); + + gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + distanceScale = new Scale(scaleComp, SWT.HORIZONTAL); + distanceScale.setMinimum(0); + distanceScale.setMaximum(200); + distanceScale.setSelection(100); + distanceScale.setLayoutData(gd); + distanceScale.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + setShipDistScaleLabel(); + } + }); + + gd = new GridData(50, SWT.DEFAULT); + distanceScaleLBl = new Label(scaleComp, SWT.NONE); + distanceScaleLBl.setFont(controlFont); + distanceScaleLBl.setLayoutData(gd); + + setShipDistScaleLabel(); + + /* + * Create the Fog check box. + */ + addSeparator(scaleComp); + + gd = new GridData(); + gd.horizontalSpan = 2; + fogChk = new Button(scaleComp, SWT.CHECK); + setAlgorithmText(); + } + + /** + * Create the bottom OK/Cancel buttons. + */ + private void createBottomButtons() { + addSeparator(shell); + + GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + Composite mainButtonComp = new Composite(shell, SWT.NONE); + mainButtonComp.setLayout(new GridLayout(1, false)); + mainButtonComp.setLayoutData(gd); + + gd = new GridData(SWT.CENTER, SWT.DEFAULT, false, false); + Composite buttonComp = new Composite(shell, SWT.NONE); + buttonComp.setLayout(new GridLayout(2, false)); + buttonComp.setLayoutData(gd); + + gd = new GridData(100, SWT.DEFAULT); + Button okBtn = new Button(buttonComp, SWT.PUSH); + okBtn.setText("OK"); + okBtn.setLayoutData(gd); + okBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + handleOkBtnSelection(); + } + }); + + gd = new GridData(100, SWT.DEFAULT); + Button cancelBtn = new Button(buttonComp, SWT.PUSH); + cancelBtn.setText("Cancel"); + cancelBtn.setLayoutData(gd); + cancelBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + closeWithoutSave(); + } + }); + } + + /** + * Add a separator bar to the display. + * + * @param parentComp + * Parent composite. + */ + private void addSeparator(Composite parentComp) { + GridLayout gl = (GridLayout) parentComp.getLayout(); + + GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); + gd.horizontalSpan = gl.numColumns; + Label sepLbl = new Label(parentComp, SWT.SEPARATOR | SWT.HORIZONTAL); + sepLbl.setLayoutData(gd); + } + + /** + * Round a value to the hundredths decimal place. + * + * @param val + * Value. + * @return Rounded value. + */ + private double roundToHundredths(double val) { + double roundedVal = 0.0; + + roundedVal = Math.round(val * 100) / 100.0; + + return roundedVal; + } + + /** + * Set the time scale label. + */ + private void setTimeScaleLabel() { + double val = timeScale.getSelection() * .05 + .25; + val = roundToHundredths(val); + timeScaleLbl.setText(String.format("%5.2f", val)); + } + + /** + * Set the ship distance scale label. + */ + private void setShipDistScaleLabel() { + distanceScaleLBl.setText(String.format("%5d", + distanceScale.getSelection())); + } + + /** + * Change the Zone and Station controls. + */ + private void changeZoneStationControls() { + if (mode == Mode.Zone) { + montiorAreaLbl.setText("Monitor Area Zones:"); + additionalLbl.setText("Additional Zones:"); + addNewBtn.setText("Add a New Zone to Monitor Area..."); + associatedLbl.setText("Associated Stations:"); + maRdo.setText("MA Stns"); + regionalRdo.setText("Regional Stns"); + editDeleteBtn.setText("Edit a Newly added Zone..."); + } else { + montiorAreaLbl.setText("Monitor Area Stations:"); + additionalLbl.setText("Additional Stations:"); + addNewBtn.setText("Add a New Stn to Monitor Area..."); + associatedLbl.setText("Associated Zones:"); + maRdo.setText("MA Zones"); + regionalRdo.setText("Regional Zones"); + editDeleteBtn.setText("Delete a Newly added Station..."); + } + } + + /** + * Handle the Add New button click. + */ + private void handleAddNewAction() { + if (zoneRdo.getSelection() == true) { + if (addNewZoneDlg == null) { + addNewZoneDlg = new AddNewZoneDlg(shell, appName, this); + addNewZoneDlg.setCloseCallback(new ICloseCallback() { + @Override + public void dialogClosed(Object returnValue) { + if ((Boolean) returnValue) { + // Update the dialog + populateLeftLists(); + } + addNewZoneDlg = null; + } + }); + } + addNewZoneDlg.open(); + } else { + if (associatedList.getSelectionIndex() == -1) { + associatedList.setSelection(0); + } + String area = associatedList.getItem(associatedList + .getSelectionIndex()); + if (addNewStnDlg == null) { + addNewStnDlg = new AddNewStationDlg(shell, appName, area, this); + addNewStnDlg.setCloseCallback(new ICloseCallback() { + @Override + public void dialogClosed(Object returnValue) { + if ((Boolean) returnValue) { + // Update the dialog + populateLeftLists(); + } + addNewStnDlg = null; + } + }); + } + addNewStnDlg.open(); + } + } + + /** + * Handle the Edit/Delete button click. + */ + private void handleEditDeleteAction() { + if (zoneRdo.getSelection() == true) { + if (editDlg == null) { + editDlg = new EditNewZoneDlg(shell, appName); + editDlg.setCloseCallback(new ICloseCallback() { + @Override + public void dialogClosed(Object returnValue) { + if ((Boolean) returnValue) { + // Update the dialog + populateLeftLists(); + } + editDlg = null; + } + }); + } + editDlg.open(); + } else { + if (deleteStnDlg == null) { + deleteStnDlg = new DeleteStationDlg(shell, appName); + deleteStnDlg.setCloseCallback(new ICloseCallback() { + @Override + public void dialogClosed(Object returnValue) { + if ((Boolean) returnValue) { + // Update the dialog + populateLeftLists(); + } + deleteStnDlg = null; + } + }); + } + deleteStnDlg.open(); + } + } + + /** + * Populate the MA-Regional list box. + */ + private void populateMaRegionalList() { + maRegionalList.removeAll(); + if (mode == Mode.Zone) { + if (maRdo.getSelection()) { + maRegionalList.setItems(maStations + .toArray(new String[maStations.size()])); + } else { + maRegionalList.setItems(additionalStns + .toArray(new String[additionalStns.size()])); + } + } else { // Station Mode + if (maRdo.getSelection()) { + maRegionalList.setItems(maZones.toArray(new String[maZones + .size()])); + } else { + maRegionalList.setItems(additionalZones + .toArray(new String[additionalZones.size()])); + } + } + } + + /** + * Populate the zone list boxes. + */ + private void populateLeftLists() { + if (mode == Mode.Zone) { + /** + * Zone Mode + */ + Collections.sort(maZones); + monitorAreaList + .setItems(maZones.toArray(new String[maZones.size()])); + Collections.sort(additionalZones); + additionalList.setItems(additionalZones + .toArray(new String[additionalZones.size()])); + } else { + /** + * Station Mode + */ + Collections.sort(maStations); + monitorAreaList.setItems(maStations.toArray(new String[maStations + .size()])); + Collections.sort(additionalStns); + additionalList.setItems(additionalStns + .toArray(new String[additionalStns.size()])); + } + if (monitorAreaList.getItemCount() > 0) { + monitorAreaList.setSelection(0); + handleMonitorAreaListSelection(); + } + } + + /** + * Set the slider values and the check box. + */ + private 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. + * + * @param shell + * The parent shell + * @param style + * The dialog style + * @param title + * The dialog title + * @param msg + * The dialog message + * @return The value representing the button clicked on the dialog + */ + protected int showMessage(Shell shell, int style, String title, String msg) { + MessageBox messageBox = new MessageBox(shell, style); + messageBox.setText(title); + messageBox.setMessage(msg); + return messageBox.open(); + } + + /** + * Add a zone or station to the monitoring area. + */ + private void addZoneStn() { + + if (additionalList.getSelectionCount() == 0) { + if (mode == Mode.Zone) { + showMessage(shell, SWT.ERROR, "Selection Needed", + "You must select a station first"); + } else { + showMessage(shell, SWT.ERROR, "Selection Needed", + "You must select a zone first"); + } + return; + } + String entry = additionalList.getItem(additionalList + .getSelectionIndex()); + additionalList.remove(additionalList.getSelectionIndex()); + if (mode == Mode.Zone) { + maZones.add(entry); + Collections.sort(maZones); + monitorAreaList + .setItems(maZones.toArray(new String[maZones.size()])); + monitorAreaList.setSelection(maZones.indexOf(entry)); + handleMonitorAreaListSelection(); + + additionalZones.remove(entry); + + configMgr.addArea(entry, entry.charAt(2) == 'Z' ? ZoneType.MARITIME + : ZoneType.REGULAR); + + if (!configMgr.getAddedZones().contains(entry)) { + configMgr.getAddedZones().add(entry); + } + } else { // Station mode + maStations.add(entry); + Collections.sort(maStations); + monitorAreaList.setItems(maStations.toArray(new String[maStations + .size()])); + monitorAreaList.setSelection(maStations.indexOf(entry)); + handleMonitorAreaListSelection(); + additionalStns.remove(entry); + } + } + + /** + * Remove a zone or station from the monitoring area. + */ + private void removeZoneStn() { + if (monitorAreaList.getSelectionCount() == 0) { + if (mode == Mode.Zone) { + showMessage(shell, SWT.ERROR, "Selection Needed", + "You must select a station first"); + } else { + showMessage(shell, SWT.ERROR, "Selection Needed", + "You must select a zone first"); + } + return; + } + String entry = monitorAreaList.getItem(monitorAreaList + .getSelectionIndex()); + monitorAreaList.remove(monitorAreaList.getSelectionIndex()); + associatedList.removeAll(); + if (mode == Mode.Zone) { + additionalZones.add(entry); + Collections.sort(additionalZones); + additionalList.setItems(additionalZones + .toArray(new String[additionalZones.size()])); + additionalList.setSelection(additionalZones.indexOf(entry)); + maZones.remove(entry); + configMgr.removeArea(entry); + if (configMgr.getAddedZones().contains(entry)) { + configMgr.getAddedZones().remove(entry); + } + } else { // Station mode + 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('#'))); + } + } + + /** + * Add an associated zone or station. + */ + private void addAssociated() { + if (monitorAreaList.getSelectionCount() == 0) { + if (mode == Mode.Zone) { + showMessage(shell, SWT.ERROR, "Select Needed", + "You must select a zone"); + } else { + showMessage(shell, SWT.ERROR, "Select Needed", + "You must select a station"); + } + return; + } + if (maRegionalList.getSelectionCount() == 0) { + if (mode == Mode.Zone) { + showMessage(shell, SWT.ERROR, "Select Needed", + "You must select a station"); + } else { + showMessage(shell, SWT.ERROR, "Select Needed", + "You must select a zone"); + } + return; + } + String entry = maRegionalList.getItem(maRegionalList + .getSelectionIndex()); + String[] items = associatedList.getItems(); + ArrayList itemList = new ArrayList(); + for (String item : items) { + itemList.add(item); + } + if (itemList.contains(entry)) { + /** + * if selected entry is already in associated list: highlight the + * entry, and no need to do anything else + */ + associatedList.setSelection(itemList.indexOf(entry)); + return; + } + itemList.add(entry); + Collections.sort(itemList); + associatedList.setItems(itemList.toArray(new String[itemList.size()])); + associatedList.setSelection(itemList.indexOf(entry)); + /** + * Make changes to the zone/station lists accordingly, if needed, and + * store the changes in Monitor Configuration Manager + */ + if (mode == Mode.Zone) { + if (regionalRdo.getSelection()) { + // entry is a station selected from additional stations + maStations.add(entry); + Collections.sort(maStations); + additionalStns.remove(entry); + maRegionalList.remove(maRegionalList.getSelectionIndex()); + } + String zone = monitorAreaList.getItem(monitorAreaList + .getSelectionIndex()); + String stnId = entry.substring(0, entry.indexOf('#')); + String stnType = entry.substring(entry.indexOf('#') + 1); + configMgr.addStation(zone, stnId, stnType, configMgr + .getAddedStations().contains(stnId)); + } else { // Station mode + if (regionalRdo.getSelection()) { + // entry is a zone selected from additional zones + maZones.add(entry); + Collections.sort(maZones); + additionalZones.remove(entry); + maRegionalList.remove(maRegionalList.getSelectionIndex()); + configMgr.addArea(entry, + entry.charAt(2) == 'Z' ? ZoneType.MARITIME + : ZoneType.REGULAR); + } + 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 + .getAddedStations().contains(stnId)); + } + } + + /** + * Remove an associated zone or station. + */ + private void removeAssociated() { + if (associatedList.getItemCount() == 0) { + if (mode == Mode.Zone) { + showMessage(shell, SWT.ERROR, "Select Needed", + "You must select a station"); + } else { + showMessage(shell, SWT.ERROR, "Select Needed", + "You must select a zone"); + } + return; + } + String entry = associatedList.getItem(associatedList + .getSelectionIndex()); + associatedList.remove(associatedList.getSelectionIndex()); + if (mode == Mode.Zone) { + String zone = monitorAreaList.getItem(monitorAreaList + .getSelectionIndex()); + configMgr.removeStation(zone, entry); + java.util.List zones = configMgr.getAreaByStationId(entry + .substring(0, entry.indexOf('#'))); + if (zones.size() == 0) { + // entry is no longer an MA station + maStations.remove(entry); + additionalStns.add(entry); + Collections.sort(additionalStns); + if (maRdo.getSelection()) { + maRegionalList.setItems(maStations + .toArray(new String[maStations.size()])); + } else { + maRegionalList.setItems(additionalStns + .toArray(new String[additionalStns.size()])); + } + } + } else { // Station mode + String stn = monitorAreaList.getItem(monitorAreaList + .getSelectionIndex()); + configMgr.removeStation(entry, stn); + } + } + + /** + * Handle the monitor area list selection. + */ + private void handleMonitorAreaListSelection() { + if (mode == Mode.Zone) { + String zone = monitorAreaList.getItem(monitorAreaList + .getSelectionIndex()); + selectedStnZoneTF.setText(zone); + + java.util.List stations = configMgr + .getAreaStationsWithType(zone); + if (stations.size() > 1) { + Collections.sort(stations); + } + associatedList.removeAll(); + if (stations.size() > 0) { + associatedList.setItems(stations.toArray(new String[stations + .size()])); + } + } else { // Station mode + String station = monitorAreaList.getItem(monitorAreaList + .getSelectionIndex()); + selectedStnZoneTF.setText(station); + java.util.List zones = configMgr.getAreaByStationId(station + .substring(0, station.indexOf('#'))); + if (zones.size() > 1) { + Collections.sort(zones); + } + associatedList.removeAll(); + if (zones.size() > 0) { + associatedList + .setItems(zones.toArray(new String[zones.size()])); + } + } + populateMaRegionalList(); + } + + /** + * Get the appropriate configuration manager. + * + * @return The correct MonitorConfigurationManager + */ + protected MonitorConfigurationManager getConfigManager() { + MonitorConfigurationManager configManager = null; + if (appName == AppName.FOG) { + configManager = FogMonitorConfigurationManager.getInstance(); + } else if (appName == AppName.SNOW) { + configManager = SnowMonitorConfigurationManager.getInstance(); + } else if (appName == AppName.SAFESEAS) { + configManager = SSMonitorConfigurationManager.getInstance(); + } + return configManager; + } + + /** + * Called when the cancel or "X" button is clicked. + */ + private void closeWithoutSave() { + int choice = showMessage(shell, SWT.YES | SWT.NO, appName + + " Monitor Exit", "Are you sure you want to exit?"); + if (choice == SWT.YES) { + MonitorConfigurationManager configManager = getConfigManager(); + configManager.setAddedZones(new ArrayList()); + configManager.setAddedStations(new ArrayList()); + setReturnValue(true); + close(); + } + } + + /** + * Sets algorithm text. + */ + protected abstract void setAlgorithmText(); + + /** + * Handles OK button. + */ + protected abstract void handleOkBtnSelection(); + + /** + * Reads configuration file. + */ + protected abstract void readConfigData(); + + /** + * Add a new zone to monitor area and refresh GUI + * + * @param zone + */ + public void addZoneToMA(String zone) { + maZones.add(zone); + Collections.sort(maZones); + populateLeftLists(); + } + + /** + * Add a new station to monitor area and refresh GUI + * + * @param stnWithType + * (String of station ID with type) + */ + public void addStationToMA(String stnWithType) { + maStations.add(stnWithType); + Collections.sort(maStations); + populateLeftLists(); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.monitor.ui.dialogs.INewZoneStnAction#addNewZoneAction + * (java.lang.String, java.lang.String, java.lang.String) + */ + @Override + public void addNewZoneAction(String id, String lat, String log) { + addZoneToMA(id); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.monitor.ui.dialogs.INewZoneStnAction#isExistingZone + * (java.lang.String) + */ + @Override + public boolean isExistingZone(String zone) { + if (maZones.contains(zone) || additionalZones.contains(zone)) { + return true; + } + return false; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.monitor.ui.dialogs.INewZoneStnAction#addNewStationAction + * (java.lang.String) + */ + @Override public void addNewStationAction(String stnWithType) { - addStationToMA(stnWithType); - } - - public boolean isExistingStation(String stnWithType) { - if ( maStations.contains(stnWithType) || additionalStns.contains(stnWithType) ) { - return true; - } - return false; + addStationToMA(stnWithType); } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.monitor.ui.dialogs.INewZoneStnAction#isExistingStation + * (java.lang.String) + */ + @Override + public boolean isExistingStation(String stnWithType) { + if (maStations.contains(stnWithType) + || additionalStns.contains(stnWithType)) { + return true; + } + return false; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() + */ + @Override + protected void disposed() { + waitCursor.dispose(); + arrowCursor.dispose(); + controlFont.dispose(); + } } diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ObsHistTableDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ObsHistTableDlg.java index 06901a039f..5aaf55d944 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ObsHistTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ObsHistTableDlg.java @@ -38,7 +38,7 @@ import com.raytheon.uf.common.localization.LocalizationContext; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.monitor.data.CommonConfig; +import com.raytheon.uf.common.monitor.data.CommonConfig.AppName; import com.raytheon.uf.common.monitor.data.CommonTableConfig.ObsHistType; import com.raytheon.uf.viz.monitor.data.TableData; import com.raytheon.uf.viz.monitor.xml.HistConfigXML; @@ -50,10 +50,12 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; *
  * 
  * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
+ * Date          Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
- * Apr 6, 2009            lvenable     Initial creation
- * Aug 6, 2010  6877      skorolev     Rewrote with using CaveSWTDialog
+ * Apr 6,  2009            lvenable     Initial creation
+ * Aug 6,  2010  6877      skorolev     Rewrote with using CaveSWTDialog
+ * Nov 29, 2012  1351      skorolev     Clean up code. Changes for non-blocking dialog.
+ * 
  * 
* * @author lvenable @@ -61,26 +63,54 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; */ public class ObsHistTableDlg extends CaveSWTDialog { - private final CommonConfig.AppName appName; + /** Monitor name **/ + private final AppName appName; + /** Station ID **/ private final String stationId; + /** Visible columns XML file **/ private HistConfigXML visColsXML; + /** **/ private ObsHistTableComp obsHistTable; + /** Observation type **/ private final ObsHistType obsType; + /** Table data **/ private final TableData tableData; + /** Latitude **/ private final double lat; + /** Longitude **/ private final double lon; + /** Observation history configuration dialog **/ + private ObsHistConfigDlg obsHistConfigDlg; + + /** Dialog ID **/ + protected String dlgId; + + /** + * Constructor + * + * @param parent + * @param tableData + * @param appName + * @param stationID + * @param lat + * @param lon + * @param obsType + * @param dlgId + * dialog ID + */ protected ObsHistTableDlg(Shell parent, TableData tableData, - String stationID, double lat, double lon, - CommonConfig.AppName appName, ObsHistType obsType) { - super(parent, SWT.DIALOG_TRIM | SWT.RESIZE); + AppName appName, String stationID, double lat, double lon, + ObsHistType obsType, String dlgId) { + super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.DO_NOT_BLOCK + | CAVE.INDEPENDENT_SHELL); setText(appName.name() + ":24-Hour Observation History Table"); this.tableData = tableData; this.appName = appName; @@ -88,6 +118,7 @@ public class ObsHistTableDlg extends CaveSWTDialog { this.lat = lat; this.lon = lon; this.obsType = obsType; + this.dlgId = dlgId; } /* @@ -104,6 +135,9 @@ public class ObsHistTableDlg extends CaveSWTDialog { createObsHistTable(); } + /** + * Creates Obs History Table. + */ private void createObsHistTable() { obsHistTable = new ObsHistTableComp(shell, tableData, appName, obsType); if (visColsXML != null) { @@ -116,6 +150,9 @@ public class ObsHistTableDlg extends CaveSWTDialog { obsHistTable.pack(); } + /** + * Creates Top Controls. + */ private void createTopControls() { GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); Composite controlComp = new Composite(shell, SWT.NONE); @@ -146,24 +183,39 @@ public class ObsHistTableDlg extends CaveSWTDialog { closeBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - shell.dispose(); + setReturnValue(dlgId); + close(); } }); } + /** + * Opens Configuration dialog. + */ private void configAction() { - ObsHistConfigDlg obsHistConfigDlg = new ObsHistConfigDlg(shell, - appName, obsHistTable, obsType); + if (obsHistConfigDlg == null) { + obsHistConfigDlg = new ObsHistConfigDlg(shell, appName, + obsHistTable, obsType); + } obsHistConfigDlg.open(); } + /** + * Gets formated coordinates. + * + * @return formated lat, lon + */ private String getFormattedLatLon() { String format = "(%.2f, %.2f)"; return String.format(format, lat, lon); } + /** + * Gets user file if exist. + * + * @return visible Columns XML + */ private HistConfigXML getHistConfigFile() { - // Open user file if exist. visColsXML = null; IPathManager pm = PathManagerFactory.getPathManager(); LocalizationContext context = pm.getContext( @@ -180,6 +232,11 @@ public class ObsHistTableDlg extends CaveSWTDialog { return visColsXML; } + /** + * Gets history file path. + * + * @return path + */ private String getHistPath() { String fs = String.valueOf(File.separatorChar); StringBuilder sb = new StringBuilder(); diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ZoneTableDlg.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ZoneTableDlg.java index 9012b14cc4..4fd5d6a7fe 100644 --- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ZoneTableDlg.java +++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/ZoneTableDlg.java @@ -148,7 +148,7 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements public ObConst.VarName varName; /** Application name. **/ - protected final CommonConfig.AppName appName; + protected final AppName appName; /** Table attribute dialog. **/ private TableAttribDlg attrDlg; @@ -208,15 +208,6 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements /** Data source. **/ public String dataSrc = "METAR"; - /** trend plots. **/ - private TrendPlotDlg tpd, tpdHodo; - - /** Hodograph. **/ - private HodographDlg hodographDlg; - - /** History table. **/ - private ObsHistTableDlg obsHstTblDlg; - /** dispose action. **/ protected abstract void shellDisposeAction(); @@ -614,7 +605,6 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements * (int, int) */ public void launchTrendPlot(int rowIndex, int colIndex) { - setRowIndex(rowIndex); setColIndex(colIndex); String colKey = config.getTableColumnKeys(appName)[colIndex]; @@ -630,7 +620,8 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements dlgTitle = getTrendPlotName(prodArray) + " Trend Plot for " + station + "#" + dataSrc; if (graphType == GraphType.Trend) { - if (mustCreate(tpd) || !openedDlgs.containsKey(dlgTitle)) { + TrendPlotDlg tpd = (TrendPlotDlg) openedDlgs.get(dlgTitle); + if (tpd == null) { tpd = new TrendPlotDlg(getShell(), selectedZone, station, prodArray, dataSrc, dlgTitle); tpd.setCloseCallback(new ICloseCallback() { @@ -641,10 +632,8 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements }); openedDlgs.put(dlgTitle, tpd); tpd.setData(obData); - tpd.open(); - } else { - openedDlgs.get(dlgTitle).bringToTop(); } + tpd.open(); } if (graphType == GraphType.HodoWindDir) { // get data for a hodograph trend plot @@ -652,9 +641,9 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements station, varName, ObConst.ProductName.UNDEFINED_PRODUCT); if (dataset != null && !dataset.isEmpty()) { float[] thresholds = dataset.getDualValuedThresholds(); - - if (mustCreate(hodographDlg) - || !openedDlgs.containsKey(dlgTitle)) { + HodographDlg hodographDlg = (HodographDlg) openedDlgs + .get(dlgTitle); + if (hodographDlg == null) { hodographDlg = new HodographDlg(getShell(), station, dataSrc, dlgTitle); hodographDlg.setCloseCallback(new ICloseCallback() { @@ -677,14 +666,13 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements thresholds[3]); hodographDlg.setRedThreshold(thresholds[0], thresholds[1]); hodographDlg.setHodoGraphData(dataset.getDataSet()); - hodographDlg.open(); - } else { - openedDlgs.get(dlgTitle).bringToTop(); } + hodographDlg.open(); } else { prodArray = new ArrayList(); prodArray.add("VAR_" + varName.name()); - if (mustCreate(tpdHodo) || !openedDlgs.containsKey(dlgTitle)) { + TrendPlotDlg tpdHodo = (TrendPlotDlg) openedDlgs.get(dlgTitle); + if (tpdHodo == null) { tpdHodo = new TrendPlotDlg(getShell(), selectedZone, station, prodArray, dataSrc, dlgTitle); tpdHodo.setCloseCallback(new ICloseCallback() { @@ -695,10 +683,8 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements }); openedDlgs.put(dlgTitle, tpdHodo); tpdHodo.setData(obData); - tpdHodo.open(); - } else { - openedDlgs.get(dlgTitle).bringToTop(); } + tpdHodo.open(); } } } @@ -712,11 +698,9 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements public void launchObHistoryTable(int rowIndex) { String station = stnTblData.getTableRows().get(rowIndex) .getTableCellData(0).getCellText(); - ObStnHourReports report = obData.getObHourReports() .getObZoneHourReports(selectedZone) .getObStnHourReports(station); - if (report.getStationCenter() != null) { lat = report.getStationCenter()[1]; lon = report.getStationCenter()[0]; @@ -724,11 +708,10 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements lat = 0.0; lon = 0.0; } - + // Set dialog index + String dialogID = appName.name() + station; MonitorConfigurationManager configMgr = getConfigMgr(); - ObsHistType histType = configMgr.getStationType(selectedZone, station); - /** * For Snow monitor, no history table is displayed for a Maritime * station @@ -736,16 +719,28 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements if (appName == AppName.SNOW && histType == ObsHistType.Maritime) { return; } - if (mustCreate(obsHstTblDlg)) { + ObsHistTableDlg obsHstTblDlg = (ObsHistTableDlg) openedDlgs + .get(dialogID); + if (obsHstTblDlg == null) { obsHstTblDlg = new ObsHistTableDlg(getShell(), obData.getHistTableData(selectedZone, station, histType), - station, lat, lon, obData.getAppName(), histType); - obsHstTblDlg.open(); - } else { - obsHstTblDlg.bringToTop(); + appName, station, lat, lon, histType, dialogID); + obsHstTblDlg.setCloseCallback(new ICloseCallback() { + @Override + public void dialogClosed(Object returnValue) { + openedDlgs.remove(returnValue); + } + }); + openedDlgs.put(dialogID, obsHstTblDlg); } + obsHstTblDlg.open(); } + /** + * Gets Configuration manager. + * + * @return manager + */ protected abstract MonitorConfigurationManager getConfigMgr(); /** @@ -825,7 +820,9 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements } /** - * @return linkedToFrame + * Linked To Frame + * + * @return True/False */ public boolean isLinkedToFrame() { return linkedToFrame; @@ -841,7 +838,7 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements } /** - * Handls checkbox "Link to frame" + * Handles checkbox "Link to frame" */ protected void handleLinkToFrame() { linkedToFrame = linkToFrameChk.getSelection(); @@ -860,22 +857,42 @@ public abstract class ZoneTableDlg extends CaveSWTDialog implements /** * Initiates array of products to plot * - * @return + * @return variable names */ protected abstract void initiateProdArray(); + /** + * Gets row index. + * + * @return rowIndex + */ public int getRowIndex() { return rowIndex; } + /** + * Sets row index. + * + * @param rowIndex + */ public void setRowIndex(int rowIndex) { this.rowIndex = rowIndex; } + /** + * Gets column index. + * + * @return colIndex + */ public int getColIndex() { return colIndex; } + /** + * Sets column index. + * + * @param colIndex + */ public void setColIndex(int colIndex) { this.colIndex = colIndex; } diff --git a/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/config/MonitorConfigurationManager.java b/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/config/MonitorConfigurationManager.java index acc816cc62..0063fbb5c7 100644 --- a/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/config/MonitorConfigurationManager.java +++ b/edexOsgi/com.raytheon.uf.common.monitor/src/com/raytheon/uf/common/monitor/config/MonitorConfigurationManager.java @@ -20,48 +20,64 @@ package com.raytheon.uf.common.monitor.config; import java.util.ArrayList; +import java.util.List; import com.raytheon.uf.common.localization.IPathManager; import com.raytheon.uf.common.localization.LocalizationContext; -import com.raytheon.uf.common.localization.LocalizationFile; -import com.raytheon.uf.common.localization.PathManagerFactory; 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.monitor.MonitorAreaUtils; import com.raytheon.uf.common.monitor.data.AdjacentWfoMgr; import com.raytheon.uf.common.monitor.data.CommonTableConfig.ObsHistType; 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.monitor.xml.AreaIdXML.ZoneType; import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.site.SiteMap; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.status.UFStatus.Priority; /** - * TODO Add Description + * Monitor configuration manager. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Jan 5, 2010            mpduff     Initial creation
  * Apr 29, 2011 DR#8986   zhao       Read in Counties instead of Forecast Zones
  * Feb 21 2012  14413     zhao       add code handling "adjacent areas"
+ * Nov 20 2012  1297      skorolev   Cleaned code
  * 
  * 
- * + * * @author mpduff - * @version 1.0 + * @version 1.0 */ public abstract class MonitorConfigurationManager { - - public static final String COUNTY_TABLE = "mapdata.county"; - - public static final String FORECAST_ZONE_TABLE = "mapdata.zone"; - + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(MonitorConfigurationManager.class); + + /** + * Maps county table in the PostgreSQL database. + */ + public static final String COUNTY_TABLE = "mapdata.county"; + + /** + * Maps forecast zones table in the PostgreSQL database. + */ + public static final String FORECAST_ZONE_TABLE = "mapdata.zone"; + + /** + * Maps marine zones table in the PostgreSQL database. + */ public static final String MARINE_ZONE_TABLE = "mapdata.marinezones"; /** @@ -77,41 +93,50 @@ public abstract class MonitorConfigurationManager { /** * List of newly added zones. */ - protected ArrayList addedZones = new ArrayList(); - + protected List addedZones = new ArrayList(); + /** * List of newly added stations. */ - protected ArrayList addedStations = new ArrayList(); - + protected List addedStations = new ArrayList(); - public abstract void readConfigXml(String currentSite); - /** - * Read the XML configuration data for the current XML file name. - * filename: monitor area config file name - * adjAreaFileName: adjacent areas config file name + * Station data type in the XML configuration file. */ - protected void readConfigXml(String currentSite, String filename, String adjAreaFilename) { + private String xmlDataType = StationIdXML.METAR; + + /** + * Reads area configuration file. + * + * @param currentSite + */ + public abstract void readConfigXml(String currentSite); + + /** + * Reads the XML configuration data for the current XML file name. filename: + * monitor area config file name adjAreaFileName: adjacent areas config file + * name + * + * @param currentSite + * @param filename + * @param adjAreaFilename + */ + protected void readConfigXml(String currentSite, String filename, + String adjAreaFilename) { boolean monitorAreaFileExists = true; boolean adjacentAreaFileExists = true; try { - // configXml = null; IPathManager pm = PathManagerFactory.getPathManager(); - String monitorAreaFilePath = pm.getFile( pm.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.SITE), filename) .getAbsolutePath(); - - System.out.println("Read path = " + monitorAreaFilePath); - MonAreaConfigXML configXmltmp = (MonAreaConfigXML) SerializationUtil .jaxbUnmarshalFromXmlFile(monitorAreaFilePath.toString()); configXml = configXmltmp; } catch (Exception e) { - // e.printStackTrace(); - System.err.println("No mopnitor area configuration file found"); + statusHandler.handle(Priority.ERROR, + "No mopnitor area configuration file found", e); monitorAreaFileExists = false; } @@ -122,150 +147,137 @@ public abstract class MonitorConfigurationManager { pm.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.SITE), adjAreaFilename) .getAbsolutePath(); - - System.out.println("Read path = " + adjacentAreaFilePath); - MonAreaConfigXML configXmltmp = (MonAreaConfigXML) SerializationUtil .jaxbUnmarshalFromXmlFile(adjacentAreaFilePath.toString()); adjAreaConfigXml = configXmltmp; } catch (Exception e) { - // e.printStackTrace(); - System.err.println("No adjacent area configuration file found"); + statusHandler.handle(Priority.ERROR, + "No adjacent area configuration file found", e); adjacentAreaFileExists = false; } try { - // Check for a monitor area config file, if one does not exist, create and use defaults + // Check for a monitor area config file, if one does not exist, + // create and use defaults /** - * Note: Read in "county" for CONUS site, "forecast zone" for OCONUS site - * [DR#9905] - */ + * Note: Read in "county" for CONUS site, "forecast zone" for OCONUS + * site [DR#9905] + */ if (!monitorAreaFileExists) { - ArrayList zones; - if ( SiteMap.getInstance().getSite4LetterId(currentSite).charAt(0) == 'K' ) { // CONUS site - zones = MonitorAreaUtils.getUniqueCounties(currentSite); - } else { // OCONUS site - zones = MonitorAreaUtils.getForecastZones(currentSite); + List zones; + if (SiteMap.getInstance().getSite4LetterId(currentSite) + .charAt(0) == 'K') { // CONUS site + zones = MonitorAreaUtils.getUniqueCounties(currentSite); + } else { // OCONUS site + zones = MonitorAreaUtils.getForecastZones(currentSite); } - ArrayList marineZones = MonitorAreaUtils.getMarineZones(currentSite); - - if (zones.size() > 0) { - for (String zone: zones) { - AreaIdXML zoneXml = new AreaIdXML(); - zoneXml.setAreaId(zone); - zoneXml.setType(ZoneType.REGULAR); - ArrayList stations = MonitorAreaUtils.getZoneReportingStationXMLs(zone); - if ( stations.size() > 0 ) { - for ( StationIdXML station : stations ) { - zoneXml.addStationIdXml(station); - } - } - configXml.addAreaId(zoneXml); + List marineZones = MonitorAreaUtils + .getMarineZones(currentSite); + if (zones.isEmpty()) { + for (String zone : zones) { + AreaIdXML zoneXml = new AreaIdXML(); + zoneXml.setAreaId(zone); + zoneXml.setType(ZoneType.REGULAR); + List stations = MonitorAreaUtils + .getZoneReportingStationXMLs(zone); + if (stations.isEmpty()) { + for (StationIdXML station : stations) { + zoneXml.addStationIdXml(station); + } + } + configXml.addAreaId(zoneXml); } } - // add marine zones if any exist - if (marineZones.size() > 0) { + if (marineZones.isEmpty()) { for (String zone : marineZones) { - AreaIdXML zoneXml = new AreaIdXML(); - zoneXml.setAreaId(zone); - zoneXml.setType(ZoneType.MARITIME); - ArrayList stations = MonitorAreaUtils.getZoneReportingStationXMLs(zone); - if ( stations.size() > 0 ) { - for ( StationIdXML station : stations ) { - zoneXml.addStationIdXml(station); - } - } - configXml.addAreaId(zoneXml); + AreaIdXML zoneXml = new AreaIdXML(); + zoneXml.setAreaId(zone); + zoneXml.setType(ZoneType.MARITIME); + List stations = MonitorAreaUtils + .getZoneReportingStationXMLs(zone); + if (stations.isEmpty()) { + for (StationIdXML station : stations) { + zoneXml.addStationIdXml(station); + } + } + configXml.addAreaId(zoneXml); } } - saveConfigXml(filename); } - - // Check for an adjacent area config file, if one does not exist, create and use defaults + // Check for an adjacent area config file, if one does not exist, + // create and use defaults if (!adjacentAreaFileExists) { - AdjacentWfoMgr adjMgr = new AdjacentWfoMgr(currentSite); - ArrayList zones = adjMgr.getAdjZones(); - if (zones.size() > 0) { - for (String zone: zones) { - AreaIdXML zoneXml = new AreaIdXML(); - zoneXml.setAreaId(zone); - zoneXml.setType(ZoneType.REGULAR); - ArrayList stations = MonitorAreaUtils.getZoneReportingStationXMLs(zone); - if ( stations.size() > 0 ) { - for ( StationIdXML station : stations ) { - zoneXml.addStationIdXml(station); - } - } - adjAreaConfigXml.addAreaId(zoneXml); + AdjacentWfoMgr adjMgr = new AdjacentWfoMgr(currentSite); + List zones = adjMgr.getAdjZones(); + if (zones.isEmpty()) { + for (String zone : zones) { + AreaIdXML zoneXml = new AreaIdXML(); + zoneXml.setAreaId(zone); + zoneXml.setType(ZoneType.REGULAR); + List stations = MonitorAreaUtils + .getZoneReportingStationXMLs(zone); + if (stations.isEmpty()) { + for (StationIdXML station : stations) { + zoneXml.addStationIdXml(station); + } + } + adjAreaConfigXml.addAreaId(zoneXml); } } - saveAdjacentAreaConfigXml(adjAreaFilename); } } catch (Exception e) { - e.printStackTrace(); + statusHandler.handle(Priority.ERROR, e.getMessage()); } } /** - * Save the monitor area XML configuration data to the current XML file name. + * Save the monitor area XML configuration data to the current XML file + * name. + * + * @param filename */ protected void saveConfigXml(String filename) { // Save the xml object to disk IPathManager pm = PathManagerFactory.getPathManager(); LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.SITE); - LocalizationFile newXmlFile = pm.getLocalizationFile(lc, - filename); - + LocalizationFile newXmlFile = pm.getLocalizationFile(lc, filename); if (newXmlFile.getFile().getParentFile().exists() == false) { - System.out.println("Creating new directory"); - - if (newXmlFile.getFile().getParentFile().mkdirs() == false) { - System.out.println("Could not create new directory..."); - } + newXmlFile.getFile().getParentFile().mkdirs(); } - try { - System.out.println("Saving -- " - + newXmlFile.getFile().getAbsolutePath()); SerializationUtil.jaxbMarshalToXmlFile(configXml, newXmlFile .getFile().getAbsolutePath()); newXmlFile.save(); } catch (Exception e) { - e.printStackTrace(); + statusHandler.handle(Priority.ERROR, e.getMessage()); } } /** - * Save the adjacent area XML configuration data to the current XML file name. + * Save the adjacent area XML configuration data to the current XML file + * name. + * + * @param filename */ protected void saveAdjacentAreaConfigXml(String filename) { // Save the xml object to disk IPathManager pm = PathManagerFactory.getPathManager(); LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.SITE); - LocalizationFile newXmlFile = pm.getLocalizationFile(lc, - filename); - + LocalizationFile newXmlFile = pm.getLocalizationFile(lc, filename); if (newXmlFile.getFile().getParentFile().exists() == false) { - System.out.println("Creating new directory"); - - if (newXmlFile.getFile().getParentFile().mkdirs() == false) { - System.out.println("Could not create new directory..."); - } + newXmlFile.getFile().getParentFile().mkdirs(); } - try { - System.out.println("Saving -- " - + newXmlFile.getFile().getAbsolutePath()); SerializationUtil.jaxbMarshalToXmlFile(adjAreaConfigXml, newXmlFile .getFile().getAbsolutePath()); newXmlFile.save(); } catch (Exception e) { - e.printStackTrace(); + statusHandler.handle(Priority.ERROR, e.getMessage()); } } @@ -275,67 +287,67 @@ public abstract class MonitorConfigurationManager { * this class. * * @param areaId - * The area Id (name) + * @param type */ public void addArea(String areaId, ZoneType type) { - ArrayList areaXmlList = configXml.getAreaIds(); + List areaXmlList = configXml.getAreaIds(); boolean areaExists = false; - for (AreaIdXML area: areaXmlList) { + 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); + configXml.addAreaId(area); } } - + /** * Add 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. * * @param areaId - * The area id + * The area id * @param lat - * The area latitude + * The area latitude * @param lon - * The area longitude + * The area longitude * @param type - * The area type + * The area type * @param existingArea - * Does the area already exist + * Does the area already exist */ - public void addArea(String areaId, double lat, double lon, ZoneType type, boolean existingArea) { - ArrayList areaXmlList = configXml.getAreaIds(); + public void addArea(String areaId, double lat, double lon, ZoneType type, + boolean existingArea) { + List areaXmlList = configXml.getAreaIds(); boolean areaExists = false; - for (AreaIdXML area: areaXmlList) { + for (AreaIdXML area : areaXmlList) { if (area.getAreaId().equals(areaId)) { area.setType(type); - area.setCLat(lat); - area.setCLon(lon); areaExists = true; break; } } - if (areaExists == false) { AreaIdXML area = new AreaIdXML(); area.setAreaId(areaId); area.setType(type); - area.setCLat(lat); - area.setCLon(lon); - configXml.addAreaId(area); - } - - if ((existingArea == false) && !addedZones.contains(areaId)) { - addedZones.add(areaId); + if (lat < -90.0 || lat > 90.0) { + area.setCLat(lat); + } + if (lon < -180.0 || lon > 180.0) { + area.setCLon(lon); + } + configXml.addAreaId(area); + if (!addedZones.contains(areaId)) { + addedZones.add(areaId); + } } } @@ -348,20 +360,22 @@ public abstract class MonitorConfigurationManager { * The station id * @param type * The station type + * @param existingStation + * Does the station already exist */ - public void addStation(String areaId, String stationId, String type, boolean existingStation) { - ArrayList areaList = configXml.getAreaIds(); + public void addStation(String areaId, String stationId, String type, + boolean existingStation) { + List areaList = configXml.getAreaIds(); if (stationId.contains("#")) { stationId = stationId.substring(0, stationId.indexOf("#")); } - - for (AreaIdXML area: areaList) { + for (AreaIdXML area : areaList) { if (area.getAreaId().equals(areaId)) { StationIdXML stationXml = new StationIdXML(); stationXml.setName(stationId); stationXml.setType(type); area.addStationIdXml(stationXml); - addedStations.add(stationId); + addedStations.add(stationId); } } } @@ -373,18 +387,14 @@ public abstract class MonitorConfigurationManager { * ZoneType of the area * @return List of areas of the specified type */ - public ArrayList getAreasByType(ZoneType type) { - ArrayList results = new ArrayList(); - ArrayList areaList = configXml.getAreaIds(); - + public List getAreasByType(ZoneType type) { + List results = new ArrayList(); + List areaList = configXml.getAreaIds(); for (AreaIdXML area : areaList) { if (area.getType().equals(type)) { results.add(area.getAreaId()); } } - - results.trimToSize(); - return results; } @@ -392,135 +402,115 @@ public abstract class MonitorConfigurationManager { * Get stations associated with an area. * * @param areaId - * AreaId of associated stations - * @return - * List of stations for area + * AreaId of associated stations + * @return List of stations for area */ - public ArrayList getAreaStationsWithType(String areaId) { - ArrayList results = new ArrayList(); - ArrayList areaList = configXml.getAreaIds(); - for (AreaIdXML area: areaList) { + public List getAreaStationsWithType(String areaId) { + List results = new ArrayList(); + List areaList = configXml.getAreaIds(); + for (AreaIdXML area : areaList) { if (area.getAreaId().equals(areaId)) { - ArrayList stationList = area.getStationIds(); - + List stationList = area.getStationIds(); for (StationIdXML station : stationList) { results.add(station.getName() + "#" + station.getType()); } - } } - return results; } - + /** * Get stations associated with an adjacent area. * * @param areaId - * AreaId of associated stations - * @return - * List of stations for area + * AreaId of associated stations + * @return List of stations for area */ - public ArrayList getAdjacentAreaStationsWithType(String areaId) { - ArrayList results = new ArrayList(); - ArrayList areaList = adjAreaConfigXml.getAreaIds(); - for (AreaIdXML area: areaList) { + public List getAdjacentAreaStationsWithType(String areaId) { + List results = new ArrayList(); + List areaList = adjAreaConfigXml.getAreaIds(); + for (AreaIdXML area : areaList) { if (area.getAreaId().equals(areaId)) { - ArrayList stationList = area.getStationIds(); - + List stationList = area.getStationIds(); for (StationIdXML station : stationList) { results.add(station.getName() + "#" + station.getType()); } - } } - return results; } - + /** * Get stations associated with an area. * * @param areaId - * AreaId of associated stations - * @return - * List of stations for area + * AreaId of associated stations + * @return List of stations for area */ - public ArrayList getAreaStations(String areaId) { - ArrayList results = new ArrayList(); - ArrayList areaList = configXml.getAreaIds(); - for (AreaIdXML area: areaList) { + public List getAreaStations(String areaId) { + List results = new ArrayList(); + List areaList = configXml.getAreaIds(); + for (AreaIdXML area : areaList) { if (area.getAreaId().equals(areaId)) { - ArrayList stationList = area.getStationIds(); - + List stationList = area.getStationIds(); for (StationIdXML station : stationList) { results.add(station.getName()); } - } } - return results; } - + /** * Get an area of a station. * * @param stationId - * The station to get the area - * @return - * List of areas + * The station to get the area + * @return List of areas */ - public ArrayList getAreaByStationId(String stationId) { - ArrayList results = new ArrayList(); - - ArrayList areaList = configXml.getAreaIds(); - - for (AreaIdXML area: areaList) { - ArrayList stationList = area.getStationIds(); - for (StationIdXML station: stationList) { + public List getAreaByStationId(String stationId) { + List results = new ArrayList(); + List areaList = configXml.getAreaIds(); + for (AreaIdXML area : areaList) { + List stationList = area.getStationIds(); + for (StationIdXML station : stationList) { if (station.getName().equals(stationId)) { results.add(area.getAreaId()); } } - } - + } return results; } - + /** * Get all the stations associated with the areas. - * @return + * + * @return List of stations */ - public ArrayList getStations() { - ArrayList areaXml = configXml.getAreaIds(); - ArrayList stations = new ArrayList(); - - for (AreaIdXML area: areaXml) { - ArrayList stationList = area.getStationIds(); - for (StationIdXML station: stationList) { - stations.add(station.getName() + "#" + station.getType() + "#" + area.getAreaId()); + public List getStations() { + List areaXml = configXml.getAreaIds(); + List stations = new ArrayList(); + for (AreaIdXML area : areaXml) { + List stationList = area.getStationIds(); + for (StationIdXML station : stationList) { + stations.add(station.getName() + "#" + station.getType() + "#" + + area.getAreaId()); } } - return stations; } /** * Get a list of all monitoring areas. * - * @return ArrayList of monitor area ids + * @return List of monitor area ids */ - public ArrayList getAreaList() { - ArrayList areaXmlList = configXml.getAreaIds(); - ArrayList areaList = new ArrayList(); - + public List getAreaList() { + List areaXmlList = configXml.getAreaIds(); + List areaList = new ArrayList(); for (AreaIdXML area : areaXmlList) { areaList.add(area.getAreaId()); } - - areaList.trimToSize(); - return areaList; } @@ -529,16 +519,12 @@ public abstract class MonitorConfigurationManager { * * @return ArrayList of adjacent area ids */ - public ArrayList getAdjacentAreaList() { - ArrayList areaXmlList = adjAreaConfigXml.getAreaIds(); - ArrayList areaList = new ArrayList(); - + public List getAdjacentAreaList() { + List areaXmlList = adjAreaConfigXml.getAreaIds(); + List areaList = new ArrayList(); for (AreaIdXML area : areaXmlList) { areaList.add(area.getAreaId()); } - - areaList.trimToSize(); - return areaList; } @@ -552,33 +538,29 @@ public abstract class MonitorConfigurationManager { */ public void removeStation(String area, String station) { station = station.substring(0, station.indexOf("#")); - - ArrayList areaList = configXml.getAreaIds(); - - for (AreaIdXML areaXml: areaList) { + List areaList = configXml.getAreaIds(); + for (AreaIdXML areaXml : areaList) { if (areaXml.getAreaId().equals(area)) { - ArrayList stationList = areaXml.getStationIds(); - + List stationList = areaXml.getStationIds(); for (int i = 0; i < stationList.size(); i++) { if (stationList.get(i).getName().equals(station)) { stationList.remove(i); } - } + } } } } - + /** * Remove a station from the monitoring area. * * @param station - * The station to remove + * The station to remove */ public void removeStation(String station) { - ArrayList areaList = configXml.getAreaIds(); - - for (AreaIdXML areaXml: areaList) { - ArrayList stationList = areaXml.getStationIds(); + List areaList = configXml.getAreaIds(); + for (AreaIdXML areaXml : areaList) { + List stationList = areaXml.getStationIds(); for (int i = 0; i < stationList.size(); i++) { StationIdXML stationXml = stationList.get(i); if (stationXml.getName().equals(station)) { @@ -588,43 +570,38 @@ public abstract class MonitorConfigurationManager { } } } - + /** * Get an AreaIdXML object. * * @param area - * The area to get - * @return - * The AreaIdXML object + * The area to get + * @return The AreaIdXML object */ public AreaIdXML getAreaXml(String area) { - ArrayList areaList = configXml.getAreaIds(); - - for (AreaIdXML areaXml: areaList) { + List areaList = configXml.getAreaIds(); + for (AreaIdXML areaXml : areaList) { if (areaXml.equals(area)) { return areaXml; } } - return null; } - + /** * Remove an area from the monitoring area. * * @param area - * The area to remove + * The area to remove */ public void removeArea(String area) { - ArrayList areaList = configXml.getAreaIds(); - + List areaList = configXml.getAreaIds(); for (int i = 0; i < areaList.size(); i++) { - if (areaList.get(i).getAreaId().equals(area)) { + 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); @@ -632,12 +609,12 @@ public abstract class MonitorConfigurationManager { } } } - + /** * Remove an added area. * * @param area - * The area to remove + * The area to remove */ public void removeAddedArea(String area) { for (int i = 0; i < addedZones.size(); i++) { @@ -647,7 +624,7 @@ public abstract class MonitorConfigurationManager { } } } - + /** * @return the timeWindow */ @@ -673,12 +650,13 @@ public abstract class MonitorConfigurationManager { /** * @return the addedZones */ - public ArrayList getAddedZones() { + public List getAddedZones() { return addedZones; } /** - * @param addedZones the addedZones to set + * @param addedZones + * the addedZones to set */ public void setAddedZones(ArrayList addedZones) { this.addedZones = addedZones; @@ -687,33 +665,42 @@ public abstract class MonitorConfigurationManager { /** * @return the addedStations */ - public ArrayList getAddedStations() { + public List getAddedStations() { return addedStations; } /** - * @param addedStations the addedStations to set + * @param addedStations + * the addedStations to set */ public void setAddedStations(ArrayList addedStations) { this.addedStations = addedStations; } - public ObsHistType getStationType(String theZone, String theStation) { - ObsHistType result = null; - ArrayList areaList = configXml.getAreaIds(); - for (AreaIdXML area: areaList) { + // TODO: Include Mesonet data types. + /** + * Get station type. + * + * @param theZone + * @param theStation + * @return type of station + */ + public ObsHistType getStationType(String theZone, String theStation) { + ObsHistType result = null; + List areaList = configXml.getAreaIds(); + for (AreaIdXML area : areaList) { if (area.getAreaId().equals(theZone)) { - ArrayList stationList = area.getStationIds(); - + List stationList = area.getStationIds(); for (StationIdXML station : stationList) { - if ( station.getName().equals(theStation) ) { - String typeString = station.getType(); - result = typeString.equals("METAR")?ObsHistType.METAR:ObsHistType.Maritime; + if (station.getName().equals(theStation)) { + String typeString = station.getType(); + result = typeString.equals(xmlDataType) ? ObsHistType.METAR + : ObsHistType.Maritime; + return result; } } } } - - return result; - } + return result; + } } diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsURIFilter.java b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsURIFilter.java index 820680d0f2..efa1704351 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsURIFilter.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsURIFilter.java @@ -1,9 +1,9 @@ package com.raytheon.uf.edex.plugin.fssobs; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.TimeZone; import java.util.regex.Pattern; @@ -13,40 +13,68 @@ import com.raytheon.edex.urifilter.URIFilter; import com.raytheon.edex.urifilter.URIGenerateMessage; import com.vividsolutions.jts.geom.Coordinate; +/** + * FSSObs URI Filter + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 5, 2012  #1351      skorolev    Cleaned code
+ * 
+ * 
+ * + * @author skorolev + * @version 1.0 + */ public class FSSObsURIFilter extends URIFilter { - public String stn; // station + /** Station ID **/ + private String stn; - public String cwa; + /** CWA **/ + private String cwa; - public String monitorName; + /** Monitor's name **/ + private String monitorName; - public Coordinate stationCoor = null; + /** Station coordinates **/ + private Coordinate stationCoor = null; - /** patterns used for matching URI's **/ + /** Patterns used for matching URI's **/ private HashMap patternKeys = null; - public Pattern MetarPattern = null; + /** METAR Pattern **/ + private Pattern MetarPattern = null; - public Pattern MaritimePattern = null; + /** Maritime Pattern **/ + private Pattern MaritimePattern = null; - public Pattern MesowestPattern = null; + /** Mesowest Pattern **/ + private Pattern MesowestPattern = null; - // IDecoderConstants - - // callback to the generator - public FSSObsGenerator fssgen = null; - - // Current data type #METAR, #Maritime or #Mesonet + /** Current data type #METAR, #Maritime or #Mesonet **/ private String dataType; + /** Current Site **/ private String currentSite = SiteUtil.getSite(); - // dataTypes to process - private HashMap dataTypes; + /** Date format **/ + private static String datePattern = "yyyy-MM-dd_HH:mm:ss.S"; - public static String datePattern = "yyyy-MM-dd_HH:mm:ss.S"; + /** Station type **/ + private enum StnType { + METAR, MARITIME, MESONET + }; + /** + * Constructor + * + * @param name + * Monitor name + */ public FSSObsURIFilter(String name) { super(name); logger.info("FSSObsFilter " + name + " Filter construction..."); @@ -61,22 +89,28 @@ public class FSSObsURIFilter extends URIFilter { setMatchURIs(); } + /* + * (non-Javadoc) + * + * @see com.raytheon.edex.urifilter.URIFilter#setMatchURIs() + */ @Override public void setMatchURIs() { - ArrayList stns = FSSObsUtils.getStations(name); + List stns = FSSObsUtils.getStations(name); + Pattern pat = Pattern.compile("#"); for (String st : stns) { - String[] tokens = st.split("#"); + String[] tokens = pat.split(st); setStn(tokens[0]); setDataType(tokens[1]); - if (getDataType().equals("METAR")) { + if (getDataType().equals(StnType.METAR.name())) { setMetarPattern(); getMatchURIs().put(getMetarPattern(), 0l); } - if (getDataType().equals("MARITIME")) { + if (getDataType().equals(StnType.MARITIME.name())) { setMaritimePattern(); getMatchURIs().put(getMaritimePattern(), 0l); } - if (getDataType().equals("MESONET")) { + if (getDataType().equals(StnType.MESONET.name())) { setMesowestPattern(); getMatchURIs().put(getMesowestPattern(), 0l); } @@ -87,6 +121,13 @@ public class FSSObsURIFilter extends URIFilter { * @param message * @return boolean */ + /* + * (non-Javadoc) + * + * @see + * com.raytheon.edex.urifilter.URIFilter#isMatched(com.raytheon.edex.msg + * .DataURINotificationMessage) + */ @Override public boolean isMatched(DataURINotificationMessage message) { setCurrentTime(new Date(System.currentTimeMillis())); @@ -112,11 +153,16 @@ public class FSSObsURIFilter extends URIFilter { + " Age of MatchedURI: " + duration / (1000 * 60) + " minutes"); - // got a replacement - logger.debug(name + ": not new. " + dataUri - + " Age of MatchURI: " - + getMatchURIs().get(pattern).longValue() - / (1000 * 60) + " minutes"); + if (logger.isDebugEnabled()) { + // got a replacement + logger.debug(name + + ": not new. " + + dataUri + + " Age of MatchURI: " + + getMatchURIs().get(pattern) + .longValue() / (1000 * 60) + + " minutes"); + } if (duration <= getMatchURIs().get(pattern) .longValue()) { // replace @@ -143,10 +189,10 @@ public class FSSObsURIFilter extends URIFilter { } /** - * gets the matching key for a matching pattern + * Gets the matching key for a matching pattern * * @param pattern - * @return + * @return key */ public String getPatternName(Pattern pattern) { for (String key : patternKeys.keySet()) { @@ -158,6 +204,12 @@ public class FSSObsURIFilter extends URIFilter { return null; } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.edex.urifilter.URIFilter#applyWildCards(java.lang.String) + */ @Override protected String applyWildCards(String key) { @@ -177,6 +229,12 @@ public class FSSObsURIFilter extends URIFilter { return newKey.toString(); } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.edex.urifilter.URIFilter#removeWildCards(java.lang.String) + */ @Override protected String removeWildCards(String key) { @@ -198,22 +256,45 @@ public class FSSObsURIFilter extends URIFilter { return newKey.toString(); } + /** + * Gets CWA + * + * @return cwa + */ public String getCwa() { return cwa; } + /** + * Sets CWA + * + * @param cwa + */ public void setCwa(String cwa) { this.cwa = cwa; } + /** + * Gets station coordinates + * + * @return stationCoor + */ public Coordinate getStationCoor() { return stationCoor; } + /** + * Gets Metar Pattern. + * + * @return MetarPattern + */ public Pattern getMetarPattern() { return MetarPattern; } + /** + * Sets Metar Pattern. + */ public void setMetarPattern() { // "/obs/2010-11-01_14:15:00.0/METAR/null/K0A9/36.371/-82.173" MetarPattern = Pattern.compile("/obs/" + wildCard + uriSeperator @@ -221,10 +302,18 @@ public class FSSObsURIFilter extends URIFilter { + uriSeperator); } + /** + * Gets Maritime Pattern. + * + * @return MaritimePattern + */ public Pattern getMaritimePattern() { return MaritimePattern; } + /** + * Sets Maritime Pattern + */ public void setMaritimePattern() { // /sfcobs/2010-10-28_10:36:00.0/1004/null/BEPB6/32.373/-64.703 MaritimePattern = Pattern.compile("/sfcobs/" + wildCard + uriSeperator @@ -233,6 +322,8 @@ public class FSSObsURIFilter extends URIFilter { } /** + * Gets Mesowest Pattern. + * * @return the mesowestPattern */ public Pattern getMesowestPattern() { @@ -240,6 +331,8 @@ public class FSSObsURIFilter extends URIFilter { } /** + * Sets Mesowest Pattern. + * * @param mesowestPattern * the mesowestPattern to set */ @@ -250,12 +343,19 @@ public class FSSObsURIFilter extends URIFilter { + uriSeperator + getStn()); } + /* + * (non-Javadoc) + * + * @see com.raytheon.edex.urifilter.URIFilter#createGenerateMessage() + */ @Override public URIGenerateMessage createGenerateMessage() { return new FSSObsURIGenrtMessage(this); } /** + * Gets station name + * * @return the stn */ public String getStn() { @@ -263,6 +363,8 @@ public class FSSObsURIFilter extends URIFilter { } /** + * Sets station name. + * * @param stn * the stn to set */ @@ -271,14 +373,18 @@ public class FSSObsURIFilter extends URIFilter { } /** + * Sets data type. + * * @param the * dataType to set */ - public void setDataType(String marine) { - this.dataType = marine; + public void setDataType(String type) { + this.dataType = type; } /** + * Gets data type. + * * @return the dataType */ public String getDataType() { @@ -286,6 +392,8 @@ public class FSSObsURIFilter extends URIFilter { } /** + * Gets Monitor Name. + * * @return the monitorName */ public String getMonitorName() { @@ -293,6 +401,8 @@ public class FSSObsURIFilter extends URIFilter { } /** + * Sets Monitor Name. + * * @param monitorName * the monitorName to set */ diff --git a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsUtils.java b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsUtils.java index c46a1715a3..7540d3c62c 100644 --- a/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsUtils.java +++ b/edexOsgi/com.raytheon.uf.edex.plugin.fssobs/src/com/raytheon/uf/edex/plugin/fssobs/FSSObsUtils.java @@ -20,6 +20,7 @@ package com.raytheon.uf.edex.plugin.fssobs; import java.util.ArrayList; +import java.util.List; import java.util.Scanner; import com.raytheon.edex.site.SiteUtil; @@ -46,6 +47,7 @@ import com.raytheon.uf.edex.pointdata.PointDataQuery; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Nov 12, 2010 skorolev Initial creation + * Nov 26, 2012 1297 skorolev Changed ArrayList to List.Clean code * * * @@ -57,17 +59,56 @@ public class FSSObsUtils { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(FSSObsUtils.class); + /** + * Value of missed data. + */ public static final float MISSING = -9999.0f; - // The constant representing the sky condition for sky clear - public static final int SKC_SKY_CONDITION = 9999999; + /** + * The constant representing the sky condition for sky clear + */ + private static final int SKC_SKY_CONDITION = 9999999; - // The constant representing the sky condition for clear sky - public static final int CLR_SKY_CONDITION = 8888888; + /** + * The constant representing the sky condition for clear sky + */ + private static final int CLR_SKY_CONDITION = 8888888; + /** Monitor ID **/ + private enum monID { + ss, fog, snow + }; + + /** Plug-in name **/ + private enum plgn { + obs, sfcobs, ldadmesonet + }; + + /** Selected column in database **/ + private static String slct = "dataURI"; + + /** Equal sign **/ + private static String equ = "="; + + /** Database **/ + private static String db = "metadata"; + + /** SQL expression **/ + private static String sqlexp = "select name from common_obs_spatial where ( catalogtype=1 or catalogtype=33 or catalogtype = 32 or catalogtype = 1000) and stationid = '"; + + /** + * Constructor + */ private FSSObsUtils() { } + /** + * Gets METAR records from Obs. + * + * @param uri + * @return Metar record + * @throws PluginException + */ public static FSSObsRecord getRecordFromMetar(String uri) throws PluginException { @@ -75,14 +116,13 @@ public class FSSObsUtils { PointDataQuery request = null; PointDataContainer result = null; try { - request = new PointDataQuery("obs"); + request = new PointDataQuery(plgn.obs.toString()); request.requestAllLevels(); - request.addParameter("dataURI", uri, "="); + request.addParameter(slct, uri, equ); request.setParameters(FSSObsDataTransform.OBS_PARAMS_LIST); result = request.execute(); if (result != null) { recFromMetar = FSSObsDataTransform.fromMetarRecord(result); - } } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); @@ -90,42 +130,60 @@ public class FSSObsUtils { return recFromMetar; } + /** + * Gets station name from database. + * + * @param stnId + * @return station name + */ public static String getStationName(String stnId) { String retVal = null; ISpatialQuery sq = null; - String sql = "select name from common_obs_spatial where ( catalogtype=1 or catalogtype=33 or catalogtype = 32 or catalogtype = 1000) and stationid = '" - + stnId + "'"; + String sql = sqlexp + stnId + "'"; try { sq = SpatialQueryFactory.create(); - Object[] results = sq.dbRequest(sql, "metadata"); + Object[] results = sq.dbRequest(sql, db); retVal = (String) results[0]; } catch (Exception e) { - e.printStackTrace(); + statusHandler.handle(Priority.ERROR, e.getMessage()); } return retVal; } + /** + * Gets Maritime record from sfcobs. + * + * @param uri + * @return maritaime record + * @throws PluginException + */ public static FSSObsRecord getRecordFromMaritime(String uri) throws PluginException { FSSObsRecord recFromMaritime = null; PointDataQuery request = null; PointDataContainer result = null; try { - request = new PointDataQuery("sfcobs"); - request.addParameter("dataURI", uri, "="); + request = new PointDataQuery(plgn.sfcobs.toString()); + request.addParameter(slct, uri, equ); request.setParameters(FSSObsDataTransform.SFCOBS_PARAMS_LIST); result = request.execute(); if (result != null) { recFromMaritime = FSSObsDataTransform .fromMaritimeRecord(result); - } } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); + statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e); } return recFromMaritime; } + /** + * Gets Mesowest record from ldadmesonet. + * + * @param uri + * @return mesowest record + * @throws PluginException + */ public static FSSObsRecord getRecordFromMesowest(String uri) throws PluginException { @@ -133,8 +191,8 @@ public class FSSObsUtils { PointDataQuery request = null; PointDataContainer result = null; try { - request = new PointDataQuery("ldadmesonet"); - request.addParameter("dataURI", uri, "="); + request = new PointDataQuery(plgn.ldadmesonet.toString()); + request.addParameter(slct, uri, equ); request.setParameters(FSSObsDataTransform.MESOWEST_PARAMS_LIST); result = request.execute(); if (result != null) { @@ -163,18 +221,14 @@ public class FSSObsUtils { // Temperature must be lower than -4.8C (23F) to avoid a calculation // error (a negative number to -1.668 power is NAN) - if (temperatureC < -4.8) fbMinutes = ((-24.5f * ((0.667f * windspeedKPH) + 4.8f)) + 2111f) * (float) Math.pow((-4.8 - temperatureC), -1.668); else return MISSING; - // Check for frost bite boundaries - if (!(fbMinutes <= 30 && windspeedKPH > 25.0 && windspeedKPH <= 80.5)) fbMinutes = MISSING; - return fbMinutes; } @@ -189,11 +243,9 @@ public class FSSObsUtils { */ public static float calcWindChill(float temp, float windSpd) { float spd; - /* arbitrarily do the calculation only for temps at or below 60F */ if (temp > 16.) return 1e37f; - /* no chilling if speed < 4 mph = 6.44km/h */ if (windSpd < 6.4) return temp; @@ -202,7 +254,6 @@ public class FSSObsUtils { spd = 128.75f; else spd = windSpd; - spd = (float) Math.pow(spd, 0.16); float windChillTemp = 13.12f + 0.6215f * temp - 11.37f * spd + 0.3965f * temp * spd; @@ -258,7 +309,6 @@ public class FSSObsUtils { */ public static Float getRH(float dewpoint, float temperature) { float retVal = MISSING; - // From http://www.hpc.ncep.noaa.gov/html/dewrh.shtml // to Celsius if (dewpoint != MISSING && temperature != MISSING) { @@ -277,6 +327,8 @@ public class FSSObsUtils { } /** + * Gets snow data. + * * @param tableRow * @return -- Snow data from METAR */ @@ -310,10 +362,9 @@ public class FSSObsUtils { } } } - if ((tableRow.getTemperature() != MISSING) - && (tableRow.getTemperature() < 4.4f) // 277.6) // 40 F = - // 4.44444 Celsium + && (tableRow.getTemperature() < 4.4f) + // 277.6 K = 40 F = 4.44444 Celsium && (tableRow.getWindSpeed() != MISSING) && (tableRow.getWindSpeed() <= 43.0f && tableRow.getWindSpeed() >= 14.0f)) { float speedKPH = tableRow.getWindSpeed() * 1.6f; @@ -326,9 +377,10 @@ public class FSSObsUtils { return retVal; } - // Routine to calculate dewpoint depression from temperature - // and relative humidity. /** + * Routine to calculate dewpoint depression from temperature and relative + * humidity. + * * @param TK * - temperature in K * @param RH @@ -346,30 +398,36 @@ public class FSSObsUtils { return retVal; } - public static ArrayList getStations(String monitor) { + /** + * Gets stations which FSS monitor is using. + * + * @param monitor + * @return stations + */ + public static List getStations(String monitor) { String currentSite = SiteUtil.getSite(); - ArrayList stations = new ArrayList(); - // Which monitor should use this station: fog, ss or snow - if (monitor.equals("fog")) { + List stations = new ArrayList(); + // Which monitor should use this station: fog, ss or snow + if (monitor.equals(monID.fog.name())) { FogMonitorConfigurationManager fogConfigManager = FogMonitorConfigurationManager .getInstance(); fogConfigManager.readConfigXml(currentSite); - ArrayList fogStations = fogConfigManager.getStations(); + List fogStations = fogConfigManager.getStations(); stations.addAll(fogStations); } - if (monitor.equals("ss")) { + if (monitor.equals(monID.ss.name())) { SSMonitorConfigurationManager ssConfigManger = SSMonitorConfigurationManager .getInstance(); ssConfigManger.readConfigXml(currentSite); - ArrayList ssStaitions = ssConfigManger.getStations(); + List ssStaitions = ssConfigManger.getStations(); stations.addAll(ssStaitions); } - if (monitor.equals("snow")) { + if (monitor.equals(monID.snow.name())) { SnowMonitorConfigurationManager snowConfigManager = SnowMonitorConfigurationManager .getInstance(); snowConfigManager.readConfigXml(currentSite); - ArrayList snowStations = snowConfigManager.getStations(); + List snowStations = snowConfigManager.getStations(); stations.addAll(snowStations); } return stations;