Merge "Issue #1586 add color to area validation." into development

Former-commit-id: f8a90106eef02f27f65a6a0eda5e92a5720adf90
This commit is contained in:
Richard Peter 2013-02-07 14:22:46 -06:00 committed by Gerrit Code Review
commit 27ce3e37f2
2 changed files with 27 additions and 5 deletions

View file

@ -139,6 +139,9 @@ public class ArealSelectionDlg extends CaveSWTDialog implements IDataSize {
@Override
public void widgetSelected(SelectionEvent e) {
if (!areaComp.isEnvelopeValid()) {
DataDeliveryUtils.showMessage(getShell(), SWT.OK,
"Validation Error",
"The defined area area is invalid\nAdjust the selected area and try again.");
return;
}

View file

@ -805,29 +805,48 @@ public class AreaComp extends Composite implements ISubset {
lr, 0.05);
envelopeValid = ulValid && lrValid;
int lrColor = SWT.COLOR_WHITE;
int ulColor = SWT.COLOR_WHITE;
StringBuilder errorText = null;
if (envelopeValid) {
subEnvelope = EnvelopeUtils.createSubenvelopeFromLatLon(
fullEnvelope, ul, lr);
updateDataSize();
} else {
StringBuilder errorText = new StringBuilder();
errorText = new StringBuilder();
errorText.append("The ");
if (ulValid) {
errorText.append("Lower Right Coordinate is");
lrColor = SWT.COLOR_RED;
} else if (lrValid) {
errorText.append("Upper Left Coordinate is");
ulColor = SWT.COLOR_RED;
} else {
lrColor = SWT.COLOR_RED;
ulColor = SWT.COLOR_RED;
errorText.append("Lower Right and Upper Left Coordinates are");
}
errorText.append(" not within the dataset area.");
}
// Set the background color before displaying an error message.
Color color = getDisplay().getSystemColor(lrColor);
lowerRightLatTxt.setBackground(color);
lowerRightLonTxt.setBackground(color);
if (lrColor != ulColor) {
color = getDisplay().getSystemColor(ulColor);
}
upperLeftLatTxt.setBackground(color);
upperLeftLonTxt.setBackground(color);
if (errorText != null) {
DataDeliveryUtils.showMessage(getShell(), SWT.OK,
"Validation Error", errorText.toString());
}
// Entries are valid so save them off.
this.envelopeValid = true;
return true;
return envelopeValid;
}
/**