Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/MultiBehaviour.java @ 9256:6c24c857ccf9
fixation refactoring and inputItem behaviour to interfaces
author | gernotbelger |
---|---|
date | Fri, 13 Jul 2018 12:04:21 +0200 |
parents | |
children | 7337034eb5d5 |
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.sinfo; | |
11 | |
12 import java.util.List; | |
13 | |
14 import org.dive4elements.river.client.client.FLYSConstants; | |
15 import org.dive4elements.river.client.client.ui.uinfo.ValidationBehaviourSingleMultiInputItem; | |
16 | |
17 import com.smartgwt.client.widgets.form.fields.TextItem; | |
18 | |
19 /** | |
20 * @author Domenico Nardi Tironi | |
21 * | |
22 */ | |
23 public class MultiBehaviour extends ValidationBehaviourSingleMultiInputItem { | |
24 | |
25 public MultiBehaviour(final List<String> validInputs, final String errorForItemMsg, final FLYSConstants MSG) { | |
26 super(validInputs, errorForItemMsg, MSG); | |
27 } | |
28 | |
29 public MultiBehaviour() { | |
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 oldYears = inputItem.getValueAsString(); | |
37 if (oldYears != null && !oldYears.isEmpty()) | |
38 inputItem.setValue(oldYears.trim() + " " + value); | |
39 else | |
40 inputItem.setValue(value); | |
41 | |
42 } | |
43 | |
44 @Override | |
45 public List<String> validate(final List<String> errors, final String inputValueString) { | |
46 if (inputValueString != null) { | |
47 final String[] sValues = inputValueString.trim().split(" "); | |
48 for (final String value : sValues) { | |
49 errors.addAll(this.validateSingleInput(value)); | |
50 } | |
51 } | |
52 return errors; | |
53 } | |
54 | |
55 } |