Merge "Issue #2088 Made FcstPointGroupDlg, FloodReportDlg, HydroBaseDlg and StationFilterOptionsDlg non-blocking." into development

Former-commit-id: ab16e2c8a1 [formerly c2d9a2d394fc2ab0f60c63d11323af8db90655da]
Former-commit-id: 2933cc2ca8
This commit is contained in:
Lee Venable 2013-07-08 17:06:42 -05:00 committed by Gerrit Code Review
commit b36c421c9a
6 changed files with 412 additions and 179 deletions

View file

@ -35,6 +35,9 @@ import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.MessageBox;
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.listeners.IForecastGroupAssignmentListener;
import com.raytheon.viz.hydrocommon.data.RPFFcstGroupData;
@ -51,6 +54,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* ------------ ---------- ----------- --------------------------
* Sep 4, 2008 lvenable Initial creation
* Jan 7, 2008 1802 askripsk Connect to DB
* Jun 27,2013 2088 rferrel Make dialog non-blocking.
*
* </pre>
*
@ -58,6 +62,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*/
public class FcstPointGroupDlg extends CaveSWTDialog {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(FcstPointGroupDlg.class);
/**
* Control font.
@ -91,12 +97,17 @@ public class FcstPointGroupDlg extends CaveSWTDialog {
* Parent shell.
*/
public FcstPointGroupDlg(Shell parent, String previousGroup) {
super(parent);
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Fcst Point Group Assignment");
this.previousGroup = previousGroup;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override
protected Layout constructShellLayout() {
// Create the main layout for the shell.
@ -107,11 +118,23 @@ public class FcstPointGroupDlg 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);
@ -171,7 +194,7 @@ public class FcstPointGroupDlg extends CaveSWTDialog {
okBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
fireUpdateEvent();
shell.dispose();
close();
}
});
@ -184,7 +207,7 @@ public class FcstPointGroupDlg extends CaveSWTDialog {
public void widgetSelected(SelectionEvent event) {
groupList.deselectAll();
fireUpdateEvent();
shell.dispose();
close();
}
});
@ -195,7 +218,7 @@ public class FcstPointGroupDlg extends CaveSWTDialog {
cancelBtn.setLayoutData(gd);
cancelBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
shell.dispose();
close();
}
});
}
@ -210,7 +233,8 @@ public class FcstPointGroupDlg extends CaveSWTDialog {
fcstGroups = HydroDBDataManager.getInstance().getData(seedData);
} catch (VizException e) {
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM,
"Unable to load RPF Forecast Group Data: ", e);
}
updateDisplay();

View file

@ -33,6 +33,10 @@ import java.util.Set;
import java.util.TimeZone;
import java.util.TreeMap;
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;
@ -57,7 +61,11 @@ import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.hydro.service.WhfsServiceRequest;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse;
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.common.time.SimulatedTime;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.hydrocommon.HydroConstants;
@ -78,6 +86,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* "Compute Latest data" button runs
* May 14, 2012 14965 wkwock fix crash in query for data
* Jun 18, 2012 14377 wkwock Correct insert data into crest table.
* Jun 27, 2013 2088 rferrel Made dialog non-blocking.
*
* </pre>
*
@ -85,7 +94,10 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*/
public class FloodReportDlg extends CaveSWTDialog {
private static final String format = "%-15S %-10S %6.2f %16S %4.1f";
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(FloodReportDlg.class);
private final String format = "%-15S %-10S %6.2f %16S %4.1f";
/**
* Control font.
@ -171,12 +183,6 @@ public class FloodReportDlg extends CaveSWTDialog {
*/
private Date endDate;
/** The standard arrow cursor */
protected Cursor arrowCursor;
/** The Hand cursor */
protected Cursor waitCursor;
/**
* Flood canvas.
*/
@ -209,7 +215,7 @@ public class FloodReportDlg extends CaveSWTDialog {
* Parent shell.
*/
public FloodReportDlg(Shell parent) {
super(parent);
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Flood Report");
dbFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -224,6 +230,11 @@ public class FloodReportDlg extends CaveSWTDialog {
fr.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.
@ -234,18 +245,27 @@ public class FloodReportDlg 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);
arrowCursor = new Cursor(getDisplay(), SWT.CURSOR_ARROW);
waitCursor = new Cursor(getDisplay(), SWT.CURSOR_WAIT);
// Initialize all of the controls and layouts
initializeComponents();
@ -366,15 +386,14 @@ public class FloodReportDlg extends CaveSWTDialog {
gd = new GridData(550, 250);
gd.horizontalSpan = 2;
locationList = new List(leftComp, SWT.BORDER | SWT.MULTI
| SWT.V_SCROLL);
locationList = new List(leftComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
locationList.setLayoutData(gd);
locationList.setFont(controlFont);
locationList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
if (locationList.getSelectionIndices().length==1)
handleSelection();
if (locationList.getSelectionIndices().length == 1)
handleSelection();
}
});
@ -417,17 +436,21 @@ public class FloodReportDlg extends CaveSWTDialog {
int answer = messageBox.open();
if (answer == SWT.OK) {
int selectedIndexes[]=locationList.getSelectionIndices();
String selectedLids[]= new String[selectedIndexes.length];
int i=0;
for (int index:selectedIndexes){ //get the lids to be deleted
selectedLids[i++] = locationLidList.get(index);
}
for (String lid: selectedLids){ //delete the records
selectedLid=lid;
deleteRecord();
}
}
int selectedIndexes[] = locationList
.getSelectionIndices();
String selectedLids[] = new String[selectedIndexes.length];
int i = 0;
// get the lids to be deleted
for (int index : selectedIndexes) {
selectedLids[i++] = locationLidList.get(index);
}
// delete the records
for (String lid : selectedLids) {
selectedLid = lid;
deleteRecord();
}
}
}
}
});
@ -524,7 +547,17 @@ public class FloodReportDlg extends CaveSWTDialog {
int answer = messageBox.open();
if (answer == SWT.OK) {
insertRecord();
final String[] selectedEvent = eventList.getSelection();
Job job = new Job("Insert Crest table") {
@Override
protected IStatus run(IProgressMonitor monitor) {
insertRecord(selectedEvent);
return Status.OK_STATUS;
}
};
job.schedule();
}
}
}
@ -551,7 +584,7 @@ public class FloodReportDlg extends CaveSWTDialog {
@Override
public void widgetSelected(SelectionEvent event) {
FloodReportDataManager.getInstance().setDrawGraph(false);
shell.dispose();
close();
}
});
@ -562,47 +595,77 @@ public class FloodReportDlg extends CaveSWTDialog {
computeLatestDataBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
shell.setCursor(waitCursor);
setBusy(true);
MessageBox messageBox = new MessageBox(shell, SWT.OK
| SWT.CANCEL);
messageBox.setText("WHFS");
messageBox.setMessage("Update flood sequences?\n" +
"This may take a few minutes. \n" +
"Press 'OK' to proceed, 'Cancel' to abort.");
int answer = messageBox.open();
try {
if (answer == SWT.OK) {
WhfsServiceRequest request = new WhfsServiceRequest();
request.setServicesToExecute("run_floodseq");
Object obj= ThriftClient.sendRequest(request);
shell.setCursor(arrowCursor);
if (!(obj instanceof ServerErrorResponse)) {
MessageBox messageBox2 = new MessageBox(shell, SWT.OK);
messageBox2.setText("WHFS");
messageBox2.setMessage("Update of flood " +
"sequences complete.");
messageBox2.open();
}
}
} catch (VizException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
messageBox.setText("WHFS");
messageBox.setMessage("Update flood sequences?\n"
+ "This may take a few minutes. \n"
+ "Press 'OK' to proceed, 'Cancel' to abort.");
int answer = messageBox.open();
if (answer == SWT.OK) {
Job job = new Job("Latest Data") {
@Override
protected IStatus run(IProgressMonitor monitor) {
handelLatestData();
return Status.OK_STATUS;
}
};
job.schedule();
} else {
setBusy(false);
}
shell.setCursor(arrowCursor);
}
});
}
/**
* Get the latestes data. Assume called from non-UI thread.
*/
private void handelLatestData() {
try {
WhfsServiceRequest request = new WhfsServiceRequest();
request.setServicesToExecute("run_floodseq");
Object obj = ThriftClient.sendRequest(request);
if (!(obj instanceof ServerErrorResponse)) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
MessageBox messageBox2 = new MessageBox(shell, SWT.OK);
messageBox2.setText("WHFS");
messageBox2.setMessage("Update of flood "
+ "sequences complete.");
messageBox2.open();
}
});
}
} catch (VizException e1) {
statusHandler.handle(Priority.ERROR,
"Unable able to update flood sequences. ", e1);
} finally {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
setBusy(false);
}
});
}
}
/**
* Get the label text for the location list control.
*
* @return Label text.
*/
private String getListLabel() {
String format = "%S %S %S %S";
String listFormat = "%S %S %S %S";
String labelStr = String.format(format, "Location", "Crest Stage",
String labelStr = String.format(listFormat, "Location", "Crest Stage",
"Crest Time", "Flood Stage");
return labelStr;
@ -617,23 +680,27 @@ public class FloodReportDlg extends CaveSWTDialog {
}
}
/**
* Populate flood list doing getting the information needed from the manager
* off of the UI thread.
*/
private void updateFloodList() {
FloodReportDataManager dman = FloodReportDataManager.getInstance();
final FloodReportDataManager dman = FloodReportDataManager
.getInstance();
locationList.removeAll();
stageLbl.setText("Stage: ");
locationLbl.setText("Location: ");
int month = 0;
String hsaWhere = null;
String where = null;
Map<String, FloodReportData> dataMap = new TreeMap<String, FloodReportData>();
// Determine the selected time period
String period = reportPeriodArray[reportPeriodCbo.getSelectionIndex()];
// Set Calendar objects to current date/time
Date date = SimulatedTime.getSystemTime().getTime();
Calendar endCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
Calendar startCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
final Calendar endCal = Calendar.getInstance(TimeZone
.getTimeZone("GMT"));
final Calendar startCal = Calendar.getInstance(TimeZone
.getTimeZone("GMT"));
endCal.setTime(date);
startCal.setTime(date);
if (period.equals(reportPeriodArray[0])) {
@ -683,7 +750,8 @@ public class FloodReportDlg extends CaveSWTDialog {
endDate = endCal.getTime();
dman.setStartDate(startDate);
dman.setEndDate(endDate);
setBusy(true);
String hsaWhere = null;
/* HSA filtering section */
if (hsaCbo.getSelectionIndex() > 0) {
/* a specific HSA has been chosen */
@ -693,25 +761,49 @@ public class FloodReportDlg extends CaveSWTDialog {
/* no specific HSA has been chosen, so don't filter on this */
hsaWhere = "";
}
final String where = hsaWhere;
Job job = new Job("Flood Data") {
@Override
protected IStatus run(IProgressMonitor monitor) {
updateFloodData(dman, startCal, endCal, where);
return Status.OK_STATUS;
}
};
job.schedule();
}
/**
* Get information for the flood list. This assumes it is called from a
* non-UI thread.
*
* @param dman
* @param startCal
* @param endCal
*/
private void updateFloodData(FloodReportDataManager dman,
Calendar startCal, Calendar endCal, String hsaWhere) {
String where = null;
Map<String, FloodReportData> dataMap = new TreeMap<String, FloodReportData>();
/* create the where clause */
String start = dbFormat.format(startCal.getTime());
String end = dbFormat.format(endCal.getTime());
where = "WHERE" + hsaWhere + " obstime >= '"
+ start + "' and obstime <= '"
+ end + "' and flood_event_id > 0 order by lid";
where = "WHERE" + hsaWhere + " obstime >= '" + start
+ "' and obstime <= '" + end
+ "' and flood_event_id > 0 order by lid";
locationLidList.clear();
ArrayList<String> lidList = dman.getLidList(where);
int i = 0;
for (String lid : lidList) {
ArrayList<FloodReportData> dataList = dman.getFloodRptData(lid,
ArrayList<FloodReportData> dataList = dman.getFloodRptData(lid,
start, end);
for (FloodReportData data : dataList) {
if ((data.getFloodEventId() > 0) && (data.getCrest() >= data.getFloodStage())) {
dataMap.put(lid + data.getFloodEventId(), data);
}
i++;
if ((data.getFloodEventId() > 0)
&& (data.getCrest() >= data.getFloodStage())) {
dataMap.put(lid + data.getFloodEventId(), data);
}
}
}
@ -725,6 +817,8 @@ public class FloodReportDlg extends CaveSWTDialog {
locationLidList.clear();
String prevSite = null;
String line = null;
final java.util.List<String> locationLines = new ArrayList<String>(
keySet.size());
while (iter.hasNext()) {
FloodReportData data = dataMap.get(iter.next());
@ -734,26 +828,44 @@ public class FloodReportDlg extends CaveSWTDialog {
data.setLongName(data.getLongName().substring(0, 15));
}
line = String.format(format, data.getLongName(), data.getLid(),
data.getCrest(), fr.format(data.getCrestDate()), data
.getFloodStage());
data.getCrest(), fr.format(data.getCrestDate()),
data.getFloodStage());
} else {
line = String.format(format, " ", " ", data.getCrest(), fr
.format(data.getCrestDate()), data.getFloodStage());
}
locationList.add(line);
locationLidList.add(data.getLid() + data.getFloodEventId());
locationList.setSelection(0);
if (locationList.getSelectionIndex() !=-1 ) {
loadSignificantTimes();
FloodReportDataManager.getInstance().setDrawGraph(true);
floodCanvas.setSelectedKey(selectedKey);
floodCanvas.redraw();
locationLbl.setText("Location: " + selectedLid);
line = String.format(format, " ", " ", data.getCrest(),
fr.format(data.getCrestDate()), data.getFloodStage());
}
locationLines.add(line);
locationLidList.add(data.getLid() + data.getFloodEventId());
prevSite = data.getLid();
}
VizApp.runAsync(new Runnable() {
@Override
public void run() {
for (String l : locationLines) {
locationList.add(l);
}
locationList.setSelection(0);
// Check just in the locationList is empty.
if (locationList.getSelectionIndex() != -1) {
loadSignificantTimes();
FloodReportDataManager.getInstance().setDrawGraph(true);
floodCanvas.setSelectedKey(selectedKey);
floodCanvas.redraw();
locationLbl.setText("Location: " + selectedLid);
}
setBusy(false);
}
});
}
/**
* Update graph based oh new selection.
*/
private void handleSelection() {
loadSignificantTimes();
FloodReportDataManager.getInstance().setDrawGraph(true);
@ -862,7 +974,8 @@ public class FloodReportDlg extends CaveSWTDialog {
out.write(output);
out.close();
} catch (IOException e) {
e.printStackTrace();
statusHandler.handle(Priority.ERROR,
"Unable able to update flood file. ", e);
}
}
@ -880,8 +993,7 @@ public class FloodReportDlg extends CaveSWTDialog {
String prevLid = null;
StringBuilder buffer = new StringBuilder();
buffer
.append("Flood report information listing generated by WHFS HydroBase.\n");
buffer.append("Flood report information listing generated by WHFS HydroBase.\n");
Calendar now = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
buffer.append("File created on: "
+ HydroConstants.DATE_FORMAT.format(now.getTime()) + " Z\n");
@ -893,14 +1005,10 @@ public class FloodReportDlg extends CaveSWTDialog {
+ HydroConstants.DATE_FORMAT.format(endDate));
buffer.append("\nAll times given in GMT.\n");
buffer.append("N/A= Not Available q= questionable\n\n");
buffer
.append("Flood events are grouped by location, river, and basin.\n");
buffer
.append("For each event, the following information is given:\n\n");
buffer
.append(" FLD STG ABOVE FLOOD - BELOW FLOOD CREST TIME\n");
buffer
.append("\n------------------------------------------------------------------\n");
buffer.append("Flood events are grouped by location, river, and basin.\n");
buffer.append("For each event, the following information is given:\n\n");
buffer.append(" FLD STG ABOVE FLOOD - BELOW FLOOD CREST TIME\n");
buffer.append("\n------------------------------------------------------------------\n");
/* No Data, return the text */
if (locationList.getItemCount() == 0) {
@ -998,19 +1106,20 @@ public class FloodReportDlg extends CaveSWTDialog {
String stream = dman.getRiver(data.getLid());
String basin = dman.getRiverBasin(data.getLid());
if (basin!=null && prevBasin!=null && !basin.equals(prevBasin)) {
if (basin != null && prevBasin != null
&& !basin.equals(prevBasin)) {
buffer.append("\n\nBASIN: " + basin + "\n");
}
if (stream!=null && prevStream!=null && !stream.equals(prevStream)) {
if (stream != null && prevStream != null
&& !stream.equals(prevStream)) {
buffer.append("\n RIVER: " + stream + "\n");
}
if (!data.getLid().equals(prevLid)) {
buffer
.append("\n " + data.getLongName() + ", "
+ dman.getState(data.getLid()) + " (" + data.getLid()
+ ")\n");
buffer.append("\n " + data.getLongName() + ", "
+ dman.getState(data.getLid()) + " ("
+ data.getLid() + ")\n");
}
buffer.append(String.format(dataFormat, data.getFloodStage(),
@ -1051,27 +1160,36 @@ public class FloodReportDlg extends CaveSWTDialog {
}
/**
* Insert the crest into the crest table.
* Insert the crest into the crest table. Assume invoke on non-UI thread.
*
* @param selectedEvent
* @return
*/
private int insertRecord() {
private int insertRecord(String[] selectedEvent) {
FloodReportDataManager dman = FloodReportDataManager.getInstance();
Map<String, FloodReportData> dataMap = dman.getReportData();
FloodReportData data = dataMap.get(selectedLid);
String cremark = "Inserted from the FloodTS table via Hydrobase";
String[] selectedEvent=eventList.getSelection();
String stage=selectedEvent[0].substring(1, 13).trim();
String eventDateStr=selectedEvent[0].substring(17, 33);
Date eventDate=null;
String stage = selectedEvent[0].substring(1, 13).trim();
String eventDateStr = selectedEvent[0].substring(17, 33);
Date eventDate = null;
try {
eventDate=fr.parse(eventDateStr);
} catch (ParseException e) {
e.printStackTrace();
MessageBox mbe = new MessageBox(shell, SWT.OK | SWT.ERROR);
mbe.setMessage("ERROR while attempting to parse :"+eventDateStr+" at insertRecord()");
mbe.open();
return -2;
}
eventDate = fr.parse(eventDateStr);
} catch (ParseException e) {
final String message = "ERROR while attempting to parse :"
+ eventDateStr + " at insertRecord()";
VizApp.runSync(new Runnable() {
@Override
public void run() {
MessageBox mbe = new MessageBox(shell, SWT.OK | SWT.ERROR);
mbe.setMessage(message);
mbe.open();
}
});
return -2;
}
long discharge = Math.round(RatingUtils.stage2discharge(data.getLid(),
Double.parseDouble(stage)));
@ -1095,15 +1213,21 @@ public class FloodReportDlg extends CaveSWTDialog {
sql.append(")");
int status = dman.insertCrest(sql.toString());
final int status = dman.insertCrest(sql.toString());
if (status < 0) {
MessageBox mbe = new MessageBox(shell, SWT.OK | SWT.ERROR);
if (status == -2) {
mbe.setMessage("Record already exists in the Crest table!");
} else {
mbe.setMessage("ERROR while attempting to insert crest...");
}
mbe.open();
VizApp.runSync(new Runnable() {
@Override
public void run() {
MessageBox mbe = new MessageBox(shell, SWT.OK | SWT.ERROR);
if (status == -2) {
mbe.setMessage("Record already exists in the Crest table!");
} else {
mbe.setMessage("ERROR while attempting to insert crest...");
}
mbe.open();
}
});
}
return status;
@ -1125,4 +1249,17 @@ public class FloodReportDlg extends CaveSWTDialog {
public void setStageLbl(String text) {
stageLbl.setText(text);
}
/**
* Handles setting the shell's cursor to the desired state.
*
* @param state
*/
private void setBusy(boolean state) {
Cursor cursor = null;
if (state) {
cursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
}
shell.setCursor(cursor);
}
}

View file

@ -157,6 +157,9 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* Changes for non-blocking RiverProFcstGrpPointsDlg.
* Changes for non-blocking RiverProGenParamsDlg.
* Changes for non-blocking StatesCountiesZonesDlg.
* Changes for non-blocking StationFilterOptionsDlg.
* Changes for non-blocking FloodReportDlg.
* Make dialog non-blocking.
*
* </pre>
*
@ -309,6 +312,16 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
*/
private RiverProFcstGrpPointsDlg riverProFcst;
/**
* Allow one instance of the Station Filter Option dialog.
*/
private StationFilterOptionsDlg stationFilterDlg;
/**
* Alllow one instance of the Flood Report Dialog.
*/
private FloodReportDlg floodReportDlg;
/**
* Flood category menu item.
*/
@ -427,7 +440,8 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
* Dialog title information.
*/
public HydroBaseDlg(Shell parent, String titleInfo, String selectedLid) {
super(parent, SWT.DIALOG_TRIM | SWT.MIN, CAVE.INDEPENDENT_SHELL);
super(parent, SWT.DIALOG_TRIM | SWT.MIN, CAVE.INDEPENDENT_SHELL
| CAVE.DO_NOT_BLOCK);
setText("HydroBase on " + titleInfo);
this.selectedLid = selectedLid;
}
@ -1249,8 +1263,12 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
floodReportMI.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
FloodReportDlg floodReportDlg = new FloodReportDlg(shell);
floodReportDlg.open();
if (floodReportDlg == null || floodReportDlg.isDisposed()) {
floodReportDlg = new FloodReportDlg(shell);
floodReportDlg.open();
} else {
floodReportDlg.bringToTop();
}
}
});
@ -1265,10 +1283,6 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
TextReportDlg textReportDlg = new TextReportDlg(shell, lid
.substring(0, lid.indexOf(" ")));
textReportDlg.open();
// MessageBox messageBox = new MessageBox(shell, SWT.OK);
// messageBox.setText("Not Yet Implemented");
// messageBox.setMessage("This Function Is Not Yet Implemented");
// messageBox.open();
}
});
}
@ -1822,11 +1836,20 @@ public class HydroBaseDlg extends CaveSWTDialog implements IGetSortType,
* Opens the Station Filter Dialog
*/
private void openStationFilterOptions() {
StationFilterOptionsDlg stationFilterDlg = new StationFilterOptionsDlg(
shell);
stationFilterDlg.addListener(this);
stationFilterDlg.open();
stationFilterDlg.removeListener(this);
if (stationFilterDlg == null || stationFilterDlg.isDisposed()) {
stationFilterDlg = new StationFilterOptionsDlg(shell);
stationFilterDlg.addListener(this);
stationFilterDlg.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
stationFilterDlg.removeListener(HydroBaseDlg.this);
}
});
stationFilterDlg.open();
} else {
stationFilterDlg.bringToTop();
}
}
/*

View file

@ -21,6 +21,7 @@
*
*/
package com.raytheon.viz.hydrobase;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
@ -45,6 +46,7 @@ import com.raytheon.viz.hydrocommon.HydroDisplayManager;
* 07/03/2010 6586 mduff Fixed problem introduced from the
* CaveSWTDialog refactor and added
* a pre-selected lid.
* 06/27/2013 2088 rferrel Changes for non-blocking HydroBaseDlg.
*
* </pre>
*
@ -52,22 +54,31 @@ import com.raytheon.viz.hydrocommon.HydroDisplayManager;
*
*/
public class HydrobaseAction extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
String lid = HydroDisplayManager.getInstance().getCurrentLid();
String dbName = AppsDefaults.getInstance().getToken("db_name");
HydroBaseDlg hydrobaseDlg = new HydroBaseDlg(shell, dbName, lid);
boolean verified = hydrobaseDlg.promptForPassword(new Shell());
if (verified) {
hydrobaseDlg.open();
}
return null;
}
private HydroBaseDlg hydrobaseDlg;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
if (hydrobaseDlg == null || hydrobaseDlg.isDisposed()) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
String lid = HydroDisplayManager.getInstance().getCurrentLid();
String dbName = AppsDefaults.getInstance().getToken("db_name");
hydrobaseDlg = new HydroBaseDlg(shell, dbName, lid);
Shell passwdShell = new Shell();
boolean verified = hydrobaseDlg.promptForPassword(passwdShell);
passwdShell.dispose();
if (verified) {
hydrobaseDlg.open();
} else {
hydrobaseDlg = null;
}
} else {
hydrobaseDlg.bringToTop();
}
return null;
}
}

