annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/ManualWSPEditor.java @ 7597:fca46ce8e4f5

(issue1225) Implement Magic labels. There is now a new value in the chartsettings "Suggested Label" which is hidden in the property editor. A suggested label is the label that combines the label's of all processors that wrote data to an axis. This suggested label is set as the label when the user has not overwritten the label.
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 25 Nov 2013 14:58:14 +0100
parents ea9eef426962
children 5e38e2924c07
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
6 * documentation coming with Dive4Elements River for details.
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.client.ui.chart;
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
2939
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
11 import com.google.gwt.core.client.GWT;
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
12 import com.google.gwt.i18n.client.NumberFormat;
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import com.google.gwt.json.client.JSONArray;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import com.google.gwt.json.client.JSONNumber;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import com.google.gwt.json.client.JSONParser;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import com.google.gwt.json.client.JSONString;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import com.google.gwt.user.client.rpc.AsyncCallback;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18
2939
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
19 import com.smartgwt.client.types.Alignment;
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 import com.smartgwt.client.util.SC;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 import com.smartgwt.client.widgets.Button;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22 import com.smartgwt.client.widgets.Label;
2939
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
23 import com.smartgwt.client.widgets.Window;
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24 import com.smartgwt.client.widgets.events.ClickEvent;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 import com.smartgwt.client.widgets.events.ClickHandler;
2939
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
26 import com.smartgwt.client.widgets.form.DynamicForm;
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
27 import com.smartgwt.client.widgets.form.fields.TextItem;
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
28 import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
29 import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
30 import com.smartgwt.client.widgets.layout.HLayout;
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
31 import com.smartgwt.client.widgets.layout.VLayout;
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
33 import org.dive4elements.river.client.client.Config;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
34 import org.dive4elements.river.client.client.FLYSConstants;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
35 import org.dive4elements.river.client.client.event.RedrawRequestEvent;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
36 import org.dive4elements.river.client.client.event.RedrawRequestHandler;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
37 import org.dive4elements.river.client.client.services.FeedServiceAsync;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
38 import org.dive4elements.river.client.client.services.LoadArtifactServiceAsync;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
39 import org.dive4elements.river.client.client.utils.DoubleValidator;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
40 import org.dive4elements.river.client.shared.model.Artifact;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
41 import org.dive4elements.river.client.shared.model.Collection;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
42 import org.dive4elements.river.client.shared.model.CollectionItem;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
43 import org.dive4elements.river.client.shared.model.Data;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
44 import org.dive4elements.river.client.shared.model.DefaultArtifact;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
45 import org.dive4elements.river.client.shared.model.DefaultData;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
46 import org.dive4elements.river.client.shared.model.Property;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
47 import org.dive4elements.river.client.shared.model.PropertyGroup;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
48 import org.dive4elements.river.client.shared.model.Recommendation;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
49 import org.dive4elements.river.client.shared.model.Settings;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
50 import org.dive4elements.river.client.shared.model.StringProperty;
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51
2939
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
52 import java.util.List;
8e6b1df7c3b0 Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2937
diff changeset
53 import java.util.Map;
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 /**
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 * UI to enter point data and save it to an PointArtifact.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 public class ManualWSPEditor
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 extends Window
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 implements ClickHandler
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 /** The interface that provides i18n messages. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 /** Name of the main data item to be fed. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 public static final String LINE_DATA = "manualpoints.lines";
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67
4568
bbd82bd8e541 flys-client: Cosmetics and warnings.
Christian Lins <christian.lins@intevation.de>
parents: 3354
diff changeset
68 /** When we change something, we need a RedrawRequest(Handler). */
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 protected RedrawRequestHandler redrawRequestHandler;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 /** The collection */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 protected Collection collection;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 /** Service handle to clone and add artifacts to collection. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 LoadArtifactServiceAsync loadArtifactService = GWT.create(
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
76 org.dive4elements.river.client.client.services.LoadArtifactService.class);
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 /** Service to feed the artifact with new point-data. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 FeedServiceAsync feedService = GWT.create(
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
80 org.dive4elements.river.client.client.services.FeedService.class);
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 /** UUID of artifact to feed. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 protected String uuid;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 /** Name of the outputmode, important when feeding data. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 protected String outputModeName;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
88 /** Name of the data item for lines in this context. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
89 protected String dataItemName;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
91 /** Input Field for y-coor of line. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
92 protected TextItem valueInputPanel;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
93
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
94 /** Input Field for name of line. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
95 protected TextItem nameInputPanel;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
96
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97 /** Line data that is not added in this session. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98 protected JSONArray oldLines = null;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
99
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 /**
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 * Setup editor dialog.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
103 * @param collection The collection to use.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
104 */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
105 public ManualWSPEditor(Collection collection,
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
106 RedrawRequestHandler handler, String outputModeName
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
107 ) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
108 this.collection = collection;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
109 this.redrawRequestHandler = handler;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
110 this.outputModeName = outputModeName;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
111 this.dataItemName = outputModeName + "." + LINE_DATA;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
112 init();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
113 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
114
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
115
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
116 /** Searches collection for first artifact to serve (manual) line data. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
117 public String findManualPointsUUID() {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
118 int size = collection.getItemLength();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
119
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
120 for (int i = 0; i < size; i++) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 CollectionItem item = collection.getItem(i);
4568
bbd82bd8e541 flys-client: Cosmetics and warnings.
Christian Lins <christian.lins@intevation.de>
parents: 3354
diff changeset
122 String dataValue = item.getData().get(dataItemName);
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
123 if (dataValue != null) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
124 // Found it.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
125 uuid = item.identifier();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
126 return uuid;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
127 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
128 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
129
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
130 return null;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
131 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
132
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
133
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
134 /**
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
135 * Initialize the editor window and its components.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
136 */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
137 protected void init() {
2927
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
138 setTitle(MSG.addWSP());
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
139 setCanDragReposition(true);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
140 setCanDragResize(true);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
141
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
142 if(findManualPointsUUID() == null) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
143 addArtifactCreateUI();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
144 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
145 else {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
146 createUI();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
147 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
148 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
149
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
150
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
151 /** Create and setup/add the ui. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
152 public void createUI() {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
153 Button accept = new Button(MSG.label_ok());
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
154 Button cancel = new Button(MSG.label_cancel());
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
155 cancel.addClickHandler(this);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
156
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
157 accept.addClickHandler(new ClickHandler() {
4568
bbd82bd8e541 flys-client: Cosmetics and warnings.
Christian Lins <christian.lins@intevation.de>
parents: 3354
diff changeset
158 @Override
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
159 public void onClick(ClickEvent e) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
160 okClicked();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
161 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
162 });
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
163
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
164 HLayout buttons = new HLayout();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
165 buttons.addMember(accept);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
166 buttons.addMember(cancel);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
167 buttons.setAlign(Alignment.CENTER);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
168 buttons.setHeight(30);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
169
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
170 // Use X and Y as default fallback.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
171 String yAxis = "Y";
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
172
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
173 // Get header text from collection settings.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
174 Settings settings = this.collection.getSettings(outputModeName);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
175 List<Property> axes = settings.getSettings("axes");
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
176 if(axes != null) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
177 for (Property p: axes) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
178 PropertyGroup pg = (PropertyGroup)p;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
179 StringProperty id =
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
180 (StringProperty)pg.getPropertyByName("id");
2927
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
181 if (id.getValue().equals("W")) {
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
182 StringProperty name =
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
183 (StringProperty)pg.getPropertyByName("label");
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
184 yAxis = name.getValue();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
185 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
186 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
187 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
188
2927
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
189 DynamicForm form = new DynamicForm();
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
190 valueInputPanel = new TextItem();
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
191 valueInputPanel.setTitle(yAxis);
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
192 valueInputPanel.setShowTitle(true);
2928
f0c7c52203c0 Minor Manual WSP editor polish.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2927
diff changeset
193 valueInputPanel.addBlurHandler(new BlurHandler() {
4568
bbd82bd8e541 flys-client: Cosmetics and warnings.
Christian Lins <christian.lins@intevation.de>
parents: 3354
diff changeset
194 @Override
2928
f0c7c52203c0 Minor Manual WSP editor polish.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2927
diff changeset
195 public void onBlur(BlurEvent e) {
f0c7c52203c0 Minor Manual WSP editor polish.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2927
diff changeset
196 DoubleValidator validator = new DoubleValidator();
f0c7c52203c0 Minor Manual WSP editor polish.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2927
diff changeset
197 Map errors = e.getForm().getErrors();
3354
22f39c2d7a72 Cosmetic compression.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2939
diff changeset
198 validator.validate(e.getItem(), errors);
22f39c2d7a72 Cosmetic compression.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2939
diff changeset
199 e.getForm().setErrors(errors, true);
2928
f0c7c52203c0 Minor Manual WSP editor polish.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2927
diff changeset
200 }
f0c7c52203c0 Minor Manual WSP editor polish.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2927
diff changeset
201 });
2927
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
202 nameInputPanel = new TextItem();
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
203 nameInputPanel.setTitle(MSG.pointname());
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
204 nameInputPanel.setShowTitle(true);
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
205 form.setFields(valueInputPanel, nameInputPanel);
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
206
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
207 VLayout layout = new VLayout();
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
208 layout.addMember(form);
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
209
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
210 // Find the artifacts uuid.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
211 // TODO this has been called already, why call it again?
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
212 findManualPointsUUID();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
213 CollectionItem item = collection.getItem(uuid);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
214
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
215 // Store the old line data.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
216 if (item != null) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
217 String jsonData = item.getData().get(dataItemName);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
218 oldLines = (JSONArray) JSONParser.parse(jsonData);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
219 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
220 else {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
221 GWT.log("No old lines found for " + uuid);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
222 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
223
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
224 addItem(layout);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
225
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
226 addItem(buttons);
2927
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
227 setWidth(360);
f978058dc835 Nicen Manual WSP editor.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2925
diff changeset
228 setHeight(120);
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
229 centerInPage();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
230 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
231
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
232
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
233 /**
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
234 * Create JSON representation of the points present in the form.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
235 * Add old data, too.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
236 * @return a jsonarray with the old and the new lines.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
237 */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
238 protected JSONArray jsonArrayFromForm() {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
239 if (oldLines == null) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
240 oldLines = new JSONArray();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
241 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
242
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
243 double val;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
244 if (valueInputPanel.getValue() == null)
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
245 return oldLines;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
246 try {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
247 NumberFormat nf = NumberFormat.getDecimalFormat();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
248 double d = nf.parse(valueInputPanel.getValue().toString());
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
249 val = d;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
250 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
251 catch(NumberFormatException nfe) {
4568
bbd82bd8e541 flys-client: Cosmetics and warnings.
Christian Lins <christian.lins@intevation.de>
parents: 3354
diff changeset
252 GWT.log("fehler... nfe... TODO");
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
253 return oldLines;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
254 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
255
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
256 JSONArray data = new JSONArray();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
257 data.set(0, new JSONNumber(val));
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
258 if (nameInputPanel.getValue() == null) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
259 data.set(1, new JSONString(valueInputPanel.getValue().toString()));
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
260 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
261 else {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
262 data.set(1, new JSONString(nameInputPanel.getValue().toString()));
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
263 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
264 oldLines.set(oldLines.size(), data);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
265
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
266 return oldLines;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
267 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
268
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
269
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
270 /**
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
271 * Called when OK Button was clicked. Then, if entered values are valid,
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
272 * fire a RedrawRequest and destroy.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
273 */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
274 protected void okClicked() {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
275 if (valueInputPanel.getValue() == null) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
276 return;
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
277 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
278 GWT.log(valueInputPanel.getValue().toString());
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
279 if(isDialogValid()) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
280 // Feed JSON-encoded content of form.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
281 JSONArray list = jsonArrayFromForm();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
282
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
283 Data[] feedData = new Data[] {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
284 DefaultData.createSimpleStringData(dataItemName,
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
285 list.toString())
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
286 };
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
287
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
288 feedService.feed(
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
289 Config.getInstance().getLocale(),
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
290 new DefaultArtifact(uuid, "TODO:hash"),
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
291 feedData,
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
292 new AsyncCallback<Artifact>() {
4568
bbd82bd8e541 flys-client: Cosmetics and warnings.
Christian Lins <christian.lins@intevation.de>
parents: 3354
diff changeset
293 @Override
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
294 public void onFailure(Throwable caught) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
295 GWT.log("Could not feed artifact with lines.");
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
296 SC.warn(MSG.getString(caught.getMessage()));
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
297 enable();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
298 }
4568
bbd82bd8e541 flys-client: Cosmetics and warnings.
Christian Lins <christian.lins@intevation.de>
parents: 3354
diff changeset
299 @Override
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
300 public void onSuccess(Artifact fartifact) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
301 GWT.log("Successfully set lines ");
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
302 redrawRequestHandler.onRedrawRequest(
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
303 new RedrawRequestEvent());
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
304 destroy();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
305 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
306 });
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
307 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
308 else {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
309 GWT.log("Dialog not valid");
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
310 SC.warn(MSG.error_dialog_not_valid());
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
311 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
312 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
313
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
314
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
315 /** Add a ManualPointArtifact to Collection. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
316 public void addArtifactCreateUI() {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
317 final Label standByLabel = new Label(MSG.standby());
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
318 addItem(standByLabel);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
319
2928
f0c7c52203c0 Minor Manual WSP editor polish.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2927
diff changeset
320 setWidth(360);
f0c7c52203c0 Minor Manual WSP editor polish.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2927
diff changeset
321 setHeight(120);
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
322 centerInPage();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
323
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
324 Config config = Config.getInstance();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
325 String locale = config.getLocale();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
326
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
327 loadArtifactService.load(
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
328 this.collection,
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
329 new Recommendation("manualpoints", ""),
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
330 "manualpoints",
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
331 locale,
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
332 new AsyncCallback<Artifact>() {
4568
bbd82bd8e541 flys-client: Cosmetics and warnings.
Christian Lins <christian.lins@intevation.de>
parents: 3354
diff changeset
333 @Override
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
334 public void onFailure(Throwable caught) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
335 GWT.log("Creating manualpoint artifact failed!");
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
336 }
4568
bbd82bd8e541 flys-client: Cosmetics and warnings.
Christian Lins <christian.lins@intevation.de>
parents: 3354
diff changeset
337 @Override
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
338 public void onSuccess(Artifact artifact) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
339 GWT.log("Successfully created artifact.");
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
340 removeItem(standByLabel);
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
341 uuid = artifact.getUuid();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
342 createUI();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
343 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
344 });
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
345 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
346
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
347
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
348 /**
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
349 * This method is called when the user aborts point editing.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
350 * @param event The event.
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
351 */
4568
bbd82bd8e541 flys-client: Cosmetics and warnings.
Christian Lins <christian.lins@intevation.de>
parents: 3354
diff changeset
352 @Override
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
353 public void onClick(ClickEvent event) {
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
354 this.destroy();
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
355 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
356
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
357
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
358 /** Return false if x or y attribute is missing. */
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
359 protected boolean isDialogValid() {
2929
0ef4753e5515 Improved manual wsp input validation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2928
diff changeset
360 return (DoubleValidator.isDouble(valueInputPanel.getValue()));
2925
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
361 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
362 }
6461b8dbe093 Added basic GUI for manual WSPs in cross sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
363 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org