annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java @ 563:469528551b78

Introduced an input validation for the location panels. flys-client/trunk@2104 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 14 Jun 2011 10:42:34 +0000
parents 2e02db03e576
children 1d20533a4ae3
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
563
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
3 import java.util.ArrayList;
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 import java.util.List;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 import com.google.gwt.core.client.GWT;
563
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
7 import com.google.gwt.i18n.client.NumberFormat;
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 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
9
563
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
10 import com.smartgwt.client.util.SC;
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import com.smartgwt.client.widgets.Canvas;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 import com.smartgwt.client.widgets.Label;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 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
14 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
15 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
16 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
17 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
18 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
19 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
20 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
21 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
22 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
23
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 import com.smartgwt.client.types.ListGridFieldType;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25
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.Data;
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.DataItem;
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.DataList;
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.DefaultData;
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.DefaultDataItem;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 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
32 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
33 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
34
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.services.DistanceInfoService;
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.services.DistanceInfoServiceAsync;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 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
38 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
39 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
40
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 /**
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 * 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
44 *
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 * @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
46 */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 public class SingleLocationPanel
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 extends AbstractUIProvider
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 message class that provides i18n strings.*/
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 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
52
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 /** 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
54 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
55
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 /** 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
57 protected DistanceInfoServiceAsync distanceInfoService =
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 GWT.create(DistanceInfoService.class);
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 /** 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
61 protected HLayout container;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62
563
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
63 /** The minimal value that the user is allowed to enter.*/
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
64 protected double min;
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
65
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
66 /** The maximal value that the user is allowed to enter.*/
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
67 protected double max;
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
68
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 /** 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
70 protected double[] values;
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 /** The input panel for locations */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 protected DoubleArrayPanel locationPanel;
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 /** The locations table */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 protected ListGrid locationTable;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 /** The table data. */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 protected DistanceInfoObject[] tableData;
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 * Creates a new LocationDistancePanel instance.
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 public SingleLocationPanel() {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 locationTable = new ListGrid();
284
be842e36ce1c ISSUE 46: Removed the table header context menu.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 276
diff changeset
86 locationTable.setShowHeaderContextMenu(false);
238
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
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 /**
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 * 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
92 * 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
93 * and a the mode specific panel.
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 *
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 * @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
96 *
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 * @return a panel.
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 public Canvas create(DataList data) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 VLayout layout = new VLayout();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 layout.setMembersMargin(10);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 Label label = new Label(MESSAGES.location ());
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 Canvas widget = createWidget(data);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 Canvas submit = getNextButton();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106
519
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
107 initDefaults(data);
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
108
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 createLocationTable();
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 widget.setHeight(50);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 label.setHeight(25);
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 layout.addMember(label);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 layout.addMember(widget);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 layout.addMember(submit);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 return layout;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121
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 * 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
124 */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 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
126 locationTable.setWidth100();
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 locationTable.setShowRecordComponents(true);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 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
129 locationTable.setHeight100();
268
eb3f9b6496a5 ISSUE-57 Replaced wrong i18n function call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 263
diff changeset
130 locationTable.setEmptyMessage(MESSAGES.empty_table());
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 ListGridField addLocation = new ListGridField ("", "");
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 addLocation.setType (ListGridFieldType.ICON);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 addLocation.setWidth ("30");
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 addLocation.addRecordClickHandler (new RecordClickHandler () {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 public void onRecordClick (RecordClickEvent e) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 ListGridRecord[] records = locationTable.getSelection();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 double[] selected = new double[1];
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 selected[0] = records[0].getAttributeAsDouble("from");
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 setLocationValues(selected);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 });
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 addLocation.setCellIcon (IMAGES.markerGreen ().getURL ());
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 ListGridField ldescr = new ListGridField("description",
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 MESSAGES.description());
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 ldescr.setType(ListGridFieldType.TEXT);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 ldescr.setWidth("*");
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 ListGridField lside = new ListGridField("riverside",
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 MESSAGES.riverside());
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 lside.setType(ListGridFieldType.TEXT);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 lside.setWidth(60);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153 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
154 loc.setType(ListGridFieldType.TEXT);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
155 loc.setWidth(80);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156 locationTable.setFields(addLocation, ldescr, loc, lside);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 }
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
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
160 public Canvas createOld(DataList dataList) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
161 List<Data> items = dataList.getAll();
242
f9ca49e59fb6 Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 238
diff changeset
162 Data dLocation = getData(items, "ld_locations");
f9ca49e59fb6 Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 238
diff changeset
163 DataItem[] loc = dLocation.getItems();
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
165 HLayout layout = new HLayout();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 layout.setWidth("400px");
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 Label label = new Label(dataList.getLabel());
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169 label.setWidth("200px");
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 Canvas back = getBackButton(dataList.getState());
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172
242
f9ca49e59fb6 Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 238
diff changeset
173 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
174 selected.setWidth("130px");
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 layout.addMember(label);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
177 layout.addMember(selected);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
178 layout.addMember(back);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
179
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
180 return layout;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
181 }
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 * 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
186 * objects in <i>list</i>.
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
187 *
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
188 * @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
189 */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
190 protected void initDefaults(DataList list) {
519
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
191 Data data = list.get(0);
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
192
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
193 if (data == null) {
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
194 return;
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
195 }
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
196
563
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
197 DataItem[] items = data.getItems();
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
198 DataItem iMin = getDataItem(items, "min");
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
199 DataItem iMax = getDataItem(items, "max");
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
200
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
201 try {
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
202 min = Double.parseDouble(iMin.getStringValue());
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
203 max = Double.parseDouble(iMax.getStringValue());
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
204 }
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
205 catch (NumberFormatException nfe) {
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
206 SC.warn(MESSAGES.error_read_minmax_values());
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
207 min = -Double.MAX_VALUE;
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
208 max = Double.MAX_VALUE;
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
209 }
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
210
519
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
211 DataItem def = data.getDefault();
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
212 String value = def.getStringValue();
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
213
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
214 try {
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
215 double d = Double.parseDouble(value);
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
216 setLocationValues(new double[] { d } );
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
217 }
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
218 catch (NumberFormatException nfe) {
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
219 // could not parse, dont know what to do else
77234b1d009c ISSUE-90 & ISSUE-40 (part II/II) Former selected values are preselected after back jumps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 284
diff changeset
220 }
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
221 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
222
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 * 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
226 * returns it.
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 *
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
228 * @param items A list of Data.
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
229 * @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
230 *
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231 * @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
232 */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
233 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
234 for (Data d: data) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
235 if (name.equals(d.getLabel())) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
236 return d;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
237 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
238 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
239
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
240 return null;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
241 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
242
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
243
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
244 protected Canvas createWidget(DataList data) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
245 VLayout layout = new VLayout();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
246 container = new HLayout();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
247
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
248 // 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
249 locationPanel = new DoubleArrayPanel(
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
250 MESSAGES.unitLocation(),
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
251 getLocationValues(),
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
252 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
253 container.addMember(locationPanel);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
254
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
255 layout.addMember(container);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
256
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
257 container.setMembersMargin(30);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
258
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
259 helperContainer.addChild(locationTable);
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
260 createInputPanel();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
261 return layout;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
262 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
263
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
264
563
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
265 @Override
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
266 public List<String> validate() {
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
267 List<String> errors = new ArrayList<String>();
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
268 NumberFormat nf = NumberFormat.getDecimalFormat();
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
269
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
270 saveLocationValues(locationPanel);
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
271
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
272 if (!locationPanel.validateForm()) {
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
273 errors.add(MESSAGES.wrongFormat());
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
274 return errors;
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
275 }
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
276
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
277 double[] values = getLocationValues();
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
278 double[] good = new double[values.length];
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
279 int idx = 0;
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
280
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
281 for (double value: values) {
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
282 if (value < min || value > max) {
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
283 String tmp = MESSAGES.error_validate_range();
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
284 tmp = tmp.replace("$1", nf.format(value));
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
285 tmp = tmp.replace("$2", nf.format(min));
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
286 tmp = tmp.replace("$3", nf.format(max));
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
287 errors.add(tmp);
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
288 }
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
289 else {
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
290 good[idx++] = value;
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
291 }
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
292 }
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
293
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
294 double[] justGood = new double[idx];
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
295 for (int i = 0; i < justGood.length; i++) {
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
296 justGood[i] = good[i];
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
297 }
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
298
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
299 if (!errors.isEmpty()) {
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
300 locationPanel.setValues(justGood);
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
301 }
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
302
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
303 return errors;
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
304 }
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
305
469528551b78 Introduced an input validation for the location panels.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 522
diff changeset
306
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
307 /**
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
308 * This method returns the selected data.
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
309 *
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
310 * @return the selected/inserted data.
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
311 */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
312 public Data[] getData() {
242
f9ca49e59fb6 Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 238
diff changeset
313 saveLocationValues(locationPanel);
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
314 double[] values = getLocationValues();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
315 Data[] data = new Data[values.length];
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
316 DataItem item = new DefaultDataItem();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
317 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
318 item = new DefaultDataItem(
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
319 "ld_locations",
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
320 "ld_locations",
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
321 Double.valueOf(values[i]).toString());
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
322 data[i] = new DefaultData(
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
323 "ld_locations",
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
324 null,
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
325 null,
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
326 new DataItem[] {item});
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 return data;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
329 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
330
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
331
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
332
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
333
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 * 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
336 *
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
337 * @param p The DoubleArrayPanel.
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 protected void saveLocationValues(DoubleArrayPanel p) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
340 FormItem[] formItems = p.getFields();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
341
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
342 for (FormItem item: formItems) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
343 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
344 saveLocationValue(p, item);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
345 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
346 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
347 }
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 /**
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
351 * 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
352 *
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
353 * @param p The DoubleArrayPanel.
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
354 * @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
355 */
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
356 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
357 if (p.validateForm(item)) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
358 setLocationValues(p.getInputValues(item));
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
359 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
360 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
361
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
362
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
363 protected void createInputPanel() {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
364 Config config = Config.getInstance();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
365 String url = config.getServerUrl();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
366 String locale = config.getLocale ();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
367 String river = "";
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
368
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
369 ArtifactDescription adescr = artifact.getArtifactDescription();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
370 DataList[] data = adescr.getOldData();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
371
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
372 if (data != null && data.length > 0) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
373 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
374 DataList dl = data[i];
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
375 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
376 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
377 Data d = dl.get(j);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
378 DataItem[] di = d.getItems();
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
379 if (di != null && di.length == 1) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
380 river = d.getItems()[0].getStringValue();
276
f4c8ce11df33 UI stub for data cage
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 272
diff changeset
381 break;
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
382 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
383 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
384 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
385 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
386 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
387
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
388 distanceInfoService.getDistanceInfo(url, locale, river,
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
389 new AsyncCallback<DistanceInfoObject[]>() {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
390 public void onFailure(Throwable caught) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
391 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
392 GWT.log(caught.getMessage());
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
393 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
394
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
395 public void onSuccess(DistanceInfoObject[] di) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
396 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
397 GWT.log("Recieved " + num + " location informations.");
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
398
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
399 if (num == 0) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
400 return;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
401 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
402 tableData = di;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
403 updateLocationInfo(di);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
404 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
405 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
406 );
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
407 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
408
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
409
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
410 protected void updateLocationInfo(DistanceInfoObject[] di) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
411 int i = 0;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
412 for (DistanceInfoObject dio: di) {
242
f9ca49e59fb6 Fixed the single location input panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 238
diff changeset
413 if (dio.getTo() == null) {
238
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
414 locationTable.addData(new DistanceInfoRecord(dio));
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
415 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
416 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
417 return;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
418 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
419
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
420
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
421 protected double[] getLocationValues() {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
422 return values;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
423 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
424
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
425
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
426 protected void setLocationValues(double[] values) {
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
427 this.values = values;
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
428 locationPanel.setValues(values);
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
429 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
430 }
234c78a91c15 Added new UI provider for single location selection.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
431 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org