9481
|
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.uinfo; |
|
11 |
|
12 import java.util.List; |
|
13 |
|
14 import org.dive4elements.river.client.client.FLYSConstants; |
|
15 |
|
16 import com.smartgwt.client.widgets.form.fields.TextItem; |
|
17 |
|
18 /** |
|
19 * @author Domenico Nardi Tironi |
|
20 * |
|
21 */ |
|
22 public class UinfoInundationSingleYearEpochBehaviour extends ValidationBehaviourSingleMultiInputItem { |
|
23 |
|
24 private final String titleForCreateOld; |
|
25 |
|
26 public UinfoInundationSingleYearEpochBehaviour(final FLYSConstants msg, final String titleForCreateOld) { |
|
27 super(msg); |
|
28 this.titleForCreateOld = titleForCreateOld; |
|
29 } |
|
30 |
|
31 @Override |
|
32 public void appendValue(final TextItem inputItem, final String value) { |
|
33 inputItem.setValue(value); |
|
34 } |
|
35 |
|
36 @Override |
|
37 public List<String> validate(final List<String> errors, final String inputValueString) { |
|
38 boolean isGood = false; |
|
39 for (final String validYear : this.getValidInputs()) { // no numeric check |
|
40 /* No list contains for strings? */ |
|
41 if (inputValueString.equals(validYear)) { |
|
42 isGood = true; |
|
43 break; |
|
44 } |
|
45 } |
|
46 if (!isGood) { |
|
47 String tmp = this.errorForItemMsg; |
|
48 tmp = tmp.replace("$1", inputValueString); |
|
49 errors.add(tmp); |
|
50 } |
|
51 |
|
52 return errors; |
|
53 |
|
54 } |
|
55 |
|
56 @Override |
|
57 public boolean isMultipleInputsAllowed() { |
|
58 return false; |
|
59 } |
|
60 |
|
61 @Override |
|
62 public String titleForCreateOld() { |
|
63 return this.titleForCreateOld; |
|
64 } |
|
65 } |