annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java @ 3859:62332fa199bf

Work on "Date" support for ManualPointsEditor. flys-client/trunk@5621 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Thu, 27 Sep 2012 14:09:24 +0000
parents b6b2d9aad95d
children 65e369ac4f99
rev   line source
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui.chart;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
3 import com.google.gwt.core.client.GWT;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
4 import com.google.gwt.i18n.client.NumberFormat;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5 import com.google.gwt.json.client.JSONArray;
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
6 import com.google.gwt.json.client.JSONBoolean;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7 import com.google.gwt.json.client.JSONNumber;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8 import com.google.gwt.json.client.JSONParser;
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
9 import com.google.gwt.json.client.JSONString;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10 import com.google.gwt.user.client.rpc.AsyncCallback;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
12 import com.smartgwt.client.types.Alignment;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
13 import com.smartgwt.client.types.ListGridFieldType;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import com.smartgwt.client.util.SC;
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
15 import com.smartgwt.client.widgets.Button;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
16 import com.smartgwt.client.widgets.IButton;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
17 import com.smartgwt.client.widgets.Label;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import com.smartgwt.client.widgets.Window;
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
19 import com.smartgwt.client.widgets.events.ClickEvent;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
20 import com.smartgwt.client.widgets.events.ClickHandler;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
21 import com.smartgwt.client.widgets.grid.CellEditValueFormatter;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
22 import com.smartgwt.client.widgets.grid.CellEditValueParser;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
23 import com.smartgwt.client.widgets.grid.CellFormatter;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24 import com.smartgwt.client.widgets.grid.ListGrid;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 import com.smartgwt.client.widgets.grid.ListGridField;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 import com.smartgwt.client.widgets.grid.ListGridRecord;
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
27 import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
28 import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
29 import com.smartgwt.client.widgets.layout.HLayout;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
30 import com.smartgwt.client.widgets.layout.VLayout;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 import de.intevation.flys.client.client.Config;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33 import de.intevation.flys.client.client.FLYSConstants;
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
34 import de.intevation.flys.client.client.event.RedrawRequestEvent;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
35 import de.intevation.flys.client.client.event.RedrawRequestHandler;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
36 import de.intevation.flys.client.client.services.FeedServiceAsync;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
37 import de.intevation.flys.client.client.services.LoadArtifactServiceAsync;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
38 import de.intevation.flys.client.shared.model.Artifact;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 import de.intevation.flys.client.shared.model.Collection;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 import de.intevation.flys.client.shared.model.CollectionItem;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 import de.intevation.flys.client.shared.model.Data;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 import de.intevation.flys.client.shared.model.DefaultArtifact;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 import de.intevation.flys.client.shared.model.DefaultData;
1569
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
44 import de.intevation.flys.client.shared.model.Property;
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
45 import de.intevation.flys.client.shared.model.PropertyGroup;
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
46 import de.intevation.flys.client.shared.model.Recommendation;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
47 import de.intevation.flys.client.shared.model.Settings;
1569
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
48 import de.intevation.flys.client.shared.model.StringProperty;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
50 import java.util.List;
1549
42f1213dfbcc Let ManualPointEditor use RedrawRequests to let freshly edited points show up in Chart.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1548
diff changeset
51
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 /**
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 * UI to enter point data and save it to an PointArtifact.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 public class ManualPointsEditor
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 extends Window
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 implements ClickHandler
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 /** The interface that provides i18n messages. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62
2924
60c375173263 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2905
diff changeset
63 /** Part of name of the main data item to be fed. */
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 public static final String POINT_DATA = "manualpoints.data";
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65
1549
42f1213dfbcc Let ManualPointEditor use RedrawRequests to let freshly edited points show up in Chart.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1548
diff changeset
66 /** When we chaged something, we need a RedrawRequest(Handler). */
42f1213dfbcc Let ManualPointEditor use RedrawRequests to let freshly edited points show up in Chart.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1548
diff changeset
67 protected RedrawRequestHandler redrawRequestHandler;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 /** The collection */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 protected Collection collection;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 /** The listGrid showing point entries. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 protected ListGrid listGrid;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74
3859
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
75 protected ListGridFieldType fieldTypeX = ListGridFieldType.FLOAT;
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
76
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 /** Service handle to clone and add artifacts to collection. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 LoadArtifactServiceAsync loadArtifactService = GWT.create(
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 de.intevation.flys.client.client.services.LoadArtifactService.class);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 /** Service to feed the artifact with new point-data. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 FeedServiceAsync feedService = GWT.create(
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 de.intevation.flys.client.client.services.FeedService.class);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 /** UUID of artifact to feed. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 protected String uuid;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87
1568
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
88 /** Name of the outputmode, important when feeding data. */
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
89 protected String outputModeName;
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
90
2924
60c375173263 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2905
diff changeset
91 /** Name of the point data item. */
60c375173263 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2905
diff changeset
92 protected String pointDataItemName;
60c375173263 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2905
diff changeset
93
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
94
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
95 /**
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
96 * Setup editor dialog.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97 * @param collection The collection to use.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98 */
1549
42f1213dfbcc Let ManualPointEditor use RedrawRequests to let freshly edited points show up in Chart.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1548
diff changeset
99 public ManualPointsEditor(Collection collection,
1568
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
100 RedrawRequestHandler handler, String outputModeName
1549
42f1213dfbcc Let ManualPointEditor use RedrawRequests to let freshly edited points show up in Chart.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1548
diff changeset
101 ) {
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 this.collection = collection;
1549
42f1213dfbcc Let ManualPointEditor use RedrawRequests to let freshly edited points show up in Chart.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1548
diff changeset
103 this.redrawRequestHandler = handler;
1568
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
104 this.outputModeName = outputModeName;
2924
60c375173263 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2905
diff changeset
105 this.pointDataItemName = outputModeName + "." + POINT_DATA;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
106 init();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
107 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
108
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
109
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
110 /** Searches collection for first artifact to serve (manual) point data. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
111 public String findManualPointsUUID() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
112 // TODO Need to be more picky (different points in different diagrams)
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
113 int size = collection.getItemLength();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
114
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
115 for (int i = 0; i < size; i++) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
116 CollectionItem item = collection.getItem(i);
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3706
diff changeset
117 String dataValue = item.getData().get(pointDataItemName);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
118 if (dataValue != null) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
119 // Found it.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
120 uuid = item.identifier();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 return uuid;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
123 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
124
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
125 return null;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
126 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
127
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
128
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
129 /**
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
130 * Initialize the editor window and its components.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
131 */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
132 protected void init() {
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
133 setTitle(MSG.addpoints());
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
134 setCanDragReposition(true);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
135 setCanDragResize(true);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
136
2905
51ed89b754ae FLYS client: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2482
diff changeset
137 // If no manualpoints artifact found, create it now.
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
138 if(findManualPointsUUID() == null) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
139 addArtifactCreateUI();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
140 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
141 else {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
142 createUI();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
143 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
144 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
145
1547
76377fe3f0c7 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1545
diff changeset
146
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
147 /** Create and setup/add the ui. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
148 public void createUI() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
149 Config config = Config.getInstance();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
150
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
151 Button accept = new Button(MSG.label_ok());
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
152 Button cancel = new Button(MSG.label_cancel());
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
153 cancel.addClickHandler(this);
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
154
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
155 accept.addClickHandler(new ClickHandler() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
156 public void onClick(ClickEvent e) {
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
157 okClicked();
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
158 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
159 });
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
160
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
161 HLayout buttons = new HLayout();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
162 buttons.addMember(accept);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
163 buttons.addMember(cancel);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
164 buttons.setAlign(Alignment.CENTER);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
165 buttons.setHeight(30);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
166
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
167 VLayout layout = new VLayout();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
168 listGrid = new ListGrid();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
169 listGrid.setWidth100();
1570
eeee85c4d996 Adjusted table height to fill the window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1569
diff changeset
170 listGrid.setHeight("*");
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
171 listGrid.setCanSort(false);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
172 listGrid.setCanEdit(true);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
173 listGrid.setShowHeaderContextMenu(false);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
174
1569
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
175 // Use X and Y as default fallback.
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
176 String xAxis = "X";
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
177 String yAxis = "Y";
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
178
1569
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
179 // Get header text from collection settings.
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
180 Settings settings = this.collection.getSettings(outputModeName);
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
181 List<Property> axes = settings.getSettings("axes");
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
182 if(axes != null) {
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
183 for (Property p: axes) {
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
184 PropertyGroup pg = (PropertyGroup)p;
3859
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
185 GWT.log(pg.toString());
1569
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
186 StringProperty id =
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
187 (StringProperty)pg.getPropertyByName("id");
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
188 if(id.getValue().equals("X")) {
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
189 StringProperty name =
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
190 (StringProperty)pg.getPropertyByName("label");
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
191 xAxis = name.getValue();
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
192 }
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
193 else if (yAxis.equals("Y")) {
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
194 StringProperty name =
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
195 (StringProperty)pg.getPropertyByName("label");
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
196 yAxis = name.getValue();
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
197 }
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
198 }
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
199 }
3859
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
200
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
201 CellFormatter format = createCellFormatter();
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
202 CellEditValueParser cevp = createCellEditValueParser();
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
203 CellEditValueFormatter cevf = createCellEditValueFormatter();
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
204
1569
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
205 ListGridField xField =
3859
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
206 new ListGridField(PointRecord.ATTRIBUTE_X, xAxis);
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
207 if(xAxis.equalsIgnoreCase("date") || xAxis.equalsIgnoreCase("Datum")) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
208 // FIXME: This is a hack for the special axis with Date type
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
209 xField.setType(ListGridFieldType.DATE);
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
210 this.fieldTypeX = ListGridFieldType.DATE;
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
211 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
212 else {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
213 xField.setType(ListGridFieldType.FLOAT);
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
214 xField.setCellFormatter(format);
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
215 xField.setEditValueParser(cevp);
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
216 xField.setEditValueFormatter(cevf);
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
217 }
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
218
1569
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
219 ListGridField yField =
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
220 new ListGridField(PointRecord.ATTRIBUTE_Y, yAxis);
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
221 yField.setType(ListGridFieldType.FLOAT);
3859
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
222 yField.setCellFormatter(format);
1604
cb3629a01126 Issue 473.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1594
diff changeset
223 yField.setEditValueParser(cevp);
cb3629a01126 Issue 473.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1594
diff changeset
224 yField.setEditValueFormatter(cevf);
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
225
1562
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
226 ListGridField nameField = new ListGridField(PointRecord.ATTRIBUTE_NAME,
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
227 MSG.pointname());
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
228 final ListGridField removeField =
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
229 new ListGridField("_removeRecord", MSG.removepoint()){{
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
230 setType(ListGridFieldType.ICON);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
231 setIcon(GWT.getHostPageBaseURL() + MSG.removeFeature());
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
232 setCanEdit(false);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
233 setCanFilter(false);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
234 setCanSort(false);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
235 setCanGroupBy(false);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
236 setCanFreeze(false);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
237 setWidth(25);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
238 }};
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
239
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
240 ListGridField activeField = new ListGridField(
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
241 PointRecord.ATTRIBUTE_ACTIVE, MSG.selection());
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
242 activeField.setType(ListGridFieldType.BOOLEAN);
1564
3606f2caf93e Make manual Points active by default.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1563
diff changeset
243 activeField.setDefaultValue(true);
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
244
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
245 listGrid.setFields(new ListGridField[] {activeField, xField, yField,
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
246 nameField, removeField});
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
247
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
248 listGrid.addRecordClickHandler(new RecordClickHandler() {
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
249 public void onRecordClick(final RecordClickEvent event) {
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
250 // Just handle remove-clicks
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
251 if(!event.getField().getName().equals(removeField.getName())) {
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
252 return;
2905
51ed89b754ae FLYS client: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2482
diff changeset
253 }
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
254 event.getViewer().removeData(event.getRecord());
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
255 }
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
256 });
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
257
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
258 // Find the artifacts uuid.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
259 findManualPointsUUID();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
260 CollectionItem item = collection.getItem(uuid);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
261
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
262 // Add points to grid.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
263 if (item != null) {
2924
60c375173263 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2905
diff changeset
264 // TODO store this from findPointUUID instead (we touched these).
60c375173263 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2905
diff changeset
265 String jsonData = item.getData().get(pointDataItemName);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
266 JSONArray jsonArray = (JSONArray) JSONParser.parse(jsonData);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
267 for (int i = 0; i < jsonArray.size(); i++) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
268 JSONArray point = (JSONArray) jsonArray.get(i);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
269 listGrid.addData(pointRecordFromJSON(point));
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
270 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
271 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
272 else {
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
273 // TODO proper log
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
274 System.out.println("No item found for " + uuid);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
275 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
276
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
277 IButton button = new IButton(MSG.newpoint());
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
278 button.setTop(250);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
279 button.addClickHandler(new ClickHandler() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
280 public void onClick(ClickEvent event) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
281 listGrid.startEditingNew();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
282 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
283 });
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
284
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
285 layout.addMember(listGrid);
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
286 layout.addMember(button);
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
287
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
288 addItem(layout);
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
289
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
290 addItem(buttons);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
291 setWidth(380);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
292 setHeight(470);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
293 centerInPage();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
294 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
295
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
296
3859
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
297 protected CellFormatter createCellFormatter() {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
298 return new CellFormatter() {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
299 public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
300 if(value != null) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
301 NumberFormat nf = NumberFormat.getDecimalFormat();
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
302 try {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
303 double d = Double.valueOf(value.toString()).doubleValue();
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
304 return nf.format(d);
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
305 } catch (Exception e) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
306 return value.toString();
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
307 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
308 } else {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
309 return null;
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
310 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
311 }};
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
312 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
313
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
314
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
315 protected CellEditValueParser createCellEditValueParser() {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
316 return new CellEditValueParser() {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
317 public Object parse(Object value, ListGridRecord record, int rowNum, int colNum) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
318 if (value == null)
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
319 return null;
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
320 try {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
321 NumberFormat nf = NumberFormat.getDecimalFormat();
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
322 double d = nf.parse(value.toString());
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
323 return (new Double(d)).toString();
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
324 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
325 catch(NumberFormatException nfe) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
326 return value;
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
327 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
328 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
329 };
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
330 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
331
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
332
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
333 protected CellEditValueFormatter createCellEditValueFormatter() {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
334 return new CellEditValueFormatter() {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
335 public Object format(Object value, ListGridRecord record, int rowNum, int colNum) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
336 if (value == null) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
337 return "";
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
338 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
339 NumberFormat nf = NumberFormat.getDecimalFormat();
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
340 try {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
341 double d = Double.valueOf(value.toString()).doubleValue();
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
342 return nf.format(d);
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
343 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
344 catch(NumberFormatException nfe) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
345 return value;
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
346 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
347 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
348 };
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
349 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
350
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
351
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
352 /** Create JSON representation of the points present in the list grid. */
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
353 protected JSONArray jsonArrayFromListGrid() {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
354 JSONArray list = new JSONArray();
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
355 int idx = 0;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
356
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
357 for(ListGridRecord record : listGrid.getRecords()) {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
358 if (record instanceof PointRecord) {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
359 JSONArray data = new JSONArray();
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
360
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
361 PointRecord point = (PointRecord) record;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
362 data.set(0, new JSONNumber(point.getX()));
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
363 data.set(1, new JSONNumber(point.getY()));
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
364 data.set(2, new JSONString(point.getName()));
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
365 data.set(3, JSONBoolean.getInstance(point.isActive()));
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
366
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
367 list.set(idx, data);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
368 idx++;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
369 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
370 else {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
371 JSONArray data = new JSONArray();
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
372
1565
87f5ed6960e8 Improved form validation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1564
diff changeset
373 String nameString = record.getAttributeAsString(PointRecord.ATTRIBUTE_NAME);
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
374 // Apply default name if none set.
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
375 if (nameString == null || nameString.equals("")) {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
376 String xString = record.getAttributeAsString(
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
377 PointRecord.ATTRIBUTE_X);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
378 String yString = record.getAttributeAsString(
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
379 PointRecord.ATTRIBUTE_Y);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
380 nameString = xString + "/" + yString;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
381 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
382
3859
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
383 if(fieldTypeX.equals(ListGridFieldType.DATE)) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
384 data.set(0, new JSONString(record.getAttribute(PointRecord.ATTRIBUTE_X)));
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
385 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
386 else {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
387 data.set(0, new JSONNumber(record.
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
388 getAttributeAsDouble(PointRecord.ATTRIBUTE_X)));
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
389 }
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
390 data.set(1, new JSONNumber(record.
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
391 getAttributeAsDouble(PointRecord.ATTRIBUTE_Y)));
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
392 data.set(2, new JSONString(nameString));
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
393 data.set(3, JSONBoolean.getInstance(record.getAttributeAsBoolean(
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
394 PointRecord.ATTRIBUTE_ACTIVE)));
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
395
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
396 list.set(idx, data);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
397 idx++;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
398 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
399 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
400 return list;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
401 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
402
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
403
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
404 /**
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
405 * Called when OK Button was clicked. Then, if entered values are valid,
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
406 * fire a RedrawRequest and destroy.
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
407 */
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
408 protected void okClicked() {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
409 if(isDialogValid()) {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
410 // Feed JSON-encoded content of listgrid.
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
411 JSONArray list = jsonArrayFromListGrid();
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
412
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
413 Data[] feedData = new Data[] {
2924
60c375173263 Minor refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2905
diff changeset
414 DefaultData.createSimpleStringData(pointDataItemName,
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
415 list.toString())
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
416 };
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
417
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
418 feedService.feed(
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
419 Config.getInstance().getLocale(),
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
420 new DefaultArtifact(uuid, "TODO:hash"),
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
421 feedData,
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
422 new AsyncCallback<Artifact>() {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
423 public void onFailure(Throwable caught) {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
424 GWT.log("Could not feed artifact with points.");
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
425 SC.warn(MSG.getString(caught.getMessage()));
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
426 enable();
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
427 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
428 public void onSuccess(Artifact fartifact) {
3706
b7e93531322f Cosmetics
Christian Lins <christian.lins@intevation.de>
parents: 2924
diff changeset
429 GWT.log("Successfully set points");
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
430 redrawRequestHandler.onRedrawRequest(
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
431 new RedrawRequestEvent());
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
432 destroy();
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
433 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
434 });
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
435 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
436 else {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
437 GWT.log("Dialog not valid");
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
438 SC.warn(MSG.error_dialog_not_valid());
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
439 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
440 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
441
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
442
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
443 /** From a JSON-encoded point, create a PointRecord. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
444 public PointRecord pointRecordFromJSON(JSONArray jsonArray) {
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
445 JSONNumber x = (JSONNumber) jsonArray.get(0);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
446 JSONNumber y = (JSONNumber) jsonArray.get(1);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
447 JSONString s = (JSONString) jsonArray.get(2);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
448 JSONBoolean b = (JSONBoolean) jsonArray.get(3);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
449
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
450 return new PointRecord(b.booleanValue(), x.doubleValue(),
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
451 y.doubleValue(), s.stringValue());
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
452 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
453
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
454
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
455 /** Add a ManualPointArtifact to Collection. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
456 public void addArtifactCreateUI() {
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
457 final Label standByLabel = new Label(MSG.standby());
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
458 addItem(standByLabel);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
459
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
460 setWidth(380);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
461 setHeight(470);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
462 centerInPage();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
463
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
464 Config config = Config.getInstance();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
465 String locale = config.getLocale();
2905
51ed89b754ae FLYS client: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2482
diff changeset
466
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
467 loadArtifactService.load(
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
468 this.collection,
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
469 new Recommendation("manualpoints", ""),
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
470 "manualpoints",
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
471 locale,
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
472 new AsyncCallback<Artifact>() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
473 public void onFailure(Throwable caught) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
474 GWT.log("Creating manualpoint artifact failed!");
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
475 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
476 public void onSuccess(Artifact artifact) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
477 GWT.log("Successfully created artifact.");
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
478 removeItem(standByLabel);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
479 uuid = artifact.getUuid();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
480 createUI();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
481 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
482 });
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
483 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
484
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
485
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
486 /**
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
487 * This method is called when the user aborts point editing.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
488 * @param event The event.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
489 */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
490 public void onClick(ClickEvent event) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
491 this.destroy();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
492 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
493
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
494
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
495 /** Simple record to store points. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
496 public class PointRecord extends ListGridRecord {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
497 protected static final String ATTRIBUTE_X = "X";
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
498 protected static final String ATTRIBUTE_Y = "Y";
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
499 protected static final String ATTRIBUTE_NAME = "name";
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
500 protected static final String ATTRIBUTE_ACTIVE = "active";
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
501
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
502 public PointRecord(boolean b, double x, double y, String name) {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
503 setActive(b);
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
504 setName(name);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
505 setX(x);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
506 setY(y);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
507 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
508
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
509 public void setActive(boolean b) {
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
510 setAttribute(ATTRIBUTE_ACTIVE, b);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
511 }
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
512
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
513 public boolean isActive() {
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
514 return getAttributeAsBoolean(ATTRIBUTE_ACTIVE);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
515 }
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
516
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
517 public void setName(String name) {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
518 setAttribute(ATTRIBUTE_NAME, name);
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
519 }
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
520
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
521 public String getName() {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
522 return getAttributeAsString(ATTRIBUTE_NAME);
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
523 }
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
524
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
525 public void setX(double x) {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
526 setAttribute(ATTRIBUTE_X, x);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
527 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
528
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
529 public void setY(double y) {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
530 setAttribute(ATTRIBUTE_Y, y);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
531 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
532
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
533 public double getX() {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
534 return getAttributeAsDouble(ATTRIBUTE_X);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
535 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
536
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
537 public double getY() {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
538 return getAttributeAsDouble(ATTRIBUTE_Y);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
539 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
540 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
541
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
542
1565
87f5ed6960e8 Improved form validation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1564
diff changeset
543 /** Return false if x or y attribute is missing. */
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
544 protected boolean isDialogValid() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
545 boolean valid = true;
1565
87f5ed6960e8 Improved form validation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1564
diff changeset
546 for (ListGridRecord record : listGrid.getRecords()) {
3859
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
547 try {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
548 if (record.getAttribute(PointRecord.ATTRIBUTE_X) == null
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
549 || record.getAttribute(PointRecord.ATTRIBUTE_Y) == null) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
550 return false;
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
551 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
552 }
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
553 catch(IllegalArgumentException ex) {
62332fa199bf Work on "Date" support for ManualPointsEditor.
Christian Lins <christian.lins@intevation.de>
parents: 3855
diff changeset
554
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
555 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
556 }
1604
cb3629a01126 Issue 473.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1594
diff changeset
557 if (listGrid.hasErrors()) {
cb3629a01126 Issue 473.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1594
diff changeset
558 valid = false;
cb3629a01126 Issue 473.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1594
diff changeset
559 }
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
560 return valid;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
561 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
562 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
563 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org