Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java @ 1617:f13a7c126f24
Allow selection of multiple locations with mouse in MultipleLocationPanel.
flys-client/trunk@3986 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 09 Feb 2012 09:52:37 +0000 |
parents | 07c38d054f91 |
children | 95b821d63db3 |
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; |
1617
f13a7c126f24
Allow selection of multiple locations with mouse in MultipleLocationPanel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1615
diff
changeset
|
28 import de.intevation.flys.client.shared.DoubleUtils; |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 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
|
30 |
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.DistanceInfoService; |
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.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
|
33 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
|
34 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
|
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 /** |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 * 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
|
39 * |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 * @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
|
41 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 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
|
43 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
|
44 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
|
45 { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 /** 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
|
47 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
|
48 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
|
49 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 /** 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
|
51 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
|
52 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 /** 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
|
54 * 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
|
55 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
|
56 |
1615
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
57 |
1612
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 * 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
|
60 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 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
|
62 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
|
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 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 /** |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 * 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
|
68 * 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
|
69 * 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
|
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 * @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
|
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 * @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
|
74 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 @Override |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 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
|
77 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
|
78 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 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
|
80 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
|
81 |
1615
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
82 // Take translated data item name as label, if translation available. |
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
83 String labelString; |
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
84 try { |
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
85 labelString = MSG.getString(getDataItemName()); |
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
86 } |
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
87 catch(java.util.MissingResourceException mre) { |
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
88 GWT.log("Cannot find translation for data item name : " + getDataItemName()); |
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
89 labelString = MSG.location(); |
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
90 } |
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
91 Label label = new Label(labelString); |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 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
|
93 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
|
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 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
|
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 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
|
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 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
|
100 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
|
101 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 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
|
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 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 |
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 * 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
|
112 * 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
|
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 * @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
|
115 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
116 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
|
117 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
|
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 // 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
|
120 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
|
121 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
122 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
|
123 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
|
124 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
125 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
|
126 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
|
127 } |
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 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 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
|
131 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
|
132 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
|
133 // catch ..? |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
135 else { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
136 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
|
137 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
|
138 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
|
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 try { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
141 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
|
142 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
|
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 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
|
145 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
|
146 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
|
147 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
|
148 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
149 } |
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 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
|
152 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
|
153 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
|
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 try { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 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
|
157 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
|
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 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
|
160 // 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
|
161 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
162 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
163 } |
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 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
166 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
|
167 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
|
168 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
|
169 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
170 // 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
|
171 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
|
172 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
|
173 getLocationValues(), |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
174 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
|
175 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
176 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
|
177 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
178 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
|
179 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
180 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
|
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 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
|
183 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
184 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
|
185 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
186 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
|
187 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
|
188 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
|
189 setPickerDataSource(); |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
190 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
|
191 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
192 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
193 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
194 /** 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
|
195 @Override |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
196 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
|
197 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
|
198 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
|
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 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
|
201 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
202 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
|
203 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
|
204 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
|
205 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
206 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
207 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
|
208 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
|
209 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
|
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 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
219 else { |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
220 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
|
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 } |
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 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
|
225 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
|
226 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
|
227 } |
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 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
|
230 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
|
231 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
232 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
233 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
|
234 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
235 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
236 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
237 /** |
1615
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
238 * This method returns the selected data (to feed). |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
239 * |
1615
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
240 * @return the selected/inserted data in feedable form. |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
241 */ |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 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
|
248 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
249 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
|
250 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
|
251 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
|
252 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
|
253 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
254 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
255 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
|
256 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
257 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
|
258 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
259 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
|
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 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
262 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
263 /** 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
269 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
|
270 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
|
271 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
272 // 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
|
273 // 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
|
274 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
|
275 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
|
276 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
|
277 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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 break; |
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 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
287 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
288 } |
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 |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
291 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
|
292 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
|
293 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
294 |
1615
07c38d054f91
Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1612
diff
changeset
|
295 |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
296 // 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
|
297 /** |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
298 * 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
|
299 * 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
|
300 * @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
|
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 public void onRecordClick (RecordClickEvent e) { |
1617
f13a7c126f24
Allow selection of multiple locations with mouse in MultipleLocationPanel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1615
diff
changeset
|
303 Record record = e.getRecord(); |
f13a7c126f24
Allow selection of multiple locations with mouse in MultipleLocationPanel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1615
diff
changeset
|
304 double[] old = getLocationValues(); |
f13a7c126f24
Allow selection of multiple locations with mouse in MultipleLocationPanel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1615
diff
changeset
|
305 double[] selected = DoubleUtils.copyOf(old, old.length + 1); |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
306 try { |
1617
f13a7c126f24
Allow selection of multiple locations with mouse in MultipleLocationPanel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1615
diff
changeset
|
307 selected[old.length] = |
1612
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
308 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
|
309 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
310 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
|
311 // 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
|
312 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
313 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
|
314 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
315 } |
66671b69c7ea
Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
316 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |