Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java @ 3539:091397efaca5
Issue 791: Do not allow the same values in reference and target location.
flys-client/trunk@5352 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 04 Sep 2012 09:19:33 +0000 |
parents | e703555f8da1 |
children | 03de5c424f95 |
comparison
equal
deleted
inserted
replaced
3538:9f8f941351b1 | 3539:091397efaca5 |
---|---|
169 | 169 |
170 // The initial view will display the location input mode. | 170 // The initial view will display the location input mode. |
171 locationPanel = new DoubleArrayPanel( | 171 locationPanel = new DoubleArrayPanel( |
172 MSG.unitLocation(), | 172 MSG.unitLocation(), |
173 getLocationValues(), | 173 getLocationValues(), |
174 new BlurHandler(){public void onBlur(BlurEvent be) {}}); | 174 new BlurHandler(){public void onBlur(BlurEvent be) {validate();}}); |
175 | 175 |
176 picker.getLocationTable().setAutoFetchData(true); | 176 picker.getLocationTable().setAutoFetchData(true); |
177 | 177 |
178 inputLayout.addMember(locationPanel); | 178 inputLayout.addMember(locationPanel); |
179 | 179 |
195 @Override | 195 @Override |
196 public List<String> validate() { | 196 public List<String> validate() { |
197 List<String> errors = new ArrayList<String>(); | 197 List<String> errors = new ArrayList<String>(); |
198 NumberFormat nf = NumberFormat.getDecimalFormat(); | 198 NumberFormat nf = NumberFormat.getDecimalFormat(); |
199 | 199 |
200 DataList[] ref = artifact.getArtifactDescription().getOldData(); | |
201 String mode = ref[1].get(0).getStringValue(); | |
202 | |
200 saveLocationValues(locationPanel); | 203 saveLocationValues(locationPanel); |
201 | 204 |
202 if (!locationPanel.validateForm()) { | 205 if (!locationPanel.validateForm()) { |
203 errors.add(MSG.wrongFormat()); | 206 errors.add(MSG.wrongFormat()); |
204 return errors; | 207 return errors; |
206 | 209 |
207 double[] lValues = getLocationValues(); | 210 double[] lValues = getLocationValues(); |
208 double[] good = new double[lValues.length]; | 211 double[] good = new double[lValues.length]; |
209 int idx = 0; | 212 int idx = 0; |
210 | 213 |
214 double reference = | |
215 Double.valueOf(ref[2].get(0).getStringValue()).doubleValue(); | |
211 for (double value: lValues) { | 216 for (double value: lValues) { |
217 if (mode.equals("calc.reference.curve") && | |
218 value == reference) { | |
219 errors.add(MSG.error_contains_same_location()); | |
220 return errors; | |
221 } | |
212 if (value < min || value > max) { | 222 if (value < min || value > max) { |
213 String tmp = MSG.error_validate_range(); | 223 String tmp = MSG.error_validate_range(); |
214 tmp = tmp.replace("$1", nf.format(value)); | 224 tmp = tmp.replace("$1", nf.format(value)); |
215 tmp = tmp.replace("$2", nf.format(min)); | 225 tmp = tmp.replace("$2", nf.format(min)); |
216 tmp = tmp.replace("$3", nf.format(max)); | 226 tmp = tmp.replace("$3", nf.format(max)); |
313 Double.parseDouble(record.getAttribute("from")); | 323 Double.parseDouble(record.getAttribute("from")); |
314 } | 324 } |
315 catch(NumberFormatException nfe) { | 325 catch(NumberFormatException nfe) { |
316 // Is there anything else to do here? | 326 // Is there anything else to do here? |
317 } | 327 } |
328 | |
329 // compare reference location and target location. | |
330 DataList[] ref = artifact.getArtifactDescription().getOldData(); | |
331 String mode = ref[1].get(0).getStringValue(); | |
332 if (mode.equals("calc.reference.curve") && | |
333 ref[2].get(0).getStringValue().equals(record.getAttribute("from"))) | |
334 { | |
335 SC.warn(MSG.error_same_location()); | |
336 return; | |
337 } | |
338 | |
318 setLocationValues(selected); | 339 setLocationValues(selected); |
319 } | 340 } |
320 | 341 |
321 /** | 342 /** |
322 * Returns the label string for the input panel. | 343 * Returns the label string for the input panel. |