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 9c3959cdbc..9dc37f159d 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 @@ -138,7 +138,17 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Changes for non-blocking DataAdjustFactorDlg. * Changes for non-blocking DataIngestFilterDlg. * Changes for non-blocking DataPurgeParamsDlg. - * Changes for non-blocking DatumDlg . + * Changes for non-blocking DatumDlg. + * Changes for non-blocking DescriptionDlg. + * Changes for non-blocking FloodCategoryDlg. + * Changes for non-blocking FloodDamageDlg. + * Changes for non-blocking GageHistoryDlg. + * Changes for non-blocking HydroGenConfigDlg. + * Changes for non-blocking LowWaterDlg. + * Changes for non-blocking NwrTransmitterDlg. + * Changes for non-blocking PreferencesDlg. + * Changes for non-blocking PublicationsDlg. + * Changes for non-blocking QcAlertAlarmLimitsDlg. * * * @@ -201,6 +211,56 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, */ private final Map datumDlgMap = new HashMap(); + /** + * Allow one description dialog per station. + */ + private final Map descDlgMap = new HashMap(); + + /** + * Allow one flood category dialog per station. + */ + private final Map floodCatDlgMap = new HashMap();; + + /** + * Allow one flood damage dialog per station. + */ + private final Map floodDamDlgMap = new HashMap(); + + /** + * Allow one gage history dialog per station. + */ + private final Map ghDlgMap = new HashMap(); + + /** + * Allow one Hydrogen configuration dialog. + */ + private HydroGenConfigDlg hydroGenDlg; + + /** + * Allow one low water dialog per station. + */ + private final Map lowWaterDlgMap = new HashMap(); + + /** + * Allow one NWR Transmitter Towers dialog. + */ + private NwrTransmitterDlg nwrTransDlg; + + /** + * Allow one preferences dialog. + */ + private PreferencesDlg prefDlg; + + /** + * Allow one publication dialog per station. + */ + private final Map publicationsDlgMap = new HashMap(); + + /** + * Allow one QC alart/alarm limits dialog. + */ + private QcAlertAlarmLimitsDlg qcAlertAlarmDlg; + /** * Flood category menu item. */ @@ -454,10 +514,13 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, } private void openPreferencesDialog() { - PreferencesDlg prefDlg = new PreferencesDlg(shell); - prefDlg.addListener(this); - prefDlg.open(); - prefDlg.removeListener(this); + if (prefDlg == null || prefDlg.isDisposed()) { + prefDlg = new PreferencesDlg(shell); + prefDlg.addListener(this); + prefDlg.open(); + } else { + prefDlg.bringToTop(); + } } /** @@ -559,9 +622,26 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, gageHistoryMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - GageHistoryDlg ghDlg = new GageHistoryDlg(shell, - getStationAndName(), getSelectedLocation().getStation()); - ghDlg.open(); + String lid = getSelectedLocation().getStation(); + GageHistoryDlg ghDlg = ghDlgMap.get(lid); + + if (ghDlg == null) { + ghDlg = new GageHistoryDlg(shell, getStationAndName(), lid); + ghDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof String) { + String lid = returnValue.toString(); + ghDlgMap.remove(lid); + } + } + }); + ghDlgMap.put(lid, ghDlg); + ghDlg.open(); + } else { + ghDlg.bringToTop(); + } } }); @@ -623,9 +703,27 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, floodCategoryMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - FloodCategoryDlg floodCatDlg = new FloodCategoryDlg(shell, - getStationAndName(), getSelectedLocation().getStation()); - floodCatDlg.open(); + String lid = getSelectedLocation().getStation(); + FloodCategoryDlg floodCatDlg = floodCatDlgMap.get(lid); + + if (floodCatDlg == null) { + floodCatDlg = new FloodCategoryDlg(shell, + getStationAndName(), lid); + floodCatDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof String) { + String lid = returnValue.toString(); + floodCatDlgMap.remove(lid); + } + } + }); + floodCatDlgMap.put(lid, floodCatDlg); + floodCatDlg.open(); + } else { + floodCatDlg.bringToTop(); + } } }); riverGageMenuItems.add(floodCategoryMI); @@ -667,9 +765,27 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, floodDamageMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - FloodDamageDlg floodDamDlg = new FloodDamageDlg(shell, - getStationAndName(), getSelectedLocation().getStation()); - floodDamDlg.open(); + String lid = getSelectedLocation().getStation(); + FloodDamageDlg floodDamDlg = floodDamDlgMap.get(lid); + + if (floodDamDlg == null) { + floodDamDlg = new FloodDamageDlg(shell, + getStationAndName(), lid); + floodDamDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof String) { + String lid = returnValue.toString(); + floodDamDlgMap.remove(lid); + } + } + }); + floodDamDlgMap.put(lid, floodDamDlg); + floodDamDlg.open(); + } else { + floodDamDlg.bringToTop(); + } } }); riverGageMenuItems.add(floodDamageMI); @@ -724,9 +840,27 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, lowWaterMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - LowWaterDlg lowWaterDlg = new LowWaterDlg(shell, - getStationAndName(), getSelectedLocation().getStation()); - lowWaterDlg.open(); + String lid = getSelectedLocation().getStation(); + LowWaterDlg lowWaterDlg = lowWaterDlgMap.get(lid); + + if (lowWaterDlg == null) { + lowWaterDlg = new LowWaterDlg(shell, getStationAndName(), + lid); + lowWaterDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof String) { + String lid = returnValue.toString(); + lowWaterDlgMap.remove(lid); + } + } + }); + lowWaterDlgMap.put(lid, lowWaterDlg); + lowWaterDlg.open(); + } else { + lowWaterDlg.bringToTop(); + } } }); riverGageMenuItems.add(lowWaterMI); @@ -801,9 +935,27 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, descriptionMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - DescriptionDlg descDlg = new DescriptionDlg(shell, - getStationAndName(), getSelectedLocation().getStation()); - descDlg.open(); + String lid = getSelectedLocation().getStation(); + DescriptionDlg descDlg = descDlgMap.get(lid); + + if (descDlg == null) { + descDlg = new DescriptionDlg(shell, getStationAndName(), + lid); + descDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof String) { + String lid = returnValue.toString(); + descDlgMap.remove(lid); + } + } + }); + descDlgMap.put(lid, descDlg); + descDlg.open(); + } else { + descDlg.bringToTop(); + } } }); riverGageMenuItems.add(descriptionMI); @@ -817,9 +969,26 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, publicationsMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - PublicationsDlg publicationsDlg = new PublicationsDlg(shell, - getStationAndName(), getSelectedLocation().getStation()); - publicationsDlg.open(); + String lid = getSelectedLocation().getStation(); + PublicationsDlg publicationsDlg = publicationsDlgMap.get(lid); + if (publicationsDlg == null) { + publicationsDlg = new PublicationsDlg(shell, + getStationAndName(), lid); + publicationsDlg.setCloseCallback(new ICloseCallback() { + + @Override + public void dialogClosed(Object returnValue) { + if (returnValue instanceof String) { + String lid = returnValue.toString(); + publicationsDlgMap.remove(lid); + } + } + }); + publicationsDlgMap.put(lid, publicationsDlg); + publicationsDlg.open(); + } else { + publicationsDlg.bringToTop(); + } } }); riverGageMenuItems.add(publicationsMI); @@ -931,9 +1100,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, qcAlertAlarmMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - QcAlertAlarmLimitsDlg qcAlertAlarmDlg = new QcAlertAlarmLimitsDlg( - shell); - qcAlertAlarmDlg.open(); + if (qcAlertAlarmDlg == null || qcAlertAlarmDlg.isDisposed()) { + qcAlertAlarmDlg = new QcAlertAlarmLimitsDlg(shell); + qcAlertAlarmDlg.open(); + } else { + qcAlertAlarmDlg.bringToTop(); + } } }); @@ -1139,8 +1311,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, nwrTransmitterMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - NwrTransmitterDlg nwrTransDlg = new NwrTransmitterDlg(shell); - nwrTransDlg.open(); + if (nwrTransDlg == null || nwrTransDlg.isDisposed()) { + nwrTransDlg = new NwrTransmitterDlg(shell); + nwrTransDlg.open(); + } else { + nwrTransDlg.bringToTop(); + } } }); @@ -1181,8 +1357,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType, hydroGenConfMI.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - HydroGenConfigDlg hydroGenDlg = new HydroGenConfigDlg(shell); - hydroGenDlg.open(); + if (hydroGenDlg == null || hydroGenDlg.isDisposed()) { + hydroGenDlg = new HydroGenConfigDlg(shell); + hydroGenDlg.open(); + } else { + hydroGenDlg.bringToTop(); + } } }); } 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 09a4fb3ba7..b75d2523e8 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 @@ -206,7 +206,7 @@ public class CountyStateDlg extends CaveSWTDialog { CountiesData rval = new CountiesData(); rval.setCounty("COUNTY"); rval.setState("STATE"); - String labelStr = formatCountState(rval); + String labelStr = formatCountyState(rval); return labelStr; } @@ -232,7 +232,7 @@ public class CountyStateDlg extends CaveSWTDialog { countyStateList.removeAll(); for (CountiesData currCounty : countiesData) { - countyStateList.add(formatCountState(currCounty)); + countyStateList.add(formatCountyState(currCounty)); } } @@ -242,7 +242,7 @@ public class CountyStateDlg extends CaveSWTDialog { * @param countiesData * @return formatedString */ - private String formatCountState(CountiesData countiesData) { + private String formatCountyState(CountiesData countiesData) { return String.format("%-36s %-2s", countiesData.getCounty(), countiesData.getState()); } @@ -307,7 +307,7 @@ public class CountyStateDlg extends CaveSWTDialog { return; } - String selectedString = formatCountState(selectedData); + String selectedString = formatCountyState(selectedData); // Clear selection countyStateList.deselectAll(); diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DescriptionDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DescriptionDlg.java index 916200382a..e32690db33 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DescriptionDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/DescriptionDlg.java @@ -38,6 +38,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.data.DescriptionData; import com.raytheon.viz.hydrocommon.data.LocationAreaData; @@ -55,6 +58,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 4, 2008 lvenable Initial creation + * Apr 19,2013 1790 rferrel Make dialog non-blocking. * * * @@ -62,6 +66,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * @version 1.0 */ public class DescriptionDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(DescriptionDlg.class); /** * Control font. @@ -134,13 +140,18 @@ public class DescriptionDlg extends CaveSWTDialog { private Button affectAreaSaveBtn; private String locationId; - - private String currentRemarkText=null; - private String currentFreezeText=null; - private String currentReachText=null; - private String currentRegText=null; - private String currentTopoText=null; - private String currentAreaText=null; + + private String currentRemarkText = null; + + private String currentFreezeText = null; + + private String currentReachText = null; + + private String currentRegText = null; + + private String currentTopoText = null; + + private String currentAreaText = null; // private boolean hasCurrentData = false; @@ -153,12 +164,17 @@ public class DescriptionDlg extends CaveSWTDialog { * Dialog title information. */ public DescriptionDlg(Shell parent, String titleInfo, String lid) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("Description" + titleInfo); locationId = lid; } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ @Override protected Layout constructShellLayout() { // Create the main layout for the shell. @@ -169,14 +185,26 @@ public class DescriptionDlg 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); + setReturnValue(locationId); controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); createMainControls(); @@ -243,16 +271,15 @@ public class DescriptionDlg extends CaveSWTDialog { | SWT.V_SCROLL); remarksTF.setFont(controlFont); remarksTF.setLayoutData(gd); - currentRemarkText=remarksTF.getText(); + currentRemarkText = remarksTF.getText(); ModifyListener listener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (remarksTF.getText().length()>255){ - remarksTF.setText(currentRemarkText); - shell.getDisplay().beep(); - } - else - currentRemarkText=remarksTF.getText(); - } + public void modifyText(ModifyEvent e) { + if (remarksTF.getText().length() > 255) { + remarksTF.setText(currentRemarkText); + shell.getDisplay().beep(); + } else + currentRemarkText = remarksTF.getText(); + } }; remarksTF.addModifyListener(listener); @@ -269,16 +296,15 @@ public class DescriptionDlg extends CaveSWTDialog { | SWT.V_SCROLL); freezingTF.setFont(controlFont); freezingTF.setLayoutData(gd); - currentFreezeText=freezingTF.getText(); + currentFreezeText = freezingTF.getText(); ModifyListener listenerF = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (freezingTF.getText().length()>160){ - freezingTF.setText(currentFreezeText); - shell.getDisplay().beep(); - } - else - currentFreezeText=freezingTF.getText(); - } + public void modifyText(ModifyEvent e) { + if (freezingTF.getText().length() > 160) { + freezingTF.setText(currentFreezeText); + shell.getDisplay().beep(); + } else + currentFreezeText = freezingTF.getText(); + } }; freezingTF.addModifyListener(listenerF); @@ -294,16 +320,15 @@ public class DescriptionDlg extends CaveSWTDialog { | SWT.V_SCROLL); reachTF.setFont(controlFont); reachTF.setLayoutData(gd); - currentReachText=reachTF.getText(); + currentReachText = reachTF.getText(); ModifyListener listenerR = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (reachTF.getText().length()>80){ - reachTF.setText(currentReachText); - shell.getDisplay().beep(); - } - else - currentReachText=reachTF.getText(); - } + public void modifyText(ModifyEvent e) { + if (reachTF.getText().length() > 80) { + reachTF.setText(currentReachText); + shell.getDisplay().beep(); + } else + currentReachText = reachTF.getText(); + } }; reachTF.addModifyListener(listenerR); @@ -319,16 +344,15 @@ public class DescriptionDlg extends CaveSWTDialog { | SWT.V_SCROLL); regulationTF.setFont(controlFont); regulationTF.setLayoutData(gd); - currentRegText=regulationTF.getText(); + currentRegText = regulationTF.getText(); ModifyListener listenerReg = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (regulationTF.getText().length()>230){ - regulationTF.setText(currentRegText); - shell.getDisplay().beep(); - } - else - currentRegText=regulationTF.getText(); - } + public void modifyText(ModifyEvent e) { + if (regulationTF.getText().length() > 230) { + regulationTF.setText(currentRegText); + shell.getDisplay().beep(); + } else + currentRegText = regulationTF.getText(); + } }; regulationTF.addModifyListener(listenerReg); @@ -344,16 +368,15 @@ public class DescriptionDlg extends CaveSWTDialog { | SWT.V_SCROLL); topoTF.setFont(controlFont); topoTF.setLayoutData(gd); - currentTopoText=topoTF.getText(); + currentTopoText = topoTF.getText(); ModifyListener listenerT = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (topoTF.getText().length()>230){ - topoTF.setText(currentTopoText); - shell.getDisplay().beep(); - } - else - currentTopoText=topoTF.getText(); - } + public void modifyText(ModifyEvent e) { + if (topoTF.getText().length() > 230) { + topoTF.setText(currentTopoText); + shell.getDisplay().beep(); + } else + currentTopoText = topoTF.getText(); + } }; topoTF.addModifyListener(listenerT); @@ -410,20 +433,18 @@ public class DescriptionDlg extends CaveSWTDialog { | SWT.WRAP | SWT.V_SCROLL); affectedAreaTF.setFont(controlFont); affectedAreaTF.setLayoutData(gd); - currentAreaText=affectedAreaTF.getText(); + currentAreaText = affectedAreaTF.getText(); ModifyListener listenerA = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (affectedAreaTF.getText().length()>80){ - affectedAreaTF.setText(currentAreaText); - shell.getDisplay().beep(); - } - else - currentAreaText=affectedAreaTF.getText(); - } + public void modifyText(ModifyEvent e) { + if (affectedAreaTF.getText().length() > 80) { + affectedAreaTF.setText(currentAreaText); + shell.getDisplay().beep(); + } else + currentAreaText = affectedAreaTF.getText(); + } }; affectedAreaTF.addModifyListener(listenerA); - // --------------------------------------------- // Add the Delete and Save buttons // --------------------------------------------- @@ -475,7 +496,7 @@ public class DescriptionDlg extends CaveSWTDialog { exitBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); } @@ -502,8 +523,8 @@ public class DescriptionDlg extends CaveSWTDialog { } } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to get proximity data. ", e); } } @@ -543,8 +564,8 @@ public class DescriptionDlg extends CaveSWTDialog { affectedAreaTF.setText(locAreaData.getArea()); } } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to get description data. ", e); } } @@ -565,15 +586,8 @@ public class DescriptionDlg extends CaveSWTDialog { try { DescriptionDataManager.getInstance().deleteDescription(locationId); } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - - MessageBox errorMb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - errorMb.setText("Error"); - errorMb.setMessage("Error deleting the selected description."); - errorMb.open(); - - return; + statusHandler.handle(Priority.PROBLEM, + "Unable to delete description. ", e); } streamBedTF.setText(""); @@ -603,8 +617,8 @@ public class DescriptionDlg extends CaveSWTDialog { descriptionData); } } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to save description. ", e); } } @@ -625,14 +639,8 @@ public class DescriptionDlg extends CaveSWTDialog { try { LocationAreaManager.getInstance().deleteRecord(locationId); } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - - MessageBox errorMb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - errorMb.setText("Error"); - errorMb.setMessage("Error deleting the selected description."); - errorMb.open(); - + statusHandler.handle(Priority.PROBLEM, + "Unable to delete selected description. ", e); return; } @@ -659,8 +667,8 @@ public class DescriptionDlg extends CaveSWTDialog { locAreaData); } } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to save affected area. ", e); } } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/FloodCategoryDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/FloodCategoryDlg.java index c196d80051..93a8ca7ff6 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/FloodCategoryDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/FloodCategoryDlg.java @@ -35,6 +35,9 @@ 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.exception.VizException; import com.raytheon.viz.hydrocommon.data.FloodCategoryData; import com.raytheon.viz.hydrocommon.datamanager.FloodCategoryDataManager; @@ -52,12 +55,15 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Nov 10, 2008 1661 askripsky Connected to DB * March 3, 2011 JingtaoD Mondification - display blank on Flood category GUI * if the value is null in database + * Apr 19, 2013 1790 rferrel Make dialog non-blocking. * * * @author lvenable * @version 1.0 */ public class FloodCategoryDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(FloodCategoryDlg.class); /** * Location whose data is displayed. @@ -98,10 +104,14 @@ public class FloodCategoryDlg extends CaveSWTDialog { * constant for missing value */ private static final double missingVal = -9999.0; + + /** + * delta factor to consider 2 double values equal. + */ private static final double diffAllowed = 0.0001; /** - * Constructor. + * Non-blocking Constructor. * * @param parent * Parent shell. @@ -109,12 +119,17 @@ public class FloodCategoryDlg extends CaveSWTDialog { * Dialog title information. */ public FloodCategoryDlg(Shell parent, String titleInfo, String lid) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("Flood Category" + titleInfo); this.lid = lid; } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ @Override protected Layout constructShellLayout() { // Create the main layout for the shell. @@ -125,9 +140,16 @@ public class FloodCategoryDlg extends CaveSWTDialog { return mainLayout; } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org + * .eclipse.swt.widgets.Shell) + */ @Override protected void initializeComponents(Shell shell) { - setReturnValue(false); + setReturnValue(lid); // Initialize all of the controls and layouts initializeComponents(); @@ -230,7 +252,7 @@ public class FloodCategoryDlg extends CaveSWTDialog { okBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { if (saveChanges()) { - shell.dispose(); + close(); } } }); @@ -241,7 +263,7 @@ public class FloodCategoryDlg extends CaveSWTDialog { cancelBtn.setLayoutData(gd); cancelBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); @@ -254,12 +276,17 @@ public class FloodCategoryDlg extends CaveSWTDialog { if (MessageDialog.openConfirm(null, "Delete Confirmation", "Do you wish to delete this entry?")) { removeRecord(); - shell.dispose(); + close(); } } }); } + /** + * Verify and save changes. + * + * @return true if save successful + */ private boolean saveChanges() { boolean successful = false; @@ -272,9 +299,7 @@ public class FloodCategoryDlg extends CaveSWTDialog { modDischargeTF.getText(), minorDischargeTF.getText(), shell); } catch (VizException e) { - e.printStackTrace(); - String showErrorMsg = "Unable to save values"; - MessageDialog.openConfirm(null, "Save Failed", showErrorMsg); + statusHandler.handle(Priority.PROBLEM, "Save failed. ", e); } } @@ -301,13 +326,12 @@ public class FloodCategoryDlg 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) { - // don't care, just return false - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Check constraints failed. ", e); } return rval; @@ -317,50 +341,53 @@ public class FloodCategoryDlg extends CaveSWTDialog { try { FloodCategoryDataManager.getInstance().deleteRecord(lid); } catch (VizException e) { - String showErrorMsg = "Unable to delete records"; - MessageDialog.openConfirm(null, "Delete Failed", showErrorMsg); + statusHandler.handle(Priority.PROBLEM, "Delete record failed. ", e); } } + /** + * Get flood catagory data and update display. + */ private void loadFloodCategoryData() { try { FloodCategoryData data = FloodCategoryDataManager.getInstance() .getFloodCategoryData(lid); - - if (Math.abs(data.getMajorStage() - missingVal) < diffAllowed ) - majorStageTF.setText(""); + + if (Math.abs(data.getMajorStage() - missingVal) < diffAllowed) + majorStageTF.setText(""); else - majorStageTF.setText(Double.toString(data.getMajorStage())); - + majorStageTF.setText(Double.toString(data.getMajorStage())); + if (Math.abs(data.getModerateStage() - missingVal) < diffAllowed) - modStageTF.setText(""); + modStageTF.setText(""); else - modStageTF.setText(Double.toString(data.getModerateStage())); - + modStageTF.setText(Double.toString(data.getModerateStage())); + if (Math.abs(data.getMinorStage() - missingVal) < diffAllowed) - minorStageTF.setText(""); + minorStageTF.setText(""); else - minorStageTF.setText(Double.toString(data.getMinorStage())); - + minorStageTF.setText(Double.toString(data.getMinorStage())); + if (Math.abs(data.getMajorDischarge() - missingVal) < diffAllowed) - majorDischargeTF.setText(""); + majorDischargeTF.setText(""); else - majorDischargeTF.setText(Double.toString(data.getMajorDischarge())); - + majorDischargeTF.setText(Double.toString(data + .getMajorDischarge())); + if (Math.abs(data.getModerateDischarge() - missingVal) < diffAllowed) - modDischargeTF.setText(""); + modDischargeTF.setText(""); else - modDischargeTF.setText(Double.toString(data.getModerateDischarge())); - + modDischargeTF.setText(Double.toString(data + .getModerateDischarge())); + if (Math.abs(data.getMinorDischarge() - missingVal) < diffAllowed) - minorDischargeTF.setText(""); + minorDischargeTF.setText(""); else - minorDischargeTF.setText(Double.toString(data.getMinorDischarge())); - - + minorDischargeTF.setText(Double.toString(data + .getMinorDischarge())); + } catch (VizException e) { - String showErrorMsg = "Unable to retrieve values"; - MessageDialog.openConfirm(null, "Retrieve Failed", showErrorMsg); + statusHandler.handle(Priority.PROBLEM, "Retrieve failed. ", e); } } } diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/FloodDamageDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/FloodDamageDlg.java index 6e4f2645ba..6ecd4f06bb 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/FloodDamageDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/FloodDamageDlg.java @@ -40,6 +40,9 @@ import org.eclipse.swt.widgets.List; 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.data.FloodData; import com.raytheon.viz.hydrocommon.datamanager.FloodDataManager; @@ -53,6 +56,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 4, 2008 lvenable Initial creation + * Apr 19, 2013 1790 rferrel Make dialog non-blocking. * * * @@ -60,6 +64,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * @version 1.0 */ public class FloodDamageDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(FloodDamageDlg.class); /** * Control font. @@ -89,7 +95,7 @@ public class FloodDamageDlg extends CaveSWTDialog { /** * text from the remark text box */ - private String currentDamageText=null; + private String currentDamageText = null; /** * Lid for the dialog. @@ -102,7 +108,7 @@ public class FloodDamageDlg extends CaveSWTDialog { private ArrayList floodData; /** - * Constructor. + * Non-blocking Constructor. * * @param parent * Parent shell. @@ -110,12 +116,17 @@ public class FloodDamageDlg extends CaveSWTDialog { * Dialog title information. */ public FloodDamageDlg(Shell parent, String titleInfo, String lid) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("Flood Damage" + titleInfo); this.lid = lid; } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ @Override protected Layout constructShellLayout() { GridLayout mainLayout = new GridLayout(1, false); @@ -125,14 +136,26 @@ public class FloodDamageDlg 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); + setReturnValue(lid); // Initialize all of the controls and layouts initializeComponents(); @@ -228,16 +251,15 @@ public class FloodDamageDlg extends CaveSWTDialog { damageTF = new Text(statmentGroup, SWT.BORDER | SWT.MULTI | SWT.WRAP); damageTF.setLayoutData(gd); damageTF.setFont(controlFont); - currentDamageText=damageTF.getText(); + currentDamageText = damageTF.getText(); ModifyListener listener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - if (damageTF.getText().length()>510){ - damageTF.setText(currentDamageText); - shell.getDisplay().beep(); - } - else - currentDamageText=damageTF.getText(); - } + public void modifyText(ModifyEvent e) { + if (damageTF.getText().length() > 510) { + damageTF.setText(currentDamageText); + shell.getDisplay().beep(); + } else + currentDamageText = damageTF.getText(); + } }; damageTF.addModifyListener(listener); @@ -262,7 +284,7 @@ public class FloodDamageDlg extends CaveSWTDialog { okBtn.setLayoutData(gd); okBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); @@ -284,7 +306,7 @@ public class FloodDamageDlg extends CaveSWTDialog { cancelBtn.setLayoutData(gd); cancelBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); @@ -335,13 +357,16 @@ public class FloodDamageDlg extends CaveSWTDialog { try { floodData = FloodDataManager.getInstance().getFloodData(lid); } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Uable to get flood damage data. ", e); } updateFloodDamageData(); } + /** + * Update stage list with current flood data. + */ private void updateFloodDamageData() { // Clear current Stages stageList.removeAll(); @@ -351,20 +376,36 @@ public class FloodDamageDlg extends CaveSWTDialog { } } + /** + * Display flood damage for the currentl selected stage. + */ private void getDamageStatement() { updateDamageDisplay(getCurrentlySelectedStage()); } + /** + * Dispal the data's damage information. + * + * @param data + */ private void updateDamageDisplay(FloodData data) { stageTF.setText(Double.toString(data.getStage())); displayTF.setText(data.getDisplayStatement()); damageTF.setText(data.getDamage()); } + /** + * Get the flood data for the currently selected stage. + * + * @return data + */ private FloodData getCurrentlySelectedStage() { return floodData.get(stageList.getSelectionIndex()); } + /** + * Confirm, delete record and update display. + */ private void deleteRecord() { if (MessageDialog.openConfirm(null, "Delete Confirmation", "Do you wish to delete this entry?")) { @@ -372,8 +413,8 @@ public class FloodDamageDlg extends CaveSWTDialog { FloodDataManager.getInstance().deleteRecord( getCurrentlySelectedStage()); } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Uable to delete record. ", e); } getFloodDamageData(); @@ -382,12 +423,18 @@ public class FloodDamageDlg extends CaveSWTDialog { clearStatement(); } + /** + * Clear text fields. + */ private void clearStatement() { stageTF.setText(""); damageTF.setText(""); displayTF.setText(""); } + /** + * Save flood information for station location. + */ private void saveRecord() { try { FloodDataManager.getInstance().putFloodCategoryData(lid, @@ -397,8 +444,7 @@ public class FloodDamageDlg extends CaveSWTDialog { MessageDialog.openConfirm(null, "Invalid Stage value", "Please enter a valid numeric value for Stage"); } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, "Uable to save record. ", e); } getFloodDamageData(); 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 900154449f..259bfff5d8 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 @@ -45,6 +45,9 @@ import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.dataquery.db.QueryResult; import com.raytheon.uf.common.dataquery.db.QueryResultRow; +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.GageDBData; import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager; @@ -59,6 +62,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * Sep 4, 2008 lvenable Initial creation * Jan 8, 2008 1802 askripsk Connect to DB. + * Apr 19, 2013 170- rferrel Make dialog non-blocking. * * * @@ -66,6 +70,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * @version 1.0 */ public class GageHistoryDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(GageHistoryDlg.class); /** * Control font. @@ -147,7 +153,7 @@ public class GageHistoryDlg extends CaveSWTDialog { private String lid; /** - * Constructor. + * Non-blocking Constructor. * * @param parent * Parent shell. @@ -164,6 +170,11 @@ public class GageHistoryDlg extends CaveSWTDialog { dateFormat.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. @@ -174,14 +185,26 @@ public class GageHistoryDlg 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); + setReturnValue(lid); // Initialize all of the controls and layouts initializeComponents(); @@ -358,7 +381,7 @@ public class GageHistoryDlg extends CaveSWTDialog { okBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { if (saveRecord()) { - shell.dispose(); + close(); } } }); @@ -382,7 +405,7 @@ public class GageHistoryDlg extends CaveSWTDialog { cancelBtn.setLayoutData(gd); cancelBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); @@ -424,6 +447,9 @@ public class GageHistoryDlg extends CaveSWTDialog { return labelStr; } + /** + * Obtain and display gage static data. + */ private void loadStaticData() { typeList.removeAll(); ownerList.removeAll(); @@ -445,10 +471,19 @@ public class GageHistoryDlg extends CaveSWTDialog { maintList.add(currAgency); } } catch (VizException e) { - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to load static data. ", e); } } + /** + * Get gage data and update the display. + * + * @param table + * @param column + * @return + * @throws VizException + */ private java.util.List getGageData(String table, String column) throws VizException { java.util.List rval = new ArrayList(); @@ -467,6 +502,9 @@ public class GageHistoryDlg extends CaveSWTDialog { return rval; } + /** + * Get gage data for the station location. + */ private void getDialogData() { GageDBData seedData = new GageDBData(); seedData.setLid(lid); @@ -474,12 +512,15 @@ public class GageHistoryDlg extends CaveSWTDialog { try { gageData = HydroDBDataManager.getInstance().getData(seedData); } catch (VizException e) { - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, "Unable to load data. ", e); } updateDisplay(); } + /** + * Update display with gage data. + */ private void updateDisplay() { String format = "%-15s %-15s %-10s %-10s"; dataList.removeAll(); @@ -502,6 +543,9 @@ public class GageHistoryDlg extends CaveSWTDialog { } + /** + * Display currently selected record's information. + */ private void updateInformation() { GageDBData currData = getSelectedRecord(); @@ -544,6 +588,11 @@ public class GageHistoryDlg extends CaveSWTDialog { } } + /** + * Verify and save gage data. + * + * @return true when record saved + */ private boolean saveRecord() { boolean successful = false; @@ -608,18 +657,17 @@ public class GageHistoryDlg extends CaveSWTDialog { // Refresh Cache getDialogData(); } 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.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Error while trying to save the City. ", e); } } return successful; } + /** + * Delete selected record from data base and update display. + */ private void deleteRecord() { GageDBData currData = getSelectedRecord(); @@ -638,12 +686,8 @@ public class GageHistoryDlg extends CaveSWTDialog { // Refresh the cache getDialogData(); } 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.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to delete entry. ", e); } } } else { @@ -654,11 +698,17 @@ public class GageHistoryDlg extends CaveSWTDialog { } } + /** + * Clear information fields and update to new record. + */ private void newRecord() { clearInformation(); updateDialogState(DialogState.NEW_RECORD); } + /** + * Clear all the information list and fields. + */ private void clearInformation() { typeList.select(0); ownerList.select(0); @@ -669,6 +719,11 @@ public class GageHistoryDlg extends CaveSWTDialog { locationTF.setText(""); } + /** + * Get the gage data for the current selection in the data list. + * + * @return currData + */ private GageDBData getSelectedRecord() { GageDBData currData = null; @@ -679,6 +734,11 @@ public class GageHistoryDlg extends CaveSWTDialog { return currData; } + /** + * Update button enable state base on the state. + * + * @param currState + */ private void updateDialogState(DialogState currState) { switch (currState) { case NEW_RECORD: 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 2104d01171..964a7a4612 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 @@ -21,9 +21,14 @@ package com.raytheon.viz.hydrobase.dialogs; import java.util.ArrayList; +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; @@ -40,6 +45,10 @@ import org.eclipse.swt.widgets.Text; import com.raytheon.uf.common.dataquery.db.QueryResult; import com.raytheon.uf.common.dataquery.db.QueryResultRow; +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.data.HydroGenStationData; import com.raytheon.viz.hydrocommon.datamanager.DataTrashCanDataManager; @@ -56,6 +65,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * Sep 4, 2008 lvenable Initial creation * Dec 29, 2008 1802 askripsk Connect to database. + * Apr 19, 2013 1790 rferrel Make dialog non-blocking. * * * @@ -63,6 +73,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * @version 1.0 */ public class HydroGenConfigDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(HydroGenConfigDlg.class); /** * Control font. @@ -105,13 +117,18 @@ public class HydroGenConfigDlg extends CaveSWTDialog { private java.util.List stationData; /** - * Constructor. + * System wait cursor no need to dispose. + */ + Cursor waitCursor; + + /** + * Non-blocking Constructor. * * @param parent * Parent shell. */ public HydroGenConfigDlg(Shell parent) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("HydroGen Configuration"); } @@ -132,6 +149,8 @@ public class HydroGenConfigDlg extends CaveSWTDialog { @Override protected void initializeComponents(Shell shell) { + waitCursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT); + controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL); createSummaryGroup(); @@ -277,7 +296,7 @@ public class HydroGenConfigDlg extends CaveSWTDialog { closeBtn.setLayoutData(gd); closeBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); } @@ -325,7 +344,8 @@ public class HydroGenConfigDlg extends CaveSWTDialog { } } } catch (VizException e) { - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to load static data. ", e); } } @@ -333,14 +353,32 @@ public class HydroGenConfigDlg extends CaveSWTDialog { * Retrieves the hydrogen data from the database. */ private void getDialogData() { - try { - stationData = HydroDBDataManager.getInstance().getData( - HydroGenStationData.class); - } catch (VizException e) { - e.printStackTrace(); - } + shell.setCursor(waitCursor); - updateDialogDisplay(); + Job job = new Job("HydroGen") { + + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + stationData = HydroDBDataManager.getInstance().getData( + HydroGenStationData.class); + } catch (VizException e) { + statusHandler.handle(Priority.PROBLEM, + "Unable to load data. ", e); + } + + VizApp.runAsync(new Runnable() { + + @Override + public void run() { + updateDialogDisplay(); + shell.setCursor(null); + } + }); + return Status.OK_STATUS; + } + }; + job.schedule(); } /** @@ -490,12 +528,8 @@ public class HydroGenConfigDlg extends CaveSWTDialog { // Refresh data getDialogData(); } 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.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to delete the record. ", e); } } } else { @@ -521,13 +555,8 @@ public class HydroGenConfigDlg extends CaveSWTDialog { try { HydroDBDataManager.getInstance().putData(newData); } 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, + "Unable to save the data. ", e); } } } else { @@ -618,8 +647,8 @@ public class HydroGenConfigDlg extends CaveSWTDialog { mb.open(); } } catch (VizException e) { - // don't care, just return false - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to verify constraints. ", e); } return rval; diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/LowWaterDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/LowWaterDlg.java index d77b555d6a..4d21a26e42 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/LowWaterDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/LowWaterDlg.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.jface.dialogs.MessageDialog; @@ -41,6 +40,9 @@ import org.eclipse.swt.widgets.List; 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.data.LowWaterData; import com.raytheon.viz.hydrocommon.datamanager.LowWaterDataManager; @@ -55,6 +57,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * Sep 5, 2008 lvenable Initial creation * Nov 12, 2008 1697 askripsky Connect to DB + * Apr 19, 2013 1790 rferrel Make dialog non-blocking. * * * @@ -62,6 +65,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * @version 1.0 */ public class LowWaterDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(LowWaterDlg.class); /** * Control font. @@ -109,9 +114,9 @@ public class LowWaterDlg extends CaveSWTDialog { private String lid; /** - * Low water Data for the current location + * Low water Data for the current location. */ - private ArrayList lwData; + private java.util.List lwData; /** * Formats date. @@ -128,7 +133,7 @@ public class LowWaterDlg extends CaveSWTDialog { private DialogStates buttonState; /** - * Constructor. + * Non-blocking Constructor. * * @param parent * Parent shell. @@ -136,7 +141,7 @@ public class LowWaterDlg extends CaveSWTDialog { * Dialog title information. */ public LowWaterDlg(Shell parent, String titleInfo, String lid) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("Low Water" + titleInfo); this.lid = lid; @@ -144,6 +149,11 @@ public class LowWaterDlg extends CaveSWTDialog { dateFormat.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. @@ -154,14 +164,26 @@ public class LowWaterDlg 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); + setReturnValue(lid); // Initialize all of the controls and layouts initializeComponents(); @@ -285,7 +307,7 @@ public class LowWaterDlg extends CaveSWTDialog { okBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { saveRecord(); - shell.dispose(); + close(); } }); @@ -307,7 +329,7 @@ public class LowWaterDlg extends CaveSWTDialog { cancelBtn.setLayoutData(gd); cancelBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); @@ -348,7 +370,7 @@ public class LowWaterDlg extends CaveSWTDialog { } /** - * Loads the Stage/Display statement data for a location + * Loads the Stage/Display statement data for a location. */ private void getLowWaterData() { if (lwData != null) { @@ -358,13 +380,16 @@ public class LowWaterDlg extends CaveSWTDialog { try { lwData = LowWaterDataManager.getInstance().getLowWaterData(lid); } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to get low water data. ", e); } updateFloodDamageData(); } + /** + * Update flood damage stages based on selected data. + */ private void updateFloodDamageData() { // Clear current Stages dataList.removeAll(); @@ -383,15 +408,16 @@ public class LowWaterDlg extends CaveSWTDialog { setButtonStates(); } + /** + * Display information on currently selected stage. + */ private void getLowWaterInformation() { updateInformationDisplay(getCurrentlySelectedStage()); } private void updateInformationDisplay(LowWaterData data) { - stageTF - .setText((data.getStage() != LowWaterData.MISSING_VALUE_D) ? Double - .toString(data.getStage()) - : ""); + stageTF.setText((data.getStage() != LowWaterData.MISSING_VALUE_D) ? Double + .toString(data.getStage()) : ""); flowTF.setText((data.getFlow() != LowWaterData.MISSING_VALUE) ? Integer .toString(data.getFlow()) : ""); dateTF.setText(dateFormat.format(data.getDate())); @@ -409,8 +435,8 @@ public class LowWaterDlg extends CaveSWTDialog { LowWaterDataManager.getInstance().deleteRecord( getCurrentlySelectedStage()); } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to delete low water data. ", e); } getLowWaterData(); @@ -453,8 +479,8 @@ public class LowWaterDlg extends CaveSWTDialog { MessageDialog.openConfirm(null, "Invalid Stage value", "Please enter a valid numeric value for Stage"); } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Unable to save low water data. ", e); } catch (ParseException e) { MessageDialog.openConfirm(null, "Invalid Date value", "Please enter a date in the form: MM/DD/YYYY"); 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 48a581cc8f..30d064c828 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 @@ -36,6 +36,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.hydrobase.listeners.ICountyStateListener; import com.raytheon.viz.hydrocommon.data.CountiesData; @@ -57,6 +60,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Sep 5, 2008 lvenable Initial creation * Jan 9, 2008 1802 askripsk Connect to DB. * Apr 17,2013 1790 rferrel Changes for non-blocking CountyStateDlg. + * Make dialog non-blocking. * * * @@ -65,6 +69,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; */ public class NwrTransmitterDlg extends CaveSWTDialog implements ICountyStateListener { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(NwrTransmitterDlg.class); /** * Allow one Count/State dialog. @@ -215,10 +221,15 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements * Parent shell. */ public NwrTransmitterDlg(Shell parent) { - super(parent); + super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); setText("NWR Transmitter"); } + /* + * (non-Javadoc) + * + * @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout() + */ @Override protected Layout constructShellLayout() { // Create the main layout for the shell. @@ -229,11 +240,23 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements 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); @@ -584,7 +607,7 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements closeBtn.setLayoutData(gd); closeBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - shell.dispose(); + close(); } }); } @@ -654,7 +677,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements } } catch (VizException e) { - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Uable to load static data. ", e); } } @@ -667,7 +691,7 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements txData = HydroDBDataManager.getInstance().getData( NWRTransmitterData.class); } catch (VizException e) { - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, "Uable to load data. ", e); } updateDisplay(); @@ -822,12 +846,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements 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 trying to save the City"); - mb.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Uable to save city data. ", e); } } @@ -855,12 +875,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements // Update county cache getSelectedCountiesData(); } 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.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Uable to save county data. ", e); } } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); @@ -904,12 +920,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements // Refresh the cache getDialogData(); } 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.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Uable to delete city data. ", e); } } } @@ -945,12 +957,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements // Refresh the cache getSelectedCountiesData(); } 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.open(); - - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Uable to delete county data. ", e); } } } else { @@ -1033,7 +1041,8 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements updateDialogState(DialogState.NO_COUNTIES_SELECTED); } } catch (VizException e) { - e.printStackTrace(); + statusHandler.handle(Priority.PROBLEM, + "Uable to load county data. ", e); } } } @@ -1146,6 +1155,13 @@ public class NwrTransmitterDlg extends CaveSWTDialog implements } } + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.hydrobase.listeners.ICountyStateListener#notifyUpdate + * (com.raytheon.viz.hydrocommon.data.CountiesData) + */ @Override public void notifyUpdate(CountiesData selectedCountyState) { if (selectedCountyState.getCounty().startsWith("XXXXX")) { diff --git a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/PreferencesDlg.java b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/PreferencesDlg.java index 58453d57d0..9df0f57dc1 100644 --- a/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/PreferencesDlg.java +++ b/cave/com.raytheon.viz.hydrobase/src/com/raytheon/viz/hydrobase/dialogs/PreferencesDlg.java @@ -32,10 +32,13 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Layout; 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.hydrobase.PreferencesData; -import com.raytheon.viz.hydrobase.PreferencesDataManager; import com.raytheon.viz.hydrobase.PreferencesData.SortCriteria; +import com.raytheon.viz.hydrobase.PreferencesDataManager; import com.raytheon.viz.hydrobase.listeners.IPreferencesListener; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; @@ -47,6 +50,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 5, 2008 lvenable Initial creation + * Apr 19, 2013 1790 rferrel Made dialog non-blocking. * * * @@ -54,6 +58,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * @version 1.0 */ public class PreferencesDlg extends CaveSWTDialog { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(PreferencesDlg.class); /** * Handbook V identifier check box. @@ -108,7 +114,7 @@ public class PreferencesDlg extends CaveSWTDialog { /** * Field included array. */ - private ArrayList