comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/BunduWstWQPanel.java @ 9276:3141f0e7314e

clone for bundu.ws.wq
author gernotbelger
date Thu, 19 Jul 2018 17:54:10 +0200
parents
children 2323d005f9a5
comparison
equal deleted inserted replaced
9275:ff9372d0cc1c 9276:3141f0e7314e
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU AGPL (>=v3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6 * documentation coming with Dive4Elements River for details.
7 */
8
9 package org.dive4elements.river.client.client.ui.bundu;
10
11 import java.util.ArrayList;
12 import java.util.List;
13 import java.util.Map;
14
15 import org.dive4elements.river.client.client.ui.DoubleArrayPanel;
16 import org.dive4elements.river.client.client.ui.WQAdaptedInputPanel;
17
18 import com.google.gwt.i18n.client.NumberFormat;
19
20 /**
21 * This UIProvider creates a widget to enter W or Q data for
22 * Fixation analysis
23 *
24 * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a>
25 */
26 public class BunduWstWQPanel extends WQAdaptedInputPanel {
27 private static final long serialVersionUID = -3218827566805476423L;
28
29 @Override
30 protected List<String> validateRange(final Map<String, double[]> ranges) {
31 final List<String> errors = new ArrayList<String>();
32 final NumberFormat nf = NumberFormat.getDecimalFormat();
33
34 for (final DoubleArrayPanel dap : this.wqranges.values()) {
35
36 if (!dap.validateForm()) {
37 errors.add(this.MSG.error_invalid_double_value());
38 return errors;
39 }
40
41 int idx = 0;
42
43 final double[] values = dap.getInputValues();
44
45 final double[] good = new double[values.length];
46
47 for (final double value : values) {
48 if (value <= 0) {
49 String tmp = this.MSG.error_validate_positive();
50 tmp = tmp.replace("$1", nf.format(value));
51 errors.add(tmp);
52 } else {
53 good[idx++] = value;
54 }
55 }
56
57 final double[] justGood = new double[idx];
58 for (int i = 0; i < justGood.length; i++) {
59 justGood[i] = good[i];
60 }
61
62 if (!errors.isEmpty()) {
63 dap.setValues(justGood);
64 }
65 }
66 return errors;
67 }
68 }
69 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org