annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java @ 4221:480de0dbca8e

Extended location input helper. The locationpicker has now an attribute whether the input is distance or location to display one or two clickable columns. Replaced the record click handler with cell click handler.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 23 Oct 2012 13:17:20 +0200
parents 03de5c424f95
children e70ff0a600a3
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 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
4 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
5
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
6 import com.smartgwt.client.data.Record;
1612
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.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
8 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
9 import com.smartgwt.client.widgets.Label;
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
10 import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
1612
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.form.fields.events.BlurHandler;
4221
480de0dbca8e Extended location input helper.
Raimund Renkert <rrenkert@intevation.de>
parents: 4184
diff changeset
12 import com.smartgwt.client.widgets.grid.events.CellClickEvent;
480de0dbca8e Extended location input helper.
Raimund Renkert <rrenkert@intevation.de>
parents: 4184
diff changeset
13 import com.smartgwt.client.widgets.grid.events.CellClickHandler;
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 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
15 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
16
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
17 import de.intevation.flys.client.client.Config;
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
18 import de.intevation.flys.client.client.services.DistanceInfoService;
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
19 import de.intevation.flys.client.client.services.DistanceInfoServiceAsync;
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
20 import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource;
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
21 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
22 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
23 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
24 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
25 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
26 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
27 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
28
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
29 import java.util.ArrayList;
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
30 import java.util.List;
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 /**
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 * 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
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 * @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
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 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
39 extends LocationPanel
4221
480de0dbca8e Extended location input helper.
Raimund Renkert <rrenkert@intevation.de>
parents: 4184
diff changeset
40 implements CellClickHandler
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 {
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
42 private static final long serialVersionUID = -3359966826794082718L;
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
43
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 /** 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
45 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
46 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
47
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 /** 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
49 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
50
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 /** 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
52 * 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
53 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
54
1615
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
55
1612
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
1615
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
80 // 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
81 String labelString;
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
82 try {
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
83 labelString = MSG.getString(getDataItemName());
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
84 }
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
85 catch(java.util.MissingResourceException mre) {
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
86 GWT.log("Cannot find translation for data item name : " + getDataItemName());
3493
e703555f8da1 Issue 752.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2905
diff changeset
87 labelString = getLabelString();
1615
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
88 }
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
89 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
90 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
91 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
92
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
93 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
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 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
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 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
98 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
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 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
101 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
102 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
103
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
104 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
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
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 * 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
110 * 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
111 *
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
112 * @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
113 */
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
114 @Override
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
115 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
116 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
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 // 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
119 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
120
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 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
122 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
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 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
125 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
126 }
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 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
130 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
131 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
132 // catch ..?
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
133 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
134 else {
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
135 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
136 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
137 DataItem iMax = getDataItem(items, "max");
2905
51ed89b754ae FLYS client: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2898
diff changeset
138
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
139 try {
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
140 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
141 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
142 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
143 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
144 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
145 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
146 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
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 }
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 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
151 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
152 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
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 try {
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
155 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
156 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
157 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
158 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
159 // 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
160 }
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
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
165 @Override
1612
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(),
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
174 new BlurHandler(){@Override
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
175 public void onBlur(BlurEvent be) {validate();}});
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
176
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
177 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
178
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
179 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
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 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
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 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
184
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
185 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
186
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.getLocationTable());
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.getFilterLayout());
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
189 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
190 setPickerDataSource();
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
191 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
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
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
195 /** 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
196 @Override
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
197 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
198 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
199 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
200
3539
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
201 DataList[] ref = artifact.getArtifactDescription().getOldData();
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
202 String mode = ref[1].get(0).getStringValue();
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
203
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
204 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
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 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
207 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
208 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
209 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
210
1618
95b821d63db3 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1617
diff changeset
211 double[] lValues = getLocationValues();
95b821d63db3 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1617
diff changeset
212 double[] good = new double[lValues.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
213 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
214
3539
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
215 double reference =
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
216 Double.valueOf(ref[2].get(0).getStringValue()).doubleValue();
1618
95b821d63db3 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1617
diff changeset
217 for (double value: lValues) {
3539
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
218 if (mode.equals("calc.reference.curve") &&
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
219 value == reference) {
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
220 errors.add(MSG.error_contains_same_location());
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
221 return errors;
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
222 }
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
223 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
224 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
225 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
226 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
227 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
228 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
229 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
230 else {
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
231 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
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 }
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 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
236 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
237 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
238 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
239
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
240 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
241 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
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 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
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
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 /**
1615
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
249 * 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
250 *
1615
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
251 * @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
252 */
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
253 @Override
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
254 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
255 saveLocationValues(locationPanel);
1618
95b821d63db3 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1617
diff changeset
256 double[] lValues = getLocationValues();
1612
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[] 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
258 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
259 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
260
1618
95b821d63db3 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1617
diff changeset
261 for (int i = 0; i < lValues.length; i++) {
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
262 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
263 else first = false;
1618
95b821d63db3 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1617
diff changeset
264 valueString += Double.valueOf(lValues[i]).toString();
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
265 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
266
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
267 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
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 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
270
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
271 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
272 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
273
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 /** 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
276 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
277 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
278 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
279 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
280
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
281 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
282 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
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 // 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
285 // list grid.
2898
242b5c230707 Added UI for S-Q-relation parameters in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1618
diff changeset
286 String dataFilter = "locations";
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
287 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
288 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
289 DataList dl = data[i];
2898
242b5c230707 Added UI for S-Q-relation parameters in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1618
diff changeset
290 if (dl.getState().equals("state.minfo.river")) {
242b5c230707 Added UI for S-Q-relation parameters in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1618
diff changeset
291 dataFilter = "measuringpoint";
242b5c230707 Added UI for S-Q-relation parameters in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1618
diff changeset
292 }
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
293 if (dl.getState().equals("state.winfo.river") ||
2898
242b5c230707 Added UI for S-Q-relation parameters in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1618
diff changeset
294 dl.getState().equals("state.chart.river") ||
242b5c230707 Added UI for S-Q-relation parameters in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1618
diff changeset
295 dl.getState().equals("state.minfo.river")) {
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 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
297 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
298 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
299 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
300 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
301 break;
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 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
304 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
305 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
306 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
307
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
308 picker.getLocationTable().setDataSource(new DistanceInfoDataSource(
2898
242b5c230707 Added UI for S-Q-relation parameters in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1618
diff changeset
309 url, river, dataFilter));
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
310 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
311
1615
07c38d054f91 Translate data item in locationpanel label.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1612
diff changeset
312
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
313 // 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
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 * 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
316 * 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
317 * @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
318 */
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
319 @Override
4221
480de0dbca8e Extended location input helper.
Raimund Renkert <rrenkert@intevation.de>
parents: 4184
diff changeset
320 public void onCellClick (CellClickEvent e) {
1617
f13a7c126f24 Allow selection of multiple locations with mouse in MultipleLocationPanel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1615
diff changeset
321 Record record = e.getRecord();
f13a7c126f24 Allow selection of multiple locations with mouse in MultipleLocationPanel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1615
diff changeset
322 double[] old = getLocationValues();
f13a7c126f24 Allow selection of multiple locations with mouse in MultipleLocationPanel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1615
diff changeset
323 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
324 try {
1617
f13a7c126f24 Allow selection of multiple locations with mouse in MultipleLocationPanel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1615
diff changeset
325 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
326 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
327 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
328 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
329 // Is there anything else to do here?
4184
03de5c424f95 Fix warnings and minor TODOs in flys-client.
Christian Lins <christian.lins@intevation.de>
parents: 3539
diff changeset
330 GWT.log(nfe.getMessage());
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
331 }
3539
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
332
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
333 // compare reference location and target location.
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
334 DataList[] ref = artifact.getArtifactDescription().getOldData();
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
335 String mode = ref[1].get(0).getStringValue();
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
336 if (mode.equals("calc.reference.curve") &&
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
337 ref[2].get(0).getStringValue().equals(record.getAttribute("from")))
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
338 {
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
339 SC.warn(MSG.error_same_location());
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
340 return;
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
341 }
091397efaca5 Issue 791: Do not allow the same values in reference and target location.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3493
diff changeset
342
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
343 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
344 }
3493
e703555f8da1 Issue 752.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2905
diff changeset
345
e703555f8da1 Issue 752.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2905
diff changeset
346 /**
e703555f8da1 Issue 752.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2905
diff changeset
347 * Returns the label string for the input panel.
e703555f8da1 Issue 752.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2905
diff changeset
348 */
e703555f8da1 Issue 752.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2905
diff changeset
349 protected String getLabelString() {
e703555f8da1 Issue 752.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2905
diff changeset
350 return MSG.location();
e703555f8da1 Issue 752.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2905
diff changeset
351 }
e703555f8da1 Issue 752.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2905
diff changeset
352
1612
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
353 }
66671b69c7ea Added new UIProvider to enter mutliple locations (yet only input view textfield possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
354 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org