View file

@ -61,6 +61,7 @@ import com.raytheon.viz.hydrocommon.util.HydroDataUtils;
import com.raytheon.viz.hydrocommon.util.StnClassSyncUtil;
import com.raytheon.viz.hydrocommon.whfslib.GeoUtil;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.dialogs.ICloseCallback;
/**
* This class displays the River Gage dialog.
@ -75,6 +76,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Also see https://bugs.eclipse.org/bugs/show_bug.cgi?id=43004
* Apr 16,2012 14797 wkwock Change lat/lon from hour minute sec to decimal.
* Jun 11,2013 2088 rferrel Make dialog non-blocking.
* Changes for non-blocking FcstPointGroupDlg.
*
* </pre>
*
@ -86,6 +88,11 @@ public class RiverGageDlg extends CaveSWTDialog implements
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(RiverGageDlg.class);
/**
* Allow only a single instance of the Forcast Point Group dialog.
*/
private FcstPointGroupDlg fcstPointDlg;
/**
* Control font.
*/
@ -1500,14 +1507,23 @@ public class RiverGageDlg extends CaveSWTDialog implements
* Opens the Forecast Point Group Assignment Dialog
*/
private void openFcstGroupAssignmentDlg() {
FcstPointGroupDlg fcstPointDlg = new FcstPointGroupDlg(shell,
forecastPointTF.getText());
fcstPointDlg.addListener(this);
if (fcstPointDlg == null || fcstPointDlg.isDisposed()) {
fcstPointDlg = new FcstPointGroupDlg(shell,
forecastPointTF.getText());
fcstPointDlg.addListener(this);
fcstPointDlg.setCloseCallback(new ICloseCallback() {
// Open the Fcst Assignment dlg
fcstPointDlg.open();
@Override
public void dialogClosed(Object returnValue) {
fcstPointDlg.removeListener(RiverGageDlg.this);
}
});
fcstPointDlg.removeListener(this);
// Open the Fcst Assignment dlg
fcstPointDlg.open();
} else {
fcstPointDlg.bringToTop();
}
}
/**

View file

@ -37,6 +37,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.HydroStationDataManager;
import com.raytheon.viz.hydrobase.listeners.IStationFilterListener;
@ -55,7 +58,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 9, 2008 lvenable Initial creation
* Jun 17,2010 #5414 lbousaidi Apply button closing
* Jun 17,2010 #5414 lbousaidi Apply button closing
* Jun 27, 2013 #2088 rferrel Make dialog non-blocking.
*
* </pre>
*
@ -63,6 +67,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @version 1.0
*/
public class StationFilterOptionsDlg extends CaveSWTDialog {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(StationFilterOptionsDlg.class);
/**
* Control font.
@ -121,10 +127,15 @@ public class StationFilterOptionsDlg extends CaveSWTDialog {
* Parent shell.
*/
public StationFilterOptionsDlg(Shell parent) {
super(parent);
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Station List Filter Options");
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override
protected Layout constructShellLayout() {
// Create the main layout for the shell.
@ -135,11 +146,23 @@ public class StationFilterOptionsDlg 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);
@ -288,7 +311,7 @@ public class StationFilterOptionsDlg extends CaveSWTDialog {
@Override
public void widgetSelected(SelectionEvent event) {
if (saveSettings()) {
fireUpdateEvent();
fireUpdateEvent();
}
}
});
@ -300,11 +323,14 @@ public class StationFilterOptionsDlg extends CaveSWTDialog {
closeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
shell.dispose();
close();
}
});
}
/**
* Get the static HSA data.
*/
private void loadStaticData() {
// Load HSAs
hsaList.removeAll();
@ -314,7 +340,8 @@ public class StationFilterOptionsDlg extends CaveSWTDialog {
hsaList.add(currHSA);
}
} catch (VizException e) {
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM,
"Unable to load HSA static data: ", e);
}
}
@ -347,13 +374,11 @@ public class StationFilterOptionsDlg extends CaveSWTDialog {
latCenterTF
.setText((man.getLatCenter() != HydroConstants.MISSING_VALUE) ? GeoUtil
.getInstance().cvt_latlon_from_double(
man.getLatCenter())
: "");
man.getLatCenter()) : "");
lonCenterTF
.setText((man.getLonCenter() != HydroConstants.MISSING_VALUE) ? GeoUtil
.getInstance().cvt_latlon_from_double(
man.getLonCenter())
: "");
man.getLonCenter()) : "");
enableChk.setSelection(man.isFilterByLatLon());
}
@ -407,8 +432,7 @@ public class StationFilterOptionsDlg extends CaveSWTDialog {
if ((lat < -90) || (lat > 90) || invalidLat) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Value");
mb
.setMessage("Please enter a VALID (-90 to 90) Latitude\nin the form: DD MM SS");
mb.setMessage("Please enter a VALID (-90 to 90) Latitude\nin the form: DD MM SS");
mb.open();
return false;
@ -426,14 +450,12 @@ public class StationFilterOptionsDlg extends CaveSWTDialog {
lon = GeoUtil.getInstance().cvt_spaced_format(lonTxt, 0);
} catch (Exception e) {
invalidLon = true;
e.printStackTrace();
}
if ((lon > 180) || (lon < -180) || invalidLon) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Value");
mb
.setMessage("Please enter a VALID (-180 to 180) Longitude\nin the form: DD MM SS");
mb.setMessage("Please enter a VALID (-180 to 180) Longitude\nin the form: DD MM SS");
mb.open();
return false;