Merge "Issue #1578 Changes for non-blocking FilteringDlg and bug fix to TimeSeriesDlg." into development

Former-commit-id: 3932a3e7c2 [formerly 002f832ca109fdd0df9112d2341aeab038aba0db]
Former-commit-id: 2b63f58269
This commit is contained in:
Lee Venable 2013-02-07 12:58:13 -06:00 committed by Gerrit Code Review
commit 758d23cc43
3 changed files with 120 additions and 51 deletions

View file

@ -34,6 +34,9 @@ import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.List;
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.hydro.pointdatacontrol.data.PointControlPeTs;
import com.raytheon.viz.hydro.pointdatacontrol.db.PDCDataManager;
@ -53,6 +56,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 25 JAN 2011 7625 bkowal The dialog will now be a modal dialog
* and it will include a title bar and
* close button.
* 07 FEB 2013 1578 rferrel Change for non-blocking dialog.
*
* </pre>
*
@ -61,6 +65,10 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*
*/
public class FilteringDlg extends CaveSWTDialog {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(FilteringDlg.class);
/** Type sources to always include. */
private static final String[] HARD_CODED_TYPE_SOURCES = { "RG", "RP", "RM",
"RR", "RZ" };
@ -122,7 +130,7 @@ public class FilteringDlg extends CaveSWTDialog {
*/
public FilteringDlg(Shell parent, String title, DialogType dialogType,
String peSelection) {
super(parent, SWT.DIALOG_TRIM | SWT.SYSTEM_MODAL);
super(parent, SWT.DIALOG_TRIM | SWT.SYSTEM_MODAL, CAVE.DO_NOT_BLOCK);
setText(title);
this.dialogType = dialogType;
@ -130,6 +138,11 @@ public class FilteringDlg extends CaveSWTDialog {
this.peSelection = peSelection;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override
protected Layout constructShellLayout() {
GridLayout mainLayout = new GridLayout(1, true);
@ -138,6 +151,13 @@ public class FilteringDlg extends CaveSWTDialog {
return mainLayout;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override
protected void initializeComponents(Shell shell) {
setReturnValue(false);
@ -181,7 +201,7 @@ public class FilteringDlg extends CaveSWTDialog {
public void widgetSelected(SelectionEvent event) {
handleApply();
setReturnValue(true);
shell.dispose();
close();
}
});
@ -194,7 +214,7 @@ public class FilteringDlg extends CaveSWTDialog {
@Override
public void widgetSelected(SelectionEvent event) {
setReturnValue(false);
shell.dispose();
close();
}
});
@ -367,9 +387,8 @@ public class FilteringDlg extends CaveSWTDialog {
ArrayList<String> tsList = new ArrayList<String>();
// add all of the hard_coded_type_sources
int i = 0;
for (i = 0; i < HARD_CODED_TYPE_SOURCES.length; i++) {
tsList.add(HARD_CODED_TYPE_SOURCES[i]);
for (String ts : HARD_CODED_TYPE_SOURCES) {
tsList.add(ts);
}
if ((rs != null) && (rs.size() > 0)) {
@ -429,7 +448,8 @@ public class FilteringDlg extends CaveSWTDialog {
}
}
} catch (VizException e) {
e.printStackTrace();
statusHandler.handle(Priority.PROBLEM, "Error populating list: "
+ e);
}
}

View file

@ -78,6 +78,7 @@ import com.raytheon.viz.hydrocommon.colorscalemgr.NamedColorSetGroup;
import com.raytheon.viz.hydrocommon.events.StationDisplayUpdateEvent;
import com.raytheon.viz.hydrocommon.pdc.PDCOptionData;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.dialogs.ICloseCallback;
/**
* This class displays the Point Data Control dialog for Hydroview.
@ -96,13 +97,15 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* The actionListeners for certain controls
* have been updated so that they will set it
* to true when an update is actually required.
*
*
* 03 OCT 2012 #15395 Added code to handle TimeStep when default is set
* to be "30 minutes Instantaneous" in the database.
* 09 OCT 2012 #15396 Fixed Instantaneous precip index so legend and map display
* will change each time duration is incremented or decremented
* for the "30 minutes Instantaneous" rainfall map .
* 04 Dec 2012 15602 wkwock Fix Hrs hour capped at 100.
* 07 Feb 2013 1578 rferrel Changes for non-blocking FilteringDlg.
* (TODO More code clean up when this dialog is converted.)
*
* </pre>
*
@ -166,6 +169,15 @@ public class PointDataControlDlg extends CaveSWTDialog {
// WIND
"WIND SPEED", "WIND DIRECTION" };
/** Filter dialog for Type/Source. */
private FilteringDlg typeSourceDlg;
/** Filter dialog for Service Area. */
private FilteringDlg serviceDlg;
/** Filter dialog for Data Source . */
private FilteringDlg dataSourceDlg;
/**
* The Stack Composite.
*/
@ -606,10 +618,12 @@ public class PointDataControlDlg extends CaveSWTDialog {
timeTF.setText(dateTimeFmt.format(cal.getTime()));
populatePresetData(null);
/* this is when in the database, the timeStep is set to be the
default one */
/*
* this is when in the database, the timeStep is set to be the default
* one
*/
if (timeStepRdo.getSelection() == true) {
handleQueryModeSelection(PDCConstants.QueryMode.TIME_STEP_MODE);
previousQueryMode = PDCConstants.QueryMode.TIME_STEP_MODE;
@ -874,18 +888,18 @@ public class PointDataControlDlg extends CaveSWTDialog {
upPrecipBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
PDCOptionData pcOptions = PDCOptionData.getInstance();
PDCOptionData pcOptions = PDCOptionData.getInstance();
if (precipIndex >= HydroConstants.InstPrecipSelection.values().length - 1) {
precipIndex = 0;
} else {
precipIndex++;
if (precipIndex == HydroConstants.InstPrecipSelection.
values().length - 1) {
precipIndex=0;
if (precipIndex == HydroConstants.InstPrecipSelection
.values().length - 1) {
precipIndex = 0;
}
}
pcOptions.setInstPrecipAccumTimeSelection(precipIndex);
pcOptions.setInstPrecipAccumTimeSelection(precipIndex);
setInstPrecipAccumText();
shell.setCursor(waitCursor);
updateData = true;
@ -899,20 +913,19 @@ public class PointDataControlDlg extends CaveSWTDialog {
downPrecipBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
PDCOptionData pcOptions = PDCOptionData.getInstance();
PDCOptionData pcOptions = PDCOptionData.getInstance();
if (precipIndex == 0) {
precipIndex = HydroConstants.InstPrecipSelection.
values().length - 1;
if (precipIndex == HydroConstants.InstPrecipSelection.
values().length - 1) {
precipIndex=HydroConstants.InstPrecipSelection.
values().length - 2;
}
precipIndex = HydroConstants.InstPrecipSelection.values().length - 1;
if (precipIndex == HydroConstants.InstPrecipSelection
.values().length - 1) {
precipIndex = HydroConstants.InstPrecipSelection
.values().length - 2;
}
} else {
precipIndex--;
}
pcOptions.setInstPrecipAccumTimeSelection(precipIndex);
setInstPrecipAccumText();
shell.setCursor(waitCursor);
@ -1117,17 +1130,21 @@ public class PointDataControlDlg extends CaveSWTDialog {
typeSourceBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
FilteringDlg typeSourceDlg = new FilteringDlg(shell,
"Type Source Selection Dialog",
FilteringDlg.DialogType.TYPE_SOURCE,
physicalElementCbo.getItem(physicalElementCbo
.getSelectionIndex()));
boolean redraw = (Boolean) typeSourceDlg.open();
if (redraw) {
shell.setCursor(waitCursor);
drawMap();
shell.setCursor(arrowCursor);
if (typeSourceDlg == null) {
typeSourceDlg = new FilteringDlg(shell,
"Type Source Selection Dialog",
FilteringDlg.DialogType.TYPE_SOURCE,
physicalElementCbo.getItem(physicalElementCbo
.getSelectionIndex()));
typeSourceDlg.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
redrawCheck(returnValue);
}
});
}
typeSourceDlg.open();
}
});
@ -1188,14 +1205,18 @@ public class PointDataControlDlg extends CaveSWTDialog {
serviceAreaBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
FilteringDlg serviceDlg = new FilteringDlg(shell,
"Service Area", FilteringDlg.DialogType.SERVICE_AREA);
boolean redraw = (Boolean) serviceDlg.open();
if (redraw) {
shell.setCursor(waitCursor);
drawMap();
shell.setCursor(arrowCursor);
if (serviceDlg == null) {
serviceDlg = new FilteringDlg(shell, "Service Area",
FilteringDlg.DialogType.SERVICE_AREA);
serviceDlg.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
redrawCheck(returnValue);
}
});
}
serviceDlg.open();
}
});
@ -1225,14 +1246,18 @@ public class PointDataControlDlg extends CaveSWTDialog {
dataSourceBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
FilteringDlg dataSourceDlg = new FilteringDlg(shell,
"Data Source", FilteringDlg.DialogType.DATA_SOURCE);
boolean redraw = (Boolean) dataSourceDlg.open();
if (redraw) {
shell.setCursor(waitCursor);
drawMap();
shell.setCursor(arrowCursor);
if (dataSourceDlg == null) {
dataSourceDlg = new FilteringDlg(shell, "Data Source",
FilteringDlg.DialogType.DATA_SOURCE);
dataSourceDlg.setCloseCallback(new ICloseCallback() {
@Override
public void dialogClosed(Object returnValue) {
redrawCheck(returnValue);
}
});
}
dataSourceDlg.open();
}
});
@ -2891,6 +2916,23 @@ public class PointDataControlDlg extends CaveSWTDialog {
return mode;
}
/**
* Determine if a redraw needs to be performed.
*
* @param returnValue
* - return value from the Filtering dialog.
*/
private void redrawCheck(Object returnValue) {
if (returnValue instanceof Boolean) {
boolean redraw = (Boolean) returnValue;
if (redraw) {
shell.setCursor(waitCursor);
drawMap();
shell.setCursor(arrowCursor);
}
}
}
/**
* Set the Instantaneous precip accum time option.
*/

View file

@ -989,6 +989,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
stnLayoutDisplayed = true;
}
prevModeIdx = modeCbo.getSelectionIndex();
checkBottomButtons();
}
}
});
@ -1487,7 +1488,13 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
* Update the enable status of the bottom buttons.
*/
private void checkBottomButtons() {
boolean enabled = topDataList.getSelectionIndex() >= 0;
boolean enabled = false;
if (modeCbo.getText().equals(PREDEFINED_GROUP)) {
enabled = true;
} else {
enabled = topDataList.getSelectionCount() > 0;
}
graphButton.setEnabled(enabled);
tableButton.setEnabled(enabled);
bothButton.setEnabled(enabled);