Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java @ 1612:66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
flys-client/trunk@3979 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 08 Feb 2012 16:24:39 +0000 |
parents | |
children | 07c38d054f91 |
rev | line source |
---|---|
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client.ui; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
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:
diff
changeset
|
4 import java.util.List; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 import com.google.gwt.core.client.GWT; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 import com.google.gwt.i18n.client.NumberFormat; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 import com.smartgwt.client.util.SC; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 import com.smartgwt.client.widgets.Canvas; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import com.smartgwt.client.widgets.Label; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import com.smartgwt.client.widgets.form.fields.events.BlurEvent; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import com.smartgwt.client.widgets.layout.HLayout; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 import com.smartgwt.client.widgets.layout.VLayout; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 import com.smartgwt.client.data.Record; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.shared.model.ArtifactDescription; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.flys.client.shared.model.Data; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.client.shared.model.DataItem; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.flys.client.shared.model.DataList; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 import de.intevation.flys.client.shared.model.DistanceInfoObject; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 import de.intevation.flys.client.shared.model.RangeData; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 import de.intevation.flys.client.client.services.DistanceInfoService; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 import de.intevation.flys.client.client.services.DistanceInfoServiceAsync; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 import de.intevation.flys.client.client.Config; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 /** |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 * This UIProvider creates a widget to enter a single location (km). |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 * |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 public class MultipleLocationPanel |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 extends LocationPanel |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 implements RecordClickHandler |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 /** The DistanceInfoService used to retrieve locations about rivers. */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 protected DistanceInfoServiceAsync distanceInfoService = |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 GWT.create(DistanceInfoService.class); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 /** The table data. */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 protected DistanceInfoObject[] tableData; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 /** The input helper (usually right side, table to click on, values are |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 * then entered in the texfield. */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 protected LocationPicker picker; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 /** |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 * Creates a new LocationDistancePanel instance. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 public MultipleLocationPanel() { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 picker = new LocationPicker(this); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 /** |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 * This method creates a widget that contains a label, a panel with |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 * checkboxes to switch the input mode between location and distance input, |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 * and a mode specific panel. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 * |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 * @param data The data that might be inserted. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 * |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 * @return a panel. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 @Override |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 public Canvas create(DataList data) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 findDataItemName(data); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 VLayout layout = new VLayout(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 layout.setMembersMargin(10); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 Label label = new Label(MSG.location ()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 Canvas widget = createWidget(data); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 Canvas submit = getNextButton(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
83 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 initDefaults(data); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 picker.createLocationTable(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
87 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
88 widget.setHeight(50); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 label.setHeight(25); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
91 layout.addMember(label); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 layout.addMember(widget); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 layout.addMember(submit); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 return layout; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 /** |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 * This method reads the default values defined in the DataItems of the Data |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 * objects in <i>list</i>. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 * |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 * @param list The DataList container that stores the Data objects. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 protected void initDefaults(DataList list) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 Data data = list.get(0); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
108 // Compatibility with MinMax- DataItems: |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 RangeData rangeData = null; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
110 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
111 for (int i = 0, n = list.size(); i < n; i++) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
112 Data tmp = list.get(i); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
113 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
114 if (tmp instanceof RangeData) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
115 rangeData = (RangeData) tmp; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
116 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
118 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
119 if (rangeData != null) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
120 min = Double.parseDouble(rangeData.getDefaultLower().toString()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
121 max = Double.parseDouble(rangeData.getDefaultUpper().toString()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
122 // catch ..? |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
123 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
124 else { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
125 DataItem[] items = data.getItems(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
126 DataItem iMin = getDataItem(items, "min"); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
127 DataItem iMax = getDataItem(items, "max"); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
128 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
129 try { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 min = Double.parseDouble(iMin.getStringValue()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 max = Double.parseDouble(iMax.getStringValue()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
132 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
133 catch (NumberFormatException nfe) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 SC.warn(MSG.error_read_minmax_values()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
135 min = -Double.MAX_VALUE; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
136 max = Double.MAX_VALUE; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
137 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
138 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
139 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
140 DataItem def = data.getDefault(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
141 if (def != null) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 String value = def.getStringValue(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
143 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
144 try { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
145 double d = Double.parseDouble(value); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
146 setLocationValues(new double[] { d } ); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
147 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
148 catch (NumberFormatException nfe) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
149 // could not parse, dont know what to do else |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
150 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
151 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
152 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
153 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
154 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
155 protected Canvas createWidget(DataList data) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 VLayout layout = new VLayout(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
157 inputLayout = new HLayout(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
158 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
159 // The initial view will display the location input mode. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
160 locationPanel = new DoubleArrayPanel( |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
161 MSG.unitLocation(), |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
162 getLocationValues(), |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
163 new BlurHandler(){public void onBlur(BlurEvent be) {}}); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
164 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
165 picker.getLocationTable().setAutoFetchData(true); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
166 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
167 inputLayout.addMember(locationPanel); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
168 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
169 layout.addMember(inputLayout); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
170 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
171 inputLayout.setMembersMargin(30); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
172 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
173 picker.prepareFilter(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
174 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
175 helperContainer.addMember(picker.getLocationTable()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
176 helperContainer.addMember(picker.getFilterLayout()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
177 helperContainer.addMember(picker.getResultCountForm()); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
178 setPickerDataSource(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
179 return layout; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
180 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
181 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
182 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
183 /** Overridden to restrict to one entered value. */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
184 @Override |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
185 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:
diff
changeset
|
186 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:
diff
changeset
|
187 NumberFormat nf = NumberFormat.getDecimalFormat(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
188 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
189 saveLocationValues(locationPanel); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
190 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
191 if (!locationPanel.validateForm()) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
192 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:
diff
changeset
|
193 return errors; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
194 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
195 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
196 double[] values = getLocationValues(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
197 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:
diff
changeset
|
198 int idx = 0; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
199 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
200 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:
diff
changeset
|
201 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:
diff
changeset
|
202 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:
diff
changeset
|
203 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:
diff
changeset
|
204 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:
diff
changeset
|
205 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:
diff
changeset
|
206 errors.add(tmp); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
207 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
208 else { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
209 good[idx++] = value; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
210 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
211 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
212 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
213 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:
diff
changeset
|
214 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:
diff
changeset
|
215 justGood[i] = good[i]; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
216 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
217 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
218 if (!errors.isEmpty()) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
219 locationPanel.setValues(justGood); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
220 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
221 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
222 return errors; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
223 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
224 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
225 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
226 /** |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
227 * This method returns the selected data. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
228 * |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
229 * @return the selected/inserted data. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
230 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
231 public Data[] getData() { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
232 saveLocationValues(locationPanel); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
233 double[] values = getLocationValues(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
234 Data[] data = new Data[2]; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
235 boolean first = true; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
236 String valueString = ""; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
237 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
238 for (int i = 0; i < values.length; i++) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
239 if (!first) valueString += " "; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
240 else first = false; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
241 valueString += Double.valueOf(values[i]).toString(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
242 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
243 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
244 data[0] = createDataArray(getDataItemName(), valueString); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
245 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
246 data[1] = createDataArray("ld_mode", "locations"); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
247 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
248 return data; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
249 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
250 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
251 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
252 /** Hook service to the listgrid with possible input values. */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
253 protected void setPickerDataSource() { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
254 Config config = Config.getInstance(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
255 String url = config.getServerUrl(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
256 String river = ""; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
257 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
258 ArtifactDescription adescr = artifact.getArtifactDescription(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
259 DataList[] data = adescr.getOldData(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
260 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
261 // Try to find a "river" data item to set the source for the |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
262 // list grid. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
263 if (data != null && data.length > 0) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
264 for (int i = 0; i < data.length; i++) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
265 DataList dl = data[i]; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
266 if (dl.getState().equals("state.winfo.river") || |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
267 dl.getState().equals("state.chart.river")) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
268 for (int j = 0; j < dl.size(); j++) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
269 Data d = dl.get(j); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
270 DataItem[] di = d.getItems(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
271 if (di != null && di.length == 1) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
272 river = d.getItems()[0].getStringValue(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
273 break; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
274 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
275 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
276 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
277 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
278 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
279 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
280 picker.getLocationTable().setDataSource(new DistanceInfoDataSource( |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
281 url, river, "locations")); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
282 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
283 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
284 // TODO allow multiple selections here or in LocationPanel |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
285 /** |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
286 * Callback when an item from the input helper was clicked. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
287 * Set the respective km-value in the location value field. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
288 * @param e event passed. |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
289 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
290 public void onRecordClick (RecordClickEvent e) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
291 Record record = e.getRecord(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
292 double[] selected = new double[1]; |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
293 try { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
294 selected[0] = |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
295 Double.parseDouble(record.getAttribute("from")); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
296 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
297 catch(NumberFormatException nfe) { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
298 // Is there anything else to do here? |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
299 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
300 setLocationValues(selected); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
301 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
302 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
303 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |