Issue #1790 Changes for non-blocking dialogs DescriptionDlg, FloodCategoryDlg, FloodDamageDlg, GageHistoryDlg, HydroGenConfigDlg, LowWaterDlg, NwrTransmitterDlg, PreferencesDlg, PublicationsDlg and QcAlertAlarmLimitsDlg.

Change-Id: Ic4a3ccb3e13344244415786591accbffda0d0e96

Former-commit-id: 2dafedfed2 [formerly b9d5321cdeaeb9b37783e96b76321ddb90c0d6dd]
Former-commit-id: 75c1470c3a
This commit is contained in:
Roger Ferrel 2013-04-23 11:42:14 -05:00
parent 42b2e12061
commit 1af1e9e61a
13 changed files with 1079 additions and 578 deletions

View file

@ -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.
*
* </pre>
*
@ -201,6 +211,56 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
*/
private final Map<String, DatumDlg> datumDlgMap = new HashMap<String, DatumDlg>();
/**
* Allow one description dialog per station.
*/
private final Map<String, DescriptionDlg> descDlgMap = new HashMap<String, DescriptionDlg>();
/**
* Allow one flood category dialog per station.
*/
private final Map<String, FloodCategoryDlg> floodCatDlgMap = new HashMap<String, FloodCategoryDlg>();;
/**
* Allow one flood damage dialog per station.
*/
private final Map<String, FloodDamageDlg> floodDamDlgMap = new HashMap<String, FloodDamageDlg>();
/**
* Allow one gage history dialog per station.
*/
private final Map<String, GageHistoryDlg> ghDlgMap = new HashMap<String, GageHistoryDlg>();
/**
* Allow one Hydrogen configuration dialog.
*/
private HydroGenConfigDlg hydroGenDlg;
/**
* Allow one low water dialog per station.
*/
private final Map<String, LowWaterDlg> lowWaterDlgMap = new HashMap<String, LowWaterDlg>();
/**
* 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<String, PublicationsDlg> publicationsDlgMap = new HashMap<String, PublicationsDlg>();
/**
* 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();
}
}
});
}

View file

@ -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();

View file

@ -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.
*
* </pre>
*
@ -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);
}
}

View file

@ -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.
* </pre>
*
* @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);
}
}
}

View file

@ -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.
*
* </pre>
*
@ -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> 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();

View file

@ -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.
*
* </pre>
*
@ -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<String> getGageData(String table, String column)
throws VizException {
java.util.List<String> rval = new ArrayList<String>();
@ -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:

View file

@ -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.
*
* </pre>
*
@ -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<HydroGenStationData> 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;

View file

@ -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.
*
* </pre>
*
@ -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<LowWaterData> lwData;
private java.util.List<LowWaterData> 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");

View file

@ -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.
*
* </pre>
*
@ -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")) {

View file

@ -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.
*
* </pre>
*
@ -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<Button> fieldIncArray;
private java.util.List<Button> fieldIncArray;
/**
* Maximum number of checked check boxes.
@ -118,19 +124,24 @@ public class PreferencesDlg extends CaveSWTDialog {
/**
* Listeners to notify main HB Dialog of settings
*/
private ArrayList<IPreferencesListener> preferencesListeners;
private java.util.List<IPreferencesListener> preferencesListeners;
/**
* Constructor.
* Non-blocking Constructor.
*
* @param parent
* Parent shell.
*/
public PreferencesDlg(Shell parent) {
super(parent);
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Preferences");
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override
protected Layout constructShellLayout() {
// Create the main layout for the shell.
@ -141,6 +152,13 @@ public class PreferencesDlg 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);
@ -273,7 +291,7 @@ public class PreferencesDlg extends CaveSWTDialog {
public void widgetSelected(SelectionEvent event) {
savePreferences();
fireUpdateEvent();
shell.dispose();
close();
}
});
@ -283,7 +301,7 @@ public class PreferencesDlg extends CaveSWTDialog {
cancelBtn.setLayoutData(gd);
cancelBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
shell.dispose();
close();
}
});
}
@ -410,9 +428,9 @@ public class PreferencesDlg extends CaveSWTDialog {
PreferencesDataManager dm = PreferencesDataManager.getInstance();
// Save display columns
dm.setSelectedColumns(stateCountyChk.getSelection(), basinChk
.getSelection(), riverStreamChk.getSelection(), latLonChk
.getSelection());
dm.setSelectedColumns(stateCountyChk.getSelection(),
basinChk.getSelection(), riverStreamChk.getSelection(),
latLonChk.getSelection());
// Save sort preference
if (stationRdo.getSelection())
@ -423,14 +441,14 @@ public class PreferencesDlg extends CaveSWTDialog {
dm.setSortCriteria(SortCriteria.STATE_COUNTY);
// Save dialog preferences
dm.setTitleString(handbookVIdChk.getSelection(), locationNameChk
.getSelection());
dm.setTitleString(handbookVIdChk.getSelection(),
locationNameChk.getSelection());
try {
dm.savePreferences();
} catch (VizException e) {
// TODO Auto-generated catch block
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM,
"Unable to save preferences. ", e);
}
}

