9276
|
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; |
9277
|
17 import org.dive4elements.river.client.shared.model.Data; |
|
18 import org.dive4elements.river.client.shared.model.DataList; |
9276
|
19 |
|
20 import com.google.gwt.i18n.client.NumberFormat; |
9277
|
21 import com.smartgwt.client.widgets.Canvas; |
9276
|
22 |
|
23 /** |
|
24 * This UIProvider creates a widget to enter W or Q data for |
|
25 * Fixation analysis |
|
26 * |
|
27 * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a> |
|
28 */ |
|
29 public class BunduWstWQPanel extends WQAdaptedInputPanel { |
|
30 private static final long serialVersionUID = -3218827566805476423L; |
|
31 |
9277
|
32 /** get bezugsjahr + range from server HERE **/ |
|
33 @Override |
|
34 public Canvas create(final DataList data) { |
|
35 final Data test = data.get(0); |
|
36 |
|
37 return super.create(data); |
|
38 } |
|
39 |
|
40 // TODO: ValidateRange verstehen und dann ggf. Löschen/Ändern/was auch immer |
9276
|
41 @Override |
|
42 protected List<String> validateRange(final Map<String, double[]> ranges) { |
|
43 final List<String> errors = new ArrayList<String>(); |
|
44 final NumberFormat nf = NumberFormat.getDecimalFormat(); |
|
45 |
|
46 for (final DoubleArrayPanel dap : this.wqranges.values()) { |
|
47 |
|
48 if (!dap.validateForm()) { |
|
49 errors.add(this.MSG.error_invalid_double_value()); |
|
50 return errors; |
|
51 } |
|
52 |
|
53 int idx = 0; |
|
54 |
|
55 final double[] values = dap.getInputValues(); |
|
56 |
|
57 final double[] good = new double[values.length]; |
|
58 |
|
59 for (final double value : values) { |
|
60 if (value <= 0) { |
|
61 String tmp = this.MSG.error_validate_positive(); |
|
62 tmp = tmp.replace("$1", nf.format(value)); |
|
63 errors.add(tmp); |
|
64 } else { |
|
65 good[idx++] = value; |
|
66 } |
|
67 } |
|
68 |
|
69 final double[] justGood = new double[idx]; |
|
70 for (int i = 0; i < justGood.length; i++) { |
|
71 justGood[i] = good[i]; |
|
72 } |
|
73 |
|
74 if (!errors.isEmpty()) { |
|
75 dap.setValues(justGood); |
|
76 } |
|
77 } |
|
78 return errors; |
|
79 } |
|
80 } |
|
81 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |