comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java @ 4184:03de5c424f95

Fix warnings and minor TODOs in flys-client.
author Christian Lins <christian.lins@intevation.de>
date Fri, 19 Oct 2012 09:29:57 +0200
parents 091397efaca5
children 480de0dbca8e
comparison
equal deleted inserted replaced
4183:1755a1bfe5ce 4184:03de5c424f95
1 package de.intevation.flys.client.client.ui; 1 package de.intevation.flys.client.client.ui;
2
3 import java.util.ArrayList;
4 import java.util.List;
5 2
6 import com.google.gwt.core.client.GWT; 3 import com.google.gwt.core.client.GWT;
7 import com.google.gwt.i18n.client.NumberFormat; 4 import com.google.gwt.i18n.client.NumberFormat;
8 5
6 import com.smartgwt.client.data.Record;
9 import com.smartgwt.client.util.SC; 7 import com.smartgwt.client.util.SC;
10 import com.smartgwt.client.widgets.Canvas; 8 import com.smartgwt.client.widgets.Canvas;
11 import com.smartgwt.client.widgets.Label; 9 import com.smartgwt.client.widgets.Label;
10 import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
12 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; 11 import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
13 import com.smartgwt.client.widgets.form.fields.events.BlurEvent; 12 import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
14 13 import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
15 import com.smartgwt.client.widgets.layout.HLayout; 14 import com.smartgwt.client.widgets.layout.HLayout;
16 import com.smartgwt.client.widgets.layout.VLayout; 15 import com.smartgwt.client.widgets.layout.VLayout;
17 16
18 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; 17 import de.intevation.flys.client.client.Config;
19 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; 18 import de.intevation.flys.client.client.services.DistanceInfoService;
20 19 import de.intevation.flys.client.client.services.DistanceInfoServiceAsync;
21 import com.smartgwt.client.data.Record; 20 import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource;
22 21 import de.intevation.flys.client.shared.DoubleUtils;
23 import de.intevation.flys.client.shared.model.ArtifactDescription; 22 import de.intevation.flys.client.shared.model.ArtifactDescription;
24 import de.intevation.flys.client.shared.model.Data; 23 import de.intevation.flys.client.shared.model.Data;
25 import de.intevation.flys.client.shared.model.DataItem; 24 import de.intevation.flys.client.shared.model.DataItem;
26 import de.intevation.flys.client.shared.model.DataList; 25 import de.intevation.flys.client.shared.model.DataList;
27 import de.intevation.flys.client.shared.model.DistanceInfoObject; 26 import de.intevation.flys.client.shared.model.DistanceInfoObject;
28 import de.intevation.flys.client.shared.DoubleUtils;
29 import de.intevation.flys.client.shared.model.RangeData; 27 import de.intevation.flys.client.shared.model.RangeData;
30 28
31 import de.intevation.flys.client.client.services.DistanceInfoService; 29 import java.util.ArrayList;
32 import de.intevation.flys.client.client.services.DistanceInfoServiceAsync; 30 import java.util.List;
33 import de.intevation.flys.client.client.Config;
34 import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource;
35 31
36 32
37 /** 33 /**
38 * This UIProvider creates a widget to enter a single location (km). 34 * This UIProvider creates a widget to enter a single location (km).
39 * 35 *
41 */ 37 */
42 public class MultipleLocationPanel 38 public class MultipleLocationPanel
43 extends LocationPanel 39 extends LocationPanel
44 implements RecordClickHandler 40 implements RecordClickHandler
45 { 41 {
42 private static final long serialVersionUID = -3359966826794082718L;
43
46 /** The DistanceInfoService used to retrieve locations about rivers. */ 44 /** The DistanceInfoService used to retrieve locations about rivers. */
47 protected DistanceInfoServiceAsync distanceInfoService = 45 protected DistanceInfoServiceAsync distanceInfoService =
48 GWT.create(DistanceInfoService.class); 46 GWT.create(DistanceInfoService.class);
49 47
50 /** The table data. */ 48 /** The table data. */
111 * This method reads the default values defined in the DataItems of the Data 109 * This method reads the default values defined in the DataItems of the Data
112 * objects in <i>list</i>. 110 * objects in <i>list</i>.
113 * 111 *
114 * @param list The DataList container that stores the Data objects. 112 * @param list The DataList container that stores the Data objects.
115 */ 113 */
114 @Override
116 protected void initDefaults(DataList list) { 115 protected void initDefaults(DataList list) {
117 Data data = list.get(0); 116 Data data = list.get(0);
118 117
119 // Compatibility with MinMax- DataItems: 118 // Compatibility with MinMax- DataItems:
120 RangeData rangeData = null; 119 RangeData rangeData = null;
161 } 160 }
162 } 161 }
163 } 162 }
164 163
165 164
165 @Override
166 protected Canvas createWidget(DataList data) { 166 protected Canvas createWidget(DataList data) {
167 VLayout layout = new VLayout(); 167 VLayout layout = new VLayout();
168 inputLayout = new HLayout(); 168 inputLayout = new HLayout();
169 169
170 // The initial view will display the location input mode. 170 // The initial view will display the location input mode.
171 locationPanel = new DoubleArrayPanel( 171 locationPanel = new DoubleArrayPanel(
172 MSG.unitLocation(), 172 MSG.unitLocation(),
173 getLocationValues(), 173 getLocationValues(),
174 new BlurHandler(){public void onBlur(BlurEvent be) {validate();}}); 174 new BlurHandler(){@Override
175 public void onBlur(BlurEvent be) {validate();}});
175 176
176 picker.getLocationTable().setAutoFetchData(true); 177 picker.getLocationTable().setAutoFetchData(true);
177 178
178 inputLayout.addMember(locationPanel); 179 inputLayout.addMember(locationPanel);
179 180
247 /** 248 /**
248 * This method returns the selected data (to feed). 249 * This method returns the selected data (to feed).
249 * 250 *
250 * @return the selected/inserted data in feedable form. 251 * @return the selected/inserted data in feedable form.
251 */ 252 */
253 @Override
252 public Data[] getData() { 254 public Data[] getData() {
253 saveLocationValues(locationPanel); 255 saveLocationValues(locationPanel);
254 double[] lValues = getLocationValues(); 256 double[] lValues = getLocationValues();
255 Data[] data = new Data[2]; 257 Data[] data = new Data[2];
256 boolean first = true; 258 boolean first = true;
312 /** 314 /**
313 * Callback when an item from the input helper was clicked. 315 * Callback when an item from the input helper was clicked.
314 * Set the respective km-value in the location value field. 316 * Set the respective km-value in the location value field.
315 * @param e event passed. 317 * @param e event passed.
316 */ 318 */
319 @Override
317 public void onRecordClick (RecordClickEvent e) { 320 public void onRecordClick (RecordClickEvent e) {
318 Record record = e.getRecord(); 321 Record record = e.getRecord();
319 double[] old = getLocationValues(); 322 double[] old = getLocationValues();
320 double[] selected = DoubleUtils.copyOf(old, old.length + 1); 323 double[] selected = DoubleUtils.copyOf(old, old.length + 1);
321 try { 324 try {
322 selected[old.length] = 325 selected[old.length] =
323 Double.parseDouble(record.getAttribute("from")); 326 Double.parseDouble(record.getAttribute("from"));
324 } 327 }
325 catch(NumberFormatException nfe) { 328 catch(NumberFormatException nfe) {
326 // Is there anything else to do here? 329 // Is there anything else to do here?
330 GWT.log(nfe.getMessage());
327 } 331 }
328 332
329 // compare reference location and target location. 333 // compare reference location and target location.
330 DataList[] ref = artifact.getArtifactDescription().getOldData(); 334 DataList[] ref = artifact.getArtifactDescription().getOldData();
331 String mode = ref[1].get(0).getStringValue(); 335 String mode = ref[1].get(0).getStringValue();

http://dive4elements.wald.intevation.org