From 2d0155e16d8c9fddb48c73cb634cab10590fdf9a Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Thu, 18 Apr 2013 16:56:21 -0500 Subject: [PATCH] Issue #1790 Changes for non-blocking dialogs CountyStateDlg, CountyZoneUgcDlg, DataAdjustFactorDlg, DataIngestFilterDlg, DataPurgeParamsDlg and DatumDlg; also changes to hydro data mangagers to remove ArrayList for method interfaces. Change-Id: Id5f56669045afd402bed893c13977641ef59835b Former-commit-id: ec275df412353121c3faae56cccae5d39b0dc7ff [formerly c761fd09389c2c1a67a9ecf96d29ded958379cd7 [formerly 23bf9839c60aa33d7bf43492b72acbeedcf518b9]] Former-commit-id: c761fd09389c2c1a67a9ecf96d29ded958379cd7 Former-commit-id: 2bcc5e655c21be37dec2776ef4fa80952ac1f0d4 --- .../viz/hydrobase/FcstPointGroupDlg.java | 7 +- .../raytheon/viz/hydrobase/HydroBaseDlg.java | 103 +++- .../dialogs/AddModifyLocationDlg.java | 8 +- .../hydrobase/dialogs/AdministrationDlg.java | 3 +- .../viz/hydrobase/dialogs/BenchmarkDlg.java | 2 +- .../dialogs/CoopAgencyOfficeDlg.java | 6 +- .../viz/hydrobase/dialogs/CountyStateDlg.java | 4 +- .../hydrobase/dialogs/CountyZoneUgcDlg.java | 89 ++-- .../dialogs/DataAdjustFactorDlg.java | 83 ++-- .../dialogs/DataIngestFilterDlg.java | 221 ++++++--- .../hydrobase/dialogs/DataPurgeParamsDlg.java | 224 +++++++-- .../viz/hydrobase/dialogs/DatumDlg.java | 46 +- .../viz/hydrobase/dialogs/GageHistoryDlg.java | 44 +- .../hydrobase/dialogs/HydroGenConfigDlg.java | 22 +- .../hydrobase/dialogs/NwrTransmitterDlg.java | 8 +- .../hydrobase/dialogs/PublicationsDlg.java | 12 +- .../hydrobase/dialogs/RadarLocationsDlg.java | 29 +- .../hydrobase/dialogs/ReferenceFieldsDlg.java | 9 +- .../viz/hydrobase/dialogs/ReferencesDlg.java | 59 ++- .../viz/hydrobase/dialogs/ReservoirDlg.java | 50 +- .../viz/hydrobase/dialogs/RiverGageDlg.java | 165 ++++--- .../dialogs/RiverProFcstGrpPointsDlg.java | 58 +-- .../dialogs/RiverProGenParamsDlg.java | 6 +- .../dialogs/StatesCountiesZonesDlg.java | 33 +- .../colorscalemgr/ColorDataTypeSets.java | 10 +- .../colorscalemgr/ColorScaleMgrDlg.java | 119 ++--- .../colorscalemgr/ColorScaleSets.java | 21 +- .../colorscalemgr/EditColorData.java | 14 +- .../hydrocommon/data/RPFFcstPointData.java | 16 +- .../AddModifyLocationDataManager.java | 105 +++-- .../datamanager/CountyZoneUgcDataManager.java | 439 +++++++++--------- .../DataAdjustFactorDataManager.java | 52 ++- .../DataIngestFilterDataManager.java | 39 +- .../datamanager/HydroDBDataManager.java | 116 ++--- .../QcAlertAlarmLimitsDataManager.java | 59 +-- .../datasources/DataSourcesDlg.java | 22 +- .../impactstatement/ImpactStatementDlg.java | 94 +--- .../hydrocommon/util/StnClassSyncUtil.java | 14 +- 38 files changed, 1362 insertions(+), 1049 deletions(-) diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/FcstPointGroupDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/FcstPointGroupDlg.java index 9e26f72c03..82c45497cc 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/FcstPointGroupDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/FcstPointGroupDlg.java @@ -72,7 +72,7 @@ public class FcstPointGroupDlg extends CaveSWTDialog { /** * Cache of forecast groups */ - private ArrayList fcstGroups; + private java.util.List fcstGroups; /** * Previously selected group @@ -82,7 +82,7 @@ public class FcstPointGroupDlg extends CaveSWTDialog { /** * List of listeners to group assignment changes */ - private ArrayList fcstGroupListeners; + private java.util.List fcstGroupListeners; /** * Constructor. @@ -236,8 +236,7 @@ public class FcstPointGroupDlg extends CaveSWTDialog { } } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - mb - .setMessage("No forecast groups have been defined under \"Setup\""); + mb.setMessage("No forecast groups have been defined under \"Setup\""); mb.open(); } } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydroBaseDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydroBaseDlg.java index 201acb3577..9c3959cdbc 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydroBaseDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/HydroBaseDlg.java @@ -134,6 +134,11 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Changes for non-blocking AdministrationDlg. * Changes for non-blocking ArealDefinitionsDlg. * Changes for non-blocking BenchmarkDlg. + * Changes for non-blocking CountyZoneUgcDlg. + * Changes for non-blocking DataAdjustFactorDlg. + * Changes for non-blocking DataIngestFilterDlg. + * Changes for non-blocking DataPurgeParamsDlg. + * Changes for non-blocking DatumDlg . * * * @@ -171,6 +176,31 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, */ private final Map benchmarkDlgMap = new HashMap(); + /** + * Allow one County/Zone UGC dialog per location. + */ + private final Map czDlgMap = new HashMap();; + + /** + * Allow one Data Adjustment Factor dialog. + */ + private DataAdjustFactorDlg dataAdjustDlg; + + /** + * Allow one Ingest Filter Dialog. + */ + private DataIngestFilterDlg dataIngestDlg; + + /* + * Allow one data purge paramertres dialog. + */ + private DataPurgeParamsDlg dataPurgeDlg; + + /** + * Allow one dataum dialog per station. + */ + private final Map datumDlgMap = new HashMap(); + /** * Flood category menu item. */ @@ -499,9 +529,26 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, countyZoneUgcMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - CountyZoneUgcDlg czDlg = new CountyZoneUgcDlg(shell, - getStationAndName(), getSelectedLocation().getStation()); - czDlg.open(); + String lid = getSelectedLocation().getStation(); + CountyZoneUgcDlg czDlg = czDlgMap.get(lid); + if (czDlg == null) { + czDlg = new CountyZoneUgcDlg(shell, getStationAndName(), + lid); + czDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof String) { + String lid = returnValue.toString(); + czDlgMap.remove(lid); + } + } + }); + czDlgMap.put(lid, czDlg); + czDlg.open(); + } else { + czDlg.bringToTop(); + } } }); @@ -724,9 +771,25 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, datumMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - DatumDlg datumDlg = new DatumDlg(shell, getStationAndName(), - getSelectedLocation().getStation()); - datumDlg.open(); + String lid = getSelectedLocation().getStation(); + DatumDlg datumDlg = datumDlgMap.get(lid); + if (datumDlg == null) { + datumDlg = new DatumDlg(shell, getStationAndName(), lid); + datumDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof String) { + String lid = returnValue.toString(); + datumDlgMap.remove(lid); + } + } + }); + datumDlgMap.put(lid, datumDlg); + datumDlg.open(); + } else { + datumDlg.bringToTop(); + } } }); riverGageMenuItems.add(datumMI); @@ -838,9 +901,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, ingestFilterMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - DataIngestFilterDlg dataIngetsDlg = new DataIngestFilterDlg( - shell); - dataIngetsDlg.open(); + if (dataIngestDlg == null || dataIngestDlg.isDisposed()) { + dataIngestDlg = new DataIngestFilterDlg(shell); + dataIngestDlg.open(); + } else { + dataIngestDlg.bringToTop(); + } } }); @@ -850,9 +916,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, adjustmentFactorsMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - DataAdjustFactorDlg dataAdjustDlg = new DataAdjustFactorDlg( - shell); - dataAdjustDlg.open(); + if (dataAdjustDlg == null || dataAdjustDlg.isDisposed()) { + dataAdjustDlg = new DataAdjustFactorDlg(shell); + dataAdjustDlg.open(); + } else { + dataAdjustDlg.bringToTop(); + } } }); @@ -874,8 +943,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, purgeParamsMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - DataPurgeParamsDlg dataPurgeDlg = new DataPurgeParamsDlg(shell); - dataPurgeDlg.open(); + if (dataPurgeDlg == null || dataPurgeDlg.isDisposed()) { + dataPurgeDlg = new DataPurgeParamsDlg(shell); + dataPurgeDlg.open(); + } else { + dataPurgeDlg.bringToTop(); + } } }); } @@ -1702,7 +1775,7 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, private String getPassword() { String pw = null; try { - ArrayList data = HydroDBDataManager + java.util.List data = HydroDBDataManager .getInstance().getData(AdministrationData.class); // if no data is returned, clear the current display data diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AddModifyLocationDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AddModifyLocationDlg.java index 9faabe5335..868a4f6b86 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AddModifyLocationDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AddModifyLocationDlg.java @@ -389,7 +389,7 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements /** * Listeners to notify main HB Dialog of station list changes */ - private ArrayList stationListeners; + private java.util.List stationListeners; /** * States for the dialog @@ -1300,7 +1300,7 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements StationClassData seedData = new StationClassData(); seedData.setLid(lid); - ArrayList classData = new ArrayList(); + java.util.List classData = new ArrayList(); try { classData = HydroDBDataManager.getInstance().getData(seedData); @@ -1494,7 +1494,7 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements coopAgencyOfficeList.removeAll(); try { - ArrayList offices = AddModifyLocationDataManager + java.util.List offices = AddModifyLocationDataManager .getInstance().getSelectedAgenciesAndOffices(lid); for (String currOffice : offices) { @@ -1578,7 +1578,7 @@ public class AddModifyLocationDlg extends CaveSWTDialog implements private void setDefaultHsaWfo() { // If adding location, HSA and WFO default to Admin table values try { - ArrayList data = HydroDBDataManager + java.util.List data = HydroDBDataManager .getInstance().getData(AdministrationData.class); if (data.size() > 0) { diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AdministrationDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AdministrationDlg.java index 83f37bab5c..089c7d7def 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AdministrationDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/AdministrationDlg.java @@ -21,7 +21,6 @@ package com.raytheon.viz.hydrobase.dialogs; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; import java.util.TimeZone; @@ -342,7 +341,7 @@ public class AdministrationDlg extends CaveSWTDialog { private void getAdministrationData() { try { - ArrayList data = HydroDBDataManager + java.util.List data = HydroDBDataManager .getInstance().getData(AdministrationData.class); // if no data is returned, clear the current display data diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/BenchmarkDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/BenchmarkDlg.java index 0f001c249d..95bf833907 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/BenchmarkDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/BenchmarkDlg.java @@ -121,7 +121,7 @@ public class BenchmarkDlg extends CaveSWTDialog { /** * Benchmark data for the current location. */ - private ArrayList benchData; + private java.util.List benchData; /** * Dialog states. diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CoopAgencyOfficeDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CoopAgencyOfficeDlg.java index 1c1cf9c962..822eb6f5ac 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CoopAgencyOfficeDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CoopAgencyOfficeDlg.java @@ -19,8 +19,6 @@ **/ package com.raytheon.viz.hydrobase.dialogs; -import java.util.ArrayList; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -105,12 +103,12 @@ public class CoopAgencyOfficeDlg extends CaveSWTDialog { /** * Cache of available agencies/offices */ - private ArrayList availData; + private java.util.List availData; /** * Cache of selected agencies/offices */ - private ArrayList selectedData; + private java.util.List selectedData; /** * Non-blocking Constructor. diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyStateDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyStateDlg.java index aec22c8b0e..09a4fb3ba7 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyStateDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyStateDlg.java @@ -72,12 +72,12 @@ public class CountyStateDlg extends CaveSWTDialog { /** * Hold the county/state data */ - private ArrayList countiesData; + private java.util.List countiesData; /** * List of listeners for changes */ - private ArrayList countyStateListeners; + private java.util.List countyStateListeners; /** * Constructor. diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyZoneUgcDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyZoneUgcDlg.java index 686eefbfa6..9ca0123463 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyZoneUgcDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/CountyZoneUgcDlg.java @@ -33,6 +33,9 @@ import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Shell; +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.exception.VizException; import com.raytheon.viz.hydrocommon.data.CountiesData; import com.raytheon.viz.hydrocommon.data.CountyInfoData; @@ -51,6 +54,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 02 Sep 2008 lvenable Initial creation. * 30 Dec 2008 1802 askripsk Connect to database. * 04 Dec 2012 15522 wkwock Fix incorrect zones and not able to add + * 18 Apr 2013 1790 rferrel Make dialog non-blocking. * * * @@ -59,6 +63,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * */ public class CountyZoneUgcDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(CountyZoneUgcDlg.class); /** * Control font. @@ -96,11 +102,13 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { private Button clearBtn; /** - * for keep track whether selected zones are initialized. false is not initialized. + * For keep track whether selected zones are initialized. false is not + * initialized. */ private boolean zonesFlag = false; + /** - * Constructor. + * Non-blocking Constructor. * * @param parent * Parent shell. @@ -108,12 +116,17 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { * Dialog title information. */ public CountyZoneUgcDlg(Shell parent, String titleInfo, String lid) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("County/Zone UGC" + titleInfo); - + setReturnValue(lid); CountyZoneUgcDataManager.getInstance().setLid(lid); } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ @Override protected Layout constructShellLayout() { // Create the main layout for the shell. @@ -124,6 +137,11 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { return mainLayout; } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() + */ @Override protected void disposed() { controlFont.dispose(); @@ -131,7 +149,6 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { @Override protected void initializeComponents(Shell shell) { - setReturnValue(false); controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); @@ -162,9 +179,9 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { selectionCbo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - if (!zonesFlag) { - getZoneData(); - } + if (!zonesFlag) { + getZoneData(); + } updateDisplay(); } }); @@ -272,7 +289,7 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { okBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { saveRecords(); - shell.dispose(); + close(); } }); @@ -292,7 +309,7 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { cancelBtn.setLayoutData(gd); cancelBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); } @@ -326,7 +343,8 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { try { CountyZoneUgcDataManager.getInstance().getCountiesSelected(true); } catch (VizException e) { - e.printStackTrace(); + statusHandler + .handle(Priority.PROBLEM, "Unable to county data. ", e); } } @@ -336,9 +354,9 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { private void getZoneData() { try { CountyZoneUgcDataManager.getInstance().getZonesSelected(true); - zonesFlag=true; + zonesFlag = true; } catch (VizException e) { - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, "Unable to zone data. ", e); } } @@ -365,24 +383,25 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { try { for (CountiesData availCounty : CountyZoneUgcDataManager .getInstance().getCountiesAvailable()) { - availableList.add(String.format(countyFormat, availCounty - .getCountyNumber(), availCounty.getCounty(), + availableList.add(String.format(countyFormat, + availCounty.getCountyNumber(), availCounty.getCounty(), availCounty.getState())); } for (CountyInfoData selectedCounty : CountyZoneUgcDataManager .getInstance().getCountiesSelected()) { - selectedList.add(String.format(countyFormat, selectedCounty - .getCountyNumber(), selectedCounty.getCounty(), - selectedCounty.getState())); + selectedList.add(String.format(countyFormat, + selectedCounty.getCountyNumber(), + selectedCounty.getCounty(), selectedCounty.getState())); } } catch (VizException e) { - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to get county data. ", e); } } /** - * Displayes the current Zone data. + * Displays the current Zone data. */ private void updateZoneDisplay() { String zoneFormat = "%3s %-20s %2s"; @@ -390,19 +409,22 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { try { for (EligZoneData availZone : CountyZoneUgcDataManager .getInstance().getZonesAvailable()) { - availableList.add(String.format(zoneFormat, availZone - .getZoneNumber(), availZone.getDescription(), availZone - .getState())); + availableList.add(String.format(zoneFormat, + availZone.getZoneNumber(), availZone.getDescription(), + availZone.getState())); } for (ZoneInfoData selectedZone : CountyZoneUgcDataManager .getInstance().getZonesSelected()) { - selectedList.add(String.format(zoneFormat, selectedZone - .getZoneNumber(), selectedZone.getDescription(), - selectedZone.getState())); + selectedList + .add(String.format(zoneFormat, + selectedZone.getZoneNumber(), + selectedZone.getDescription(), + selectedZone.getState())); } } catch (VizException e) { - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to get county data. ", e); } } @@ -432,6 +454,9 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { updateDisplay(); } + /** + * Delete the selected record and update display. + */ private void deleteRecord() { int selectedIndex = selectedList.getSelectionIndex(); @@ -448,6 +473,9 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { updateDisplay(); } + /** + * Clear all the records and update the display. + */ private void clearRecords() { if (countiesDisplayed()) { CountyZoneUgcDataManager.getInstance().clearSelectedCounties(); @@ -458,6 +486,9 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { updateDisplay(); } + /** + * Save records to the manager. + */ private void saveRecords() { try { if (countiesDisplayed()) { @@ -466,8 +497,8 @@ public class CountyZoneUgcDlg extends CaveSWTDialog { CountyZoneUgcDataManager.getInstance().saveZones(); } } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler + .handle(Priority.PROBLEM, "Unable to save records ", e); } getDialogData(); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataAdjustFactorDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataAdjustFactorDlg.java index ef53e2f467..48d5fa8d7a 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataAdjustFactorDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataAdjustFactorDlg.java @@ -36,11 +36,14 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.*; +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.exception.VizException; import com.raytheon.viz.hydrocommon.HydroConstants; import com.raytheon.viz.hydrocommon.data.DataAdjustFactorData; @@ -64,6 +67,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Mar 05, 2010 1928 mpduff Added additional form validation. * Oct 26, 2010 5937 Judy Wang Converted lower case to upper * case in Location box. + * Apr 18, 2013 1790 rferrel Make dialog non-blocking. * * * @@ -71,6 +75,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * @version 1.0 */ public class DataAdjustFactorDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(DataAdjustFactorDlg.class); /** * Control font. @@ -134,10 +140,15 @@ public class DataAdjustFactorDlg extends CaveSWTDialog { * Parent shell. */ public DataAdjustFactorDlg(Shell parent) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("Data Adjustment Factors"); } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ @Override protected Layout constructShellLayout() { GridLayout mainLayout = new GridLayout(1, false); @@ -147,11 +158,23 @@ public class DataAdjustFactorDlg extends CaveSWTDialog { return mainLayout; } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() + */ @Override protected void disposed() { controlFont.dispose(); } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) + */ @Override protected void initializeComponents(Shell shell) { setReturnValue(false); @@ -236,21 +259,21 @@ public class DataAdjustFactorDlg extends CaveSWTDialog { locationTF = new Text(selectedItemGroup, SWT.BORDER); locationTF.setLayoutData(gd); locationTF.setTextLimit(8); - locationTF.addListener(SWT.Verify, new Listener(){ - public void handleEvent(Event e){ - String newStr = e.text; - char[] newChars = new char[newStr.length()]; - newStr.getChars(0, newChars.length, newChars, 0); - for (int i = 0; i < newChars.length; i++){ - if (!('0' <= newChars[i] && newChars[i] <= '9') && - !('a' <= newChars[i] && newChars[i] <= 'z') && - !('A' <= newChars[i] && newChars[i] <= 'Z')) { - e.doit = false; - } - } - e.text = e.text.toUpperCase(); - } - }); + locationTF.addListener(SWT.Verify, new Listener() { + public void handleEvent(Event e) { + String newStr = e.text; + char[] newChars = new char[newStr.length()]; + newStr.getChars(0, newChars.length, newChars, 0); + for (int i = 0; i < newChars.length; i++) { + if (!('0' <= newChars[i] && newChars[i] <= '9') + && !('a' <= newChars[i] && newChars[i] <= 'z') + && !('A' <= newChars[i] && newChars[i] <= 'Z')) { + e.doit = false; + } + } + e.text = e.text.toUpperCase(); + } + }); gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); gd.verticalSpan = 4; Label filler = new Label(selectedItemGroup, SWT.NONE); @@ -377,7 +400,7 @@ public class DataAdjustFactorDlg extends CaveSWTDialog { closeBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); @@ -440,8 +463,8 @@ public class DataAdjustFactorDlg extends CaveSWTDialog { } } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problem getting dialog data ", e); } } @@ -482,8 +505,8 @@ public class DataAdjustFactorDlg extends CaveSWTDialog { peList.add(currPE); } } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problem loading static data ", e); } } @@ -553,8 +576,7 @@ public class DataAdjustFactorDlg extends CaveSWTDialog { getDialogData(true); } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, "Probem saving record "); } } @@ -609,8 +631,8 @@ public class DataAdjustFactorDlg extends CaveSWTDialog { } // Divisor - divisorTF.setText(HydroDataUtils - .getDisplayString(currData.getDivisor())); + divisorTF + .setText(HydroDataUtils.getDisplayString(currData.getDivisor())); // Base baseTF.setText(HydroDataUtils.getDisplayString(currData.getBase())); @@ -693,7 +715,8 @@ public class DataAdjustFactorDlg extends CaveSWTDialog { try { HydroDBDataManager.getInstance().deleteRecord(currData); } catch (VizException e) { - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problem deleting record ", e); } getDialogData(true); @@ -704,6 +727,12 @@ public class DataAdjustFactorDlg extends CaveSWTDialog { } } + /** + * Display error message. + * + * @param title + * @param message + */ private void showMessage(String title, String message) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText(title); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataIngestFilterDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataIngestFilterDlg.java index eb0c416bb3..bd192b48d0 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataIngestFilterDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataIngestFilterDlg.java @@ -20,14 +20,20 @@ package com.raytheon.viz.hydrobase.dialogs; import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -44,6 +50,10 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.dataquery.db.QueryResult; +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.VizApp; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.viz.hydrocommon.HydroConstants; import com.raytheon.viz.hydrocommon.data.DataIngestFilterData; @@ -63,6 +73,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * Sep 4, 2008 lvenable Initial creation * Dec 11, 2008 1787 askripsk Connect to DB + * Apr 18, 2013 1790 rferrel Make dialog non-blocking. * * * @@ -70,6 +81,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * @version 1.0 */ public class DataIngestFilterDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(DataIngestFilterDlg.class); /** * Control font. @@ -263,6 +276,16 @@ public class DataIngestFilterDlg extends CaveSWTDialog { ADD_RECORD, NO_DATA, DATA_AVAILABLE } + /** + * Set to display's wait cursor. No need to dispose. + */ + private Cursor waitCursor; + + /** + * Used by setBusy to determine which cursor to display. + */ + private AtomicInteger busyCnt = new AtomicInteger(0); + /** * Constructor. * @@ -270,10 +293,15 @@ public class DataIngestFilterDlg extends CaveSWTDialog { * Parent shell. */ public DataIngestFilterDlg(Shell parent) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("Data Ingest Filter"); } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ @Override protected Layout constructShellLayout() { GridLayout mainLayout = new GridLayout(1, false); @@ -283,15 +311,29 @@ public class DataIngestFilterDlg extends CaveSWTDialog { return mainLayout; } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() + */ @Override protected void disposed() { controlFont.dispose(); } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) + */ @Override protected void initializeComponents(Shell shell) { setReturnValue(false); + waitCursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT); + controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); selectedItemControls = new ArrayList(); @@ -300,9 +342,17 @@ public class DataIngestFilterDlg extends CaveSWTDialog { createSelectedItemGroup(); createBottomButtons(); + } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened() + */ + @Override + protected void preOpened() { + super.preOpened(); populateStaticData(); - populateLists(true); } @@ -798,7 +848,7 @@ public class DataIngestFilterDlg extends CaveSWTDialog { okBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { if (saveRecord()) { - shell.dispose(); + close(); } } }); @@ -821,7 +871,7 @@ public class DataIngestFilterDlg extends CaveSWTDialog { cancelBtn.setLayoutData(gd); cancelBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); @@ -889,19 +939,12 @@ public class DataIngestFilterDlg extends CaveSWTDialog { physElemSelectedList.add(currPE); } } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problem populating static data ", e); } } - /** - * Populates the main ingest filter list with data from the database cache. - */ - private void populateLists() { - populateLists(false); - } - /** * Populates the main ingest filter list with data from the database. * @@ -911,32 +954,98 @@ public class DataIngestFilterDlg extends CaveSWTDialog { */ private void populateLists(boolean forceLoad) { ingestDataList.removeAll(); + setBusy(true); - DataIngestFilterDataManager man = DataIngestFilterDataManager - .getInstance(); + getIngestFilter(physElemChk.getSelection(), getSelectedPEs(), + locationChk.getSelection(), locationFilterTF.getText(), + switchesChk.getSelection(), masterFilterChk.getSelection(), + ofsFilterChk.getSelection(), mpeFilterChk.getSelection(), + typeSrcChk.getSelection(), + getSelectedStringValue(typeSrcFilterCbo), forceLoad); + } - try { - ArrayList temp = man.getIngestFilter( - physElemChk.getSelection(), getSelectedPEs(), locationChk - .getSelection(), locationFilterTF.getText(), - switchesChk.getSelection(), masterFilterChk.getSelection(), - ofsFilterChk.getSelection(), mpeFilterChk.getSelection(), - typeSrcChk.getSelection(), - getSelectedStringValue(typeSrcFilterCbo), forceLoad); + /** + * Queries manager for data to populate the ingest data list off the UI + * thread. + * + * @param physElemChkSelection + * @param selectedPEs + * @param locationChkSelection + * @param locationFilterText + * @param switchesChkSelection + * @param masterFilterChkSelection + * @param ofsFilterChkSelection + * @param mpeFilterChkSelection + * @param typeSrcChkSelection + * @param typeSrcFilterCboValue + * @param forceLoad + */ + private void getIngestFilter(final boolean physElemChkSelection, + final java.util.List selectedPEs, + final boolean locationChkSelection, + final String locationFilterText, + final boolean switchesChkSelection, + final boolean masterFilterChkSelection, + final boolean ofsFilterChkSelection, + final boolean mpeFilterChkSelection, + final boolean typeSrcChkSelection, + final String typeSrcFilterCboValue, final boolean forceLoad) { - for (DataIngestFilterData currData : temp) { + Job job = new Job("") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + + DataIngestFilterDataManager man = DataIngestFilterDataManager + .getInstance(); + java.util.List temp = null; + try { + temp = man.getIngestFilter(physElemChkSelection, + selectedPEs, locationChkSelection, + locationFilterText, switchesChkSelection, + masterFilterChkSelection, ofsFilterChkSelection, + mpeFilterChkSelection, typeSrcChkSelection, + typeSrcFilterCboValue, forceLoad); + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, + "Problem filter list ", e); + } finally { + final java.util.List t = temp; + VizApp.runAsync(new Runnable() { + + @Override + public void run() { + updatePopulateList(t); + } + }); + + } + return Status.OK_STATUS; + } + }; + job.schedule(); + } + + /** + * Update the ingest data list. + * + * @param difData + */ + private void updatePopulateList(java.util.List difData) { + if (difData != null) { + DataIngestFilterDataManager man = DataIngestFilterDataManager + .getInstance(); + for (DataIngestFilterData currData : difData) { ingestDataList.add(man.getIngestFilterString(currData)); } - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if (ingestDataList.getItemCount() > 0) { - updateDialogState(DialogStates.DATA_AVAILABLE); - } else { - updateDialogState(DialogStates.NO_DATA); + if (ingestDataList.getItemCount() > 0) { + updateDialogState(DialogStates.DATA_AVAILABLE); + } else { + updateDialogState(DialogStates.NO_DATA); + } } + setBusy(false); } /** @@ -944,9 +1053,9 @@ public class DataIngestFilterDlg extends CaveSWTDialog { * * @return */ - private ArrayList getSelectedPEs() { + private java.util.List getSelectedPEs() { int[] selectedInd = physElemFilterList.getSelectionIndices(); - ArrayList peFilter = new ArrayList(); + java.util.List peFilter = new ArrayList(); for (int i : selectedInd) { peFilter.add(physElemFilterList.getItem(i).split(" ")[0] @@ -1071,12 +1180,7 @@ public class DataIngestFilterDlg extends CaveSWTDialog { successful = true; } } catch (VizException e) { - MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - mb.setText("Unable to Save"); - mb.setMessage("An error occurred while saving"); - mb.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, "Problem saving record ", e); } populateLists(true); @@ -1108,8 +1212,8 @@ public class DataIngestFilterDlg extends CaveSWTDialog { mb.open(); } } catch (VizException e) { - // don't care, just return false - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problem checking constraints ", e); } return rval; @@ -1217,13 +1321,8 @@ public class DataIngestFilterDlg extends CaveSWTDialog { populateLists(true); } catch (VizException e) { - MessageBox mbErr = new MessageBox(shell, SWT.ICON_ERROR - | SWT.OK); - mbErr.setText("Unable to Save"); - mbErr.setMessage("An error occurred while saving"); - mbErr.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problem savings switches ", e); } } } @@ -1267,14 +1366,8 @@ public class DataIngestFilterDlg extends CaveSWTDialog { // Synchronize StnClass table StnClassSyncUtil.setStnClass(selectedData.getLid()); } catch (VizException e) { - MessageBox mbErr = new MessageBox(shell, SWT.ICON_ERROR - | SWT.OK); - mbErr.setText("Delete Failure"); - mbErr - .setMessage("An error occurred while trying to delete the record."); - mbErr.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problem deleting record ", e); } populateLists(true); @@ -1331,4 +1424,18 @@ public class DataIngestFilterDlg extends CaveSWTDialog { break; } } + + /** + * Determine what cursor to display. + * + * @param busy + */ + private void setBusy(boolean busy) { + if (busy) { + busyCnt.incrementAndGet(); + shell.setCursor(waitCursor); + } else if (busyCnt.decrementAndGet() == 0) { + shell.setCursor(null); + } + } } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataPurgeParamsDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataPurgeParamsDlg.java index 17a9495a97..e77b96e0dc 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataPurgeParamsDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DataPurgeParamsDlg.java @@ -20,12 +20,17 @@ package com.raytheon.viz.hydrobase.dialogs; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.TimeZone; +import java.util.concurrent.atomic.AtomicInteger; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -39,6 +44,10 @@ import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +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.VizApp; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.viz.hydrocommon.HydroConstants; import com.raytheon.viz.hydrocommon.data.PurgeDynData; @@ -58,6 +67,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Sep 4, 2008 lvenable Initial creation * Dec 17, 2008 1787 askripsk Connected to Database. * May 6, 2009 2181 mpduff Keep selection upon submit. + * Apr 18, 2013 1790 rferrel Make dialog non-blocking. * * * @@ -65,6 +75,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * @version 1.0 */ public class DataPurgeParamsDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(DataPurgeParamsDlg.class); /** * Location data list control. @@ -134,12 +146,12 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { /** * Cache of data for Location Data Purge Parameters */ - private ArrayList locDataPurgeParams; + private java.util.List locDataPurgeParams; /** * Cache of data for Text Product Purge Parameters */ - private ArrayList textProdPurgeParams; + private java.util.List textProdPurgeParams; /** * Date format for text products. @@ -151,6 +163,16 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { */ private int selectionIndex = -999; + /** + * System wait cursor. No need to dispose. + */ + Cursor waitCursor; + + /** + * Use by setBusy to determine cursor display. + */ + AtomicInteger busyCnt = new AtomicInteger(0); + /** * Constructor. * @@ -158,13 +180,18 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { * Parent shell. */ public DataPurgeParamsDlg(Shell parent) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("Data Purge Parameters"); textDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); textDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ @Override protected Layout constructShellLayout() { // Create the main layout for the shell. @@ -175,14 +202,29 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { return mainLayout; } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed() + */ @Override protected void disposed() { controlFont.dispose(); } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) + */ @Override protected void initializeComponents(Shell shell) { setReturnValue(false); + + waitCursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT); + // Initialize all of the controls and layouts controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); @@ -385,7 +427,7 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { closeBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); } @@ -445,31 +487,88 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { return labelStr; } + /** + * Retrieve purge data and update the display. + * + */ private void getDialogData() { getLocDialogData(); getTextDialogData(); } + /** + * Retrieve Purge Dyn Data and update the display. + */ private void getLocDialogData() { - try { - locDataPurgeParams = HydroDBDataManager.getInstance().getData( - PurgeDynData.class); + setBusy(true); - updateLocDialogDisplay(); - } catch (VizException e) { - e.printStackTrace(); - } + // Remove from UI thread. + Job job = new Job("") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + locDataPurgeParams = HydroDBDataManager.getInstance() + .getData(PurgeDynData.class); + VizApp.runAsync(new Runnable() { + @Override + public void run() { + updateLocDialogDisplay(); + } + }); + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, + "Problems getting location data. ", e); + } finally { + VizApp.runAsync(new Runnable() { + @Override + public void run() { + setBusy(false); + } + }); + } + return Status.OK_STATUS; + } + }; + job.schedule(); } + /** + * Retrieve Purge Product data and update the display. + */ private void getTextDialogData() { - try { - textProdPurgeParams = HydroDBDataManager.getInstance().getData( - PurgeProductData.class); + setBusy(true); - updateTextDialogDisplay(); - } catch (VizException e) { - e.printStackTrace(); - } + // Remove from UI thread. + Job job = new Job("") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + textProdPurgeParams = HydroDBDataManager.getInstance() + .getData(PurgeProductData.class); + VizApp.runAsync(new Runnable() { + + @Override + public void run() { + updateTextDialogDisplay(); + } + }); + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, + "Problems getting purge data. ", e); + } finally { + VizApp.runAsync(new Runnable() { + @Override + public void run() { + setBusy(false); + } + }); + } + return Status.OK_STATUS; + } + }; + job.schedule(); } private void updateLocDialogDisplay() { @@ -508,6 +607,12 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { } } + /** + * Format the Purge Dyn Data for display. + * + * @param currData + * @return + */ private String getDisplayString(PurgeDynData currData) { String displayFormat = "%-18s %-8s (%5s) %-8s (%5s) %-18.18s"; @@ -532,12 +637,19 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { String dayHoursBackup = String.format("%5d/%2d", numDays, numHours); return String.format(displayFormat, currData.getTableName(), - dayHoursHost, HydroDataUtils.getDisplayString(currData - .getHostHours()), dayHoursBackup, HydroDataUtils - .getDisplayString(currData.getBackupHours()), currData - .getTimeColumnName()); + dayHoursHost, + HydroDataUtils.getDisplayString(currData.getHostHours()), + dayHoursBackup, + HydroDataUtils.getDisplayString(currData.getBackupHours()), + currData.getTimeColumnName()); } + /** + * Format the purge product data for display. + * + * @param currData + * @return + */ private String getDisplayString(PurgeProductData currData) { String displayFormat = "%-10s %6s %-19s %-19s"; @@ -557,6 +669,9 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { prodTime, postTime); } + /** + * Update purge information for selected location. + */ private void updateLocationInformationDisplay() { PurgeDynData currData = getCurrentlySelectedLocation(); @@ -570,6 +685,9 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { } } + /** + * Update purge information for selected text product. + */ private void updateTextInformationDisplay() { PurgeProductData currData = getCurrentlySelectedText(); @@ -580,6 +698,10 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { } } + /** + * + * @return selected location purge data or null if none + */ private PurgeDynData getCurrentlySelectedLocation() { PurgeDynData rval = null; @@ -590,6 +712,10 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { return rval; } + /** + * + * @return selected text product purge data or null if none + */ private PurgeProductData getCurrentlySelectedText() { PurgeProductData rval = null; @@ -601,6 +727,9 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { return rval; } + /** + * Save current purged data. + */ private void saveLocRecord() { PurgeDynData currData = new PurgeDynData(); @@ -620,16 +749,15 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { getLocDialogData(); } catch (VizException e) { - MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - mb.setText("Unable to Save"); - mb.setMessage("An error occurred while trying to save."); - mb.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problems saving data. ", e); } } } + /* + * Save a record. + */ private void saveTextRecord() { PurgeProductData currData = new PurgeProductData(); @@ -647,24 +775,21 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { getTextDialogData(); } catch (VizException e) { - MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR - | SWT.OK); - mb.setText("Unable to Save"); - mb.setMessage("An error occurred while trying to save."); - mb.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problems saving data. ", e); } } else { MessageBox mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("Please enter data for Product ID and Versions To Keep."); + mb.setMessage("Please enter data for Product ID and Versions To Keep."); mb.open(); } } } + /** + * Remove a record. + */ private void deleteTextRecord() { PurgeProductData currData = getCurrentlySelectedText(); @@ -682,13 +807,8 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { selectionIndex = 0; getTextDialogData(); } catch (VizException e) { - mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete item."); - mb.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problems deleteing data. ", e); } } } else { @@ -698,4 +818,18 @@ public class DataPurgeParamsDlg extends CaveSWTDialog { mb.open(); } } + + /** + * Determine what cursor to display. + * + * @param busy + */ + private void setBusy(boolean busy) { + if (busy) { + busyCnt.incrementAndGet(); + shell.setCursor(waitCursor); + } else if (busyCnt.decrementAndGet() == 0) { + shell.setCursor(null); + } + } } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DatumDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DatumDlg.java index 5c3e09670f..37f8ad92fe 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DatumDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DatumDlg.java @@ -21,7 +21,6 @@ package com.raytheon.viz.hydrobase.dialogs; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.TimeZone; import org.eclipse.swt.SWT; @@ -40,6 +39,9 @@ import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +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.exception.VizException; import com.raytheon.viz.hydrocommon.HydroConstants; import com.raytheon.viz.hydrocommon.data.DatumData; @@ -56,6 +58,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Sep 4, 2008 lvenable Initial creation * Dec 5, 2008 1744 askripsky Connected to DB * 12/19/2008 1782 grichard Implemented IHydroDialog + * Apr 18, 2013 1790 rferrel Changes for non-blocking dialog. * * * @@ -63,6 +66,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * @version 1.0 */ public class DatumDlg extends CaveSWTDialog implements IHydroDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(DatumDlg.class); /** * Control font. @@ -96,7 +101,7 @@ public class DatumDlg extends CaveSWTDialog implements IHydroDialog { private DialogStates dialogState; - private ArrayList locationDatum; + private java.util.List locationDatum; private String lid; @@ -134,7 +139,7 @@ public class DatumDlg extends CaveSWTDialog implements IHydroDialog { @Override protected void initializeComponents(Shell shell) { - setReturnValue(false); + setReturnValue(lid); // Initialize all of the controls and layouts initializeComponents(); @@ -257,7 +262,7 @@ public class DatumDlg extends CaveSWTDialog implements IHydroDialog { closeBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); } @@ -286,8 +291,8 @@ public class DatumDlg extends CaveSWTDialog implements IHydroDialog { try { locationDatum = HydroDBDataManager.getInstance().getData(seedData); } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problem getting Datum data. ", e); } updateDialogDisplay(); @@ -345,8 +350,7 @@ public class DatumDlg extends CaveSWTDialog implements IHydroDialog { .format(currData.getDate()) : ""); elevationTF .setText((currData.getElevation() != HydroConstants.MISSING_VALUE) ? Double - .toString(currData.getElevation()) - : ""); + .toString(currData.getElevation()) : ""); } @Override @@ -391,16 +395,15 @@ public class DatumDlg extends CaveSWTDialog implements IHydroDialog { try { HydroDBDataManager.getInstance().putData(dataToSave); } catch (VizException e) { - MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - mb.setText("Unable to Save"); - mb.setMessage("An error occurred while trying to save."); - String cause = e.getCause().getMessage(); - int causeStart = cause.indexOf("ERROR:"); // If the exception contain the SQL exception "ERROR:" if (causeStart > 0) { + MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); + mb.setText("Unable to Save"); + mb.setMessage("An error occurred while trying to save."); + int causeEnd = cause.indexOf("\n", causeStart); cause = cause.substring(causeStart, causeEnd); @@ -409,11 +412,11 @@ public class DatumDlg extends CaveSWTDialog implements IHydroDialog { mb.setMessage("Please enter data for " + lid + " in the River Gauge dialog first"); } + mb.open(); + } else { + statusHandler.handle(Priority.PROBLEM, + "Problem saving record. ", e); } - - mb.open(); - - e.printStackTrace(); return false; } @@ -439,13 +442,8 @@ public class DatumDlg extends CaveSWTDialog implements IHydroDialog { dateTF.setText(""); elevationTF.setText(""); } catch (VizException e) { - MessageBox mbDel = new MessageBox(shell, SWT.ICON_ERROR - | SWT.OK); - mbDel.setText("Unable to Delete"); - mbDel.setMessage("An error occurred while trying to delete."); - mbDel.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Problem deleting record. ", e); } } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/GageHistoryDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/GageHistoryDlg.java index 3acd1fc922..900154449f 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/GageHistoryDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/GageHistoryDlg.java @@ -106,8 +106,9 @@ public class GageHistoryDlg extends CaveSWTDialog { * Location text control. */ private Text locationTF; - - private String currentLocText=null; + + private String currentLocText = null; + /** * OK button. */ @@ -126,7 +127,7 @@ public class GageHistoryDlg extends CaveSWTDialog { /** * Cache of Gages */ - private ArrayList gageData; + private java.util.List gageData; /** * Date format @@ -322,16 +323,15 @@ public class GageHistoryDlg extends CaveSWTDialog { locationTF = new Text(locationGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP); locationTF.setLayoutData(gd); locationTF.setTextLimit(255); - currentLocText=locationTF.getText(); + currentLocText = locationTF.getText(); ModifyListener listener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (locationTF.getText().length()>255){ - locationTF.setText(currentLocText); - shell.getDisplay().beep(); - } - else - currentLocText=locationTF.getText(); - } + public void modifyText(ModifyEvent e) { + if (locationTF.getText().length() > 255) { + locationTF.setText(currentLocText); + shell.getDisplay().beep(); + } else + currentLocText = locationTF.getText(); + } }; locationTF.addModifyListener(listener); @@ -449,9 +449,9 @@ public class GageHistoryDlg extends CaveSWTDialog { } } - private ArrayList getGageData(String table, String column) + private java.util.List getGageData(String table, String column) throws VizException { - ArrayList rval = new ArrayList(); + java.util.List rval = new ArrayList(); String query = "SELECT %s FROM %s ORDER BY %s"; query = String.format(query, column, table, column); @@ -490,8 +490,8 @@ public class GageHistoryDlg extends CaveSWTDialog { for (GageDBData currData : gageData) { endDate = (currData.getEndDate() != null) ? dateFormat .format(currData.getEndDate()) : ""; - dataList.add(String.format(format, currData.getType(), currData - .getOwner(), + dataList.add(String.format(format, currData.getType(), + currData.getOwner(), dateFormat.format(currData.getBeginDate()), endDate)); } @@ -564,8 +564,7 @@ public class GageHistoryDlg extends CaveSWTDialog { } catch (ParseException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("Please enter the Begin Date\nin the form: YYYY-MM-DD"); + mb.setMessage("Please enter the Begin Date\nin the form: YYYY-MM-DD"); mb.open(); return successful; @@ -581,8 +580,7 @@ public class GageHistoryDlg extends CaveSWTDialog { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("Please enter the End Date\nin the form: YYYY-MM-DD"); + mb.setMessage("Please enter the End Date\nin the form: YYYY-MM-DD"); mb.open(); return successful; @@ -612,8 +610,7 @@ public class GageHistoryDlg extends CaveSWTDialog { } catch (VizException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("An error occurred while trying to save the City"); + mb.setMessage("An error occurred while trying to save the City"); mb.open(); e.printStackTrace(); @@ -643,8 +640,7 @@ public class GageHistoryDlg extends CaveSWTDialog { } catch (VizException e) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete the entry"); + mb.setMessage("An error occurred while trying to delete the entry"); mb.open(); e.printStackTrace(); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/HydroGenConfigDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/HydroGenConfigDlg.java index 4e1193217c..2104d01171 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/HydroGenConfigDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/HydroGenConfigDlg.java @@ -102,7 +102,7 @@ public class HydroGenConfigDlg extends CaveSWTDialog { /** * Cache of display data. */ - private ArrayList stationData; + private java.util.List stationData; /** * Constructor. @@ -354,9 +354,9 @@ public class HydroGenConfigDlg extends CaveSWTDialog { String displayStr; for (HydroGenStationData currData : stationData) { - displayStr = String.format(format, currData.getLid(), currData - .getHsa(), currData.getPe(), currData.getTs(), currData - .getForecastTs()); + displayStr = String.format(format, currData.getLid(), + currData.getHsa(), currData.getPe(), currData.getTs(), + currData.getForecastTs()); locationList.add(displayStr); } @@ -368,8 +368,8 @@ public class HydroGenConfigDlg extends CaveSWTDialog { * @return The display string for the TS. * @throws VizException */ - public ArrayList getShefTs() throws VizException { - ArrayList rval = new ArrayList(); + public java.util.List getShefTs() throws VizException { + java.util.List rval = new ArrayList(); String tsQuery = "SELECT name, ts FROM shefts WHERE ts LIKE 'P%' or ts LIKE 'R%' ORDER BY ts"; @@ -395,8 +395,8 @@ public class HydroGenConfigDlg extends CaveSWTDialog { * @return The display string for the TS. * @throws VizException */ - public ArrayList getShefFcstTs() throws VizException { - ArrayList rval = new ArrayList(); + public java.util.List getShefFcstTs() throws VizException { + java.util.List rval = new ArrayList(); String tsQuery = "SELECT name, ts FROM shefts WHERE ts LIKE 'C%' or ts LIKE 'F%' ORDER BY ts"; @@ -492,8 +492,7 @@ public class HydroGenConfigDlg extends CaveSWTDialog { } catch (VizException e) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete the record."); + mb.setMessage("An error occurred while trying to delete the record."); mb.open(); e.printStackTrace(); @@ -615,8 +614,7 @@ public class HydroGenConfigDlg extends CaveSWTDialog { } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("The location must be add via the River Gauge dialog first."); + mb.setMessage("The location must be added via the River Gauge dialog first."); mb.open(); } } catch (VizException e) { diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/NwrTransmitterDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/NwrTransmitterDlg.java index 9c6f8acd88..48a581cc8f 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/NwrTransmitterDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/NwrTransmitterDlg.java @@ -19,8 +19,6 @@ **/ package com.raytheon.viz.hydrobase.dialogs; -import java.util.ArrayList; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -186,17 +184,17 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements /** * Cache of available counties */ - private ArrayList availableCounties; + private java.util.List availableCounties; /** * Cache of Transmitters */ - private ArrayList txData; + private java.util.List txData; /** * Cache of Transmitter's Counties */ - private ArrayList selectedCounties; + private java.util.List selectedCounties; /** * Cache of selected county and state diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/PublicationsDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/PublicationsDlg.java index 9968902a7b..36b42d046e 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/PublicationsDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/PublicationsDlg.java @@ -21,7 +21,6 @@ package com.raytheon.viz.hydrobase.dialogs; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.TimeZone; import org.eclipse.swt.SWT; @@ -136,7 +135,7 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog { /** * Publications Data. */ - private ArrayList pubData; + private java.util.List pubData; /** * Location Identifier. @@ -571,8 +570,7 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog { } catch (ParseException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Invalid Date"); - mb - .setMessage("Please enter a valid date in the form: MM/DD/YYYY"); + mb.setMessage("Please enter a valid date in the form: MM/DD/YYYY"); mb.open(); return false; } @@ -584,8 +582,7 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog { } catch (ParseException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Invalid Date"); - mb - .setMessage("Please enter a valid date in the form: MM/DD/YYYY"); + mb.setMessage("Please enter a valid date in the form: MM/DD/YYYY"); mb.open(); return false; } @@ -647,8 +644,7 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog { MessageBox mbDel = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mbDel.setText("Unable to Delete"); - mbDel - .setMessage("No item is selected in the publications list"); + mbDel.setMessage("No item is selected in the publications list"); mbDel.open(); } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RadarLocationsDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RadarLocationsDlg.java index bb6d7ac8bd..e5400c7292 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RadarLocationsDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RadarLocationsDlg.java @@ -19,8 +19,6 @@ **/ package com.raytheon.viz.hydrobase.dialogs; -import java.util.ArrayList; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -144,7 +142,7 @@ public class RadarLocationsDlg extends CaveSWTDialog { /** * Cache of Radar Locations */ - private ArrayList radarData; + private java.util.List radarData; /** * States of the dialog @@ -466,10 +464,10 @@ public class RadarLocationsDlg extends CaveSWTDialog { .getLatLonDisplayString(currLoc.getLatitude()), HydroDataUtils.getLatLonDisplayString(currLoc .getLongitude()), HydroDataUtils - .getDisplayString("%s", "%6.1f", currLoc - .getElevation()), HydroDataUtils - .getDisplayString("%s", "%5.1f", currLoc - .getTowerHeight()), currLoc + .getDisplayString("%s", "%6.1f", + currLoc.getElevation()), HydroDataUtils + .getDisplayString("%s", "%5.1f", + currLoc.getTowerHeight()), currLoc .getUseRadar(), currLoc.getOfficeID())); } @@ -590,8 +588,7 @@ public class RadarLocationsDlg extends CaveSWTDialog { } catch (VizException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("An error occurred while trying to save the Radar Location"); + mb.setMessage("An error occurred while trying to save the Radar Location"); mb.open(); e.printStackTrace(); @@ -610,12 +607,11 @@ public class RadarLocationsDlg extends CaveSWTDialog { MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); mb.setText("Delete Confirmation"); - mb - .setMessage("WARNING: You are about to delete radar information \n" - + "from multiple tables. Are you sure you want to do this? \n\n" - + "(Note: If you delete this radar now, you will NOT be able to \n" - + "recover the non-default values for the affected tables.) \n\n" - + "If you do not wish to delete at this time, click \"Cancel\"."); + mb.setMessage("WARNING: You are about to delete radar information \n" + + "from multiple tables. Are you sure you want to do this? \n\n" + + "(Note: If you delete this radar now, you will NOT be able to \n" + + "recover the non-default values for the affected tables.) \n\n" + + "If you do not wish to delete at this time, click \"Cancel\"."); int result = mb.open(); @@ -631,8 +627,7 @@ public class RadarLocationsDlg extends CaveSWTDialog { } catch (VizException e) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete the City"); + mb.setMessage("An error occurred while trying to delete the City"); mb.open(); e.printStackTrace(); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReferenceFieldsDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReferenceFieldsDlg.java index d3eabaac1e..7a86987101 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReferenceFieldsDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReferenceFieldsDlg.java @@ -19,8 +19,6 @@ **/ package com.raytheon.viz.hydrobase.dialogs; -import java.util.ArrayList; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -98,12 +96,12 @@ public class ReferenceFieldsDlg extends CaveSWTDialog { /** * Dam Type Data. */ - private ArrayList damTypeData; + private java.util.List damTypeData; /** * Reservoir Owner Data. */ - private ArrayList resOwnerData; + private java.util.List resOwnerData; private final int OWNER = 0; @@ -389,8 +387,7 @@ public class ReferenceFieldsDlg extends CaveSWTDialog { if (dataList.getSelectionIndex() < 0) { MessageBox mb = new MessageBox(getParent(), SWT.ICON_ERROR | SWT.OK); mb.setText("Delete Error"); - mb - .setMessage("You need to select an item from the list for deletion."); + mb.setMessage("You need to select an item from the list for deletion."); mb.open(); return; } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReferencesDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReferencesDlg.java index 9d9783e83f..58e0b0a45e 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReferencesDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReferencesDlg.java @@ -19,8 +19,6 @@ **/ package com.raytheon.viz.hydrobase.dialogs; -import java.util.ArrayList; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -51,7 +49,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Sep 8, 2008 lvenable Initial creation. * 12/19/2008 1782 grichard Connected to IHFS DB. * Nov 03 2011 11273 lbousaidi make changes to update an existing entry - * without creating new entry + * without creating new entry * * * @@ -105,16 +103,14 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog { /** * Array of reference data. */ - private ArrayList referenceData; + private java.util.List referenceData; /** * Location ID. */ private String lid; - - private boolean newInsert=false; - - + + private boolean newInsert = false; /** * Constructor. @@ -273,7 +269,7 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog { newBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - newInsert=true; + newInsert = true; clearForm(); okBtn.setEnabled(true); applyBtn.setEnabled(true); @@ -426,22 +422,21 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog { // Save to DB try { - if ((referenceList.getSelectionIndex() < 0) && - (newInsert)) { - HydroDBDataManager.getInstance().putData(dataToSave); - newInsert=false; - } else { - - //Data Listed - ReferencesData dataDisplayed = new ReferencesData(); - dataDisplayed.setLid(lid); - dataDisplayed.setReference(referenceList. - getItem(referenceList.getSelectionIndex())); - HydroDBDataManager.getInstance(). - putNewData(dataToSave, dataDisplayed, newInsert); - referenceList.setSelection(referenceList.getSelectionIndex()); - newInsert=false; - } + if ((referenceList.getSelectionIndex() < 0) && (newInsert)) { + HydroDBDataManager.getInstance().putData(dataToSave); + newInsert = false; + } else { + + // Data Listed + ReferencesData dataDisplayed = new ReferencesData(); + dataDisplayed.setLid(lid); + dataDisplayed.setReference(referenceList.getItem(referenceList + .getSelectionIndex())); + HydroDBDataManager.getInstance().putNewData(dataToSave, + dataDisplayed, newInsert); + referenceList.setSelection(referenceList.getSelectionIndex()); + newInsert = false; + } } catch (VizException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); @@ -495,8 +490,7 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog { MessageBox mbDel = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mbDel.setText("Unable to Delete"); - mbDel - .setMessage("No item is selected in the reference list"); + mbDel.setMessage("No item is selected in the reference list"); mbDel.open(); } @@ -515,12 +509,11 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog { // Refresh the data getDialogData(); - - if (referenceList.getItemCount() !=0 ) { - referenceList.setSelection(0); - updateInformation(); - } - + + if (referenceList.getItemCount() != 0) { + referenceList.setSelection(0); + updateInformation(); + } } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReservoirDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReservoirDlg.java index 0d1867de52..f412c0c3ff 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReservoirDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/ReservoirDlg.java @@ -21,7 +21,6 @@ package com.raytheon.viz.hydrobase.dialogs; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.TimeZone; import org.eclipse.swt.SWT; @@ -212,17 +211,17 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog { /** * Dam Type Data. */ - private ArrayList damTypesData; + private java.util.List damTypesData; /** * Reservoir Owner Data. */ - private ArrayList resOwnerData; + private java.util.List resOwnerData; /** * Reservoir Data. */ - private ArrayList resData; + private java.util.List resData; /** * Location Identifier. @@ -718,8 +717,7 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog { topTF.setText(HydroDataUtils.getDisplayString(currData.getTop())); maxSurchargeTF.setText(HydroDataUtils.getDisplayString(currData .getSurchg())); - gatesTF.setText(HydroDataUtils - .getDisplayString(currData.getGates())); + gatesTF.setText(HydroDataUtils.getDisplayString(currData.getGates())); impoundTF.setText((currData.getImpounded() != null) ? dateFormat .format(currData.getImpounded()) : ""); floodControlChk @@ -827,18 +825,17 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog { * @return true if form is correctly filled out */ private boolean validateDateForm() { - boolean isValid = true; + boolean isValid = true; - if (impoundTF.getText().equals("")) { - isValid = false; + if (impoundTF.getText().equals("")) { + isValid = false; } if (!isValid) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Invalid Date"); - mb - .setMessage("Please enter a valid date in the form:MM/DD/YYYY"); - + mb.setMessage("Please enter a valid date in the form:MM/DD/YYYY"); + mb.open(); } @@ -859,31 +856,32 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog { dataToSave.setType(typeCbo.getText()); dataToSave.setOwner(ownerCbo.getText()); if (!deadTF.getText().equals("")) { - dataToSave.setDeadpool(Double.parseDouble(deadTF.getText())); + dataToSave.setDeadpool(Double.parseDouble(deadTF.getText())); } - if (!conservationTF.getText().equals("")){ - dataToSave.setConserpool(Double.parseDouble(conservationTF.getText())); + if (!conservationTF.getText().equals("")) { + dataToSave.setConserpool(Double.parseDouble(conservationTF + .getText())); } - if (!floodTF.getText().equals("")){ - dataToSave.setFloodpool(Double.parseDouble(floodTF.getText())); + if (!floodTF.getText().equals("")) { + dataToSave.setFloodpool(Double.parseDouble(floodTF.getText())); } if (!spillwayTF.getText().equals("")) { - dataToSave.setSpillway(Double.parseDouble(spillwayTF.getText())); + dataToSave.setSpillway(Double.parseDouble(spillwayTF.getText())); } if (!sillTF.getText().equals("")) { - dataToSave.setSill(Double.parseDouble(sillTF.getText())); + dataToSave.setSill(Double.parseDouble(sillTF.getText())); } if (!reservoirTF.getText().equals("")) { - dataToSave.setElev(Double.parseDouble(reservoirTF.getText())); + dataToSave.setElev(Double.parseDouble(reservoirTF.getText())); } if (!topTF.getText().equals("")) { - dataToSave.setTop(Double.parseDouble(topTF.getText())); + dataToSave.setTop(Double.parseDouble(topTF.getText())); } if (!maxSurchargeTF.getText().equals("")) { - dataToSave.setSurchg(Double.parseDouble(maxSurchargeTF.getText())); + dataToSave.setSurchg(Double.parseDouble(maxSurchargeTF.getText())); } if (!gatesTF.getText().equals("")) { - dataToSave.setGates(Integer.parseInt(gatesTF.getText())); + dataToSave.setGates(Integer.parseInt(gatesTF.getText())); } if (!impoundTF.getText().equals("")) { try { @@ -892,8 +890,7 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog { } catch (ParseException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Invalid Date"); - mb - .setMessage("Please enter a valid date in the form: MM/DD/YYYY"); + mb.setMessage("Please enter a valid date in the form: MM/DD/YYYY"); mb.open(); return false; } @@ -975,8 +972,7 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog { MessageBox mbDel = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mbDel.setText("Unable to Delete"); - mbDel - .setMessage("No item is selected in the reservoir list"); + mbDel.setMessage("No item is selected in the reservoir list"); mbDel.open(); } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverGageDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverGageDlg.java index 5e8c1deebe..db2e13b77d 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverGageDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverGageDlg.java @@ -21,7 +21,6 @@ package com.raytheon.viz.hydrobase.dialogs; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; @@ -290,10 +289,10 @@ public class RiverGageDlg extends CaveSWTDialog implements * Value for no Forecast Group assignment */ private final String NO_FCST_GROUP_SELECTED = "(Not a Forecast Point)"; - + /** Original latitude value */ private String origLat; - + /** Original longitude value */ private String origLon; @@ -307,12 +306,13 @@ public class RiverGageDlg extends CaveSWTDialog implements /** * text from the remark text box */ - private String currentRemarkText=null; - + private String currentRemarkText = null; + /** * maximum number of character allowed in the remark text box */ - private final int MAX_REMARK_CHAR=255; + private final int MAX_REMARK_CHAR = 255; + /** * Constructor. * @@ -633,20 +633,21 @@ public class RiverGageDlg extends CaveSWTDialog implements remarksTF.setLayoutData(gd); remarksTF.setFont(controlFont); remarksTF.setTextLimit(MAX_REMARK_CHAR); - - /*Note: use this method to control number of character in remarkTF - * because a bug in the Text class. - * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=43004*/ - currentRemarkText=remarksTF.getText(); + + /* + * Note: use this method to control number of character in remarkTF + * because a bug in the Text class. See + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=43004 + */ + currentRemarkText = remarksTF.getText(); ModifyListener listener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (remarksTF.getText().length()>MAX_REMARK_CHAR){ - remarksTF.setText(currentRemarkText); - shell.getDisplay().beep(); - } - else - currentRemarkText=remarksTF.getText(); - } + public void modifyText(ModifyEvent e) { + if (remarksTF.getText().length() > MAX_REMARK_CHAR) { + remarksTF.setText(currentRemarkText); + shell.getDisplay().beep(); + } else + currentRemarkText = remarksTF.getText(); + } }; remarksTF.addModifyListener(listener); @@ -900,14 +901,14 @@ public class RiverGageDlg extends CaveSWTDialog implements RiverStatData seedData = new RiverStatData(); seedData.setLid(lid); - ArrayList data = null; + java.util.List data = null; try { data = HydroDBDataManager.getInstance().getData(seedData); RPFFcstPointData seedDataGroup = new RPFFcstPointData(); seedDataGroup.setLid(lid); - ArrayList dataGroup = HydroDBDataManager + java.util.List dataGroup = HydroDBDataManager .getInstance().getData(seedDataGroup); if (dataGroup.size() > 0) { @@ -940,17 +941,15 @@ public class RiverGageDlg extends CaveSWTDialog implements // Lat/Lon latitudeTF - .setText((riverGageData.getLatitude() != HydroConstants.MISSING_VALUE) ? - String.valueOf(riverGageData.getLatitude()) - : ""); + .setText((riverGageData.getLatitude() != HydroConstants.MISSING_VALUE) ? String + .valueOf(riverGageData.getLatitude()) : ""); origLat = latitudeTF.getText(); - + longitudeTF - .setText((riverGageData.getLongitude() != HydroConstants.MISSING_VALUE) ? - String.valueOf(riverGageData.getLongitude()) - : ""); + .setText((riverGageData.getLongitude() != HydroConstants.MISSING_VALUE) ? String + .valueOf(riverGageData.getLongitude()) : ""); origLon = longitudeTF.getText(); - + // Drainage Area drainageAreaTF.setText(HydroDataUtils .getDisplayString(riverGageData.getDrainageArea())); @@ -1161,58 +1160,58 @@ public class RiverGageDlg extends CaveSWTDialog implements // Latitude String latTxt = latitudeTF.getText(); if (!latTxt.equals(origLat)) { - double lat = HydroConstants.MISSING_VALUE; - if (!latTxt.equals("")) { - boolean invalidLat = false; - - try { - lat = GeoUtil.getInstance().cvt_spaced_format(latTxt, 0); - } catch (Exception e) { - invalidLat = true; - } - - if ((lat < -90) || (lat > 90) || invalidLat) { - MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - mb.setText("Invalid Value"); - mb - .setMessage("Please enter a VALID (-90 to 90) Latitude\nin the form: DD MM SS"); - mb.open(); - - return successful; - } - } - newData.setLatitude(lat); + double lat = HydroConstants.MISSING_VALUE; + if (!latTxt.equals("")) { + boolean invalidLat = false; + + try { + lat = GeoUtil.getInstance().cvt_spaced_format(latTxt, 0); + } catch (Exception e) { + invalidLat = true; + } + + if ((lat < -90) || (lat > 90) || invalidLat) { + MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR + | SWT.OK); + mb.setText("Invalid Value"); + mb.setMessage("Please enter a VALID (-90 to 90) Latitude\nin the form: DD MM SS"); + mb.open(); + + return successful; + } + } + newData.setLatitude(lat); } else { - newData.setLatitude(this.riverGageData.getLatitude()); + newData.setLatitude(this.riverGageData.getLatitude()); } - + // Longitude String lonTxt = longitudeTF.getText(); if (!lonTxt.equals(origLon)) { - double lon = HydroConstants.MISSING_VALUE; - if (!lonTxt.equals("")) { - boolean invalidLon = false; - - try { - lon = GeoUtil.getInstance().cvt_spaced_format(lonTxt, 0); - } catch (Exception e) { - invalidLon = true; - e.printStackTrace(); - } - - if ((lon > 180) || (lon < -180) || invalidLon) { - MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - mb.setText("Invalid Value"); - mb - .setMessage("Please enter a VALID (-180 to 180) Longitude\nin the form: DD MM SS"); - mb.open(); - - return successful; - } - } - newData.setLongitude(lon); + double lon = HydroConstants.MISSING_VALUE; + if (!lonTxt.equals("")) { + boolean invalidLon = false; + + try { + lon = GeoUtil.getInstance().cvt_spaced_format(lonTxt, 0); + } catch (Exception e) { + invalidLon = true; + e.printStackTrace(); + } + + if ((lon > 180) || (lon < -180) || invalidLon) { + MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR + | SWT.OK); + mb.setText("Invalid Value"); + mb.setMessage("Please enter a VALID (-180 to 180) Longitude\nin the form: DD MM SS"); + mb.open(); + + return successful; + } + } + newData.setLongitude(lon); } else { - newData.setLongitude(riverGageData.getLongitude()); + newData.setLongitude(riverGageData.getLongitude()); } // Remarks @@ -1279,13 +1278,11 @@ public class RiverGageDlg extends CaveSWTDialog implements // Rating Date if (!dateRatingTF.getText().equals("")) { try { - newData.setDateOfRating(dateFormat - .parse(dateRatingTF.getText())); + newData.setDateOfRating(dateFormat.parse(dateRatingTF.getText())); } catch (ParseException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Invalid Value"); - mb - .setMessage("Please enter a Date of Rating\nin the form: YYYY-MM-DD"); + mb.setMessage("Please enter a Date of Rating\nin the form: YYYY-MM-DD"); mb.open(); e.printStackTrace(); @@ -1325,8 +1322,7 @@ public class RiverGageDlg extends CaveSWTDialog implements } catch (VizException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("An error occurred while trying to save the River Gage"); + mb.setMessage("An error occurred while trying to save the River Gage"); mb.open(); e.printStackTrace(); @@ -1392,8 +1388,8 @@ public class RiverGageDlg extends CaveSWTDialog implements RPFFcstPointData seedData = new RPFFcstPointData(); seedData.setLid(lid); - ArrayList data = HydroDBDataManager.getInstance() - .getData(seedData); + java.util.List data = HydroDBDataManager + .getInstance().getData(seedData); if (data.size() > 0) { // Should be only one record per lid @@ -1426,8 +1422,7 @@ public class RiverGageDlg extends CaveSWTDialog implements } catch (VizException e) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete the River Gage"); + mb.setMessage("An error occurred while trying to delete the River Gage"); mb.open(); e.printStackTrace(); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverProFcstGrpPointsDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverProFcstGrpPointsDlg.java index 99d8667553..526ec713e8 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverProFcstGrpPointsDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverProFcstGrpPointsDlg.java @@ -177,12 +177,12 @@ public class RiverProFcstGrpPointsDlg extends CaveSWTDialog { /** * The group info */ - private ArrayList groupData; + private java.util.List groupData; /** * The point info for each group */ - private HashMap> pointData; + private HashMap> pointData; /** * States for the dialog @@ -551,8 +551,8 @@ public class RiverProFcstGrpPointsDlg extends CaveSWTDialog { secondaryHsaList.removeAll(); try { - ArrayList hsa = AddModifyLocationDataManager.getInstance() - .getHSAs(); + java.util.List hsa = AddModifyLocationDataManager + .getInstance().getHSAs(); for (String currHSA : hsa) { primaryHsaList.add(currHSA); @@ -574,25 +574,25 @@ public class RiverProFcstGrpPointsDlg extends CaveSWTDialog { RPFFcstGroupData.class); // Initialize the Point map - pointData = new HashMap>(); + pointData = new HashMap>(); // Get the point info - ArrayList temp = HydroDBDataManager.getInstance() - .getData(RPFFcstPointData.class); + java.util.List temp = HydroDBDataManager + .getInstance().getData(RPFFcstPointData.class); - ArrayList tempArr; + java.util.List tempArr; for (RPFFcstPointData currPoint : temp) { - // Get the ArrayList for the Group ID + // Get the List for the Group ID if (pointData.containsKey(currPoint.getGroupID())) { tempArr = pointData.get(currPoint.getGroupID()); } else { tempArr = new ArrayList(); } - // Add the point to the ArrayList + // Add the point to the List tempArr.add(currPoint); - // Store the ArrayList in the point data + // Store the List in the point data pointData.put(currPoint.getGroupID(), tempArr); } @@ -630,9 +630,10 @@ public class RiverProFcstGrpPointsDlg extends CaveSWTDialog { private String getDisplayString(RPFFcstGroupData currGroup) { String rval = "%-8.8s %-32.32s %-4.4s %-1s"; - return String.format(rval, currGroup.getGroupID(), currGroup - .getGroupName(), HydroDataUtils.getDisplayString(currGroup - .getOrdinal()), currGroup.getRecommendAll()); + return String.format(rval, currGroup.getGroupID(), + currGroup.getGroupName(), + HydroDataUtils.getDisplayString(currGroup.getOrdinal()), + currGroup.getRecommendAll()); } /** @@ -645,15 +646,20 @@ public class RiverProFcstGrpPointsDlg extends CaveSWTDialog { private String getDisplayString(RPFFcstPointData currPoint) { String rval = "%-8s %-30.30s %3.3s %-3s %s %-3.3s %-3.3s %-6.6s %-6.6s %6.6s"; - return String.format(rval, currPoint.getLid(), currPoint.getLidName(), + return String.format( + rval, + currPoint.getLid(), + currPoint.getLidName(), HydroDataUtils.getDisplayString(currPoint.getOrdinal()), - currPoint.getRecordType(), HydroDataUtils.getDisplayString( - "%s", "%.2f", currPoint.getChangeThreshold()), - currPoint.getPrimaryBackup(), currPoint.getSecondaryBackup(), + currPoint.getRecordType(), + HydroDataUtils.getDisplayString("%s", "%.2f", + currPoint.getChangeThreshold()), + currPoint.getPrimaryBackup(), + currPoint.getSecondaryBackup(), HydroDataUtils.getDisplayString(currPoint.getBackHours()), HydroDataUtils.getDisplayString(currPoint.getForwardHours()), - HydroDataUtils.getDisplayString("%s", "%6.1f", currPoint - .getAdjustEndHours())); + HydroDataUtils.getDisplayString("%s", "%6.1f", + currPoint.getAdjustEndHours())); } /** @@ -696,10 +702,9 @@ public class RiverProFcstGrpPointsDlg extends CaveSWTDialog { } updateDialogState(DialogStates.POINTS_AVAILABLE); - - if (fcstPointList.getItemCount() > 0 ) - { - fcstPointList.setSelection(0); + + if (fcstPointList.getItemCount() > 0) { + fcstPointList.setSelection(0); } } else { updateDialogState(DialogStates.NO_POINTS); @@ -942,9 +947,8 @@ public class RiverProFcstGrpPointsDlg extends CaveSWTDialog { MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); mb.setText("Delete Confirmation"); - mb - .setMessage("Do you want to delete this Forecast Group?\n" - + "(This will remove all Forecast Point associations to this Group.)"); + mb.setMessage("Do you want to delete this Forecast Group?\n" + + "(This will remove all Forecast Point associations to this Group.)"); int result = mb.open(); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverProGenParamsDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverProGenParamsDlg.java index 7fd4daebf3..55f7d1bfa5 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverProGenParamsDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/RiverProGenParamsDlg.java @@ -19,8 +19,6 @@ **/ package com.raytheon.viz.hydrobase.dialogs; -import java.util.ArrayList; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -313,8 +311,8 @@ public class RiverProGenParamsDlg extends CaveSWTDialog { private void getDialogData() { try { - ArrayList data = HydroDBDataManager.getInstance() - .getData(RPFParamData.class); + java.util.List data = HydroDBDataManager + .getInstance().getData(RPFParamData.class); if (data != null && data.size() > 0) { // There should only be one record diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/StatesCountiesZonesDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/StatesCountiesZonesDlg.java index 8598a36a6f..813bd2d3dc 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/StatesCountiesZonesDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/StatesCountiesZonesDlg.java @@ -19,8 +19,6 @@ **/ package com.raytheon.viz.hydrobase.dialogs; -import java.util.ArrayList; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -186,17 +184,17 @@ public class StatesCountiesZonesDlg extends CaveSWTDialog { /** * Zone Cache */ - private ArrayList zoneData; + private java.util.List zoneData; /** * County Cache */ - private ArrayList countyData; + private java.util.List countyData; /** * State Cache */ - private ArrayList stateData; + private java.util.List stateData; /** * Display states for the dialog @@ -801,8 +799,7 @@ public class StatesCountiesZonesDlg extends CaveSWTDialog { } catch (VizException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("An error occurred while trying to save the State"); + mb.setMessage("An error occurred while trying to save the State"); mb.open(); e.printStackTrace(); @@ -840,8 +837,7 @@ public class StatesCountiesZonesDlg extends CaveSWTDialog { } catch (VizException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("An error occurred while trying to save the County"); + mb.setMessage("An error occurred while trying to save the County"); mb.open(); e.printStackTrace(); @@ -869,8 +865,7 @@ public class StatesCountiesZonesDlg extends CaveSWTDialog { } catch (VizException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("An error occurred while trying to save the Zone"); + mb.setMessage("An error occurred while trying to save the Zone"); mb.open(); e.printStackTrace(); @@ -911,8 +906,7 @@ public class StatesCountiesZonesDlg extends CaveSWTDialog { } catch (VizException e) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete the State"); + mb.setMessage("An error occurred while trying to delete the State"); mb.open(); e.printStackTrace(); @@ -946,8 +940,7 @@ public class StatesCountiesZonesDlg extends CaveSWTDialog { } catch (VizException e) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete the County"); + mb.setMessage("An error occurred while trying to delete the County"); mb.open(); e.printStackTrace(); @@ -981,8 +974,7 @@ public class StatesCountiesZonesDlg extends CaveSWTDialog { } catch (VizException e) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete the Zone"); + mb.setMessage("An error occurred while trying to delete the Zone"); mb.open(); e.printStackTrace(); @@ -1061,8 +1053,8 @@ public class StatesCountiesZonesDlg extends CaveSWTDialog { // Check if WFO Exists if (data.getResultCount() > 0) { data = HydroDBDataManager.getInstance().runMappedQuery( - String.format(stateQuery, countiesStateTF - .getText())); + String.format(stateQuery, + countiesStateTF.getText())); // Check if State Exists if (data.getResultCount() > 0) { @@ -1085,8 +1077,7 @@ public class StatesCountiesZonesDlg extends CaveSWTDialog { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("Please choose a Secondary Backup that exists."); + mb.setMessage("Please choose a Secondary Backup that exists."); mb.open(); } } else { diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorDataTypeSets.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorDataTypeSets.java index 957940e471..21457d22a4 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorDataTypeSets.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorDataTypeSets.java @@ -22,6 +22,7 @@ package com.raytheon.viz.hydrocommon.colorscalemgr; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -35,7 +36,9 @@ import org.eclipse.swt.graphics.RGB; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * 29 NOV 2007 373 lvenable Initial creation + * 29 NOV 2007 373 lvenable Initial creation. + * 18 APR 2013 1790 rferrel Clean up method interfaces; + * part of non-blocking dialogs. * * * @@ -122,7 +125,7 @@ public class ColorDataTypeSets { * Data type key. * @return Array of color set data (updated). */ - public ArrayList getColorScaleDataArray(String dataTypeKey) { + public List getColorScaleDataArray(String dataTypeKey) { ColorScaleSets colorSets = dataTypeMap.get(dataTypeKey); if (colorSets == null) { return new ArrayList(); @@ -138,8 +141,7 @@ public class ColorDataTypeSets { * Data type key. * @return Array of color set data (used). */ - public ArrayList getUsedColorScaleDataArray( - String dataTypeKey) { + public List getUsedColorScaleDataArray(String dataTypeKey) { ColorScaleSets colorSets = dataTypeMap.get(dataTypeKey); if (colorSets == null) { return new ArrayList(); diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorScaleMgrDlg.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorScaleMgrDlg.java index 98052253fd..e1e04619a3 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorScaleMgrDlg.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorScaleMgrDlg.java @@ -54,8 +54,6 @@ import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.RGBColors; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.viz.hydrocommon.Activator; -import com.raytheon.viz.hydrocommon.constants.StatusConstants; import com.raytheon.viz.hydrocommon.data.ColorValueData; import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; @@ -70,7 +68,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * 29 NOV 2007 373 lvenable Initial creation * 23 Feb 2011 5400 lbousaidi fixed issues in color/value bar * 11 Mar 2013 15065 lbousaidi fixed issue with both color legend - * disappearing after save + * disappearing after save * * * @author lvenable @@ -78,7 +76,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * */ public class ColorScaleMgrDlg extends CaveSWTDialog { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(ColorScaleMgrDlg.class); + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(ColorScaleMgrDlg.class); + private static final String OFFICE = "Office"; private static final String DEFAULT = "Default"; @@ -110,12 +110,12 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { /** * Updated Color/Value array of color and value labels. */ - private ArrayList colorValLblArray; + private java.util.List colorValLblArray; /** * Used Color/Value array of color and value labels. */ - private ArrayList usedColorValLblArray; + private java.util.List usedColorValLblArray; /** * Source combo box. @@ -228,7 +228,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { */ private Combo browseDurationCbo; - private ArrayList browseColorValLblArray; + private java.util.List browseColorValLblArray; private Composite browseLabelComp; @@ -749,7 +749,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { changeBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - if (valueTF.getText() == null || valueTF.getText().equals("")) { + if (valueTF.getText() == null || valueTF.getText().equals("")) { MessageBox mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); mb.setText("Choose a value"); @@ -757,7 +757,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { mb.open(); return; - } + } String source = getSource(); changeColor(currentColor.getRGB(), source); updateColorValueLabelBar(); @@ -1094,7 +1094,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { private void createEditColorDisplay(Composite parentComp) { String source = getSource(); - ArrayList updatedColorSet = editColorData + java.util.List updatedColorSet = editColorData .getColorScaleDataArray(source, selectedDurationInSeconds + "_" + dataTypeCbo.getText()); @@ -1134,7 +1134,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { private void createBrowseEditColorDisplay(Composite parentComp) { String source = getSource(); - ArrayList updatedColorSet = editColorData + java.util.List updatedColorSet = editColorData .getColorScaleDataArray(source, selectedBrowseDurationInSeconds + "_" + browseDataTypeCbo.getText()); @@ -1269,7 +1269,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { * Parent composite. */ private void createUsedColorDisplay(Composite parentComp) { - ArrayList usedColorSet = editColorData + java.util.List usedColorSet = editColorData .getUsedColorScaleDataArray(sourceCbo.getText(), selectedDurationInSeconds + "_" + dataTypeCbo.getText()); @@ -1419,9 +1419,11 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { durationCbo.add("0"); } else { // HERE is the NULL Pointer - String dataType = colorManager.getDataTypeName(dataTypeCbo.getText()); + String dataType = colorManager.getDataTypeName(dataTypeCbo + .getText()); Set durations = editColorData.getColorDataTypeSets( - sourceKey).getDurations(colorManager.getDescription(dataType)); + sourceKey).getDurations( + colorManager.getDescription(dataType)); Iterator i = durations.iterator(); while (i.hasNext()) { addDuration(i.next()); @@ -1436,7 +1438,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { */ private void updateBrowseDurationCombo() { String source = getSource(); - ArrayList durations; + java.util.List durations; if (source.equals(DEFAULT)) { durations = new ArrayList(); durations.add("0"); @@ -1465,17 +1467,16 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { String source = getSource(); - ArrayList updatedColorSet = editColorData + java.util.List updatedColorSet = editColorData .getColorScaleDataArray(source, selectedDurationInSeconds + "_" + dataTypeCbo.getText()); - // ArrayList updatedColorSet = editColorData + // java.util.List updatedColorSet = editColorData // .getColorScaleDataArray(source, durationCbo.getText() + "_" // + dataTypeCbo.getText()); - - if (updatedColorSet.size()==0) { - updatedColorSet = editColorData - .getColorScaleDataArray(source, 0 + "_" - + dataTypeCbo.getText()); + + if (updatedColorSet.size() == 0) { + updatedColorSet = editColorData.getColorScaleDataArray(source, 0 + + "_" + dataTypeCbo.getText()); } int numCols = updatedColorSet.size(); @@ -1515,7 +1516,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { String source = getSource(); - ArrayList updatedColorSet = editColorData + java.util.List updatedColorSet = editColorData .getColorScaleDataArray(source, selectedBrowseDurationInSeconds + "_" + browseDataTypeCbo.getText()); if (updatedColorSet == null) { @@ -1560,18 +1561,17 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { String source = getSource(); - // ArrayList updatedColorSet = editColorData + // java.util.List updatedColorSet = editColorData // .getUsedColorScaleDataArray(source, durationCbo.getText() + "_" // + dataTypeCbo.getText()); - ArrayList updatedColorSet = editColorData + java.util.List updatedColorSet = editColorData .getUsedColorScaleDataArray(source, selectedDurationInSeconds + "_" + dataTypeCbo.getText()); - - //use default color - if (updatedColorSet.size() == 0 ) { - updatedColorSet = editColorData - .getUsedColorScaleDataArray(source, 0 - + "_" + dataTypeCbo.getText()); + + // use default color + if (updatedColorSet.size() == 0) { + updatedColorSet = editColorData.getUsedColorScaleDataArray(source, + 0 + "_" + dataTypeCbo.getText()); } int numCols = updatedColorSet.size(); @@ -1713,7 +1713,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { */ private boolean populateUserIdCombo() { userIdCbo.removeAll(); - ArrayList userIds = colorManager.getUsers(); + java.util.List userIds = colorManager.getUsers(); if (userIds.size() == 0) { return false; } else { @@ -1739,7 +1739,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { private boolean createColorData(String user) { ColorDataTypeSets dataTypeSets = new ColorDataTypeSets(); // get all datatypes this user has saved data for - ArrayList userDataTypes = colorManager.getDataTypes(user); + java.util.List userDataTypes = colorManager.getDataTypes(user); if (userDataTypes.size() == 0) { return false; @@ -1753,8 +1753,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { // for each datatype in database... for (String dataType : userDataTypes) { // get all durations for this datatype and this user - ArrayList durations = colorManager.getDurations(userId, - dataType); + java.util.List durations = colorManager.getDurations( + userId, dataType); // for each duration for datatype for (String duration : durations) { @@ -1767,13 +1767,13 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { try { // actually get the data from database - ArrayList data = manager.getData(cvd); + java.util.List data = manager.getData(cvd); // sort data by double value because data is stored as // String // see ColorValueData class for compareTo function Collections.sort(data); ColorScaleSets colorScaleSets = new ColorScaleSets(); - ArrayList origList = new ArrayList(); + java.util.List origList = new ArrayList(); for (ColorValueData colorValue : data) { ColorScaleData csd = new ColorScaleData(); @@ -1792,7 +1792,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { } origList.add(csd); } - ArrayList usedList = new ArrayList(); + java.util.List usedList = new ArrayList(); usedList.addAll(origList); colorScaleSets.setOriginalArray(origList); @@ -1800,8 +1800,9 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { // Right now last data will be only data to show up // Need to incorporate duration into key for dataTypeSets - dataTypeSets.addDataTypeColorSets( - duration + "_" + colorManager.getDescription(dataType), colorScaleSets); + dataTypeSets.addDataTypeColorSets(duration + "_" + + colorManager.getDescription(dataType), + colorScaleSets); } catch (VizException e) { e.printStackTrace(); } @@ -1840,7 +1841,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { * Creates the default color data */ private void createDefaultData() { - ArrayList defaultDataTypes = colorManager.getDefaultDataTypes(); + java.util.List defaultDataTypes = colorManager + .getDefaultDataTypes(); editColorData = new EditColorData(); @@ -1848,7 +1850,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { for (int i = 0; i < defaultDataTypes.size(); i++) { ColorScaleSets colorScaleSets = new ColorScaleSets(); - ArrayList origList = colorManager + java.util.List origList = colorManager .getDefaultColorScaleData(defaultDataTypes.get(i)); colorScaleSets.setOriginalArray(origList); @@ -1889,10 +1891,11 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { Iterator i = dataTypes.iterator(); while (i.hasNext()) { String dt = i.next(); - //add a check in case there is a typo in dataType the it will be null - if (!dt.contains("null")) { - dataTypeCbo.add(colorManager.getDescription(dt)); - } + // add a check in case there is a typo in dataType the it will be + // null + if (!dt.contains("null")) { + dataTypeCbo.add(colorManager.getDescription(dt)); + } } if (dataTypeCbo.getItemCount() == 0) { @@ -1975,11 +1978,11 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { } else { createColorData(user); } - - updateDurationCombo(); - updateColorValueLabelBar(); - - setReturnValue(true); + + updateDurationCombo(); + updateColorValueLabelBar(); + + setReturnValue(true); } /** @@ -2002,8 +2005,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { updateSaveDataTypeCombo(); updateUsedColorSetGroupText(); } catch (Throwable t) { - statusHandler.handle(Priority.PROBLEM, - "Error parsing duration: " + durationCbo.getText(), t); + statusHandler.handle(Priority.PROBLEM, "Error parsing duration: " + + durationCbo.getText(), t); } } @@ -2043,7 +2046,7 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { String dataType = dataTypeCbo.getText(); String duration = selectedDurationInSeconds.toString(); String dataTypeKey = duration + "_" + dataType; - ArrayList data = editColorData + java.util.List data = editColorData .getUsedColorScaleDataArray(source, duration + "_" + dataType); ColorValueData cvd = new ColorValueData(); cvd.setApplicationName(colorManager.getApplicationName()); @@ -2156,8 +2159,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { durationCbo .add(String.valueOf(Integer.parseInt(durInSeconds) / 3600)); } catch (Throwable t) { - statusHandler.handle(Priority.PROBLEM, - "Error parsing duration: " + durInSeconds, t); + statusHandler.handle(Priority.PROBLEM, "Error parsing duration: " + + durInSeconds, t); } } @@ -2166,8 +2169,8 @@ public class ColorScaleMgrDlg extends CaveSWTDialog { browseDurationCbo .add(String.valueOf(Integer.parseInt(durInSeconds) / 3600)); } catch (Throwable t) { - statusHandler.handle(Priority.PROBLEM, - "Error parsing duration: " + durInSeconds, t); + statusHandler.handle(Priority.PROBLEM, "Error parsing duration: " + + durInSeconds, t); } } diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorScaleSets.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorScaleSets.java index 5f993fe961..8f43bf8c94 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorScaleSets.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/ColorScaleSets.java @@ -21,6 +21,7 @@ package com.raytheon.viz.hydrocommon.colorscalemgr; import java.util.ArrayList; +import java.util.List; import org.eclipse.swt.graphics.RGB; @@ -45,6 +46,8 @@ import org.eclipse.swt.graphics.RGB; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 29 NOV 2007 373 lvenable Initial creation + * 18 APR 2013 1790 rferrel Cleanup method interfaces; + * part of non-blocking dialogs. * * * @@ -56,17 +59,17 @@ public class ColorScaleSets { /** * Array containing the original color set data. */ - private ArrayList originalColorSet; + private List originalColorSet; /** * Array containing updates to the color set data. */ - private ArrayList updatedColorSet; + private List updatedColorSet; /** * Array containing the used color set data. */ - private ArrayList usedColorSet; + private List usedColorSet; /** * Constructor. @@ -85,8 +88,8 @@ public class ColorScaleSets { * @param usedColorSet * Used color set array. */ - public ColorScaleSets(ArrayList originalColorSet, - ArrayList usedColorSet) { + public ColorScaleSets(List originalColorSet, + List usedColorSet) { this.originalColorSet = new ArrayList(originalColorSet); updatedColorSet = new ArrayList(originalColorSet); this.usedColorSet = new ArrayList(usedColorSet); @@ -173,7 +176,7 @@ public class ColorScaleSets { * @param array * Array of color scale data. */ - public void setOriginalArray(ArrayList array) { + public void setOriginalArray(List array) { originalColorSet = new ArrayList(array); updatedColorSet = new ArrayList(array); } @@ -184,7 +187,7 @@ public class ColorScaleSets { * @param array * Array of color scale data. */ - public void setUsedArray(ArrayList array) { + public void setUsedArray(List array) { usedColorSet = new ArrayList(array); } @@ -243,7 +246,7 @@ public class ColorScaleSets { * * @return The update color scale data array. */ - public ArrayList getUpdatedColorSetArray() { + public List getUpdatedColorSetArray() { return updatedColorSet; } @@ -252,7 +255,7 @@ public class ColorScaleSets { * * @return The used color scale data array. */ - public ArrayList getUsedColorSetArray() { + public List getUsedColorSetArray() { return usedColorSet; } diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/EditColorData.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/EditColorData.java index 7d48566061..e9d7ac5cc4 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/EditColorData.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/colorscalemgr/EditColorData.java @@ -20,8 +20,8 @@ package com.raytheon.viz.hydrocommon.colorscalemgr; -import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import java.util.Set; import java.util.TreeMap; @@ -36,6 +36,8 @@ import org.eclipse.swt.graphics.RGB; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 29 NOV 2007 373 lvenable Initial creation + * 18 APR 2013 1790 rferrel Cleanup method interfaces; + * part of non-blocking dialogs. * * * @@ -115,7 +117,7 @@ public class EditColorData { * Data type key. * @return Updated color scale data array. */ - public ArrayList getColorScaleDataArray(String sourceKey, + public List getColorScaleDataArray(String sourceKey, String dataTypeKey) { return sourceMap.get(sourceKey).getColorScaleDataArray(dataTypeKey); } @@ -129,8 +131,8 @@ public class EditColorData { * Data type key. * @return Used color scale data array. */ - public ArrayList getUsedColorScaleDataArray( - String sourceKey, String dataTypeKey) { + public List getUsedColorScaleDataArray(String sourceKey, + String dataTypeKey) { return sourceMap.get(sourceKey).getColorScaleDataArray(dataTypeKey); } @@ -161,8 +163,8 @@ public class EditColorData { * @param dblVal * Scale value. */ - public void updateColorValue(String sourceKey, String dataTypeKey, - RGB rgb, double dblVal) { + public void updateColorValue(String sourceKey, String dataTypeKey, RGB rgb, + double dblVal) { sourceMap.get(sourceKey).addUpdateColorValue(dataTypeKey, rgb, dblVal); } diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/data/RPFFcstPointData.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/data/RPFFcstPointData.java index c6154fef2b..9b60b9c850 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/data/RPFFcstPointData.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/data/RPFFcstPointData.java @@ -19,7 +19,7 @@ **/ package com.raytheon.viz.hydrocommon.data; -import java.util.ArrayList; +import java.util.List; import java.util.Map; import com.raytheon.uf.common.dataquery.db.QueryResultRow; @@ -37,6 +37,8 @@ import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager; * ------------ ---------- ----------- -------------------------- * Dec 19, 2008 1787 askripsky Initial creation * Mar 08, 2012 14600 wkwock Delete one lid instead of one group + * 18 APR 2013 1790 rferrel Cleanup method interfaces; + * part of non-blocking dialogs. * * * @@ -137,8 +139,8 @@ public class RPFFcstPointData extends HydroDBData implements IHydroDBData { setGroupID(getDBValue("group_id", data, dataMap, "")); setOrdinal(getDBValue("ordinal", data, dataMap, HydroConstants.MISSING_VALUE)); - setChangeThreshold(getDBValue("chg_threshold", data, dataMap, Double - .valueOf(HydroConstants.MISSING_VALUE))); + setChangeThreshold(getDBValue("chg_threshold", data, dataMap, + Double.valueOf(HydroConstants.MISSING_VALUE))); setRecordType(getDBValue("rec_type", data, dataMap, "")); setPrimaryBackup(getDBValue("primary_back", data, dataMap, "")); setSecondaryBackup(getDBValue("secondary_back", data, dataMap, "")); @@ -160,8 +162,8 @@ public class RPFFcstPointData extends HydroDBData implements IHydroDBData { } try { - ArrayList data = HydroDBDataManager.getInstance() - .getData(RPFParamData.class); + List data = HydroDBDataManager.getInstance().getData( + RPFParamData.class); if (data != null && data.size() > 0) { // There should only be one record @@ -379,8 +381,8 @@ public class RPFFcstPointData extends HydroDBData implements IHydroDBData { @Override public String getDeleteStatement() { - return "DELETE FROM rpffcstpoint WHERE lid="+getDBString(lid)+" and group_id=" - + getDBString(groupID); + return "DELETE FROM rpffcstpoint WHERE lid=" + getDBString(lid) + + " and group_id=" + getDBString(groupID); } @Override diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/AddModifyLocationDataManager.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/AddModifyLocationDataManager.java index 3ba17210b8..06a6b775a9 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/AddModifyLocationDataManager.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/AddModifyLocationDataManager.java @@ -21,6 +21,7 @@ package com.raytheon.viz.hydrocommon.datamanager; import java.util.ArrayList; import java.util.Date; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -46,7 +47,9 @@ import com.raytheon.viz.hydrocommon.data.LocationData; * location table instead of hsa table. * Oct 05, 2011 15333 lbousaidi changed the queries that retrieves the HSAs from * the database. - * + * Apr 18, 2013 1790 rferrel Cleanup method interfaces; + * part of non-blocking dialogs. + * * * * @author askripsky @@ -55,9 +58,10 @@ import com.raytheon.viz.hydrocommon.data.LocationData; public class AddModifyLocationDataManager extends HydroDataManager { protected static AddModifyLocationDataManager manager = null; - - private static final String[] rval = { "AT", "N", "NNE", "NE", "ENE", "E", "ESE", "SE", - "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW" }; + + private static final String[] rval = { "AT", "N", "NNE", "NE", "ENE", "E", + "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", + "NNW" }; /** * Private constructor. @@ -95,8 +99,8 @@ public class AddModifyLocationDataManager extends HydroDataManager { LocationData locData = new LocationData(); locData.setLid(lid); - ArrayList data = HydroDBDataManager.getInstance() - .getData(locData); + List data = HydroDBDataManager.getInstance().getData( + locData); if ((data != null) && (data.size() > 0)) { locData = data.get(0); @@ -122,8 +126,8 @@ public class AddModifyLocationDataManager extends HydroDataManager { * @return The networks from the DB * @throws VizException */ - public ArrayList getNetworks() throws VizException { - ArrayList rval = new ArrayList(); + public List getNetworks() throws VizException { + List rval = new ArrayList(); String query = "Select network from network order by network"; @@ -146,8 +150,8 @@ public class AddModifyLocationDataManager extends HydroDataManager { * @return The rfcs from the DB * @throws VizException */ - public ArrayList getRFCs() throws VizException { - ArrayList rval = new ArrayList(); + public List getRFCs() throws VizException { + List rval = new ArrayList(); String query = "Select rfc from rfc order by rfc"; @@ -170,10 +174,10 @@ public class AddModifyLocationDataManager extends HydroDataManager { * @return The HSAs from the DB * @throws VizException */ - public ArrayList getHSAs() throws VizException { - ArrayList rval = new ArrayList(); + public List getHSAs() throws VizException { + List rval = new ArrayList(); - String query= "SELECT DISTINCT upper(hsa) from hsa order by upper (hsa)"; + String query = "SELECT DISTINCT upper(hsa) from hsa order by upper (hsa)"; QueryResult data = HydroDBDataManager.getInstance().runMappedQuery( query); @@ -193,8 +197,8 @@ public class AddModifyLocationDataManager extends HydroDataManager { * @return The HSAs from the DB * @throws VizException */ - public ArrayList getHSAsForFilter() throws VizException { - ArrayList rval = new ArrayList(); + public List getHSAsForFilter() throws VizException { + List rval = new ArrayList(); String query = "Select distinct(hsa) from location order by hsa"; @@ -217,11 +221,11 @@ public class AddModifyLocationDataManager extends HydroDataManager { * @return The WFOs from the DB * @throws VizException */ - public ArrayList getWFOs() throws VizException { - ArrayList rval = new ArrayList(); - - String query= "SELECT DISTINCT upper(wfo) from wfo order by upper (wfo)"; - + public List getWFOs() throws VizException { + List rval = new ArrayList(); + + String query = "SELECT DISTINCT upper(wfo) from wfo order by upper (wfo)"; + QueryResult data = HydroDBDataManager.getInstance().runMappedQuery( query); @@ -241,8 +245,8 @@ public class AddModifyLocationDataManager extends HydroDataManager { * @return The Time Zones from the DB * @throws VizException */ - public ArrayList getTimeZones() throws VizException { - ArrayList rval = new ArrayList(); + public List getTimeZones() throws VizException { + List rval = new ArrayList(); String query = "Select tzone, name from timezone order by tzone"; @@ -273,9 +277,8 @@ public class AddModifyLocationDataManager extends HydroDataManager { * @return * @throws VizException */ - public ArrayList getAvailableAgenciesAndOffices() - throws VizException { - ArrayList rval = new ArrayList(); + public List getAvailableAgenciesAndOffices() throws VizException { + List rval = new ArrayList(); String agencyCode; String office; @@ -297,7 +300,7 @@ public class AddModifyLocationDataManager extends HydroDataManager { * @return * @throws VizException */ - public ArrayList getAvailableAgenciesAndOfficesData() + public List getAvailableAgenciesAndOfficesData() throws VizException { return HydroDBDataManager.getInstance().getData(AgencyOfficeData.class); } @@ -308,7 +311,7 @@ public class AddModifyLocationDataManager extends HydroDataManager { * @return * @throws VizException */ - public ArrayList getSelectedAgenciesAndOfficesData( + public List getSelectedAgenciesAndOfficesData( String lid) throws VizException { LocationAgencyOfficeData dataToGet = new LocationAgencyOfficeData(); dataToGet.setLid(lid); @@ -322,9 +325,9 @@ public class AddModifyLocationDataManager extends HydroDataManager { * @return * @throws VizException */ - public ArrayList getSelectedAgenciesAndOffices(String lid) + public List getSelectedAgenciesAndOffices(String lid) throws VizException { - ArrayList rval = new ArrayList(); + List rval = new ArrayList(); String agencyCode; String office; @@ -416,7 +419,7 @@ public class AddModifyLocationDataManager extends HydroDataManager { // Verify Lid exists if (locationExists(sourceLocation)) { - + /* * Copy all necessary information. */ @@ -573,16 +576,18 @@ public class AddModifyLocationDataManager extends HydroDataManager { return (rowCount > 0); } - private void copyTableData(String sourceLid, String destinationLid, String table) { + private void copyTableData(String sourceLid, String destinationLid, + String table) { // Get the columns for the table - final String columnQuery = "SELECT column_name FROM information_schema.columns WHERE table_name = '" + table + "' ORDER BY ordinal_position"; + final String columnQuery = "SELECT column_name FROM information_schema.columns WHERE table_name = '" + + table + "' ORDER BY ordinal_position"; + + List columns = runQuery(columnQuery); - ArrayList columns = runQuery(columnQuery); - // Dynamically create the select statement to - // get the data out + // get the data out StringBuffer query = new StringBuffer("select "); - + for (int i = 0; i < columns.size(); i++) { Object[] oa = columns.get(i); if (i == 0) { @@ -591,14 +596,14 @@ public class AddModifyLocationDataManager extends HydroDataManager { query.append(", " + oa[0]); } } - + query.append(" from " + table + " where lid = '" + sourceLid + "'"); - + // execute the dynamically created query - ArrayList rs = runQuery(query.toString()); - + List rs = runQuery(query.toString()); + // Get the data from the query and dynamically build - // an insert statement + // an insert statement StringBuilder insert = new StringBuilder("insert into " + table + " ("); if ((rs != null) && (rs.size() > 0)) { for (int i = 0; i < columns.size(); i++) { @@ -609,17 +614,17 @@ public class AddModifyLocationDataManager extends HydroDataManager { insert.append(", " + oa[0]); } } - + insert.append(") values ("); String insertBegin = insert.toString(); - for (Object[] oa: rs) { + for (Object[] oa : rs) { insert.setLength(0); insert.append(insertBegin); - for (int i = 0; i < oa.length; i++) { + for (int i = 0; i < oa.length; i++) { if (i == 0) { insert.append("'" + destinationLid + "'"); } else { - if (oa[i] instanceof String) { + if (oa[i] instanceof String) { String s = (String) oa[i]; if (s.contains("'")) { s = s.replace("'", "''"); @@ -627,17 +632,19 @@ public class AddModifyLocationDataManager extends HydroDataManager { if (s.indexOf("\"") > 0) { s = s.replace("\"", "\\\""); } - + insert.append(", '" + s + "'"); } else if (oa[i] instanceof Date) { - insert.append(", '" + HydroConstants.DATE_FORMAT.format(oa[i]) + "'"); + insert.append(", '" + + HydroConstants.DATE_FORMAT.format(oa[i]) + + "'"); } else { insert.append(", " + oa[i]); } - } + } } insert.append(")"); - + try { runStatement(insert.toString()); } catch (VizException e) { diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/CountyZoneUgcDataManager.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/CountyZoneUgcDataManager.java index 6c6ce4f661..6ba0f01b66 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/CountyZoneUgcDataManager.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/CountyZoneUgcDataManager.java @@ -21,6 +21,7 @@ package com.raytheon.viz.hydrocommon.datamanager; import java.util.ArrayList; import java.util.Collections; +import java.util.List; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.viz.hydrocommon.data.CountiesData; @@ -38,6 +39,8 @@ import com.raytheon.viz.hydrocommon.data.ZoneInfoData; * Jan 5, 2009 1802 askripsky Initial Creation * Sep 11,2012 15362 wkwock Fix selected zones * Dec 4, 2012 15522 wkwock Fix added zones + * Apr 18,2013 1790 rferrel Cleanup method interfaces; + * part of non-blocking dialogs. * * * @@ -46,259 +49,259 @@ import com.raytheon.viz.hydrocommon.data.ZoneInfoData; */ public class CountyZoneUgcDataManager { - protected static CountyZoneUgcDataManager manager = null; + protected static CountyZoneUgcDataManager manager = null; - // Cache for selected counties - private ArrayList countiesSelected = null; + // Cache for selected counties + private List countiesSelected = null; - // Cache for available counties - private ArrayList countiesAvailable = null; + // Cache for available counties + private List countiesAvailable = null; - // Cache for selected zones - private ArrayList zonesSelected = null; + // Cache for selected zones + private List zonesSelected = null; - // Cache for available zones - private ArrayList zonesAvailable = null; + // Cache for available zones + private List zonesAvailable = null; - // Counties/Zones for this Location - private String lid = ""; + // Counties/Zones for this Location + private String lid = ""; - /** - * Private constructor. - */ - private CountyZoneUgcDataManager() { - } + /** + * Private constructor. + */ + private CountyZoneUgcDataManager() { + } - /** - * Singleton pattern of data manager. - * - * @return manager - */ - public static synchronized CountyZoneUgcDataManager getInstance() { - if (manager == null) { - manager = new CountyZoneUgcDataManager(); - } + /** + * Singleton pattern of data manager. + * + * @return manager + */ + public static synchronized CountyZoneUgcDataManager getInstance() { + if (manager == null) { + manager = new CountyZoneUgcDataManager(); + } - return (CountyZoneUgcDataManager) manager; - } + return (CountyZoneUgcDataManager) manager; + } - /** - * Sets the location for the data. - * - * @param lid - * The location for the counties/zones - */ - public void setLid(String lid) { - this.lid = lid; - } + /** + * Sets the location for the data. + * + * @param lid + * The location for the counties/zones + */ + public void setLid(String lid) { + this.lid = lid; + } - /** - * Gets the available counties. - * - * @return The counties available. - * @throws VizException - */ - public ArrayList getCountiesAvailable() throws VizException { - if (countiesAvailable == null) { - countiesAvailable = HydroDBDataManager.getInstance().getData( - CountiesData.class); - } + /** + * Gets the available counties. + * + * @return The counties available. + * @throws VizException + */ + public List getCountiesAvailable() throws VizException { + if (countiesAvailable == null) { + countiesAvailable = HydroDBDataManager.getInstance().getData( + CountiesData.class); + } - return countiesAvailable; - } + return countiesAvailable; + } - /** - * Gets the selected counties. - * - * @return The counties selected. - * @throws VizException - */ - public ArrayList getCountiesSelected() throws VizException { - return getCountiesSelected(false); - } + /** + * Gets the selected counties. + * + * @return The counties selected. + * @throws VizException + */ + public List getCountiesSelected() throws VizException { + return getCountiesSelected(false); + } - /** - * Gets the selected counties. - * - * @return The counties selected. - * @throws VizException - */ - public ArrayList getCountiesSelected(boolean forceLoad) - throws VizException { - if (countiesSelected == null || forceLoad) { - CountyInfoData seedData = new CountyInfoData(); - seedData.setLid(lid); + /** + * Gets the selected counties. + * + * @return The counties selected. + * @throws VizException + */ + public List getCountiesSelected(boolean forceLoad) + throws VizException { + if (countiesSelected == null || forceLoad) { + CountyInfoData seedData = new CountyInfoData(); + seedData.setLid(lid); - countiesSelected = HydroDBDataManager.getInstance().getData( - seedData); - } + countiesSelected = HydroDBDataManager.getInstance().getData( + seedData); + } - Collections.sort(countiesSelected); + Collections.sort(countiesSelected); - return countiesSelected; - } + return countiesSelected; + } - /** - * Gets the available zones. - * - * @return The zones available. - * @throws VizException - */ - public ArrayList getZonesAvailable() throws VizException { - if (zonesAvailable == null) { - zonesAvailable = HydroDBDataManager.getInstance().getData( - EligZoneData.class); - } + /** + * Gets the available zones. + * + * @return The zones available. + * @throws VizException + */ + public List getZonesAvailable() throws VizException { + if (zonesAvailable == null) { + zonesAvailable = HydroDBDataManager.getInstance().getData( + EligZoneData.class); + } - return zonesAvailable; - } + return zonesAvailable; + } - /** - * Gets the selected Zones. - * - * @return The zones selected. - * @throws VizException - */ - public ArrayList getZonesSelected() throws VizException { - return getZonesSelected(false); - } + /** + * Gets the selected Zones. + * + * @return The zones selected. + * @throws VizException + */ + public List getZonesSelected() throws VizException { + return getZonesSelected(false); + } - /** - * Gets the selected Zones. - * - * @return The zones selected. - * @throws VizException - */ - public ArrayList getZonesSelected(boolean forceLoad) - throws VizException { - if (zonesSelected == null || forceLoad) { - ZoneInfoData seedData = new ZoneInfoData(); - seedData.setLid(lid); + /** + * Gets the selected Zones. + * + * @return The zones selected. + * @throws VizException + */ + public List getZonesSelected(boolean forceLoad) + throws VizException { + if (zonesSelected == null || forceLoad) { + ZoneInfoData seedData = new ZoneInfoData(); + seedData.setLid(lid); - zonesSelected = HydroDBDataManager.getInstance().getData(seedData); - } + zonesSelected = HydroDBDataManager.getInstance().getData(seedData); + } - Collections.sort(zonesSelected); + Collections.sort(zonesSelected); - return zonesSelected; - } + return zonesSelected; + } - /** - * Adds the available county to the selected counties. - * - * @param selectedAvailableCounty - * The index of the selected available county to select. - */ - public void addSelectedCounty(int selectedAvailableCounty) { - CountiesData availableCounty = countiesAvailable - .get(selectedAvailableCounty); + /** + * Adds the available county to the selected counties. + * + * @param selectedAvailableCounty + * The index of the selected available county to select. + */ + public void addSelectedCounty(int selectedAvailableCounty) { + CountiesData availableCounty = countiesAvailable + .get(selectedAvailableCounty); - CountyInfoData countyToAdd = new CountyInfoData(); - countyToAdd.setLid(lid); - countyToAdd.setState(availableCounty.getState()); - countyToAdd.setCounty(availableCounty.getCounty()); - countyToAdd.setCountyNumber(availableCounty.getCountyNumber()); + CountyInfoData countyToAdd = new CountyInfoData(); + countyToAdd.setLid(lid); + countyToAdd.setState(availableCounty.getState()); + countyToAdd.setCounty(availableCounty.getCounty()); + countyToAdd.setCountyNumber(availableCounty.getCountyNumber()); - if (!countiesSelected.contains(countyToAdd)) { - countiesSelected.add(countyToAdd); - } - } + if (!countiesSelected.contains(countyToAdd)) { + countiesSelected.add(countyToAdd); + } + } - /** - * Adds the available zone to the selected zones. - * - * @param selectedAvailableZone - * The index of the selected available zone to select. - */ - public void addSelectedZone(int selectedAvailableZone) { - EligZoneData availableZone = zonesAvailable.get(selectedAvailableZone); + /** + * Adds the available zone to the selected zones. + * + * @param selectedAvailableZone + * The index of the selected available zone to select. + */ + public void addSelectedZone(int selectedAvailableZone) { + EligZoneData availableZone = zonesAvailable.get(selectedAvailableZone); - ZoneInfoData zoneToAdd = new ZoneInfoData(); - zoneToAdd.setLid(lid); - zoneToAdd.setState(availableZone.getState()); - zoneToAdd.setZoneNumber(availableZone.getZoneNumber()); - zoneToAdd.setDescription(availableZone.getDescription()); + ZoneInfoData zoneToAdd = new ZoneInfoData(); + zoneToAdd.setLid(lid); + zoneToAdd.setState(availableZone.getState()); + zoneToAdd.setZoneNumber(availableZone.getZoneNumber()); + zoneToAdd.setDescription(availableZone.getDescription()); - if (!zonesSelected.contains(zoneToAdd)) { - zonesSelected.add(zoneToAdd); - } - } + if (!zonesSelected.contains(zoneToAdd)) { + zonesSelected.add(zoneToAdd); + } + } - /** - * Removes all existing counties for the station and inserts all of selected - * counties. - * - * @throws VizException - */ - public void saveCounties() throws VizException { - // Remove all counties for the lid - CountyInfoData dataToDelete = new CountyInfoData(); - dataToDelete.setLid(lid); - HydroDBDataManager.getInstance().deleteRecord(dataToDelete); + /** + * Removes all existing counties for the station and inserts all of selected + * counties. + * + * @throws VizException + */ + public void saveCounties() throws VizException { + // Remove all counties for the lid + CountyInfoData dataToDelete = new CountyInfoData(); + dataToDelete.setLid(lid); + HydroDBDataManager.getInstance().deleteRecord(dataToDelete); - // Insert the currently selected counties - for (CountyInfoData currCounty : countiesSelected) { - HydroDBDataManager.getInstance().putData(currCounty); - } - } + // Insert the currently selected counties + for (CountyInfoData currCounty : countiesSelected) { + HydroDBDataManager.getInstance().putData(currCounty); + } + } - /** - * Removes all existing zones for the station and inserts all of selected - * zones. - * - * @throws VizException - */ - public void saveZones() throws VizException { - // Remove all zones for the lid - ZoneInfoData dataToDelete = new ZoneInfoData(); - dataToDelete.setLid(lid); - HydroDBDataManager.getInstance().deleteRecord(dataToDelete); + /** + * Removes all existing zones for the station and inserts all of selected + * zones. + * + * @throws VizException + */ + public void saveZones() throws VizException { + // Remove all zones for the lid + ZoneInfoData dataToDelete = new ZoneInfoData(); + dataToDelete.setLid(lid); + HydroDBDataManager.getInstance().deleteRecord(dataToDelete); - // Insert the currently selected zones - for (ZoneInfoData currZone : zonesSelected) { - HydroDBDataManager.getInstance().putData(currZone); - } - } + // Insert the currently selected zones + for (ZoneInfoData currZone : zonesSelected) { + HydroDBDataManager.getInstance().putData(currZone); + } + } - /** - * Removes the selected county. - * - * @param selectedIndex - * The county to be removed. - */ - public void removeSelectedCounty(int selectedIndex) { - countiesSelected.remove(selectedIndex); - } + /** + * Removes the selected county. + * + * @param selectedIndex + * The county to be removed. + */ + public void removeSelectedCounty(int selectedIndex) { + countiesSelected.remove(selectedIndex); + } - /** - * Removes the selected zone. - * - * @param selectedIndex - * The zone to be removed. - */ - public void removeSelectedZone(int selectedIndex) { - zonesSelected.remove(selectedIndex); - } + /** + * Removes the selected zone. + * + * @param selectedIndex + * The zone to be removed. + */ + public void removeSelectedZone(int selectedIndex) { + zonesSelected.remove(selectedIndex); + } - /** - * Removes all selected counties. - */ - public void clearSelectedCounties() { - if (countiesSelected != null) { - countiesSelected.clear(); - } else { - countiesSelected = new ArrayList(); - } - } + /** + * Removes all selected counties. + */ + public void clearSelectedCounties() { + if (countiesSelected != null) { + countiesSelected.clear(); + } else { + countiesSelected = new ArrayList(); + } + } - /** - * Removes all selected zones. - */ - public void clearSelectedZones() { - if (zonesSelected != null) { - zonesSelected.clear(); - } else { - zonesSelected = new ArrayList(); - } - } + /** + * Removes all selected zones. + */ + public void clearSelectedZones() { + if (zonesSelected != null) { + zonesSelected.clear(); + } else { + zonesSelected = new ArrayList(); + } + } } diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/DataAdjustFactorDataManager.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/DataAdjustFactorDataManager.java index af31b7e1fc..ff2b83d045 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/DataAdjustFactorDataManager.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/DataAdjustFactorDataManager.java @@ -20,6 +20,7 @@ package com.raytheon.viz.hydrocommon.datamanager; import java.util.ArrayList; +import java.util.List; import com.raytheon.uf.common.dataquery.db.QueryResult; import com.raytheon.uf.common.dataquery.db.QueryResultRow; @@ -35,6 +36,8 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 15, 2008 1787 askripsky Initial Creation + * Apr 18, 2013 1790 rferrel Cleanup method interfaces; + * part of non-blocking dialogs. * * * @@ -45,7 +48,7 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils; public class DataAdjustFactorDataManager { private static DataAdjustFactorDataManager manager = null; - private ArrayList adjustFactorData = null; + private List adjustFactorData = null; /** * Private constructor. @@ -72,8 +75,8 @@ public class DataAdjustFactorDataManager { * @return The duration from the DB * @throws VizException */ - public ArrayList getShefDur() throws VizException { - ArrayList rval = new ArrayList(); + public List getShefDur() throws VizException { + List rval = new ArrayList(); String durQuery = "SELECT name, dur FROM shefdur ORDER BY dur"; @@ -99,8 +102,8 @@ public class DataAdjustFactorDataManager { * @return The type sources from the DB * @throws VizException */ - public ArrayList getShefTs() throws VizException { - ArrayList rval = new ArrayList(); + public List getShefTs() throws VizException { + List rval = new ArrayList(); String tsQuery = "SELECT name, ts FROM shefts ORDER BY ts"; @@ -126,8 +129,8 @@ public class DataAdjustFactorDataManager { * @return The extremum from the DB * @throws VizException */ - public ArrayList getShefExtremum() throws VizException { - ArrayList rval = new ArrayList(); + public List getShefExtremum() throws VizException { + List rval = new ArrayList(); String extQuery = "SELECT name, extremum FROM shefex ORDER BY extremum"; @@ -147,12 +150,11 @@ public class DataAdjustFactorDataManager { return rval; } - public ArrayList getAdjustFactorData() - throws VizException { + public List getAdjustFactorData() throws VizException { return getAdjustFactorData(false); } - public ArrayList getAdjustFactorData(boolean forceLoad) + public List getAdjustFactorData(boolean forceLoad) throws VizException { if (adjustFactorData == null || forceLoad) { adjustFactorData = HydroDBDataManager.getInstance().getData( @@ -179,8 +181,10 @@ public class DataAdjustFactorDataManager { data.append(String.format("%2s ", currData.getPe())); // Duration - data.append(String.format("%s ", HydroDataUtils.getDisplayString( - "%4s", "%d", currData.getDuration()))); + data.append(String.format( + "%s ", + HydroDataUtils.getDisplayString("%4s", "%d", + currData.getDuration()))); // TS data.append(String.format("%2s ", currData.getTypeSource())); @@ -189,20 +193,28 @@ public class DataAdjustFactorDataManager { data.append(String.format("%2s ", currData.getExtremum())); // Divisor - data.append(String.format("%s ", HydroDataUtils.getDisplayString( - "%11s", "%.3f", currData.getDivisor()))); + data.append(String.format( + "%s ", + HydroDataUtils.getDisplayString("%11s", "%.3f", + currData.getDivisor()))); // Base - data.append(String.format("%s ", HydroDataUtils.getDisplayString( - "%11s", "%.3f", currData.getBase()))); + data.append(String.format( + "%s ", + HydroDataUtils.getDisplayString("%11s", "%.3f", + currData.getBase()))); // Multiplier - data.append(String.format("%s ", HydroDataUtils.getDisplayString( - "%11s", "%.3f", currData.getMultiplier()))); + data.append(String.format( + "%s ", + HydroDataUtils.getDisplayString("%11s", "%.3f", + currData.getMultiplier()))); // Adder - data.append(String.format("%s ", HydroDataUtils.getDisplayString( - "%11s", "%.3f", currData.getAdder()))); + data.append(String.format( + "%s ", + HydroDataUtils.getDisplayString("%11s", "%.3f", + currData.getAdder()))); return data.toString(); } diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/DataIngestFilterDataManager.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/DataIngestFilterDataManager.java index 4c4a031cef..8548345ea1 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/DataIngestFilterDataManager.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/DataIngestFilterDataManager.java @@ -20,6 +20,7 @@ package com.raytheon.viz.hydrocommon.datamanager; import java.util.ArrayList; +import java.util.List; import com.raytheon.uf.common.dataquery.db.QueryResult; import com.raytheon.uf.common.dataquery.db.QueryResultRow; @@ -35,6 +36,7 @@ import com.raytheon.viz.hydrocommon.data.DataIngestFilterData; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 11, 2008 1787 askripsky Initial Creation + * Apr 18, 2013 1790 rferrel Code clean up with non-blocking dialogs. * * * @@ -43,9 +45,9 @@ import com.raytheon.viz.hydrocommon.data.DataIngestFilterData; */ public class DataIngestFilterDataManager { - private static DataIngestFilterDataManager manager = null; + private static DataIngestFilterDataManager manager = new DataIngestFilterDataManager(); - private ArrayList ingestFilterData = null; + private List ingestFilterData = null; /** * Private constructor. @@ -59,10 +61,6 @@ public class DataIngestFilterDataManager { * @return manager */ public static synchronized DataIngestFilterDataManager getInstance() { - if (manager == null) { - manager = new DataIngestFilterDataManager(); - } - return manager; } @@ -72,8 +70,8 @@ public class DataIngestFilterDataManager { * @return The duration from the DB * @throws VizException */ - public ArrayList getShefDur() throws VizException { - ArrayList rval = new ArrayList(); + public List getShefDur() throws VizException { + List rval = new ArrayList(); String durQuery = "SELECT name, dur FROM shefdur ORDER BY dur"; @@ -99,8 +97,8 @@ public class DataIngestFilterDataManager { * @return The type sources from the DB * @throws VizException */ - public ArrayList getShefTs() throws VizException { - ArrayList rval = new ArrayList(); + public List getShefTs() throws VizException { + List rval = new ArrayList(); String tsQuery = "SELECT name, ts FROM shefts ORDER BY ts"; @@ -126,8 +124,8 @@ public class DataIngestFilterDataManager { * @return The extremum from the DB * @throws VizException */ - public ArrayList getShefExtremum() throws VizException { - ArrayList rval = new ArrayList(); + public List getShefExtremum() throws VizException { + List rval = new ArrayList(); String extQuery = "SELECT name, extremum FROM shefex ORDER BY extremum"; @@ -173,8 +171,8 @@ public class DataIngestFilterDataManager { * @return The filtered ingest filter data. * @throws VizException */ - public ArrayList getIngestFilter(boolean filterByPE, - ArrayList selectedPE, boolean filterByLocation, + public List getIngestFilter(boolean filterByPE, + List selectedPE, boolean filterByLocation, String selectedLocation, boolean filterBySwitches, boolean filterByIngest, boolean filterByOFS, boolean filterByMPE, boolean filterByTS, String selectedTS) throws VizException { @@ -211,15 +209,14 @@ public class DataIngestFilterDataManager { * @return The filtered ingest filter data. * @throws VizException */ - public ArrayList getIngestFilter(boolean filterByPE, - ArrayList selectedPE, boolean filterByLocation, + public List getIngestFilter(boolean filterByPE, + List selectedPE, boolean filterByLocation, String selectedLocation, boolean filterBySwitches, boolean filterByIngest, boolean filterByOFS, boolean filterByMPE, boolean filterByTS, String selectedTS, boolean forceLoad) throws VizException { if ((ingestFilterData == null) || forceLoad) { DataIngestFilterData seedData = new DataIngestFilterData(); -// seedData.setResultLimit(150); StringBuffer whereClause = new StringBuffer(); if (filterByLocation) { @@ -287,8 +284,8 @@ public class DataIngestFilterDataManager { String dataFormat = "%-9S %-4S %-6S %-7S %-6S %-7S %-5S %-5S %-5S"; return String.format(dataFormat, currData.getLid(), currData.getPe(), - getDisplayString(currData.getDuration()), currData - .getTypeSource(), currData.getExtremum(), + getDisplayString(currData.getDuration()), + currData.getTypeSource(), currData.getExtremum(), getDisplayString(currData.getTsRank()), currData.getIngest(), currData.getOfsInput(), currData.getStg2Input()); } @@ -302,8 +299,8 @@ public class DataIngestFilterDataManager { * @return The corresponding string or "" if the value is MISSING_VALUE */ public String getDisplayString(Double val) { - String temp = (Double.compare(val, Double - .valueOf(HydroConstants.MISSING_VALUE)) != 0) ? Double + String temp = (Double.compare(val, + Double.valueOf(HydroConstants.MISSING_VALUE)) != 0) ? Double .toString(val) : ""; return temp; diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/HydroDBDataManager.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/HydroDBDataManager.java index 6898414383..1f07c799ee 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/HydroDBDataManager.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/HydroDBDataManager.java @@ -23,6 +23,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.List; import java.util.Map; import com.raytheon.uf.common.dataquery.db.QueryResult; @@ -40,6 +41,7 @@ import com.raytheon.viz.hydrocommon.data.HydroDBData; * Nov 17, 2008 1697 askripsky Initial Creation * Nov 21, 2008 1697 askripsky Changed to use reflection and filter generic methods * Nov 03, 2011 11273 lbousaidi added updateNewData and putNewData. + * Apr 18, 2013 1790 rferrel Code cleanup part of non-blocking dialogs. * * * @author askripsky @@ -47,7 +49,7 @@ import com.raytheon.viz.hydrocommon.data.HydroDBData; */ public class HydroDBDataManager extends HydroDataManager { - private static HydroDBDataManager manager = null; + private static final HydroDBDataManager manager = new HydroDBDataManager(); /** * Private constructor. @@ -61,10 +63,6 @@ public class HydroDBDataManager extends HydroDataManager { * @return manager */ public static synchronized HydroDBDataManager getInstance() { - if (manager == null) { - manager = new HydroDBDataManager(); - } - return manager; } @@ -74,8 +72,8 @@ public class HydroDBDataManager extends HydroDataManager { * @param recordsToDelete * @throws VizException */ - public void deleteRecords( - ArrayList recordsToDelete) throws VizException { + public void deleteRecords(List recordsToDelete) + throws VizException { for (T currData : recordsToDelete) { deleteRecord(currData); } @@ -91,8 +89,8 @@ public class HydroDBDataManager extends HydroDataManager { public void deleteRecord(T recordToDelete) throws VizException { try { - String deleteQuery = (String) recordToDelete.getClass().getMethod( - "getDeleteStatement").invoke(recordToDelete); + String deleteQuery = (String) recordToDelete.getClass() + .getMethod("getDeleteStatement").invoke(recordToDelete); runStatement(deleteQuery); } catch (Exception e) { @@ -105,13 +103,13 @@ public class HydroDBDataManager extends HydroDataManager { * * @param clazz * The data type to run the query for. - * @return ArrayList containing the data type that is passed in containing - * data from the DB. + * @return List containing the data type that is passed in containing data + * from the DB. * @throws VizException */ - public ArrayList getData(Class clazz) + public List getData(Class clazz) throws VizException { - ArrayList rval = new ArrayList(); + List rval = new ArrayList(); try { String selectStatement = (String) clazz.getMethod( @@ -124,8 +122,8 @@ public class HydroDBDataManager extends HydroDataManager { if (result.getResultCount() > 0) { for (QueryResultRow currRow : result.getRows()) { - rval.add(dataConstructor.newInstance(currRow, result - .getColumnNames())); + rval.add(dataConstructor.newInstance(currRow, + result.getColumnNames())); } } } catch (Exception e) { @@ -154,18 +152,17 @@ public class HydroDBDataManager extends HydroDataManager { * * @param clazz * The data type to run the query for. - * @return ArrayList containing the data type that is passed in containing - * data from the DB. + * @return List containing the data type that is passed in containing data + * from the DB. * @throws VizException */ @SuppressWarnings("unchecked") - public ArrayList getData(T data) - throws VizException { - ArrayList rval = new ArrayList(); + public List getData(T data) throws VizException { + List rval = new ArrayList(); try { - String selectQuery = (String) data.getClass().getMethod( - "getConstrainedSelectStatement").invoke(data); + String selectQuery = (String) data.getClass() + .getMethod("getConstrainedSelectStatement").invoke(data); QueryResult result = runMappedQuery(selectQuery); @@ -174,8 +171,8 @@ public class HydroDBDataManager extends HydroDataManager { .getClass()); for (QueryResultRow currRow : result.getRows()) { - rval.add(dataConstructor.newInstance(currRow, result - .getColumnNames())); + rval.add(dataConstructor.newInstance(currRow, + result.getColumnNames())); } } catch (Exception e) { e.printStackTrace(); @@ -219,8 +216,8 @@ public class HydroDBDataManager extends HydroDataManager { public void updateData(T data) throws VizException { try { // Get the update statement with the values filled in - String updateQuery = (String) data.getClass().getMethod( - "getUpdateStatement").invoke(data); + String updateQuery = (String) data.getClass() + .getMethod("getUpdateStatement").invoke(data); if (updateQuery != null) { runStatement(updateQuery); @@ -238,25 +235,27 @@ public class HydroDBDataManager extends HydroDataManager { * @param updateData * @throws VizException * */ - public void updateNewData(T newData, T updateData) throws VizException { - try { - - String updateQuery = (String) newData.getClass().getMethod( - "getUpdateStatement").invoke(newData); - - String pkquery= (String) updateData.getClass().getMethod( - "getPKStatement").invoke(updateData); - - String updateQueryToRun= updateQuery + "WHERE " + pkquery ; - - if (updateQueryToRun != null) { - runStatement(updateQueryToRun); - } + public void updateNewData(T newData, T updateData) + throws VizException { + try { + + String updateQuery = (String) newData.getClass() + .getMethod("getUpdateStatement").invoke(newData); + + String pkquery = (String) updateData.getClass() + .getMethod("getPKStatement").invoke(updateData); + + String updateQueryToRun = updateQuery + "WHERE " + pkquery; + + if (updateQueryToRun != null) { + runStatement(updateQueryToRun); + } } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); } - + } + /** * Inserts into the respective DB table with the data passed in. * @@ -319,29 +318,30 @@ public class HydroDBDataManager extends HydroDataManager { insertData(newData); } } - + /** - * Checks to see if the newData passed in already exists in the DB based on the - * primary key for the data's respective table. If the data exists, an - * UPDATE is performed by replacing the updateData with NewData. - * If not, an INSERT of newData is performed. + * Checks to see if the newData passed in already exists in the DB based on + * the primary key for the data's respective table. If the data exists, an + * UPDATE is performed by replacing the updateData with NewData. If not, an + * INSERT of newData is performed. * * @param * @param lid * @param newData * @throws VizException */ - public void putNewData(T newData, T updateData, boolean insert) throws VizException { - // Check if it's going to be an update - - if ((insert) && (checkData(newData)==0) ) { - // Do an insert - insertData(newData); - - } else if (checkData(updateData) > 0) { - // Do an update - updateNewData(newData, updateData); + public void putNewData(T newData, T updateData, + boolean insert) throws VizException { + // Check if it's going to be an update + + if ((insert) && (checkData(newData) == 0)) { + // Do an insert + insertData(newData); + + } else if (checkData(updateData) > 0) { + // Do an update + updateNewData(newData, updateData); } } - + } diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/QcAlertAlarmLimitsDataManager.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/QcAlertAlarmLimitsDataManager.java index 834e2920dd..d5204ef046 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/QcAlertAlarmLimitsDataManager.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/QcAlertAlarmLimitsDataManager.java @@ -20,6 +20,7 @@ package com.raytheon.viz.hydrocommon.datamanager; import java.util.ArrayList; +import java.util.List; import com.raytheon.uf.common.dataquery.db.QueryResult; import com.raytheon.uf.common.dataquery.db.QueryResultRow; @@ -36,6 +37,8 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 8, 2008 1697 askripsky Initial Creation + * Apr 18,2013 1790 rferrel Cleanup method interfaces; + * part of non-blocking dialogs. * * * @@ -46,13 +49,13 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils; public class QcAlertAlarmLimitsDataManager { protected static QcAlertAlarmLimitsDataManager manager = null; - private ArrayList defaultData = null; + private List defaultData = null; - private ArrayList defaultDataFiltered = null; + private List defaultDataFiltered = null; - private ArrayList locationData = null; + private List locationData = null; - private ArrayList locationDataFiltered = null; + private List locationDataFiltered = null; /** * Private constructor. @@ -79,8 +82,8 @@ public class QcAlertAlarmLimitsDataManager { * @return The duration from the DB * @throws VizException */ - public ArrayList getShefDur() throws VizException { - ArrayList rval = new ArrayList(); + public List getShefDur() throws VizException { + List rval = new ArrayList(); String durQuery = "SELECT name, dur FROM shefdur ORDER BY dur"; @@ -100,14 +103,13 @@ public class QcAlertAlarmLimitsDataManager { return rval; } - public ArrayList getDefaultLimits(boolean filterByPE, - ArrayList selectedPE) throws VizException { + public List getDefaultLimits(boolean filterByPE, + List selectedPE) throws VizException { return getDefaultLimits(filterByPE, selectedPE, false); } - public ArrayList getDefaultLimits(boolean filterByPE, - ArrayList selectedPE, boolean forceLoad) - throws VizException { + public List getDefaultLimits(boolean filterByPE, + List selectedPE, boolean forceLoad) throws VizException { if (defaultData == null || forceLoad) { defaultData = HydroDBDataManager.getInstance().getData( DataLimitData.class); @@ -134,8 +136,8 @@ public class QcAlertAlarmLimitsDataManager { // PE Dur MonthStart MonthEnd defaultString.append(String.format("%13s%7s%7s%8s ", currData.getPe(), - currData.getDur(), currData.getMonthDayStart(), currData - .getMonthDayEnd())); + currData.getDur(), currData.getMonthDayStart(), + currData.getMonthDayEnd())); // Gross Min/Max defaultString.append(HydroDataUtils.getDisplayString("%9s", "%9.1f", @@ -186,17 +188,16 @@ public class QcAlertAlarmLimitsDataManager { return defaultString.toString(); } - public ArrayList getLocationLimits( - boolean filterByLID, String lidFilter, boolean filterByPE, - ArrayList selectedPE) throws VizException { + public List getLocationLimits(boolean filterByLID, + String lidFilter, boolean filterByPE, List selectedPE) + throws VizException { return getLocationLimits(filterByLID, lidFilter, filterByPE, selectedPE, false); } - public ArrayList getLocationLimits( - boolean filterByLID, String lidFilter, boolean filterByPE, - ArrayList selectedPE, boolean forceLoad) - throws VizException { + public List getLocationLimits(boolean filterByLID, + String lidFilter, boolean filterByPE, List selectedPE, + boolean forceLoad) throws VizException { if (locationData == null || forceLoad) { locationData = HydroDBDataManager.getInstance().getData( LocationDataLimitData.class); @@ -228,9 +229,9 @@ public class QcAlertAlarmLimitsDataManager { StringBuffer defaultString = new StringBuffer(); // PE Dur MonthStart MonthEnd - defaultString.append(String.format("%-10s%3s%7s%7s%8s ", currData - .getLid(), currData.getPe(), currData.getDur(), currData - .getMonthDayStart(), currData.getMonthDayEnd())); + defaultString.append(String.format("%-10s%3s%7s%7s%8s ", + currData.getLid(), currData.getPe(), currData.getDur(), + currData.getMonthDayStart(), currData.getMonthDayEnd())); // Gross Min/Max defaultString.append(HydroDataUtils.getDisplayString("%9s", "%9.1f", @@ -281,7 +282,7 @@ public class QcAlertAlarmLimitsDataManager { return defaultString.toString(); } - private void filterDefaultByPE(ArrayList selectedPE) { + private void filterDefaultByPE(List selectedPE) { if (defaultDataFiltered == null) { defaultDataFiltered = new ArrayList(); } @@ -297,9 +298,9 @@ public class QcAlertAlarmLimitsDataManager { } } - private void filterLocationByPE(ArrayList selectedPE) { + private void filterLocationByPE(List selectedPE) { // Temp array to hold values that will stay - ArrayList temp = new ArrayList(); + List temp = new ArrayList(); for (String peFilter : selectedPE) { for (LocationDataLimitData currData : locationDataFiltered) { @@ -314,11 +315,11 @@ public class QcAlertAlarmLimitsDataManager { private void filterLocationByLID(String lidFilter) { // Temp array to hold values that will stay - ArrayList temp = new ArrayList(); + List temp = new ArrayList(); for (LocationDataLimitData currData : locationDataFiltered) { - if (currData.getLid().toUpperCase().contains( - lidFilter.toUpperCase())) { + if (currData.getLid().toUpperCase() + .contains(lidFilter.toUpperCase())) { temp.add(currData); } } diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datasources/DataSourcesDlg.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datasources/DataSourcesDlg.java index 38ac4ff35e..0e5c9e6367 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datasources/DataSourcesDlg.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datasources/DataSourcesDlg.java @@ -23,7 +23,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; @@ -1109,8 +1108,8 @@ public class DataSourcesDlg extends CaveSWTDialog { } // Select the first option - dataList.getClass().getMethod("select", int.class).invoke(dataList, - 0); + dataList.getClass().getMethod("select", int.class) + .invoke(dataList, 0); } } @@ -1131,8 +1130,8 @@ public class DataSourcesDlg extends CaveSWTDialog { seedData.setLid(lid); try { - ArrayList data = HydroDBDataManager.getInstance().getData( - seedData); + java.util.List data = HydroDBDataManager.getInstance() + .getData(seedData); if (data.size() > 0) { // There will only be one record per lid @@ -1152,8 +1151,8 @@ public class DataSourcesDlg extends CaveSWTDialog { seedData.setLid(lid); try { - ArrayList data = HydroDBDataManager.getInstance() - .getData(seedData); + java.util.List data = HydroDBDataManager + .getInstance().getData(seedData); if (data.size() > 0) { // There will only be one record per lid @@ -1173,7 +1172,7 @@ public class DataSourcesDlg extends CaveSWTDialog { seedData.setLid(lid); try { - ArrayList data = HydroDBDataManager.getInstance() + java.util.List data = HydroDBDataManager.getInstance() .getData(seedData); if (data.size() > 0) { @@ -1258,8 +1257,8 @@ public class DataSourcesDlg extends CaveSWTDialog { emailTF.setText(obsData.getEmail()); // Date of service - dosTF.setText(HydroDataUtils.getDisplayString(obsData - .getDateOfService(), isoDate)); + dosTF.setText(HydroDataUtils.getDisplayString( + obsData.getDateOfService(), isoDate)); // Phone Numbers homePhoneTF.setText(obsData.getHomePhone()); @@ -1389,8 +1388,7 @@ public class DataSourcesDlg extends CaveSWTDialog { } catch (ParseException e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Invalid Date"); - mb - .setMessage("Please enter a Service Date in the form: YYYY-MM-DD"); + mb.setMessage("Please enter a Service Date in the form: YYYY-MM-DD"); mb.open(); e.printStackTrace(); diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/impactstatement/ImpactStatementDlg.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/impactstatement/ImpactStatementDlg.java index 214deb0fe4..2b753fa915 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/impactstatement/ImpactStatementDlg.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/impactstatement/ImpactStatementDlg.java @@ -24,7 +24,6 @@ import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; @@ -60,10 +59,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.dataquery.db.QueryResult; -import com.raytheon.uf.viz.core.catalog.DirectDbQuery; -import com.raytheon.uf.viz.core.catalog.DirectDbQuery.QueryLanguage; import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.viz.hydrocommon.HydroConstants; import com.raytheon.viz.hydrocommon.data.FloodStatementData; import com.raytheon.viz.hydrocommon.data.LocationData; import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager; @@ -148,10 +144,11 @@ public class ImpactStatementDlg extends CaveSWTDialog { * Text editor control. */ private StyledText textEditor; + /** * text from the remark text box */ - private String currentImpactText=null; + private String currentImpactText = null; /** * OK button. @@ -201,7 +198,7 @@ public class ImpactStatementDlg extends CaveSWTDialog { /** * Cache of data for location */ - private ArrayList statementData; + private java.util.List statementData; /** * Used by the print methods @@ -224,8 +221,6 @@ public class ImpactStatementDlg extends CaveSWTDialog { private int index, end; - private String tabs; - private StringBuffer wordBuffer; private GC gc; @@ -466,16 +461,15 @@ public class ImpactStatementDlg extends CaveSWTDialog { textEditor.setEditable(fullControl); textEditor.setWordWrap(true); textEditor.setTextLimit(512); - currentImpactText=textEditor.getText(); + currentImpactText = textEditor.getText(); ModifyListener listener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (textEditor.getText().length()>512){ - textEditor.setText(currentImpactText); - shell.getDisplay().beep(); - } - else - currentImpactText=textEditor.getText(); - } + public void modifyText(ModifyEvent e) { + if (textEditor.getText().length() > 512) { + textEditor.setText(currentImpactText); + shell.getDisplay().beep(); + } else + currentImpactText = textEditor.getText(); + } }; textEditor.addModifyListener(listener); @@ -628,39 +622,6 @@ public class ImpactStatementDlg extends CaveSWTDialog { return labelStr; } - // --------------------------------------------------------- - // Query the Floodstmt Table in the IHFS database using SQL. - // --------------------------------------------------------- - private void queryFloodstmt() { - // --------------------------------- - // Populate data list - // --------------------------------- - - String fmtStr = "%8S %13S %25S %11S %29S"; - String myQuery = "select * from floodstmt where lid = '" + lid + "'"; - - ArrayList data; - try { - data = (ArrayList) DirectDbQuery.executeQuery(myQuery, - HydroConstants.IHFS, QueryLanguage.SQL); - for (Object[] rowData : data) { - String risingIndicator; - if (rowData[3].toString().equals("R")) { - risingIndicator = RISING; - } else { - risingIndicator = FALLING; - } - - String tmpStr = String.format(fmtStr, rowData[1].toString(), - rowData[6].toString(), rowData[4].toString(), - rowData[5].toString(), risingIndicator); - dataList.add(tmpStr); - } - } catch (VizException e) { - e.printStackTrace(); - } - } - // ----------------------------------------------- // Populate characteristics of selected statement. // ----------------------------------------------- @@ -728,8 +689,8 @@ public class ImpactStatementDlg extends CaveSWTDialog { return String.format(fmtStr, currStatement.getImpactValue(), currStatement.getImpactPE(), currStatement.getDateStart(), - currStatement.getDateEnd(), (currStatement.getRiseFall() - .equals("R")) ? RISING : FALLING); + currStatement.getDateEnd(), + (currStatement.getRiseFall().equals("R")) ? RISING : FALLING); } private void clearInformation() { @@ -774,8 +735,7 @@ public class ImpactStatementDlg extends CaveSWTDialog { } catch (VizException e) { mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Delete"); - mb - .setMessage("An error occurred while trying to delete the record."); + mb.setMessage("An error occurred while trying to delete the record."); mb.open(); e.printStackTrace(); @@ -830,9 +790,7 @@ public class ImpactStatementDlg extends CaveSWTDialog { + endDayTF.getText(); try { - newData - .setDateEnd(dateFormat - .format(dateFormat.parse(endDate))); + newData.setDateEnd(dateFormat.format(dateFormat.parse(endDate))); } catch (Exception e) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); @@ -958,7 +916,7 @@ public class ImpactStatementDlg extends CaveSWTDialog { LocationData seedData = new LocationData(); seedData.setLid(lid); - ArrayList locData = null; + java.util.List locData = null; try { locData = HydroDBDataManager.getInstance().getData(seedData); } catch (VizException e) { @@ -969,14 +927,13 @@ public class ImpactStatementDlg extends CaveSWTDialog { // Should only be one record for the LID LocationData currLoc = locData.get(0); - outputStr.append(String.format("%s %s - %s COUNTY, %s\n", currLoc - .getLid(), currLoc.getName(), currLoc.getCounty(), currLoc - .getState())); + outputStr.append(String.format("%s %s - %s COUNTY, %s\n", + currLoc.getLid(), currLoc.getName(), currLoc.getCounty(), + currLoc.getState())); } else { outputStr .append(String - .format( - "The name, county, and state for station %s are not available.\n", + .format("The name, county, and state for station %s are not available.\n", lid)); } @@ -986,12 +943,12 @@ public class ImpactStatementDlg extends CaveSWTDialog { SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime(); - outputStr.append(String.format("GENERATED %s\n\n\n", dateFormat - .format(now))); + outputStr.append(String.format("GENERATED %s\n\n\n", + dateFormat.format(now))); for (FloodStatementData currStatement : statementData) { - outputStr.append(String.format("IMPACT PE: %s ", currStatement - .getImpactPE())); + outputStr.append(String.format("IMPACT PE: %s ", + currStatement.getImpactPE())); if (currStatement.getImpactPE().equals("QR")) { outputStr.append(String.format("IMPACT VALUE: %9.2f CFS. ", @@ -1217,8 +1174,7 @@ public class ImpactStatementDlg extends CaveSWTDialog { } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setText("Unable to Save"); - mb - .setMessage("Data for the location must be add via the River Gauge dialog first."); + mb.setMessage("Data for the location must be add via the River Gauge dialog first."); mb.open(); } } catch (VizException e) { diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/util/StnClassSyncUtil.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/util/StnClassSyncUtil.java index b114df9ac8..02885ee2d9 100644 --- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/util/StnClassSyncUtil.java +++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/util/StnClassSyncUtil.java @@ -19,7 +19,7 @@ **/ package com.raytheon.viz.hydrocommon.util; -import java.util.ArrayList; +import java.util.List; import com.raytheon.uf.common.dataquery.db.QueryResult; import com.raytheon.uf.common.dataquery.db.QueryResultRow; @@ -42,6 +42,8 @@ import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 13, 2009 1802 askripsk Initial creation + * Apr 18, 2013 1790 rferrel Cleanup method interfaces; + * part of non-blocking dialogs. * * * @@ -71,8 +73,8 @@ public class StnClassSyncUtil { TelemData telemSeedData = new TelemData(); telemSeedData.setLid(lid); - ArrayList telemData = HydroDBDataManager.getInstance() - .getData(telemSeedData); + List telemData = HydroDBDataManager.getInstance().getData( + telemSeedData); int telemCount = telemData.size(); if (telemCount != 0) { @@ -156,7 +158,7 @@ public class StnClassSyncUtil { ingestSeedData.setWhereClause(" WHERE lid= '" + lid + "' AND ingest= 'T'"); - ArrayList ingestFilterData = HydroDBDataManager + List ingestFilterData = HydroDBDataManager .getInstance().getData(ingestSeedData); if (ingestFilterData.size() > 0) { @@ -337,8 +339,8 @@ public class StnClassSyncUtil { * @return The number of PEs in the ingest filter list that starts with the * specified PE prefix. */ - private static int getPECount( - ArrayList ingestFilterData, String currPE) { + private static int getPECount(List ingestFilterData, + String currPE) { int peCount = 0; for (DataIngestFilterData currFilter : ingestFilterData) {