View file

@ -43,6 +43,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.PublicationsData;
import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager;
@ -57,6 +60,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* ------------ ---------- ----------- --------------------------
* Sep 5, 2008 lvenable Initial creation.
* 12/18/2008 1782 grichard Connected to IHFS DB.
* Apr 19, 2013 1790 rferrel Made dialog non-blocking.
*
* </pre>
*
@ -64,6 +68,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*/
public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(PublicationsDlg.class);
/**
* Control font.
@ -148,7 +154,7 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
private SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
/**
* Constructor.
* Non-blocking Constructor.
*
* @param parent
* Parent shell.
@ -156,7 +162,7 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
* Dialog title information.
*/
public PublicationsDlg(Shell parent, String titleInfo, String lid) {
super(parent);
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Publications" + titleInfo);
this.lid = lid;
@ -166,6 +172,11 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
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.
@ -176,14 +187,26 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
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
controlFont = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
@ -345,7 +368,7 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
@Override
public void widgetSelected(SelectionEvent event) {
if (saveRecord()) {
shell.dispose();
close();
}
}
});
@ -370,7 +393,7 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
cancelBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
shell.dispose();
close();
}
});
@ -415,8 +438,10 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
return labelStr;
}
/**
* Get the publication data from the database that matched the location ID.
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#getDialogData()
*/
@Override
public void getDialogData() {
@ -429,14 +454,18 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
try {
pubData = HydroDBDataManager.getInstance().getData(seedData);
} catch (VizException e) {
// e.printStackTrace();
statusHandler.handle(Priority.PROBLEM,
"Unable to get publication data. ", e);
}
updateDialogDisplay();
}
/**
* Update the publication list control.
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.hydrobase.dialogs.IHydroDialog#updateDialogDisplay()
*/
@Override
public void updateDialogDisplay() {
@ -465,8 +494,10 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
updateDialogState();
}
/**
* Update the dialog's state.
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#updateDialogState()
*/
@Override
public void updateDialogState() {
@ -486,8 +517,10 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
}
}
/**
* Update the publication information control.
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#updateInformation()
*/
@Override
public void updateInformation() {
@ -501,10 +534,10 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
.setText((currData.getPub() != null) ? currData.getPub() : "");
}
/**
* Obtain the currently selected publication data.
/*
* (non-Javadoc)
*
* @return the publication data
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#getSelectedDatum()
*/
@Override
public PublicationsData getSelectedDatum() {
@ -537,8 +570,12 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
mb.open();
}
/**
* Validate the user inputs in the value text control.
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.hydrobase.dialogs.IHydroDialog#validateEntryData(org
* .eclipse.swt.widgets.Text)
*/
@Override
public boolean validateEntryData(Text tf) {
@ -550,8 +587,10 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
return true;
}
/**
* Save the record to the database.
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#saveRecord()
*/
@Override
public boolean saveRecord() {
@ -592,9 +631,6 @@ public class PublicationsDlg 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();
@ -602,6 +638,9 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
// 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);
@ -610,11 +649,12 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
mb.setMessage("Please enter data for " + lid
+ " in the River Gauge dialog first");
}
mb.open();
} else {
statusHandler.handle(Priority.PROBLEM,
"Unable to save publication data. ", e);
}
mb.open();
e.printStackTrace();
return false;
}
@ -623,8 +663,10 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
return true;
}
/**
* Delete the record from the database.
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#deleteRecord()
*/
@Override
public void deleteRecord() {
@ -651,13 +693,8 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
clearForm();
} 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,
"Unable to delete publication data. ", e);
}
}
@ -665,8 +702,10 @@ public class PublicationsDlg extends CaveSWTDialog implements IHydroDialog {
getDialogData();
}
/**
* Clear the text fields in the form.
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#clearForm()
*/
@Override
public void clearForm() {

View file

@ -23,15 +23,20 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.TimeZone;
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;
@ -46,6 +51,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.DataLimitData;
@ -57,7 +66,6 @@ import com.raytheon.viz.hydrocommon.datamanager.QcAlertAlarmLimitsDataManager;
import com.raytheon.viz.hydrocommon.util.HydroDataUtils;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
* this class displays the QC Alert and Alarm dialog.
*
@ -71,13 +79,17 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* May 5, 2009 2181 mpduff Keep selection upon submit.
* Jun 16,2010 5526 lbousaidi Start/End date not correct
* Oct 27,2011 11305 lbousaidi change some logic to have physical
* elements matches the selection of default limits *
* elements matches the selection of default limits
* Apr 19, 2013 1790 rferrel Make dialog non-blocking.
*
* </pre>
*
* @author lvenable
* @version 1.0
*/
public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(QcAlertAlarmLimitsDlg.class);
/**
* Control font.
@ -223,13 +235,12 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
* Date validator.
*/
private SimpleDateFormat dateFormat1, dateFormat2;
/**
* Selection index.
*/
private int selection = -9999;
/**
* States for the dialog.
*/
@ -238,25 +249,33 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
};
/**
* Constructor.
* System wait cursor no need to dispose.
*/
private Cursor waitCursor;
/**
* Non-blocking Constructor.
*
* @param parent
* Parent shell.
*/
public QcAlertAlarmLimitsDlg(Shell parent) {
super(parent);
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Quality Control and Alert/Alarm Limits");
dateFormat1 = new SimpleDateFormat("MM/dd");
dateFormat1.setTimeZone(TimeZone.getTimeZone("GMT"));
dateFormat2 = new SimpleDateFormat("MM-dd");
dateFormat2.setTimeZone(TimeZone.getTimeZone("GMT"));
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override
protected Layout constructShellLayout() {
// Create the main layout for the shell.
@ -267,14 +286,29 @@ public class QcAlertAlarmLimitsDlg 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);
@ -384,9 +418,9 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
physElemChk.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
loadData();
loadData();
}
});
gd = new GridData(300, 125);
@ -403,7 +437,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
loadData();
}
}
});
gd = new GridData();
@ -456,7 +490,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
// -----------------------------------------------------
// Create the location, duration, and date controls
// -----------------------------------------------------
gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
gd = new GridData(SWT.FILL, SWT.TOP, true, true);
Composite leftComp = new Composite(limitSelectedGroup, SWT.NONE);
leftComp.setLayout(new GridLayout(2, false));
leftComp.setLayoutData(gd);
@ -479,7 +513,8 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
durationLbl.setLayoutData(gd);
durationCbo = new Combo(leftComp, SWT.DROP_DOWN | SWT.READ_ONLY);
durationCbo.select(0);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
durationCbo.setLayoutData(gd);
// Start Date
gd = new GridData(SWT.FILL, SWT.CENTER, false, true);
@ -681,7 +716,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
@Override
public void widgetSelected(SelectionEvent event) {
if (saveRecord()) {
shell.dispose();
close();
}
}
});
@ -706,7 +741,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
cancelBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
shell.dispose();
close();
}
});
@ -743,7 +778,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
private String getNotesText() {
StringBuilder str = new StringBuilder();
str.append("Notes:\n");
str.append("Notes:\n");
str.append("1) Individual check is not performed if the limit value is not defined.\n");
str.append("2) If the limits defined for location, default limits not considered\n");
str.append(" even if location limits are undefined.");
@ -781,28 +816,71 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
return text;
}
/**
* Get data to populate GUI.
*/
private void initializeData() {
// Populate PhysElem
try {
for (String currPE : DataTrashCanDataManager.getInstance()
.getPEList()) {
physElemList.add(currPE);
physElemSelItemList.add(currPE);
}
for (String currDur : QcAlertAlarmLimitsDataManager.getInstance()
.getShefDur()) {
durationCbo.add(currDur);
}
setBusy(true);
updateDialogState(DialogStates.DEFAULT_LIMITS);
loadData();
} catch (VizException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Job job = new Job("QcAlertAlarmLimits") {
@Override
protected IStatus run(IProgressMonitor monitor) {
// Populate PhysElem
try {
final java.util.List<String> peList = DataTrashCanDataManager
.getInstance().getPEList();
VizApp.runAsync(new Runnable() {
@Override
public void run() {
for (String currPE : peList) {
physElemList.add(currPE);
physElemSelItemList.add(currPE);
}
}
});
final java.util.List<String> durList = QcAlertAlarmLimitsDataManager
.getInstance().getShefDur();
VizApp.runAsync(new Runnable() {
@Override
public void run() {
durationCbo.setItems(durList.toArray(new String[0]));
updateDialogState(DialogStates.DEFAULT_LIMITS);
loadData();
}
});
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to load data. ", e);
} finally {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
setBusy(false);
}
});
}
return Status.OK_STATUS;
}
};
job.schedule();
}
private void setBusy(boolean busy) {
Cursor cursor = null;
if (busy) {
cursor = waitCursor;
}
shell.setCursor(cursor);
}
private void loadData() {
@ -811,38 +889,40 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
private void loadData(boolean forceLoad) {
limitsList.removeAll();
String dayStartChange, dayEndChange;
try {
if (currentlyDisplayingDefaultLimits()) {
QcAlertAlarmLimitsDataManager man = QcAlertAlarmLimitsDataManager
.getInstance();
for (DataLimitData currData : man.getDefaultLimits(physElemChk
.getSelection(), getSelectedPEs(), forceLoad)) {
//Start/End dates format will be changed to MM/DD only for display
for (DataLimitData currData : man
.getDefaultLimits(physElemChk.getSelection(),
getSelectedPEs(), forceLoad)) {
// Start/End dates format will be changed to MM/DD only for
// display
dayStartChange = changeFormat(currData.getMonthDayStart(),
dateFormat2, dateFormat1);
dayEndChange = changeFormat(currData.getMonthDayEnd(),
dateFormat2, dateFormat1);
currData.setMonthDayStart(dayStartChange);
dateFormat2, dateFormat1);
dayEndChange = changeFormat(currData.getMonthDayEnd(),
dateFormat2, dateFormat1);
currData.setMonthDayStart(dayStartChange);
currData.setMonthDayEnd(dayEndChange);
limitsList.add(man.getDefaultLimitString(currData));
limitsList.add(man.getDefaultLimitString(currData));
dayStartChange = changeFormat(currData.getMonthDayStart(),
dateFormat1, dateFormat2);
dayEndChange = changeFormat(currData.getMonthDayEnd(),
dateFormat1, dateFormat2);
currData.setMonthDayStart(dayStartChange);
currData.setMonthDayEnd(dayEndChange);
dateFormat1, dateFormat2);
dayEndChange = changeFormat(currData.getMonthDayEnd(),
dateFormat1, dateFormat2);
currData.setMonthDayStart(dayStartChange);
currData.setMonthDayEnd(dayEndChange);
updateDefaultInformationDisplay(currData);
}
if (!physElemChk.getSelection() ){
limitsList.setSelection(0);
if (!physElemChk.getSelection()) {
limitsList.setSelection(0);
getSelectedLimit();
}
} else {
@ -850,40 +930,38 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
.getInstance();
for (LocationDataLimitData currData : man
.getLocationLimits(locationChk.getSelection(),
locationLimitTF.getText(), physElemChk
.getSelection(), getSelectedPEs(),
locationLimitTF.getText(),
physElemChk.getSelection(), getSelectedPEs(),
forceLoad)) {
dayStartChange = changeFormat(currData.getMonthDayStart(),
dateFormat2, dateFormat1);
dayEndChange = changeFormat(currData.getMonthDayEnd(),
dateFormat2, dateFormat1);
currData.setMonthDayStart(dayStartChange);
currData.setMonthDayEnd(dayEndChange);
limitsList.add(man.getLocationLimitString(currData));
dayStartChange = changeFormat(currData.getMonthDayStart(),
dateFormat1, dateFormat2);
dayEndChange = changeFormat(currData.getMonthDayEnd(),
dateFormat1, dateFormat2);
currData.setMonthDayStart(dayStartChange);
currData.setMonthDayEnd(dayEndChange);
limitsList.setSelection(0);
updateLocationInformationDisplay(currData);
dateFormat2, dateFormat1);
dayEndChange = changeFormat(currData.getMonthDayEnd(),
dateFormat2, dateFormat1);
currData.setMonthDayStart(dayStartChange);
currData.setMonthDayEnd(dayEndChange);
limitsList.add(man.getLocationLimitString(currData));
dayStartChange = changeFormat(currData.getMonthDayStart(),
dateFormat1, dateFormat2);
dayEndChange = changeFormat(currData.getMonthDayEnd(),
dateFormat1, dateFormat2);
currData.setMonthDayStart(dayStartChange);
currData.setMonthDayEnd(dayEndChange);
}
limitsList.setSelection(0);
getSelectedLimit();
}
} catch (VizException e) {
// TODO Auto-generated catch block
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM, "Unable to load data. ", e);
}
if (limitsList.getItemCount() > 0) {
updateDialogState(DialogStates.NORMAL_MODE);
} else {
updateDialogState(DialogStates.NO_ENTRIES);
}
}
}
/**
@ -941,7 +1019,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
durationCbo.select(0);
limitSelectedGroup.setEnabled(true);
physElemSelItemList.setEnabled(true);
physElemSelItemList.setEnabled(true);
deleteBtn.setEnabled(false);
break;
case NORMAL_MODE:
@ -982,7 +1060,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
LocationDataLimitData currData = QcAlertAlarmLimitsDataManager
.getInstance().getSelectedLocationData(
limitsList.getSelectionIndex());
updateLocationInformationDisplay(currData);
}
@ -994,7 +1072,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
}
private void updateDefaultInformationDisplay(DataLimitData currData) {
String dateSringStart, dateStringEnd;
String dateSringStart, dateStringEnd;
clearInformation();
// No Lid for default limits
@ -1009,17 +1087,18 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
}
}
/** Get the Start/End dates and change the format from "MM-DD" to "MM/DD"
/**
* Get the Start/End dates and change the format from "MM-DD" to "MM/DD"
*
* only for the display.*/
* only for the display.
*/
try {
if (currData.getMonthDayStart()!=null) {
dateSringStart= changeFormat(currData.getMonthDayStart(),
dateFormat2, dateFormat1);
startDateTF.setText(dateSringStart);}
if (currData.getMonthDayStart() != null) {
dateSringStart = changeFormat(currData.getMonthDayStart(),
dateFormat2, dateFormat1);
startDateTF.setText(dateSringStart);
}
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
@ -1027,22 +1106,23 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
mb.open();
}
}
try {
if (currData.getMonthDayEnd()!=null) {
dateStringEnd= changeFormat(currData.getMonthDayEnd(),
dateFormat2, dateFormat1);
endDateTF.setText(dateStringEnd);}
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
mb.setMessage("Please enter a valid Start date");
if (currData.getMonthDayEnd() != null) {
dateStringEnd = changeFormat(currData.getMonthDayEnd(),
dateFormat2, dateFormat1);
endDateTF.setText(dateStringEnd);
}
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
mb.setMessage("Please enter a valid Start date");
mb.open();
}
mb.open();
}
// Get the PE
String currPE = currData.getPe();
for (int i = 0; i < physElemSelItemList.getItemCount(); i++) {
@ -1050,12 +1130,11 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
physElemSelItemList.setSelection(i);
break;
}
}
QcAlertAlarmLimitsDataManager man = QcAlertAlarmLimitsDataManager
.getInstance();
}
// QcAlertAlarmLimitsDataManager man = QcAlertAlarmLimitsDataManager
// .getInstance();
grossRangeMinTF.setText(HydroDataUtils.getDisplayString(currData
.getGrossRangeMin()));
grossRangeMaxTF.setText(HydroDataUtils.getDisplayString(currData
@ -1093,7 +1172,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
* @param currData
*/
private void updateLocationInformationDisplay(LocationDataLimitData currData) {
String dateSringStart, dateStringEnd;
String dateSringStart, dateStringEnd;
clearInformation();
locationSelItemTF.setText(currData.getLid());
@ -1106,17 +1185,18 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
break;
}
}
/** Get the Start/End dates and change the format from "MM-DD" to "MM/DD"
*
* only for the display.*/
/**
* Get the Start/End dates and change the format from "MM-DD" to "MM/DD"
*
* only for the display.
*/
try {
dateSringStart = changeFormat(currData.getMonthDayStart(),
dateFormat2, dateFormat1);
startDateTF.setText(dateSringStart);
dateSringStart = changeFormat(currData.getMonthDayStart(),
dateFormat2, dateFormat1);
startDateTF.setText(dateSringStart);
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
@ -1124,21 +1204,21 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
mb.open();
}
try {
dateStringEnd = changeFormat(currData.getMonthDayEnd(), dateFormat2, dateFormat1);
endDateTF.setText(dateStringEnd);
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
mb.setMessage("Please enter a valid Start date");
}
try {
dateStringEnd = changeFormat(currData.getMonthDayEnd(),
dateFormat2, dateFormat1);
endDateTF.setText(dateStringEnd);
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
mb.setMessage("Please enter a valid Start date");
mb.open();
}
mb.open();
}
// Get the PE
String currPE = currData.getPe();
for (int i = 0; i < physElemSelItemList.getItemCount(); i++) {
@ -1148,8 +1228,8 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
}
}
QcAlertAlarmLimitsDataManager man = QcAlertAlarmLimitsDataManager
.getInstance();
// QcAlertAlarmLimitsDataManager man = QcAlertAlarmLimitsDataManager
// .getInstance();
grossRangeMinTF.setText(HydroDataUtils.getDisplayString(currData
.getGrossRangeMin()));
grossRangeMaxTF.setText(HydroDataUtils.getDisplayString(currData
@ -1205,29 +1285,30 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
alarmDiffTF.setText("");
}
// change date format display
// change date format display
private String changeFormat(String initDateFormat, SimpleDateFormat dateF1, SimpleDateFormat dateF2) {
String finalDateFormat=null;
Date dd1=null;
if ((initDateFormat!= null) && !(initDateFormat.equals("")) ) {
try {
dateF1.setLenient(false);
dateF2.setLenient(false);
dd1=dateF1.parse(initDateFormat);
} catch (ParseException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
finalDateFormat=dateF2.format(dd1);
private String changeFormat(String initDateFormat, SimpleDateFormat dateF1,
SimpleDateFormat dateF2) {
String finalDateFormat = null;
Date dd1 = null;
if ((initDateFormat != null) && !(initDateFormat.equals(""))) {
try {
dateF1.setLenient(false);
dateF2.setLenient(false);
dd1 = dateF1.parse(initDateFormat);
} catch (ParseException e) {
statusHandler.handle(Priority.PROBLEM, "Error parsing data. ",
e);
}
return finalDateFormat;
finalDateFormat = dateF2.format(dd1);
}
return finalDateFormat;
}
private boolean saveRecord() {
@ -1242,8 +1323,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Location Does Not Exist");
mb
.setMessage("Please use Add Location from the Location Menu to add the location first.");
mb.setMessage("Please use Add Location from the Location Menu to add the location first.");
mb.open();
success = false;
@ -1255,7 +1335,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
selection = limitsList.getSelectionIndex();
loadData(true);
limitsList.setSelection(selection);
getSelectedLimit();
getSelectedLimit();
}
return success;
@ -1271,7 +1351,8 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
try {
rval = HydroDBDataManager.getInstance().checkData(locData) > 0;
} catch (VizException e) {
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM, "Error in data check. ",
e);
}
}
@ -1290,12 +1371,8 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
rval = 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");
mb.open();
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM, "Unable to save data. ",
e);
}
}
@ -1315,12 +1392,8 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
rval = 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");
mb.open();
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM, "Unable to save data. ",
e);
}
}
@ -1361,7 +1434,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
private String getSelectedInformationPE() {
String rval = "";
String selectedPE = physElemSelItemList.getSelection()[0];
rval = selectedPE.split(" ")[0];
@ -1370,16 +1443,16 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
}
private boolean setSaveValues(DataLimitData dataToSave) {
Date startDate=null;
Date endDate=null;
// Make sure that PE is selected
try {
dataToSave.setPe(getSelectedInformationPE());
} catch (Exception e) {
// Date startDate = null;
// Date endDate = null;
// Make sure that PE is selected
try {
dataToSave.setPe(getSelectedInformationPE());
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Physical Element");
mb.setMessage("You must select a Physical Element.");
@ -1389,14 +1462,13 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
return false;
}
dataToSave.setDur(getSelectedDuration());
// Validate date format
// Validate date format
String displayStartDate, displayEndDate;
if (startDateTF.getText().equals("")) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
mb.setMessage("Please enter a valid Start date");
@ -1404,17 +1476,15 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
return false;
}
try {
if (!startDateTF.getText().equals("")) {
if (!startDateTF.getText().equals("")) {
displayStartDate=changeFormat(startDateTF.getText(),
dateFormat1,dateFormat2 );
dataToSave.setMonthDayStart(displayStartDate);
}
}
catch (Exception e) {
displayStartDate = changeFormat(startDateTF.getText(),
dateFormat1, dateFormat2);
dataToSave.setMonthDayStart(displayStartDate);
}
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
mb.setMessage("Please enter a valid Start date");
@ -1424,23 +1494,7 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
return false;
}
if (endDateTF.getText().equals("")) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
mb.setMessage("Please enter a valid End date");
mb.open();
return false;
}
try {
if (!endDateTF.getText().equals("")) {
displayEndDate=changeFormat(endDateTF.getText(),
dateFormat1,dateFormat2 );
dataToSave.setMonthDayEnd(displayEndDate);
}
} catch (Exception e) {
if (endDateTF.getText().equals("")) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
mb.setMessage("Please enter a valid End date");
@ -1449,21 +1503,24 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
return false;
}
if ((startDate != null) && (endDate != null)
&& startDate.after(endDate)) {
try {
if (!endDateTF.getText().equals("")) {
displayEndDate = changeFormat(endDateTF.getText(), dateFormat1,
dateFormat2);
dataToSave.setMonthDayEnd(displayEndDate);
}
} catch (Exception e) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Date");
mb.setMessage("The end date must be >= the start date, up to\n"
+ "a maximum end date of 12/31. Please make the\n"
+ "required changes and re-Apply them.");
mb.setMessage("Please enter a valid End date");
mb.open();
return false;
}
Double temp;
Double temp = null;
temp = getDoubleFromTF(grossRangeMinTF, "Gross Range Min");
if (temp == null) {
@ -1578,6 +1635,9 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
return Integer.valueOf(temp);
}
/**
* Confirm and delete entry.
*/
private void deleteRecord() {
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK
| SWT.CANCEL);
@ -1596,14 +1656,8 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
// Delete via the Hydro Data Manager
HydroDBDataManager.getInstance().deleteRecord(currData);
} catch (VizException e) {
MessageBox mbDel = new MessageBox(shell, SWT.ICON_QUESTION
| SWT.OK | SWT.CANCEL);
mbDel.setText("Delete Error");
mbDel
.setMessage("An error occurred while trying to delete the entry");
mbDel.open();
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM,
"Unable to delete data. ", e);
}
} else {
LocationDataLimitData currData = QcAlertAlarmLimitsDataManager
@ -1614,14 +1668,8 @@ public class QcAlertAlarmLimitsDlg extends CaveSWTDialog {
// Delete via the Hydro Data Manager
HydroDBDataManager.getInstance().deleteRecord(currData);
} catch (VizException e) {
MessageBox mbDel = new MessageBox(shell, SWT.ICON_QUESTION
| SWT.OK | SWT.CANCEL);
mbDel.setText("Delete Error");
mbDel
.setMessage("An error occurred while trying to delete the entry");
mbDel.open();
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM,
"Unable to delete entry. ", e);
}
}

