Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelTwinPanelValidator.java @ 8852:8f6d6d26e96f
Refaktored the DatacageTwinPanel so it is reusable.
author | gernotbelger |
---|---|
date | Thu, 18 Jan 2018 18:32:30 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
8851:13650d8a2373 | 8852:8f6d6d26e96f |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.client.client.ui; | |
11 | |
12 import java.util.ArrayList; | |
13 import java.util.List; | |
14 | |
15 import org.dive4elements.river.client.client.FLYSConstants; | |
16 import org.dive4elements.river.client.client.ui.AbstractPairRecommendationPanel.IValidator; | |
17 | |
18 import com.smartgwt.client.widgets.grid.ListGrid; | |
19 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
20 | |
21 /** | |
22 * Contains the old code from the validate-method of the DatacageTwinPanel. | |
23 * | |
24 * @author Gernot Belger | |
25 */ | |
26 public final class WaterlevelTwinPanelValidator implements IValidator { | |
27 | |
28 @Override | |
29 public List<String> validate(final ListGrid differencesList, final FLYSConstants msgProvider) { | |
30 | |
31 final List<String> errors = new ArrayList<String>(); | |
32 if (differencesList.getRecords().length == 0) { | |
33 // FIXME: waterlevel dependent! This will lead to a bad error message in English, for M-Info/Bed-Differences calculation | |
34 errors.add(msgProvider.error_no_waterlevel_pair_selected()); | |
35 } | |
36 // Check whether minuend and subtrahend are equal. | |
37 for (ListGridRecord record: differencesList.getRecords()) { | |
38 RecommendationPairRecord r = (RecommendationPairRecord) record; | |
39 if (r.getFirst().equals(r.getSecond())) { | |
40 // FIXME: this is still waterlevel specific! | |
41 // TODO: delegate validation to specific implementations | |
42 errors.add(msgProvider.error_same_waterlevels_in_pair()); | |
43 } | |
44 } | |
45 | |
46 return errors; | |
47 } | |
48 } |