Issue #1790 Changes for non-blocking RadarLocationsDlg, ReferenceFieldsDlg, ReferencesDlg and ReservoirDlg.
Change-Id: I9852b92ee80e874d76fcfb428bd7437628a94f14 Former-commit-id:3e802aa80e
[formerlycc8eb877c0
[formerly 06c4fc493c8c3f2bd1281f062855091d402251b6]] Former-commit-id:cc8eb877c0
Former-commit-id:8c2cb5858e
This commit is contained in:
parent
b1d9b148ea
commit
6cdea96e29
5 changed files with 315 additions and 131 deletions
|
@ -149,6 +149,10 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
|||
* Changes for non-blocking PreferencesDlg.
|
||||
* Changes for non-blocking PublicationsDlg.
|
||||
* Changes for non-blocking QcAlertAlarmLimitsDlg.
|
||||
* Changes for non-blocking RadarLocationsDlg.
|
||||
* Changes for non-blocking ReferenceFieldsDlg.
|
||||
* Changes for non-blocking ReferencesDlg.
|
||||
* Changes for non-blocking ReservoirDlg.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -261,6 +265,26 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
*/
|
||||
private QcAlertAlarmLimitsDlg qcAlertAlarmDlg;
|
||||
|
||||
/**
|
||||
* Allow one Radar locations dialog.
|
||||
*/
|
||||
private RadarLocationsDlg radarLocDlg;
|
||||
|
||||
/**
|
||||
* Allow one Reference Field dialog.
|
||||
*/
|
||||
private ReferenceFieldsDlg referenceDlg;
|
||||
|
||||
/**
|
||||
* Allow one References dialog per station.
|
||||
*/
|
||||
private final Map<String, ReferencesDlg> referencesDlgMap = new HashMap<String, ReferencesDlg>();
|
||||
|
||||
/**
|
||||
* Allow one Reservoir dialog per station.
|
||||
*/
|
||||
private final Map<String, ReservoirDlg> reservoirDlgMap = new HashMap<String, ReservoirDlg>();
|
||||
|
||||
/**
|
||||
* Flood category menu item.
|
||||
*/
|
||||
|
@ -1000,9 +1024,26 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
referencesMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
ReferencesDlg referencesDlg = new ReferencesDlg(shell,
|
||||
getStationAndName(), getSelectedLocation().getStation());
|
||||
referencesDlg.open();
|
||||
String lid = getSelectedLocation().getStation();
|
||||
ReferencesDlg referencesDlg = referencesDlgMap.get(lid);
|
||||
if (referencesDlg == null) {
|
||||
referencesDlg = new ReferencesDlg(shell,
|
||||
getStationAndName(), lid);
|
||||
referencesDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
String lid = returnValue.toString();
|
||||
referencesDlgMap.remove(lid);
|
||||
}
|
||||
}
|
||||
});
|
||||
referencesDlgMap.put(lid, referencesDlg);
|
||||
referencesDlg.open();
|
||||
} else {
|
||||
referencesDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
});
|
||||
riverGageMenuItems.add(referencesMI);
|
||||
|
@ -1036,9 +1077,24 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
reservoirMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
ReservoirDlg reservoirDlg = new ReservoirDlg(shell,
|
||||
getStationAndName(), getSelectedLocation().getStation());
|
||||
reservoirDlg.open();
|
||||
String lid = getSelectedLocation().getStation();
|
||||
ReservoirDlg reservoirDlg = reservoirDlgMap.get(lid);
|
||||
if (reservoirDlg == null) {
|
||||
reservoirDlg = new ReservoirDlg(shell, getStationAndName(),
|
||||
lid);
|
||||
reservoirDlg.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof String) {
|
||||
String lid = returnValue.toString();
|
||||
reservoirDlgMap.remove(lid);
|
||||
}
|
||||
}
|
||||
});
|
||||
reservoirDlgMap.put(lid, reservoirDlg);
|
||||
reservoirDlg.open();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1229,9 +1285,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
referenceFieldsMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
|
||||
ReferenceFieldsDlg referenceDlg = new ReferenceFieldsDlg(shell);
|
||||
referenceDlg.open();
|
||||
if (referenceDlg == null || referenceDlg.isDisposed()) {
|
||||
referenceDlg = new ReferenceFieldsDlg(shell);
|
||||
referenceDlg.open();
|
||||
} else {
|
||||
referenceDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1281,8 +1340,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
|||
radarLocationsMI.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
RadarLocationsDlg radarLocDlg = new RadarLocationsDlg(shell);
|
||||
radarLocDlg.open();
|
||||
if (radarLocDlg == null || radarLocDlg.isDisposed()) {
|
||||
radarLocDlg = new RadarLocationsDlg(shell);
|
||||
radarLocDlg.open();
|
||||
} else {
|
||||
radarLocDlg.bringToTop();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -35,6 +35,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.RadarLocData;
|
||||
import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager;
|
||||
|
@ -51,6 +54,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 8, 2008 lvenable Initial creation
|
||||
* Dec 30, 2008 1802 askripsk Connect to database.
|
||||
* Apr 26, 2013 1790 rferrel Make dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -58,6 +62,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class RadarLocationsDlg extends CaveSWTDialog {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RadarLocationsDlg.class);
|
||||
|
||||
/**
|
||||
* Control font.
|
||||
|
@ -152,16 +158,21 @@ public class RadarLocationsDlg extends CaveSWTDialog {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Non-blocking Constructor.
|
||||
*
|
||||
* @param parent
|
||||
* Parent shell.
|
||||
*/
|
||||
public RadarLocationsDlg(Shell parent) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Radar Locations");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
// Create the main layout for the shell.
|
||||
|
@ -172,11 +183,23 @@ public class RadarLocationsDlg extends CaveSWTDialog {
|
|||
return mainLayout;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||
*/
|
||||
@Override
|
||||
protected void disposed() {
|
||||
controlFont.dispose();
|
||||
}
|
||||
|
||||
/*
|
||||
* shell.dispos (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||
* .eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setReturnValue(false);
|
||||
|
@ -413,7 +436,7 @@ public class RadarLocationsDlg extends CaveSWTDialog {
|
|||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -441,7 +464,8 @@ public class RadarLocationsDlg extends CaveSWTDialog {
|
|||
radarData = HydroDBDataManager.getInstance().getData(
|
||||
RadarLocData.class);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to get radar location data. ", e);
|
||||
}
|
||||
updateDisplay();
|
||||
}
|
||||
|
@ -586,12 +610,8 @@ public class RadarLocationsDlg extends CaveSWTDialog {
|
|||
|
||||
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 Radar Location");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to save radar location data. ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -625,12 +645,8 @@ public class RadarLocationsDlg 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 City");
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to delete radar location data. ", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -35,6 +35,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.DamTypeData;
|
||||
import com.raytheon.viz.hydrocommon.data.ReservoirOwnerData;
|
||||
|
@ -50,6 +53,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 8, 2008 lvenable Initial creation
|
||||
* Apr 26, 2013 rferrel Make dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,6 +61,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class ReferenceFieldsDlg extends CaveSWTDialog {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ReferenceFieldsDlg.class);
|
||||
|
||||
/**
|
||||
* Control font.
|
||||
|
@ -108,16 +114,21 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
private final int TYPE = 1;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Non-blocking Constructor.
|
||||
*
|
||||
* @param parent
|
||||
* Parent shell.
|
||||
*/
|
||||
public ReferenceFieldsDlg(Shell parent) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Reference Fields");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
// Create the main layout for the shell.
|
||||
|
@ -128,11 +139,23 @@ public class ReferenceFieldsDlg 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);
|
||||
|
@ -255,11 +278,14 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
closeBtn.setLayoutData(gd);
|
||||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dam type and reservoir owner data.
|
||||
*/
|
||||
private void getData() {
|
||||
DamTypeData seedData1 = new DamTypeData();
|
||||
seedData1.setType("Unk");
|
||||
|
@ -270,7 +296,8 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
try {
|
||||
damTypeData = HydroDBDataManager.getInstance().getData(seedData1);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Uable to get dam type data. ", e);
|
||||
}
|
||||
|
||||
// Get the Reservoir Owner Data
|
||||
|
@ -283,10 +310,16 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
try {
|
||||
resOwnerData = HydroDBDataManager.getInstance().getData(seedData2);
|
||||
} catch (VizException e) {
|
||||
// e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Uable to get reservoir owner data. ", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Place data in the desired list.
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
private void populateDataList(int index) {
|
||||
dataList.removeAll();
|
||||
|
||||
|
@ -305,6 +338,9 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new data entry and update the lists.
|
||||
*/
|
||||
private void addEntry() {
|
||||
if (dataList.getSelectionIndex() < 0) {
|
||||
return;
|
||||
|
@ -324,7 +360,8 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
newData.setOwner(dataTF.getText().trim());
|
||||
HydroDBDataManager.getInstance().putData(newData);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Uable to add reservoir owner data. ", e);
|
||||
}
|
||||
} else if (fieldsCbo.getSelectionIndex() == TYPE) {
|
||||
try {
|
||||
|
@ -332,7 +369,8 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
newData.setType(dataTF.getText().trim());
|
||||
HydroDBDataManager.getInstance().putData(newData);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Uable to add dam type data. ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,6 +378,9 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
populateDataList(fieldsCbo.getSelectionIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values for selected item and update display.
|
||||
*/
|
||||
private void updateSelectedItem() {
|
||||
if (dataList.getSelectionIndex() < 0) {
|
||||
return;
|
||||
|
@ -363,7 +404,9 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
newData.setOwner(dataTF.getText().trim());
|
||||
HydroDBDataManager.getInstance().putData(newData);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Uable to update reservoir owner data. ", e);
|
||||
;
|
||||
}
|
||||
} else if (fieldsCbo.getSelectionIndex() == TYPE) {
|
||||
try {
|
||||
|
@ -375,7 +418,8 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
newData.setType(dataTF.getText().trim());
|
||||
HydroDBDataManager.getInstance().putData(newData);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Uable to update dam type data. ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,6 +427,9 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
populateDataList(fieldsCbo.getSelectionIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete selected item and update the display.
|
||||
*/
|
||||
private void deleteSelectedItem() {
|
||||
if (dataList.getSelectionIndex() < 0) {
|
||||
MessageBox mb = new MessageBox(getParent(), SWT.ICON_ERROR | SWT.OK);
|
||||
|
@ -398,7 +445,8 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
.getSelectionIndex());
|
||||
HydroDBDataManager.getInstance().deleteRecord(data);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Uable to delete reservoir owner data. ", e);
|
||||
}
|
||||
} else if (fieldsCbo.getSelectionIndex() == TYPE) {
|
||||
try {
|
||||
|
@ -406,7 +454,8 @@ public class ReferenceFieldsDlg extends CaveSWTDialog {
|
|||
.get(dataList.getSelectionIndex());
|
||||
HydroDBDataManager.getInstance().deleteRecord(data);
|
||||
} catch (VizException e) {
|
||||
e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Uable to delete dam type data. ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,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.ReferencesData;
|
||||
import com.raytheon.viz.hydrocommon.datamanager.HydroDBDataManager;
|
||||
|
@ -50,6 +53,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 12/19/2008 1782 grichard Connected to IHFS DB.
|
||||
* Nov 03 2011 11273 lbousaidi make changes to update an existing entry
|
||||
* without creating new entry
|
||||
* Apr 26, 2013 1790 rferrel Changes for non-blocking dialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,6 +61,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ReferencesDlg.class);
|
||||
|
||||
/**
|
||||
* Control font.
|
||||
|
@ -113,7 +119,7 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
private boolean newInsert = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Non-blocking Constructor.
|
||||
*
|
||||
* @param parent
|
||||
* Parent shell.
|
||||
|
@ -121,14 +127,17 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
* Dialog title information.
|
||||
*/
|
||||
public ReferencesDlg(Shell parent, String titleInfo, String lid) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("References" + titleInfo);
|
||||
|
||||
this.lid = lid;
|
||||
// TODO Remove/comment-out this test code statement:
|
||||
// this.lid = "ABSM8";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
// Create the main layout for the shell.
|
||||
|
@ -139,14 +148,26 @@ public class ReferencesDlg 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);
|
||||
|
@ -228,7 +249,7 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (saveRecord()) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -257,7 +278,7 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -291,8 +312,10 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reference data from the database that matched the location ID.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#getDialogData()
|
||||
*/
|
||||
@Override
|
||||
public void getDialogData() {
|
||||
|
@ -305,14 +328,18 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
try {
|
||||
referenceData = HydroDBDataManager.getInstance().getData(seedData);
|
||||
} catch (VizException e) {
|
||||
// e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to get dialog data. ", e);
|
||||
}
|
||||
|
||||
updateDialogDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the reference list control.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.hydrobase.dialogs.IHydroDialog#updateDialogDisplay()
|
||||
*/
|
||||
@Override
|
||||
public void updateDialogDisplay() {
|
||||
|
@ -340,8 +367,10 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the dialog's state.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#updateDialogState()
|
||||
*/
|
||||
@Override
|
||||
public void updateDialogState() {
|
||||
|
@ -361,8 +390,10 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the reference information control.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#updateInformation()
|
||||
*/
|
||||
@Override
|
||||
public void updateInformation() {
|
||||
|
@ -372,20 +403,22 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
.getReference() : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the currently selected reference data.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @return the reference data
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#getSelectedDatum()
|
||||
*/
|
||||
@Override
|
||||
public ReferencesData getSelectedDatum() {
|
||||
return referenceData.get(referenceList.getSelectionIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the user entry. Checks for an empty entry in the text control.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @return True if there is data in the references text control.
|
||||
* @see
|
||||
* com.raytheon.viz.hydrobase.dialogs.IHydroDialog#validateEntryData(org
|
||||
* .eclipse.swt.widgets.Text)
|
||||
*/
|
||||
@Override
|
||||
public boolean validateEntryData(Text tf) {
|
||||
|
@ -402,8 +435,10 @@ public class ReferencesDlg 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() {
|
||||
|
@ -438,16 +473,16 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
newInsert = false;
|
||||
}
|
||||
} catch (VizException e) {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Unable to Save");
|
||||
mb.setMessage("An error occurred while trying to save.");
|
||||
|
||||
String cause = e.getCause().getMessage();
|
||||
|
||||
int causeStart = cause.indexOf("ERROR:");
|
||||
|
||||
// If the exception contain the SQL exception "ERROR:"
|
||||
if (causeStart > 0) {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||
mb.setText("Unable to Save");
|
||||
mb.setMessage("An error occurred while trying to save.");
|
||||
|
||||
int causeEnd = cause.indexOf("\n", causeStart);
|
||||
|
||||
cause = cause.substring(causeStart, causeEnd);
|
||||
|
@ -456,11 +491,11 @@ public class ReferencesDlg 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 record. ", e);
|
||||
}
|
||||
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -469,8 +504,10 @@ public class ReferencesDlg 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() {
|
||||
|
@ -497,13 +534,8 @@ public class ReferencesDlg 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 record. ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -517,8 +549,10 @@ public class ReferencesDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the text fields in the form.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#clearForm()
|
||||
*/
|
||||
@Override
|
||||
public void clearForm() {
|
||||
|
|
|
@ -42,6 +42,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.DamTypeData;
|
||||
import com.raytheon.viz.hydrocommon.data.ReservoirData;
|
||||
|
@ -63,6 +66,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* 05/05/2009 mpduff Added form validation.
|
||||
* 11/03/2011 11440 lbousaidi removed form validation and only kept one
|
||||
* validation check for date to match AWIPSI.
|
||||
* Apr 25, 2013 1790 rferrel Make dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -70,6 +74,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(ReservoirDlg.class);
|
||||
|
||||
/**
|
||||
* Name text control.
|
||||
|
@ -234,19 +240,24 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
private SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Non-blocking Constructor.
|
||||
*
|
||||
* @param parent
|
||||
* Parent shell.
|
||||
*/
|
||||
public ReservoirDlg(Shell parent, String titleInfo, String lid) {
|
||||
super(parent);
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||
setText("Reservoir" + titleInfo);
|
||||
|
||||
this.lid = lid;
|
||||
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.
|
||||
|
@ -257,9 +268,16 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
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
|
||||
createInformationGroup();
|
||||
|
||||
|
@ -585,7 +603,7 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
public void widgetSelected(SelectionEvent event) {
|
||||
if (validateDateForm()) {
|
||||
if (saveRecord()) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -599,7 +617,7 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -632,7 +650,8 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
try {
|
||||
damTypesData = HydroDBDataManager.getInstance().getData(seedData1);
|
||||
} catch (VizException e) {
|
||||
// e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to get dam type data. ", e);
|
||||
}
|
||||
|
||||
// Get the Reservoir Owner Data
|
||||
|
@ -645,7 +664,8 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
try {
|
||||
resOwnerData = HydroDBDataManager.getInstance().getData(seedData2);
|
||||
} catch (VizException e) {
|
||||
// e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to get reservoir owner data. ", e);
|
||||
}
|
||||
|
||||
// Type combo
|
||||
|
@ -661,8 +681,10 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reservoir data from the database that matched the location ID.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#getDialogData()
|
||||
*/
|
||||
@Override
|
||||
public void getDialogData() {
|
||||
|
@ -677,14 +699,18 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
try {
|
||||
resData = HydroDBDataManager.getInstance().getData(seedData);
|
||||
} catch (VizException e) {
|
||||
// e.printStackTrace();
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to get reservioir data. ", e);
|
||||
}
|
||||
|
||||
updateDialogDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the reservoir data.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.hydrobase.dialogs.IHydroDialog#updateDialogDisplay()
|
||||
*/
|
||||
@Override
|
||||
public void updateDialogDisplay() {
|
||||
|
@ -750,8 +776,10 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
updateDialogState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the dialog's state.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#updateDialogState()
|
||||
*/
|
||||
@Override
|
||||
public void updateDialogState() {
|
||||
|
@ -771,10 +799,20 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#updateInformation()
|
||||
*/
|
||||
@Override
|
||||
public void updateInformation() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#getSelectedDatum()
|
||||
*/
|
||||
@Override
|
||||
public ReservoirData getSelectedDatum() {
|
||||
return resData.get(0);
|
||||
|
@ -842,8 +880,10 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
return isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the record to the database.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#saveRecord()
|
||||
*/
|
||||
@Override
|
||||
public boolean saveRecord() {
|
||||
|
@ -916,9 +956,6 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
// Synchronize StnClass table
|
||||
StnClassSyncUtil.setStnClass(lid);
|
||||
} 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();
|
||||
|
||||
|
@ -926,6 +963,9 @@ public class ReservoirDlg 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);
|
||||
|
@ -934,11 +974,11 @@ public class ReservoirDlg 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 record. ", e);
|
||||
}
|
||||
|
||||
mb.open();
|
||||
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -947,8 +987,10 @@ public class ReservoirDlg 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() {
|
||||
|
@ -979,13 +1021,8 @@ public class ReservoirDlg 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 record. ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -993,25 +1030,10 @@ public class ReservoirDlg extends CaveSWTDialog implements IHydroDialog {
|
|||
getDialogData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for an empty or null string.
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @param value
|
||||
* The String to check
|
||||
* @return True if value is valid string
|
||||
*/
|
||||
private boolean checkString(String value) {
|
||||
boolean isValid = true;
|
||||
|
||||
if ((value == null) || value.trim().equals("")) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the text fields in the form.
|
||||
* @see com.raytheon.viz.hydrobase.dialogs.IHydroDialog#clearForm()
|
||||
*/
|
||||
@Override
|
||||
public void clearForm() {
|
||||
|
|
Loading…
Add table
Reference in a new issue