Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java @ 284:be842e36ce1c
ISSUE 46: Removed the table header context menu.
flys-client/trunk@1913 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 12 May 2011 15:42:37 +0000 |
parents | f4c8ce11df33 |
children | 77234b1d009c |
rev | line source |
---|---|
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client.ui; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 import com.google.gwt.core.client.GWT; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import com.google.gwt.user.client.rpc.AsyncCallback; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import com.smartgwt.client.widgets.Canvas; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import com.smartgwt.client.widgets.Label; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import com.smartgwt.client.widgets.form.fields.events.BlurEvent; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import com.smartgwt.client.widgets.form.fields.FormItem; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import com.smartgwt.client.widgets.layout.HLayout; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 import com.smartgwt.client.widgets.layout.VLayout; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import com.smartgwt.client.widgets.grid.ListGrid; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 import com.smartgwt.client.widgets.grid.ListGridField; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 import com.smartgwt.client.widgets.grid.ListGridRecord; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 import com.smartgwt.client.types.ListGridFieldType; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.shared.model.Data; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.flys.client.shared.model.DataItem; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.client.shared.model.DataList; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.flys.client.shared.model.DefaultData; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 import de.intevation.flys.client.shared.model.DefaultDataItem; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 import de.intevation.flys.client.shared.model.DistanceInfoObject; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 import de.intevation.flys.client.shared.model.DistanceInfoRecord; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 import de.intevation.flys.client.shared.model.ArtifactDescription; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 import de.intevation.flys.client.client.services.DistanceInfoService; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 import de.intevation.flys.client.client.services.DistanceInfoServiceAsync; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 import de.intevation.flys.client.client.FLYSConstants; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 import de.intevation.flys.client.client.FLYSImages; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 import de.intevation.flys.client.client.Config; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 /** |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 * This UIProvider creates a widget to enter locations. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 * |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 public class SingleLocationPanel |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 extends AbstractUIProvider |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 /** The message class that provides i18n strings.*/ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 /** The interface that provides the image resources. */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 private FLYSImages IMAGES = GWT.create(FLYSImages.class); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 /** The DistanceInfoService used to retrieve locations about rivers.*/ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 protected DistanceInfoServiceAsync distanceInfoService = |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 GWT.create(DistanceInfoService.class); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 /** A container that will contain the location or the distance panel.*/ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 protected HLayout container; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 /** The values entered in the location mode.*/ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 protected double[] values; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 /** The input panel for locations */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 protected DoubleArrayPanel locationPanel; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 /** The locations table */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 protected ListGrid locationTable; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 /** The table data. */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 protected DistanceInfoObject[] tableData; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 /** |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 * Creates a new LocationDistancePanel instance. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 public SingleLocationPanel() { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 locationTable = new ListGrid(); |
284
be842e36ce1c
ISSUE 46: Removed the table header context menu.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
276
diff
changeset
|
77 locationTable.setShowHeaderContextMenu(false); |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 /** |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 * This method creates a widget that contains a label, a panel with |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 * checkboxes to switch the input mode between location and distance input, |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 * and a the mode specific panel. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 * |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 * @param data The data that might be inserted. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 * |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 * @return a panel. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 public Canvas create(DataList data) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 VLayout layout = new VLayout(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 layout.setMembersMargin(10); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 initDefaults(data); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 Label label = new Label(MESSAGES.location ()); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 Canvas widget = createWidget(data); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 Canvas submit = getNextButton(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 createLocationTable(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 widget.setHeight(50); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 label.setHeight(25); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 layout.addMember(label); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 layout.addMember(widget); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 layout.addMember(submit); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 return layout; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 /** |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 * This method creates a table that contains the location values. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 protected void createLocationTable() { |
272
d3c053420c3b
ISSUE 44: Moved the location/range and WQ input tables to the helper panel and
Raimund Renkert <raimund.renkert@intevation.de>
parents:
268
diff
changeset
|
117 locationTable.setWidth100(); |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 locationTable.setShowRecordComponents(true); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 locationTable.setShowRecordComponentsByCell(true); |
272
d3c053420c3b
ISSUE 44: Moved the location/range and WQ input tables to the helper panel and
Raimund Renkert <raimund.renkert@intevation.de>
parents:
268
diff
changeset
|
120 locationTable.setHeight100(); |
268
eb3f9b6496a5
ISSUE-57 Replaced wrong i18n function call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
263
diff
changeset
|
121 locationTable.setEmptyMessage(MESSAGES.empty_table()); |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 ListGridField addLocation = new ListGridField ("", ""); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 addLocation.setType (ListGridFieldType.ICON); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 addLocation.setWidth ("30"); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 addLocation.addRecordClickHandler (new RecordClickHandler () { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 public void onRecordClick (RecordClickEvent e) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 ListGridRecord[] records = locationTable.getSelection(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 double[] selected = new double[1]; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 selected[0] = records[0].getAttributeAsDouble("from"); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 setLocationValues(selected); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 }); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 addLocation.setCellIcon (IMAGES.markerGreen ().getURL ()); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 ListGridField ldescr = new ListGridField("description", |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 MESSAGES.description()); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 ldescr.setType(ListGridFieldType.TEXT); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 ldescr.setWidth("*"); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 ListGridField lside = new ListGridField("riverside", |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 MESSAGES.riverside()); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 lside.setType(ListGridFieldType.TEXT); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 lside.setWidth(60); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 ListGridField loc = new ListGridField("from", MESSAGES.location()); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 loc.setType(ListGridFieldType.TEXT); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
146 loc.setWidth(80); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 locationTable.setFields(addLocation, ldescr, loc, lside); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 public Canvas createOld(DataList dataList) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 List<Data> items = dataList.getAll(); |
242
f9ca49e59fb6
Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
238
diff
changeset
|
153 Data dLocation = getData(items, "ld_locations"); |
f9ca49e59fb6
Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
238
diff
changeset
|
154 DataItem[] loc = dLocation.getItems(); |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 HLayout layout = new HLayout(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 layout.setWidth("400px"); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 Label label = new Label(dataList.getLabel()); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 label.setWidth("200px"); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 Canvas back = getBackButton(dataList.getState()); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 |
242
f9ca49e59fb6
Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
238
diff
changeset
|
164 Label selected = new Label(loc[0].getLabel()); |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 selected.setWidth("130px"); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 layout.addMember(label); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 layout.addMember(selected); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 layout.addMember(back); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 return layout; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 /** |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 * This method reads the default values defined in the DataItems of the Data |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 * objects in <i>list</i>. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 * |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
179 * @param list The DataList container that stores the Data objects. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
181 protected void initDefaults(DataList list) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
183 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
184 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
185 /** |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
186 * This method greps the Data with name <i>name</i> from the list and |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
187 * returns it. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 * |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 * @param items A list of Data. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 * @param name The name of the Data that we are searching for. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 * |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
192 * @return the Data with the name <i>name</i>. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 protected Data getData(List<Data> data, String name) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 for (Data d: data) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 if (name.equals(d.getLabel())) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
197 return d; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
199 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 return null; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
203 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
204 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
205 protected Canvas createWidget(DataList data) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
206 VLayout layout = new VLayout(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
207 container = new HLayout(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
208 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
209 // the initial view will display the location input mode |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
210 locationPanel = new DoubleArrayPanel( |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
211 MESSAGES.unitLocation(), |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
212 getLocationValues(), |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
213 new BlurHandler(){public void onBlur(BlurEvent be) {}}); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
214 container.addMember(locationPanel); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
215 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
216 layout.addMember(container); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
217 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
218 container.setMembersMargin(30); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
219 |
272
d3c053420c3b
ISSUE 44: Moved the location/range and WQ input tables to the helper panel and
Raimund Renkert <raimund.renkert@intevation.de>
parents:
268
diff
changeset
|
220 helperContainer.addChild(locationTable); |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
221 createInputPanel(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
222 return layout; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
223 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
224 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
225 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
226 /** |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
227 * This method returns the selected data. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
228 * |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
229 * @return the selected/inserted data. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
230 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
231 public Data[] getData() { |
242
f9ca49e59fb6
Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
238
diff
changeset
|
232 saveLocationValues(locationPanel); |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
233 double[] values = getLocationValues(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
234 Data[] data = new Data[values.length]; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
235 DataItem item = new DefaultDataItem(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
236 for (int i = 0; i < values.length; i++) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
237 item = new DefaultDataItem( |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
238 "ld_locations", |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
239 "ld_locations", |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
240 Double.valueOf(values[i]).toString()); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
241 data[i] = new DefaultData( |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
242 "ld_locations", |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
243 null, |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
244 null, |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
245 new DataItem[] {item}); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
246 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
247 return data; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
248 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
249 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
250 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
251 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
252 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
253 /** |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
254 * Validates and stores all values entered in the location mode. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
255 * |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
256 * @param p The DoubleArrayPanel. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
257 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
258 protected void saveLocationValues(DoubleArrayPanel p) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
259 FormItem[] formItems = p.getFields(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
260 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
261 for (FormItem item: formItems) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
262 if (item.getFieldName().equals(DoubleArrayPanel.FIELD_NAME)) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
263 saveLocationValue(p, item); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
264 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
265 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
266 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
267 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
268 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
269 /** |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
270 * Validates and stores a value entered in the location mode. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
271 * |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
272 * @param p The DoubleArrayPanel. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
273 * @param item The item that needs to be validated. |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
274 */ |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
275 protected void saveLocationValue(DoubleArrayPanel p, FormItem item) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
276 if (p.validateForm(item)) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
277 setLocationValues(p.getInputValues(item)); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
278 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
279 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
280 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
281 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
282 protected void createInputPanel() { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
283 Config config = Config.getInstance(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
284 String url = config.getServerUrl(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
285 String locale = config.getLocale (); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
286 String river = ""; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
287 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
288 ArtifactDescription adescr = artifact.getArtifactDescription(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
289 DataList[] data = adescr.getOldData(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
290 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
291 if (data != null && data.length > 0) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
292 for (int i = 0; i < data.length; i++) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
293 DataList dl = data[i]; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
294 if (dl.getState().equals("state.winfo.river")) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
295 for (int j = 0; j < dl.size(); j++) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
296 Data d = dl.get(j); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
297 DataItem[] di = d.getItems(); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
298 if (di != null && di.length == 1) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
299 river = d.getItems()[0].getStringValue(); |
276
f4c8ce11df33
UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
272
diff
changeset
|
300 break; |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
301 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
302 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
303 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
304 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
305 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
306 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
307 distanceInfoService.getDistanceInfo(url, locale, river, |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
308 new AsyncCallback<DistanceInfoObject[]>() { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
309 public void onFailure(Throwable caught) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
310 GWT.log("Could not recieve location informations."); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
311 GWT.log(caught.getMessage()); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
312 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
313 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
314 public void onSuccess(DistanceInfoObject[] di) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
315 int num = di != null ? di.length :0; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
316 GWT.log("Recieved " + num + " location informations."); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
317 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
318 if (num == 0) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
319 return; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
320 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
321 tableData = di; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
322 updateLocationInfo(di); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
323 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
324 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
325 ); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
326 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
327 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
328 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
329 protected void updateLocationInfo(DistanceInfoObject[] di) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
330 int i = 0; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
331 for (DistanceInfoObject dio: di) { |
242
f9ca49e59fb6
Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
238
diff
changeset
|
332 if (dio.getTo() == null) { |
238
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
333 locationTable.addData(new DistanceInfoRecord(dio)); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
334 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
335 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
336 return; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
337 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
338 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
339 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
340 protected double[] getLocationValues() { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
341 return values; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
342 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
343 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
344 |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
345 protected void setLocationValues(double[] values) { |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
346 this.values = values; |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
347 locationPanel.setValues(values); |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
348 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
349 } |
234c78a91c15
Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
350 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |