Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/AbstractVegZonesTablePanel.java @ 9552:7f3444cbba5f
vegZone -1 to 366
author | gernotbelger |
---|---|
date | Mon, 22 Oct 2018 16:26:12 +0200 |
parents | d421c2bf0195 |
children | 8cf2968dd4f9 |
comparison
equal
deleted
inserted
replaced
9551:342c122e3dfe | 9552:7f3444cbba5f |
---|---|
48 * | 48 * |
49 */ | 49 */ |
50 public abstract class AbstractVegZonesTablePanel extends AbstractUIProvider { | 50 public abstract class AbstractVegZonesTablePanel extends AbstractUIProvider { |
51 private static final long serialVersionUID = 1L; | 51 private static final long serialVersionUID = 1L; |
52 | 52 |
53 private static final int LOWER = -1; | |
54 private static final int UPPER = 366; | |
55 | |
53 private static final String datakey = "vegzones"; | 56 private static final String datakey = "vegzones"; |
54 final protected List<ListGridRecord> records = new ArrayList<ListGridRecord>(); | 57 final protected List<ListGridRecord> records = new ArrayList<ListGridRecord>(); |
55 private final Label validationLabel = PanelHelper.getValidationLabel(); | 58 private final Label validationLabel = PanelHelper.getValidationLabel(); |
56 private final ListGrid elements = new ListGrid() { | 59 private final ListGrid elements = new ListGrid() { |
57 | 60 |
212 return this.elements; | 215 return this.elements; |
213 } | 216 } |
214 | 217 |
215 private IntegerRangeValidator getValidator() { | 218 private IntegerRangeValidator getValidator() { |
216 final IntegerRangeValidator validator = new IntegerRangeValidator(); | 219 final IntegerRangeValidator validator = new IntegerRangeValidator(); |
217 validator.setMin(0); | 220 validator.setMin(LOWER); |
218 validator.setMax(365); | 221 validator.setMax(UPPER); |
219 validator.setErrorMessage(this.MSG.uinfo_vegetation_zones_validation_range()); | 222 validator.setErrorMessage(this.MSG.uinfo_vegetation_zones_validation_range()); |
220 return validator; | 223 return validator; |
221 } | 224 } |
222 | 225 |
223 private SortNormalizer getNormalizer() { | 226 private SortNormalizer getNormalizer() { |
325 | 328 |
326 protected final List<VegetationZoneServerClientXChange> getZones(final ListGridRecord[] lgr) { | 329 protected final List<VegetationZoneServerClientXChange> getZones(final ListGridRecord[] lgr) { |
327 final List<VegetationZoneServerClientXChange> zoneList = new ArrayList<VegetationZoneServerClientXChange>(); | 330 final List<VegetationZoneServerClientXChange> zoneList = new ArrayList<VegetationZoneServerClientXChange>(); |
328 for (final ListGridRecord element : lgr) { | 331 for (final ListGridRecord element : lgr) { |
329 final Record r = element; | 332 final Record r = element; |
330 final VegetationZoneServerClientXChange zone = VegetationZoneServerClientXChange.createFromTableEntry(r.getAttribute("vegzone"), r.getAttribute("from"), r.getAttribute("to"), | 333 final VegetationZoneServerClientXChange zone = VegetationZoneServerClientXChange.createFromTableEntry(r.getAttribute("vegzone"), |
331 r.getAttribute("color")); | 334 r.getAttribute("from"), r.getAttribute("to"), r.getAttribute("color")); |
332 zoneList.add(zone); | 335 zoneList.add(zone); |
333 } | 336 } |
334 return zoneList; | 337 return zoneList; |
335 } | 338 } |
336 | 339 |
363 | 366 |
364 try { | 367 try { |
365 final Integer from = Integer.valueOf(fromInput); | 368 final Integer from = Integer.valueOf(fromInput); |
366 final Integer to = Integer.valueOf(toInput); | 369 final Integer to = Integer.valueOf(toInput); |
367 | 370 |
368 if (from < 0 || from > 365) | 371 if (from < LOWER || from > UPPER) |
369 return this.MSG.uinfo_vegetation_zones_validation_range(); | 372 return this.MSG.uinfo_vegetation_zones_validation_range(); |
370 | 373 |
371 if (to < 0 || to > 365) | 374 if (to < LOWER || to > UPPER) |
372 return this.MSG.uinfo_vegetation_zones_validation_range(); | 375 return this.MSG.uinfo_vegetation_zones_validation_range(); |
373 | 376 |
374 if (from > to) | 377 if (from > to) |
375 return this.MSG.uinfo_vegetation_zones_validation_from_greater_to(); | 378 return this.MSG.uinfo_vegetation_zones_validation_from_greater_to(); |
376 | 379 |
385 public final List<String> validate() { | 388 public final List<String> validate() { |
386 final List<String> errors = new ArrayList<String>(); | 389 final List<String> errors = new ArrayList<String>(); |
387 | 390 |
388 if (VegetationZoneServerClientXChange.zonesAreOverlapping(this.getZones(this.elements.getRecords()))) | 391 if (VegetationZoneServerClientXChange.zonesAreOverlapping(this.getZones(this.elements.getRecords()))) |
389 errors.add(this.MSG.uinfo_vegetation_zone_overlap()); | 392 errors.add(this.MSG.uinfo_vegetation_zone_overlap()); |
390 if (VegetationZoneServerClientXChange.hasGaps(this.getZones(this.elements.getRecords()), 0, 365)) | 393 if (VegetationZoneServerClientXChange.hasGaps(this.getZones(this.elements.getRecords()), LOWER, UPPER)) |
391 errors.add(this.MSG.uinfo_vegetation_zone_has_gaps()); | 394 errors.add(this.MSG.uinfo_vegetation_zone_has_gaps()); |
392 return errors; | 395 return errors; |
393 } | 396 } |
394 | 397 |
395 protected final void updateValidationMsgLabel() { | 398 protected final void updateValidationMsgLabel() { |