Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/Limit5SalixBehaviour.java @ 9256:6c24c857ccf9
fixation refactoring and inputItem behaviour to interfaces
author | gernotbelger |
---|---|
date | Fri, 13 Jul 2018 12:04:21 +0200 |
parents | |
children | c7e5285d434f |
comparison
equal
deleted
inserted
replaced
9255:9be51f776798 | 9256:6c24c857ccf9 |
---|---|
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.util.SC; | |
17 import com.smartgwt.client.widgets.form.fields.TextItem; | |
18 | |
19 /** | |
20 * @author Domenico Nardi Tironi | |
21 * | |
22 */ | |
23 public class Limit5SalixBehaviour extends ValidationBehaviourSingleMultiInputItem { | |
24 | |
25 public Limit5SalixBehaviour(final List<String> validInputs, final String errorForItemMsg, final FLYSConstants MSG) { | |
26 super(validInputs, errorForItemMsg, MSG); | |
27 } | |
28 | |
29 public Limit5SalixBehaviour() { | |
30 super(); | |
31 } | |
32 | |
33 @Override | |
34 public void appendValue(final TextItem inputItem, final String value) { | |
35 // APPEND = ADD to existing -> MULTI YEAR | |
36 final String oldValues = inputItem.getValueAsString(); | |
37 if (oldValues != null && !oldValues.isEmpty()) { | |
38 final String[] oldVals = oldValues.split(" "); | |
39 if (oldVals.length < 5) | |
40 inputItem.setValue(oldValues.trim() + " " + value); | |
41 else { | |
42 SC.warn(this.MSG.error_limit_exceeded_salix()); | |
43 } | |
44 } | |
45 | |
46 else | |
47 inputItem.setValue(value); | |
48 | |
49 } | |
50 | |
51 @Override | |
52 public List<String> validate(final List<String> errors, final String inputValueString) { | |
53 if (inputValueString != null) { | |
54 final String[] values = inputValueString.trim().split(" "); | |
55 if (values.length > 5) { | |
56 errors.add(this.MSG.error_limit_exceeded_salix()); | |
57 } | |
58 for (int i = 0; i < values.length; i++) { | |
59 if (i < 5) | |
60 errors.addAll(this.validateNumber(values[i])); | |
61 } | |
62 } | |
63 return errors; | |
64 } | |
65 | |
66 } |