View file

@ -22,6 +22,7 @@ package com.raytheon.viz.hydrocommon.datamanager;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import com.raytheon.uf.common.dataquery.db.QueryResult;
@ -38,6 +39,8 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 10, 2008 1661 askripsky Initial Creation
* Apr 19, 2013 1790 rferrel Cleanup method interfaces;
* part of non-blocking dialogs.
*
* </pre>
*
@ -86,7 +89,7 @@ public class LowWaterDataManager extends HydroDataManager {
* @param recordsToDelete
* @throws VizException
*/
public void deleteRecords(ArrayList<LowWaterData> recordsToDelete)
public void deleteRecords(List<LowWaterData> recordsToDelete)
throws VizException {
for (LowWaterData currData : recordsToDelete) {
deleteRecord(currData);
@ -100,8 +103,8 @@ public class LowWaterDataManager extends HydroDataManager {
* @throws VizException
*/
public void deleteRecord(LowWaterData recordToDelete) throws VizException {
runStatement(String.format(DELETE_STATEMENT, HydroDataUtils
.getPKStatement(recordToDelete)));
runStatement(String.format(DELETE_STATEMENT,
HydroDataUtils.getPKStatement(recordToDelete)));
}
/**
@ -117,8 +120,9 @@ public class LowWaterDataManager extends HydroDataManager {
QueryResult result = runMappedQuery(SELECT_STATEMENT + " WHERE "
+ HydroDataUtils.getPKStatement(data));
return (result.getResultCount() > 0) ? new LowWaterData(result
.getRows()[0], result.getColumnNames()) : new LowWaterData();
return (result.getResultCount() > 0) ? new LowWaterData(
result.getRows()[0], result.getColumnNames())
: new LowWaterData();
}
/**
@ -129,9 +133,8 @@ public class LowWaterDataManager extends HydroDataManager {
* @throws VizException
* @throws VizException
*/
public ArrayList<LowWaterData> getLowWaterData(String lid)
throws VizException {
ArrayList<LowWaterData> rval = new ArrayList<LowWaterData>();
public List<LowWaterData> getLowWaterData(String lid) throws VizException {
List<LowWaterData> rval = new ArrayList<LowWaterData>();
QueryResult result = runMappedQuery(SELECT_STATEMENT + " WHERE lid='"
+ lid + "' ORDER BY stage DESC, lwdat DESC");
@ -158,7 +161,8 @@ public class LowWaterDataManager extends HydroDataManager {
}
private void updateLowWaterData(LowWaterData data) throws VizException {
runStatement(String.format(UPDATE_STATEMENT,
runStatement(String.format(
UPDATE_STATEMENT,
(data.getFlow() == LowWaterData.MISSING_VALUE) ? "null" : data
.getFlow(), data.getRemark(),
(data.getStage() == LowWaterData.MISSING_VALUE_D) ? "null"