From 45b75823acbdaa46f99868dcd45d5073140623f1 Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Wed, 6 Feb 2013 13:40:51 -0600 Subject: [PATCH] Issue #1586 add color to area validation. Former-commit-id: 80f8dc50f970addb0b93762fabacea1038ddec32 [formerly f073984ce6f73be9ff24fc43e8a62f04095ecdfe] [formerly 8a233105bc7145812b4c458d5848c2233cbe158c [formerly 452ba74bb84a2531b617675c4ee80ef4b008cd34]] Former-commit-id: 8a233105bc7145812b4c458d5848c2233cbe158c Former-commit-id: 6a8bd463a659b7a8326273eababccc3db5183de8 --- .../browser/ArealSelectionDlg.java | 3 ++ .../viz/datadelivery/common/ui/AreaComp.java | 29 +++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/browser/ArealSelectionDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/browser/ArealSelectionDlg.java index 48d8d1abea..7771be72ef 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/browser/ArealSelectionDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/browser/ArealSelectionDlg.java @@ -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; } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/common/ui/AreaComp.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/common/ui/AreaComp.java index 1852ef0f36..a40634b2a5 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/common/ui/AreaComp.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/common/ui/AreaComp.java @@ -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; } /**