annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java @ 1594:ddf43791244c

Removed superfluous imports. flys-client/trunk@3905 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 03 Feb 2012 15:04:12 +0000
parents e0d665661a1d
children cb3629a01126
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
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
3 import java.util.List;
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
4
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.core.client.GWT;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 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
12
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import com.smartgwt.client.util.SC;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import com.smartgwt.client.widgets.Window;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import com.smartgwt.client.widgets.layout.VLayout;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import com.smartgwt.client.widgets.layout.HLayout;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import com.smartgwt.client.widgets.IButton;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import com.smartgwt.client.widgets.Button;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import com.smartgwt.client.widgets.Label;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 import com.smartgwt.client.widgets.grid.ListGrid;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 import com.smartgwt.client.widgets.grid.ListGridField;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22 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
23 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
24 import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
25 import com.smartgwt.client.types.ListGridFieldType;
1562
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
26 import com.smartgwt.client.widgets.grid.CellFormatter;
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
27 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
28
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 import com.smartgwt.client.widgets.events.ClickEvent;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30 import com.smartgwt.client.widgets.events.ClickHandler;
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 com.smartgwt.client.types.Alignment;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 import de.intevation.flys.client.shared.model.Artifact;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 import de.intevation.flys.client.client.Config;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 import de.intevation.flys.client.client.FLYSConstants;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 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
39 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
40
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 import de.intevation.flys.client.client.services.LoadArtifactService;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 import de.intevation.flys.client.client.services.LoadArtifactServiceAsync;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 import de.intevation.flys.client.client.services.FeedService;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 import de.intevation.flys.client.client.services.FeedServiceAsync;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 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
47 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
48 import de.intevation.flys.client.shared.model.DefaultData;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 import de.intevation.flys.client.shared.model.Recommendation;
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
50 import de.intevation.flys.client.shared.model.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
51 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
52 import de.intevation.flys.client.shared.model.PropertyGroup;
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
53 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
54
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
55 import de.intevation.flys.client.client.event.RedrawRequestHandler;
42f1213dfbcc Let ManualPointEditor use RedrawRequests to let freshly edited points show up in Chart.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1548
diff changeset
56 import de.intevation.flys.client.client.event.RedrawRequestEvent;
42f1213dfbcc Let ManualPointEditor use RedrawRequests to let freshly edited points show up in Chart.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1548
diff changeset
57
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58
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 * 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
61 */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 public class ManualPointsEditor
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 extends Window
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 implements ClickHandler
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 /** The interface that provides i18n messages. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
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 /** Name of the main data item to be fed. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 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
71 // TODO with separate point sets in multiple diagrams, we might need
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 // different POINT_DATA-names (e.g. one per diagram).
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73
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
74 /** 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
75 protected RedrawRequestHandler redrawRequestHandler;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 /** The collection */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 protected Collection collection;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 /** The listGrid showing point entries. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 protected ListGrid listGrid;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 /** 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
84 LoadArtifactServiceAsync loadArtifactService = GWT.create(
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 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
86
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 /** 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
88 FeedServiceAsync feedService = GWT.create(
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
89 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
90
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
91 /** UUID of artifact to feed. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
92 protected String uuid;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
93
1568
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
94 /** 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
95 protected String outputModeName;
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
96
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98 /**
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
99 * Setup editor dialog.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 * @param collection The collection to use.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 */
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
102 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
103 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
104 ) {
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
105 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
106 this.redrawRequestHandler = handler;
1568
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
107 this.outputModeName = outputModeName;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
108 init();
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
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
111
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
112 /** 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
113 public String findManualPointsUUID() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
114 // 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
115 int size = collection.getItemLength();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
116
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
117 for (int i = 0; i < size; i++) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
118 CollectionItem item = collection.getItem(i);
1568
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
119 String dataValue = (String) item.getData().get(outputModeName
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
120 + "." + POINT_DATA);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 if (dataValue != null) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 // Found it.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
123 uuid = item.identifier();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
124 return uuid;
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
125 }
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 return null;
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
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 /**
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
133 * Initialize the editor window and its components.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
134 */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
135 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
136 setTitle(MSG.addpoints());
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
137 setCanDragReposition(true);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
138 setCanDragResize(true);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
139
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
140 // If no manualpoints artifact found, create it now.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
141 if(findManualPointsUUID() == null) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
142 addArtifactCreateUI();
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 else {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
145 createUI();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
146 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
147 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
148
1547
76377fe3f0c7 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1545
diff changeset
149
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
150 /** Create and setup/add the ui. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
151 public void createUI() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
152 Config config = Config.getInstance();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
153
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
154 Button accept = new Button(MSG.label_ok());
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
155 Button cancel = new Button(MSG.label_cancel());
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
156 cancel.addClickHandler(this);
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
157
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
158 accept.addClickHandler(new ClickHandler() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
159 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
160 okClicked();
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
161 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
162 });
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
163
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
164 HLayout buttons = new HLayout();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
165 buttons.addMember(accept);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
166 buttons.addMember(cancel);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
167 buttons.setAlign(Alignment.CENTER);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
168 buttons.setHeight(30);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
169
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
170 VLayout layout = new VLayout();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
171 listGrid = new ListGrid();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
172 listGrid.setWidth100();
1570
eeee85c4d996 Adjusted table height to fill the window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1569
diff changeset
173 listGrid.setHeight("*");
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
174 listGrid.setCanSort(false);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
175 listGrid.setCanEdit(true);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
176 listGrid.setShowHeaderContextMenu(false);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
177
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
178 CellFormatter doubleFormat = new CellFormatter() {
1562
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
179 public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
180 if(value != null) {
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
181 NumberFormat nf = NumberFormat.getFormat("#.##");
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
182 try {
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
183 return nf.format(((Number) value).doubleValue());
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
184 } catch (Exception e) {
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
185 return value.toString();
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
186 }
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
187 } else {
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
188 return null;
af29d43cf4da Added basic validation, improved editing function, minor refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1561
diff changeset
189 }
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
190 }};
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
191
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
192 // 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
193 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
194 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
195
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
196 // 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
197 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
198 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
199 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
200 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
201 PropertyGroup pg = (PropertyGroup)p;
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
202 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
203 (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
204 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
205 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
206 (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
207 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
208 }
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
209 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
210 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
211 (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
212 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
213 }
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
214 }
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
215 }
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
216 ListGridField xField =
b85761d21975 Get the axes name from collection settings and use them as table header.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1568
diff changeset
217 new ListGridField(PointRecord.ATTRIBUTE_X, xAxis);
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
218 xField.setType(ListGridFieldType.FLOAT);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
219 xField.setCellFormatter(doubleFormat);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
220
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
221 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
222 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
223 yField.setType(ListGridFieldType.FLOAT);
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
224 yField.setCellFormatter(doubleFormat);
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;
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
253 }
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) {
1568
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
264 String jsonData = item.getData().get(outputModeName + "." + POINT_DATA);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
265 JSONArray jsonArray = (JSONArray) JSONParser.parse(jsonData);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
266 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
267 JSONArray point = (JSONArray) jsonArray.get(i);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
268 listGrid.addData(pointRecordFromJSON(point));
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
269 }
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 else {
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
272 // TODO proper log
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
273 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
274 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
275
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
276 IButton button = new IButton(MSG.newpoint());
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
277 button.setTop(250);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
278 button.addClickHandler(new ClickHandler() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
279 public void onClick(ClickEvent event) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
280 listGrid.startEditingNew();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
281 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
282 });
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
283
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
284 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
285 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
286
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
287 addItem(layout);
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
288
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
289 addItem(buttons);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
290 setWidth(380);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
291 setHeight(470);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
292 centerInPage();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
293 }
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
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
296 /** 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
297 protected JSONArray jsonArrayFromListGrid() {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
298 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
299 int idx = 0;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
300
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
301 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
302 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
303 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
304
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
305 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
306 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
307 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
308 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
309 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
310
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
311 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
312 idx++;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
313 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
314 else {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
315 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
316
1565
87f5ed6960e8 Improved form validation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1564
diff changeset
317 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
318 // 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
319 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
320 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
321 PointRecord.ATTRIBUTE_X);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
322 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
323 PointRecord.ATTRIBUTE_Y);
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
324 nameString = xString + "/" + yString;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
325 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
326
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
327 data.set(0, new JSONNumber(record.
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
328 getAttributeAsDouble(PointRecord.ATTRIBUTE_X)));
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
329 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
330 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
331 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
332 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
333 PointRecord.ATTRIBUTE_ACTIVE)));
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
334
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
335 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
336 idx++;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
337 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
338 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
339 return list;
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
340 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
341
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
342
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
343 /**
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
344 * 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
345 * 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
346 */
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
347 protected void okClicked() {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
348 if(isDialogValid()) {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
349 // 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
350 JSONArray list = jsonArrayFromListGrid();
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
351
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
352 Data[] feedData = new Data[] {
1568
2432973ccced Handle manual points on a per-chart(type) basis.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1565
diff changeset
353 DefaultData.createSimpleStringData(outputModeName + "." + POINT_DATA,
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
354 list.toString())
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
355 };
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 feedService.feed(
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
358 Config.getInstance().getLocale(),
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
359 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
360 feedData,
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
361 new AsyncCallback<Artifact>() {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
362 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
363 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
364 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
365 enable();
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 public void onSuccess(Artifact fartifact) {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
368 GWT.log("Successfully set points ");
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
369 redrawRequestHandler.onRedrawRequest(
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
370 new RedrawRequestEvent());
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
371 destroy();
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
372 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
373 });
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
374 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
375 else {
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
376 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
377 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
378 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
379 }
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
380
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
381
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
382 /** 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
383 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
384 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
385 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
386 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
387 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
388
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
389 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
390 y.doubleValue(), s.stringValue());
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
391 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
392
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
393
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
394 /** Add a ManualPointArtifact to Collection. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
395 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
396 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
397 addItem(standByLabel);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
398
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
399 setWidth(380);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
400 setHeight(470);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
401 centerInPage();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
402
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
403 Config config = Config.getInstance();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
404 String locale = config.getLocale();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
405
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
406 loadArtifactService.load(
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
407 this.collection,
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
408 new Recommendation("manualpoints", ""),
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
409 "manualpoints",
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
410 locale,
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
411 new AsyncCallback<Artifact>() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
412 public void onFailure(Throwable caught) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
413 GWT.log("Creating manualpoint artifact failed!");
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
414 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
415 public void onSuccess(Artifact artifact) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
416 GWT.log("Successfully created artifact.");
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
417 removeItem(standByLabel);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
418 uuid = artifact.getUuid();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
419 createUI();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
420 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
421 });
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
422 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
423
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
424
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
425 /**
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
426 * 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
427 * @param event The event.
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
428 */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
429 public void onClick(ClickEvent event) {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
430 this.destroy();
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
431 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
432
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
433
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
434 /** Simple record to store points. */
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
435 public class PointRecord extends ListGridRecord {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
436 protected static final String ATTRIBUTE_X = "X";
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
437 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
438 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
439 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
440
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
441 private PointRecord() {;}
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
442
1563
41abc345d2f1 Added dummy handling for new boolean property of each point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1562
diff changeset
443 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
444 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
445 setName(name);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
446 setX(x);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
447 setY(y);
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
448 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
449
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
450 public void setActive(boolean b) {
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
451 setAttribute(ATTRIBUTE_ACTIVE, b);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
452 }
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
453
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
454 public boolean isActive() {
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
455 return getAttributeAsBoolean(ATTRIBUTE_ACTIVE);
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
456 }
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
457
1553
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
458 public void setName(String name) {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
459 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
460 }
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
461
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
462 public String getName() {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
463 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
464 }
9ad19e31d149 Improved points UI to also respect language and name of point.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1549
diff changeset
465
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
466 public void setX(double x) {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
467 setAttribute(ATTRIBUTE_X, x);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
468 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
469
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
470 public void setY(double y) {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
471 setAttribute(ATTRIBUTE_Y, y);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
472 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
473
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
474 public double getX() {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
475 return getAttributeAsDouble(ATTRIBUTE_X);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
476 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
477
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
478 public double getY() {
1561
3cf3cd8dd92d Made manual points edit- and removable.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1553
diff changeset
479 return getAttributeAsDouble(ATTRIBUTE_Y);
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
480 }
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
1565
87f5ed6960e8 Improved form validation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1564
diff changeset
484 /** 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
485 protected boolean isDialogValid() {
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
486 boolean valid = true;
1565
87f5ed6960e8 Improved form validation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1564
diff changeset
487 for (ListGridRecord record : listGrid.getRecords()) {
87f5ed6960e8 Improved form validation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1564
diff changeset
488 if (record.getAttributeAsDouble(PointRecord.ATTRIBUTE_X) == null
87f5ed6960e8 Improved form validation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1564
diff changeset
489 || record.getAttributeAsDouble(PointRecord.ATTRIBUTE_Y) == null) {
87f5ed6960e8 Improved form validation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1564
diff changeset
490 return false;
1545
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
491 }
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 return valid;
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 }
2f0150f21e77 Added basic UI to enter manual points.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
496 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org