Issue #2088 Changes for non-blocking CrestHistoryDlg.
Change-Id: Iebb031464ab25d1212b1748789f79051528d0c3a Former-commit-id:77390e1f78
[formerlyb394c8fa41
] [formerly68bc54c334
[formerly fc0cd12d87493527c6a7ddaddd70b77182a7390f]] Former-commit-id:68bc54c334
Former-commit-id:e73bfc1a54
This commit is contained in:
parent
e51ac6df59
commit
f4bafbf4d3
3 changed files with 222 additions and 178 deletions
|
@ -22,6 +22,9 @@
|
||||||
*/
|
*/
|
||||||
package com.raytheon.viz.hydro.cresthistory;
|
package com.raytheon.viz.hydro.cresthistory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.commands.AbstractHandler;
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
import org.eclipse.core.commands.ExecutionEvent;
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
import org.eclipse.core.commands.ExecutionException;
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
@ -30,6 +33,7 @@ import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
|
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
|
||||||
import com.raytheon.viz.hydrocommon.cresthistory.CrestHistoryDlg;
|
import com.raytheon.viz.hydrocommon.cresthistory.CrestHistoryDlg;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action for unimplemented features. To be used temporarily until final
|
* Action for unimplemented features. To be used temporarily until final
|
||||||
|
@ -43,6 +47,7 @@ import com.raytheon.viz.hydrocommon.cresthistory.CrestHistoryDlg;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* 6/27/06 lvenable Initial Creation.
|
* 6/27/06 lvenable Initial Creation.
|
||||||
* 20Nov2008 1628 dhladky Updated.
|
* 20Nov2008 1628 dhladky Updated.
|
||||||
|
* 11Jul2013 2088 rferrel Changes for non-blocking CrestHistoryDlg.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -50,6 +55,8 @@ import com.raytheon.viz.hydrocommon.cresthistory.CrestHistoryDlg;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CrestHistoryAction extends AbstractHandler {
|
public class CrestHistoryAction extends AbstractHandler {
|
||||||
|
/** Allow single instance of dialog per station. */
|
||||||
|
private final Map<String, CrestHistoryDlg> crestHistoryDlgMap = new HashMap<String, CrestHistoryDlg>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||||
|
@ -60,16 +67,35 @@ public class CrestHistoryAction extends AbstractHandler {
|
||||||
HydroDisplayManager manager = HydroDisplayManager.getInstance();
|
HydroDisplayManager manager = HydroDisplayManager.getInstance();
|
||||||
if (manager.isCurrentLidSelected(shell)) {
|
if (manager.isCurrentLidSelected(shell)) {
|
||||||
String lid = manager.getCurrentLid();
|
String lid = manager.getCurrentLid();
|
||||||
String name = manager.getCurrentData().getName();
|
CrestHistoryDlg crestHistoryDlg = crestHistoryDlgMap.get(lid);
|
||||||
String displayString = " - " + lid;
|
|
||||||
|
|
||||||
if (name != null && !("").equals(name)) {
|
if (crestHistoryDlg == null || crestHistoryDlg.isDisposed()) {
|
||||||
displayString = displayString + " - " + name;
|
String name = manager.getCurrentData().getName();
|
||||||
|
StringBuilder displayString = new StringBuilder(" - ");
|
||||||
|
displayString.append(lid);
|
||||||
|
|
||||||
|
if (name != null && !("").equals(name)) {
|
||||||
|
displayString.append(" - ").append(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
crestHistoryDlg = new CrestHistoryDlg(shell,
|
||||||
|
manager.getCurrentLid(), displayString.toString(),
|
||||||
|
false);
|
||||||
|
crestHistoryDlg.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof String) {
|
||||||
|
String lid = returnValue.toString();
|
||||||
|
crestHistoryDlgMap.remove(lid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
crestHistoryDlg.open();
|
||||||
|
crestHistoryDlgMap.put(lid, crestHistoryDlg);
|
||||||
|
} else {
|
||||||
|
crestHistoryDlg.bringToTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
CrestHistoryDlg crestHistoryDlg = new CrestHistoryDlg(shell,
|
|
||||||
manager.getCurrentLid(), displayString, false);
|
|
||||||
crestHistoryDlg.open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -161,6 +161,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
* Changes for non-blocking FloodReportDlg.
|
* Changes for non-blocking FloodReportDlg.
|
||||||
* Make dialog non-blocking.
|
* Make dialog non-blocking.
|
||||||
* Changes for non-blocking ContactsDlg.
|
* Changes for non-blocking ContactsDlg.
|
||||||
|
* Changes for non-blocking CrestHistoryDlg.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -328,6 +329,11 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
||||||
*/
|
*/
|
||||||
private final Map<String, ContactsDlg> contactsDlgMap = new HashMap<String, ContactsDlg>();
|
private final Map<String, ContactsDlg> contactsDlgMap = new HashMap<String, ContactsDlg>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow on instance per station.
|
||||||
|
*/
|
||||||
|
private final Map<String, CrestHistoryDlg> crestHistDlgMap = new HashMap<String, CrestHistoryDlg>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flood category menu item.
|
* Flood category menu item.
|
||||||
*/
|
*/
|
||||||
|
@ -926,9 +932,7 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
||||||
crestHistoryMI.addSelectionListener(new SelectionAdapter() {
|
crestHistoryMI.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
CrestHistoryDlg crestHistDlg = new CrestHistoryDlg(shell,
|
handleCrestHistoryDlg();
|
||||||
getStationLid(), getStationAndName(), true);
|
|
||||||
crestHistDlg.open();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
riverGageMenuItems.add(crestHistoryMI);
|
riverGageMenuItems.add(crestHistoryMI);
|
||||||
|
@ -1125,6 +1129,32 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
|
||||||
riverGageMenuItems.add(referencesMI);
|
riverGageMenuItems.add(referencesMI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display Crest History dialog for the station.
|
||||||
|
*/
|
||||||
|
private void handleCrestHistoryDlg() {
|
||||||
|
String lid = getStationLid();
|
||||||
|
CrestHistoryDlg crestHistDlg = crestHistDlgMap.get(lid);
|
||||||
|
if (crestHistDlg == null || crestHistDlg.isDisposed()) {
|
||||||
|
crestHistDlg = new CrestHistoryDlg(shell, getStationLid(),
|
||||||
|
getStationAndName(), true);
|
||||||
|
crestHistDlg.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof String) {
|
||||||
|
String lid = returnValue.toString();
|
||||||
|
crestHistDlgMap.remove(lid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
crestHistDlg.open();
|
||||||
|
crestHistDlgMap.put(lid, crestHistDlg);
|
||||||
|
} else {
|
||||||
|
crestHistDlg.bringToTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the Reservoir menu.
|
* Create the Reservoir menu.
|
||||||
*
|
*
|
||||||
|
|
|
@ -70,6 +70,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
* Nov 18, 2010 6981 lbousaidi fixed Ok button and prelim problem
|
* Nov 18, 2010 6981 lbousaidi fixed Ok button and prelim problem
|
||||||
* Mar 29,2012 14463 wkwock Fix max # of char for remark text box to 255
|
* Mar 29,2012 14463 wkwock Fix max # of char for remark text box to 255
|
||||||
* Also see https://bugs.eclipse.org/bugs/show_bug.cgi?id=43004
|
* Also see https://bugs.eclipse.org/bugs/show_bug.cgi?id=43004
|
||||||
|
* Jul 11, 2013 2088 rferrel Make dialog non-blocking.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
|
@ -193,22 +194,35 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
/**
|
/**
|
||||||
* Flag indicating if all, below or above Action Stage is selected.
|
* Flag indicating if all, below or above Action Stage is selected.
|
||||||
*/
|
*/
|
||||||
private int allFlag= 0;
|
private int allFlag = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crest history data.
|
* Crest history data.
|
||||||
*/
|
*/
|
||||||
private CrestHistoryData crestHistoryData;
|
private CrestHistoryData crestHistoryData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The currently selected crest data.
|
||||||
|
*/
|
||||||
private CrestData selectedCrest = null;
|
private CrestData selectedCrest = null;
|
||||||
|
|
||||||
private DecimalFormat df = new DecimalFormat();
|
private DecimalFormat df = new DecimalFormat();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid format for the Date field.
|
||||||
|
*/
|
||||||
private SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
|
private SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid format for the time field.
|
||||||
|
*/
|
||||||
private SimpleDateFormat stf = new SimpleDateFormat("HH:mm");
|
private SimpleDateFormat stf = new SimpleDateFormat("HH:mm");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to indicate when certain fields should be enabled.
|
||||||
|
*/
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* int that's keeps track of DB mode 0 = none 1 = new 2 = delete
|
* int that's keeps track of DB mode 0 = none 1 = new 2 = delete
|
||||||
*/
|
*/
|
||||||
|
@ -217,16 +231,25 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
/**
|
/**
|
||||||
* text from the remark text box
|
* text from the remark text box
|
||||||
*/
|
*/
|
||||||
private String currentRemarkText=null;
|
private String currentRemarkText = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* maximum number of character allowed in the remark text box
|
* maximum number of character allowed in the remark text box
|
||||||
*/
|
*/
|
||||||
private final int MAX_REMARK_CHAR=80;
|
private final int MAX_REMARK_CHAR = 80;
|
||||||
/**
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* The valid time set by the last call to verifiedTime().
|
||||||
|
*/
|
||||||
|
private Date verifiedTime = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The valid date set by the last call to verifiedDate().
|
||||||
|
*/
|
||||||
|
private Date verifiedDate = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* /** Constructor.
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* Parent shell.
|
* Parent shell.
|
||||||
|
@ -237,7 +260,7 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
*/
|
*/
|
||||||
public CrestHistoryDlg(Shell parent, String lid, String title,
|
public CrestHistoryDlg(Shell parent, String lid, String title,
|
||||||
boolean fullControl) {
|
boolean fullControl) {
|
||||||
super(parent);
|
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
|
||||||
setText("Crest History" + title);
|
setText("Crest History" + title);
|
||||||
|
|
||||||
this.fullControl = fullControl;
|
this.fullControl = fullControl;
|
||||||
|
@ -249,8 +272,14 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
df.setGroupingUsed(false);
|
df.setGroupingUsed(false);
|
||||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
stf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
stf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
setReturnValue(lid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Layout constructShellLayout() {
|
protected Layout constructShellLayout() {
|
||||||
// Create the main layout for the shell.
|
// Create the main layout for the shell.
|
||||||
|
@ -260,20 +289,31 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
return mainLayout;
|
return mainLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void disposed() {
|
protected void disposed() {
|
||||||
font.dispose();
|
font.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||||
|
* .eclipse.swt.widgets.Shell)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void initializeComponents(Shell shell) {
|
protected void initializeComponents(Shell shell) {
|
||||||
setReturnValue(false);
|
|
||||||
|
|
||||||
font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
|
||||||
|
|
||||||
// Initialize all of the controls and layouts
|
// Initialize all of the controls and layouts
|
||||||
getCrestData(allFlag);
|
getCrestData(allFlag);
|
||||||
|
|
||||||
createLeftSideControls();
|
createLeftSideControls();
|
||||||
createRightSideControls();
|
createRightSideControls();
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
@ -281,11 +321,11 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
|
|
||||||
if (crestHistoryData != null) {
|
if (crestHistoryData != null) {
|
||||||
sortCrestHistoryList();
|
sortCrestHistoryList();
|
||||||
updateCrestHistoryList();
|
updateCrestHistoryList();
|
||||||
crestHistoryList.setSelection(0);
|
crestHistoryList.setSelection(0);
|
||||||
if ((crestHistoryData != null) &&
|
if ((crestHistoryData != null)
|
||||||
(crestHistoryData.getCrestDataArray().size() >0) ) {
|
&& (crestHistoryData.getCrestDataArray().size() > 0)) {
|
||||||
setSelectedCrest(crestHistoryData.getCrestDataArray().get(0));
|
setSelectedCrest(crestHistoryData.getCrestDataArray().get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,20 +365,21 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
getCrestData(0);
|
getCrestData(0);
|
||||||
} else if (filterCrestsCbo.getSelectionIndex() == 1) {
|
} else if (filterCrestsCbo.getSelectionIndex() == 1) {
|
||||||
crestHistCanvas.drawDataAboveActionStage();
|
crestHistCanvas.drawDataAboveActionStage();
|
||||||
getCrestData(1);
|
getCrestData(1);
|
||||||
} else if (filterCrestsCbo.getSelectionIndex() == 2) {
|
} else if (filterCrestsCbo.getSelectionIndex() == 2) {
|
||||||
crestHistCanvas.drawDataBelowActionStage();
|
crestHistCanvas.drawDataBelowActionStage();
|
||||||
getCrestData(2);
|
getCrestData(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
sortCrestHistoryList();
|
sortCrestHistoryList();
|
||||||
updateCrestHistoryList();
|
updateCrestHistoryList();
|
||||||
crestHistoryList.setSelection(0);
|
crestHistoryList.setSelection(0);
|
||||||
if ((crestHistoryData != null) &&
|
if ((crestHistoryData != null)
|
||||||
(crestHistoryData.getCrestDataArray().size() >0)) {
|
&& (crestHistoryData.getCrestDataArray().size() > 0)) {
|
||||||
setSelectedCrest(crestHistoryData.getCrestDataArray().get(0));
|
setSelectedCrest(crestHistoryData.getCrestDataArray()
|
||||||
|
.get(0));
|
||||||
} else {
|
} else {
|
||||||
clearData();
|
clearData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -411,11 +452,11 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
crestHistoryList.addSelectionListener(new SelectionAdapter() {
|
crestHistoryList.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
double stage = crestHistoryData.getCrestDataArray().get(
|
double stage = crestHistoryData.getCrestDataArray()
|
||||||
crestHistoryList.getSelectionIndex()).getStage();
|
.get(crestHistoryList.getSelectionIndex()).getStage();
|
||||||
|
|
||||||
int year = crestHistoryData.getCrestDataArray().get(
|
int year = crestHistoryData.getCrestDataArray()
|
||||||
crestHistoryList.getSelectionIndex()).getYear();
|
.get(crestHistoryList.getSelectionIndex()).getYear();
|
||||||
|
|
||||||
crestHistCanvas.selectCrestData(stage, year);
|
crestHistCanvas.selectCrestData(stage, year);
|
||||||
// sets the selected crest
|
// sets the selected crest
|
||||||
|
@ -527,19 +568,20 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
remarksTF.setLayoutData(gd);
|
remarksTF.setLayoutData(gd);
|
||||||
remarksTF.setTextLimit(MAX_REMARK_CHAR);
|
remarksTF.setTextLimit(MAX_REMARK_CHAR);
|
||||||
|
|
||||||
/*Note: use this method to control number of character in remarkTF
|
/*
|
||||||
* because a bug in the Text class.
|
* Note: use this method to control number of character in remarkTF
|
||||||
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=43004*/
|
* because a bug in the Text class. See
|
||||||
currentRemarkText=remarksTF.getText();
|
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=43004
|
||||||
|
*/
|
||||||
|
currentRemarkText = remarksTF.getText();
|
||||||
ModifyListener listener = new ModifyListener() {
|
ModifyListener listener = new ModifyListener() {
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
if (remarksTF.getText().length()>MAX_REMARK_CHAR){
|
if (remarksTF.getText().length() > MAX_REMARK_CHAR) {
|
||||||
remarksTF.setText(currentRemarkText);
|
remarksTF.setText(currentRemarkText);
|
||||||
shell.getDisplay().beep();
|
shell.getDisplay().beep();
|
||||||
}
|
} else
|
||||||
else
|
currentRemarkText = remarksTF.getText();
|
||||||
currentRemarkText=remarksTF.getText();
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
remarksTF.addModifyListener(listener);
|
remarksTF.addModifyListener(listener);
|
||||||
|
@ -584,7 +626,7 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
public void widgetSelected(SelectionEvent event) {
|
public void widgetSelected(SelectionEvent event) {
|
||||||
function = 3;
|
function = 3;
|
||||||
apply();
|
apply();
|
||||||
shell.dispose();
|
close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -616,7 +658,7 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
clearData();
|
clearData();
|
||||||
function = 0;
|
function = 0;
|
||||||
selectedCrest = null;
|
selectedCrest = null;
|
||||||
shell.dispose();
|
close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -653,8 +695,6 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
sb.append(e.getCause() + "\n" + e.getMessage());
|
sb.append(e.getCause() + "\n" + e.getMessage());
|
||||||
mb.setMessage(sb.toString());
|
mb.setMessage(sb.toString());
|
||||||
mb.open();
|
mb.open();
|
||||||
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
selectedCrest = null;
|
selectedCrest = null;
|
||||||
}
|
}
|
||||||
|
@ -727,19 +767,15 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getting the crest data with All/Above/Bellow Action
|
* getting the crest data with All/Above/Bellow Action Stage flag
|
||||||
* Stage flag
|
|
||||||
*/
|
*/
|
||||||
private void getCrestData(int allFlag) {
|
private void getCrestData(int allFlag) {
|
||||||
CrestHistoryDataManager crestManager = CrestHistoryDataManager
|
CrestHistoryDataManager crestManager = CrestHistoryDataManager
|
||||||
.getInstance();
|
.getInstance();
|
||||||
crestHistoryData = crestManager.getRiverCrestData(lid, fullControl, allFlag);
|
crestHistoryData = crestManager.getRiverCrestData(lid, fullControl,
|
||||||
|
allFlag);
|
||||||
if (crestHistoryData != null) {
|
|
||||||
setEnabled(true);
|
setEnabled(crestHistoryData != null);
|
||||||
} else {
|
|
||||||
setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -759,7 +795,7 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
private void setSelectedCrest(CrestData selectedCrest) {
|
private void setSelectedCrest(CrestData selectedCrest) {
|
||||||
|
|
||||||
this.selectedCrest = selectedCrest;
|
this.selectedCrest = selectedCrest;
|
||||||
|
|
||||||
if (selectedCrest.getStage() == HydroConstants.MISSING_VALUE) {
|
if (selectedCrest.getStage() == HydroConstants.MISSING_VALUE) {
|
||||||
stageTF.setText(HydroConstants.MISSING_STRING);
|
stageTF.setText(HydroConstants.MISSING_STRING);
|
||||||
} else {
|
} else {
|
||||||
|
@ -848,65 +884,60 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
* fourth or fifth character is a colon, then reject. If 00 > hh >
|
* fourth or fifth character is a colon, then reject. If 00 > hh >
|
||||||
* 23 or 00 > mm > 59, then reject.
|
* 23 or 00 > mm > 59, then reject.
|
||||||
***********************************************************/
|
***********************************************************/
|
||||||
if (!timeTF.getText().equals("") && !verifyTime(timeTF)) {
|
if (!verifyTime(timeTF)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String tmpStage = stageTF.getText();
|
String tmpStage = stageTF.getText().trim().toUpperCase();
|
||||||
String tmpQ = flowTF.getText();
|
String tmpFlow = flowTF.getText().trim().toUpperCase();
|
||||||
|
|
||||||
// Checks to see if at least one or the other string has some value
|
// Checks to see if at least one or the other string has some value
|
||||||
// in it
|
// in it
|
||||||
if (((tmpStage != null) && !isBlank(tmpStage))
|
if ((tmpStage.length() > 0) && (tmpFlow.length() > 0)) {
|
||||||
|| ((tmpQ != null) && !isBlank(tmpQ))) {
|
if (!tmpStage.equals(HydroConstants.MISSING_STRING)) {
|
||||||
if (!isBlank(tmpStage)) {
|
try {
|
||||||
if (!stageTF.getText().equals(HydroConstants.MISSING_STRING)) {
|
cd.setStage(new Double(tmpStage));
|
||||||
cd.setStage(new Double(stageTF.getText()));
|
} catch (NumberFormatException ex) {
|
||||||
|
error("Invalid Stage value.\n", null);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isBlank(tmpQ)) {
|
if (!tmpFlow.equals(HydroConstants.MISSING_STRING)
|
||||||
if (!flowTF.getText().equals(HydroConstants.MISSING_STRING)) {
|
|| tmpFlow.equals("UNDEF")) {
|
||||||
cd.setFlow(new Integer(flowTF.getText()));
|
try {
|
||||||
|
cd.setFlow(new Integer(tmpFlow));
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
error("Invalid flow value.\n", null);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error(
|
error("You must enter either a stage value or a flow value...\n",
|
||||||
"You must enter either a stage value or a flow value...\n",
|
|
||||||
null);
|
null);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// adding a new crestdata point
|
// adding a new crestdata point
|
||||||
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||||
|
|
||||||
// a little fanagling with the dates here...
|
// a little fanagling with the dates here...
|
||||||
if (!timeTF.getText().equals("UNDEF")
|
if (verifiedTime != null) {
|
||||||
&& (!timeTF.getText().equals(""))) {
|
Calendar calDate = Calendar.getInstance(TimeZone
|
||||||
try {
|
.getTimeZone("GMT"));
|
||||||
Calendar calDate = Calendar.getInstance(TimeZone
|
calDate.setTimeInMillis(verifiedDate.getTime());
|
||||||
.getTimeZone("GMT"));
|
Calendar calTime = Calendar.getInstance(TimeZone
|
||||||
Calendar calTime = Calendar.getInstance(TimeZone
|
.getTimeZone("GMT"));
|
||||||
.getTimeZone("GMT"));
|
calTime.setTime(verifiedTime);
|
||||||
Date time = stf.parse(timeTF.getText());
|
|
||||||
calTime.setTime(time);
|
|
||||||
calDate.setTimeInMillis(sdf.parse(dateTF.getText())
|
|
||||||
.getTime());
|
|
||||||
|
|
||||||
cal.set(calDate.get(Calendar.YEAR), calDate
|
cal.set(calDate.get(Calendar.YEAR),
|
||||||
.get(Calendar.MONTH), calDate
|
calDate.get(Calendar.MONTH),
|
||||||
.get(Calendar.DAY_OF_MONTH), calTime
|
calDate.get(Calendar.DAY_OF_MONTH),
|
||||||
.get(Calendar.HOUR_OF_DAY), calTime
|
calTime.get(Calendar.HOUR_OF_DAY),
|
||||||
.get(Calendar.MINUTE));
|
calTime.get(Calendar.MINUTE));
|
||||||
cd.setIsTime(true);
|
cd.setIsTime(true);
|
||||||
} catch (ParseException pe) {
|
|
||||||
pe.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
cal.setTimeInMillis(verifiedDate.getTime());
|
||||||
cal.setTimeInMillis(sdf.parse(dateTF.getText()).getTime());
|
cd.setIsTime(false);
|
||||||
cd.setIsTime(false);
|
|
||||||
} catch (ParseException pe) {
|
|
||||||
pe.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cd.setCrestDate(cal);
|
cd.setCrestDate(cal);
|
||||||
cd.setOldDatum(oldDatumChk.getSelection());
|
cd.setOldDatum(oldDatumChk.getSelection());
|
||||||
|
@ -935,14 +966,12 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
sb.append(e.getCause() + "\n" + e.getMessage());
|
sb.append(e.getCause() + "\n" + e.getMessage());
|
||||||
mb.setMessage(sb.toString());
|
mb.setMessage(sb.toString());
|
||||||
mb.open();
|
mb.open();
|
||||||
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
getCrestData(allFlag);
|
getCrestData(allFlag);
|
||||||
sortCrestHistoryList();
|
sortCrestHistoryList();
|
||||||
crestHistCanvas.updateCrestHistotryData(crestHistoryData);
|
crestHistCanvas.updateCrestHistotryData(crestHistoryData);
|
||||||
updateCrestHistoryList();
|
updateCrestHistoryList();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -966,9 +995,9 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
* well....used.
|
* well....used.
|
||||||
*/
|
*/
|
||||||
private void create() {
|
private void create() {
|
||||||
// clear the crest window
|
// clear the crest window
|
||||||
|
|
||||||
stageTF.setText("");
|
stageTF.setText("");
|
||||||
flowTF.setText("");
|
flowTF.setText("");
|
||||||
timeTF.setText("");
|
timeTF.setText("");
|
||||||
dateTF.setText("");
|
dateTF.setText("");
|
||||||
|
@ -1005,25 +1034,27 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
updateCrestHistoryList();
|
updateCrestHistoryList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#opened()
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#opened()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void opened() {
|
protected void opened() {
|
||||||
if ((crestHistoryData.getCrestDataArray() == null) ||
|
if ((crestHistoryData.getCrestDataArray() == null)
|
||||||
(crestHistoryData.getCrestDataArray().size() == 0)) {
|
|| (crestHistoryData.getCrestDataArray().size() == 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
crestHistoryList.setSelection(0);
|
|
||||||
double stage = crestHistoryData.getCrestDataArray().get(
|
|
||||||
crestHistoryList.getSelectionIndex()).getStage();
|
|
||||||
|
|
||||||
int year = crestHistoryData.getCrestDataArray().get(
|
crestHistoryList.setSelection(0);
|
||||||
crestHistoryList.getSelectionIndex()).getYear();
|
double stage = crestHistoryData.getCrestDataArray()
|
||||||
|
.get(crestHistoryList.getSelectionIndex()).getStage();
|
||||||
|
|
||||||
|
int year = crestHistoryData.getCrestDataArray()
|
||||||
|
.get(crestHistoryList.getSelectionIndex()).getYear();
|
||||||
|
|
||||||
crestHistCanvas.selectCrestData(stage, year);
|
crestHistCanvas.selectCrestData(stage, year);
|
||||||
|
|
||||||
// sets the selected crest
|
// sets the selected crest
|
||||||
setSelectedCrest(crestHistoryData.getCrestDataArray().get(
|
setSelectedCrest(crestHistoryData.getCrestDataArray().get(
|
||||||
crestHistoryList.getSelectionIndex()));
|
crestHistoryList.getSelectionIndex()));
|
||||||
|
@ -1049,66 +1080,37 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
} else {
|
} else {
|
||||||
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
|
||||||
mb.setText("Unable to Save");
|
mb.setText("Unable to Save");
|
||||||
mb
|
mb.setMessage("Data for the location must be added via the River Gauge dialog first.");
|
||||||
.setMessage("Data for the location must be added via the River Gauge dialog first.");
|
|
||||||
mb.open();
|
mb.open();
|
||||||
}
|
}
|
||||||
} catch (VizException e) {
|
} catch (VizException e) {
|
||||||
// don't care, just return false
|
// don't care, just return false
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify validity of input
|
* Verify validity of time input. Set verfiedTime when field parses to valid
|
||||||
*
|
* time string otherwise it is null.
|
||||||
* @param field
|
|
||||||
*/
|
|
||||||
private boolean verifyDouble(Text field) {
|
|
||||||
// verify input parameters in text fields.
|
|
||||||
try {
|
|
||||||
df.parse(field.getText()).doubleValue();
|
|
||||||
} catch (ParseException pe) {
|
|
||||||
// fire a dialog here
|
|
||||||
error("Invalid Stage Format, numbers or decimals required", field);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify validity of input
|
|
||||||
*
|
|
||||||
* @param field
|
|
||||||
*/
|
|
||||||
private boolean verifyInt(Text field) {
|
|
||||||
// verify input parameters in text fields.
|
|
||||||
try {
|
|
||||||
df.parse(field.getText()).intValue();
|
|
||||||
} catch (ParseException pe) {
|
|
||||||
// fire a dialog here
|
|
||||||
error("Invalid Flow Format, whole numbers required", field);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Verify validity of input
|
|
||||||
*
|
*
|
||||||
* @param field
|
* @param field
|
||||||
|
* @return true when file is "MSG", "UNDEF" or parses to valid time.
|
||||||
*/
|
*/
|
||||||
private boolean verifyTime(Text field) {
|
private boolean verifyTime(Text field) {
|
||||||
// verify input parameters in time field.
|
// verify input parameters in time field.
|
||||||
|
verifiedTime = null;
|
||||||
try {
|
try {
|
||||||
if (field.getText().equalsIgnoreCase("MSG")
|
String time = field.getText().trim().toUpperCase();
|
||||||
|| field.getText().equalsIgnoreCase("UNDEF")) {
|
if (time.length() == 0) {
|
||||||
|
time = "UNDEF";
|
||||||
|
}
|
||||||
|
field.setText(time);
|
||||||
|
if (time.equals("MSG") || time.equals("UNDEF")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
stf.parse(field.getText());
|
verifiedTime = stf.parse(time);
|
||||||
} catch (ParseException pe) {
|
} catch (ParseException pe) {
|
||||||
// fire a dialog here
|
// fire a dialog here
|
||||||
error("Invalid Time Format, required: hh:mm", field);
|
error("Invalid Time Format, required: hh:mm", field);
|
||||||
|
@ -1118,14 +1120,16 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify validity of input
|
* Verify validity of date input. Sets verifiedDate when field parses to a
|
||||||
|
* valid date otherwise set to null.
|
||||||
*
|
*
|
||||||
* @param field
|
* @param field
|
||||||
*/
|
*/
|
||||||
private boolean verifyDate(Text field) {
|
private boolean verifyDate(Text field) {
|
||||||
// verify input parameters in date field.
|
// verify input parameters in date field.
|
||||||
|
verifiedDate = null;
|
||||||
try {
|
try {
|
||||||
sdf.parse(field.getText());
|
verifiedDate = sdf.parse(field.getText());
|
||||||
} catch (ParseException pe) {
|
} catch (ParseException pe) {
|
||||||
// fire a dialog here
|
// fire a dialog here
|
||||||
error("Invalid Date Format, required: mm/dd/yyyy", field);
|
error("Invalid Date Format, required: mm/dd/yyyy", field);
|
||||||
|
@ -1177,22 +1181,6 @@ public class CrestHistoryDlg extends CaveSWTDialog implements
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks the string to see if it is blank.
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
* The String to check
|
|
||||||
* @return True if value is blank
|
|
||||||
*/
|
|
||||||
private boolean isBlank(String value) {
|
|
||||||
boolean isBlank = false;
|
|
||||||
if (value.trim().length() == 0) {
|
|
||||||
isBlank = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isBlank;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error message box
|
* Error message box
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue