Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java @ 2920:aad006178c39
Bumped SmartGWT to version 3.0
flys-client/trunk@4760 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 22 Jun 2012 16:38:36 +0000 |
parents | 133820d1e6bf |
children | 0de3665daf36 |
rev | line source |
---|---|
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client.ui; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
3 import java.util.ArrayList; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
4 import java.util.List; |
906
39acba4b5f0b
Added formatter for numeric columns that converts the decimal separator.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
903
diff
changeset
|
5 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
6 import com.google.gwt.i18n.client.NumberFormat; |
1538
92f81eac034a
Added filter implementation for input helper tables in single location and
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1534
diff
changeset
|
7 |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.flys.client.shared.model.Data; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 /** |
1590
4b773cfd11b5
Refactoring to ease code-reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1586
diff
changeset
|
12 * This UIProvider creates a widget to enter a single location (km). |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 public class SingleLocationPanel |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
15 extends MultipleLocationPanel |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 /** |
2897
133820d1e6bf
cosmetic.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1617
diff
changeset
|
18 * Creates a new SingleLocationPanel instance. |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 public SingleLocationPanel() { |
1590
4b773cfd11b5
Refactoring to ease code-reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1586
diff
changeset
|
21 picker = new LocationPicker(this); |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
25 /** Overridden to restrict to one entered value. */ |
1586
dbdf954dbe94
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1585
diff
changeset
|
26 @Override |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
27 public List<String> validate() { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
28 List<String> errors = new ArrayList<String>(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
29 NumberFormat nf = NumberFormat.getDecimalFormat(); |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
31 saveLocationValues(locationPanel); |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
33 if (!locationPanel.validateForm()) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
34 errors.add(MSG.wrongFormat()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
35 return errors; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
36 } |
519
77234b1d009c
ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
284
diff
changeset
|
37 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
38 double[] values = getLocationValues(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
39 double[] good = new double[values.length]; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
40 int idx = 0; |
1590
4b773cfd11b5
Refactoring to ease code-reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1586
diff
changeset
|
41 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
42 // We want just one value to be allowed. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
43 if (values.length > 1) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
44 errors.add(MSG.too_many_values()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
45 } |
1590
4b773cfd11b5
Refactoring to ease code-reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1586
diff
changeset
|
46 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
47 for (double value: values) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
48 if (value < min || value > max) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
49 String tmp = MSG.error_validate_range(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
50 tmp = tmp.replace("$1", nf.format(value)); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
51 tmp = tmp.replace("$2", nf.format(min)); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
52 tmp = tmp.replace("$3", nf.format(max)); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
53 errors.add(tmp); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
54 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
55 else { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
56 good[idx++] = value; |
1590
4b773cfd11b5
Refactoring to ease code-reuse.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1586
diff
changeset
|
57 } |
519
77234b1d009c
ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
284
diff
changeset
|
58 } |
77234b1d009c
ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
284
diff
changeset
|
59 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
60 double[] justGood = new double[idx]; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
61 for (int i = 0; i < justGood.length; i++) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
62 justGood[i] = good[i]; |
563
469528551b78
Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
522
diff
changeset
|
63 } |
469528551b78
Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
522
diff
changeset
|
64 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
65 if (!errors.isEmpty()) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
66 locationPanel.setValues(justGood); |
519
77234b1d009c
ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
284
diff
changeset
|
67 } |
1591
8ab010967f78
Refactored.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1590
diff
changeset
|
68 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
69 return errors; |
1591
8ab010967f78
Refactored.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1590
diff
changeset
|
70 } |
8ab010967f78
Refactored.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1590
diff
changeset
|
71 |
8ab010967f78
Refactored.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1590
diff
changeset
|
72 |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 /** |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 * This method returns the selected data. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 * |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 * @return the selected/inserted data. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 public Data[] getData() { |
242
f9ca49e59fb6
Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
238
diff
changeset
|
79 saveLocationValues(locationPanel); |
1617
f13a7c126f24
Allow selection of multiple locations with mouse in MultipleLocationPanel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
80 double[] values = getLocationValues(); |
1387
3cbc7fbfff0e
Set attribute 'ld_mode' in appropiate UIProviders.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
907
diff
changeset
|
81 Data[] data = new Data[values.length+1]; |
1586
dbdf954dbe94
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1585
diff
changeset
|
82 |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 for (int i = 0; i < values.length; i++) { |
1593
ff9d71469b7c
Adjusted to be able to feed data to reference curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1591
diff
changeset
|
84 data[i] = createDataArray(getDataItemName(), |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 Double.valueOf(values[i]).toString()); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 } |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1594
diff
changeset
|
87 |
1586
dbdf954dbe94
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1585
diff
changeset
|
88 data[values.length] = createDataArray("ld_mode", "locations"); |
1387
3cbc7fbfff0e
Set attribute 'ld_mode' in appropiate UIProviders.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
907
diff
changeset
|
89 |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 return data; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |