annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java @ 1452:fa63366ba115

Improved area creation GUI. flys-client/trunk@3477 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 20 Dec 2011 06:54:49 +0000
parents 8da36efc839a
children 3d9f81c3f00d
rev   line source
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui.chart;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
3 import java.util.HashMap;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
4 import java.util.Map;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
5 import java.util.LinkedHashMap;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
6
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7 import com.google.gwt.core.client.GWT;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
9 import com.google.gwt.user.client.rpc.AsyncCallback;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
10
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
11 import com.smartgwt.client.util.SC;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
12
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import com.smartgwt.client.types.Alignment;
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
14 import com.smartgwt.client.types.ListGridFieldType;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
15
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import com.smartgwt.client.widgets.Canvas;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import com.smartgwt.client.widgets.grid.ListGrid;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import com.smartgwt.client.widgets.grid.ListGridField;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import com.smartgwt.client.widgets.grid.ListGridRecord;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 import com.smartgwt.client.widgets.layout.HLayout;
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
21 import com.smartgwt.client.widgets.layout.VLayout;
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
22 import com.smartgwt.client.widgets.menu.events.ClickHandler;
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
23 import com.smartgwt.client.widgets.menu.Menu;
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
24 import com.smartgwt.client.widgets.menu.MenuItem;
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
25 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 import com.smartgwt.client.widgets.form.fields.SpinnerItem;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 import com.smartgwt.client.widgets.form.DynamicForm;
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
28
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
29 import com.smartgwt.client.widgets.form.fields.SelectItem;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
30 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
33 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 import de.intevation.flys.client.client.Config;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 import de.intevation.flys.client.shared.model.Artifact;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 import de.intevation.flys.client.shared.model.Collection;
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
38 import de.intevation.flys.client.shared.model.CollectionItem;
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 import de.intevation.flys.client.shared.model.Data;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 import de.intevation.flys.client.shared.model.DefaultArtifact;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 import de.intevation.flys.client.shared.model.DefaultData;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 import de.intevation.flys.client.shared.model.FacetRecord;
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
43 import de.intevation.flys.client.shared.model.OutputMode;
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
44 import de.intevation.flys.client.shared.model.Recommendation;
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
45 import de.intevation.flys.client.shared.model.Theme;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
46 import de.intevation.flys.client.shared.model.ThemeList;
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
48 import de.intevation.flys.client.client.services.CrossSectionKMServiceAsync;
1379
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
49 import de.intevation.flys.client.client.services.FeedServiceAsync;
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
50 import de.intevation.flys.client.client.services.LoadArtifactService;
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
51 import de.intevation.flys.client.client.services.LoadArtifactServiceAsync;
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
52
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
53
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 /**
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 * ThemePanel much like ChartThemePanel, but shows an "Actions" column,
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
57 * needed for interaction in the CrossSection Charts and a selctor to
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
58 * declare which cross section profile is "master".
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 */
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 public class CrossSectionChartThemePanel
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 extends ChartThemePanel {
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
62 /** Artifact Clone/Creation service. */
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
63 protected LoadArtifactServiceAsync loadService =
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
64 GWT.create(LoadArtifactService.class);
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
66 /** Service to query measurement points of cross sections. */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
67 CrossSectionKMServiceAsync kmService = GWT.create(
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
68 de.intevation.flys.client.client.services.CrossSectionKMService.class);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
69
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
70 /** UUID of the current "master" cross section. */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
71 protected String currentMasterUUID;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
72
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
73 /** The layout (used for visual active/inactive feedback). */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
74 protected VLayout layout;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
75
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 /**
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 * Trivial constructor.
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 */
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 public CrossSectionChartThemePanel(
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
80 Collection collection,
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
81 OutputMode mode)
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 {
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 super(collection, mode);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84 }
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 /**
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
88 * Feed an artifact to let it know that it is master wrt cross-sections.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
89 * @param artifact uuid of an artifact.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
90 */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
91 public void feedTellMaster(final String artifact) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
92 Data[] feedData = DefaultData.createSimpleStringDataArray(
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
93 "cross_section.master?", "1");
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
94
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
95 feedService.feed(
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
96 Config.getInstance().getLocale(),
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
97 new DefaultArtifact(artifact, "TODO:hash"),
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
98 feedData,
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
99 new AsyncCallback<Artifact>() {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
100 public void onFailure(Throwable caught) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
101 GWT.log("Could not feed artifact (" + artifact
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
102 + ") with master marker: " + caught.getMessage());
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
103 SC.warn(MSG.getString(caught.getMessage()));
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
104 enable();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
105 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
106 public void onSuccess(Artifact artifact) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
107 GWT.log("Successfully injected master mark to " + artifact);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
108 setCurrentMaster(artifact.getUuid());
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
109 requestRedraw();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
110 enable();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
111 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
112 });
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
113 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
114
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
115
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
116 /**
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
117 * Tell an area artifact where to get the upper and lower curve from.
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
118 * @param over if null, something
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
119 */
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
120 public void feedTellArea(final String artifact, Theme under, Theme over) {
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
121
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
122 Data[] feedData;
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
123
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
124 if (over != null && under != null) {
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
125 feedData = new Data[] {
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
126 DefaultData.createSimpleStringData("area.curve_under",
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
127 under.getArtifact() + under.getIndex()),
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
128 DefaultData.createSimpleStringData("area.curve_over",
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
129 over.getArtifact() + over.getIndex()),
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
130 DefaultData.createSimpleStringData("area.name",
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
131 over.getDescription() + " / " + under.getDescription()),
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
132 DefaultData.createSimpleStringData("area.facet",
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
133 "cross_section.area")
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
134 };
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
135 GWT.log("Have over and under");
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
136 }
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
137 else if (over == null && under != null) {
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
138 feedData = new Data[] {
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
139 DefaultData.createSimpleStringData("area.curve_under",
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
140 under.getArtifact() + under.getIndex()),
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
141 DefaultData.createSimpleStringData("area.name",
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
142 under.getDescription() + " / " + MSG.getString("x_axis")),
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
143 DefaultData.createSimpleStringData("area.facet",
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
144 "cross_section.area")
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
145 };
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
146 GWT.log("Have under only");
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
147 }
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
148 else if (over != null && under == null) {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
149 feedData = new Data[] {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
150 DefaultData.createSimpleStringData("area.curve_over",
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
151 over.getArtifact() + over.getIndex()),
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
152 DefaultData.createSimpleStringData("area.name",
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
153 MSG.getString("x_axis") + " / " + over.getDescription()),
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
154 DefaultData.createSimpleStringData("area.facet",
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
155 "cross_section.area")
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
156 };
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
157 GWT.log("Have over only");
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
158 }
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
159 else {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
160 GWT.log("Missing Data for area painting.");
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
161 return;
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
162 }
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
163
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
164
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
165 feedService.feed(
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
166 Config.getInstance().getLocale(),
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
167 new DefaultArtifact(artifact, "TODO:hash"),
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
168 feedData,
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
169 new AsyncCallback<Artifact>() {
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
170 public void onFailure(Throwable caught) {
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
171 GWT.log("Could not feed artifact (" + artifact
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
172 + ") with area info: " + caught.getMessage());
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
173 SC.warn(MSG.getString(caught.getMessage()));
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
174 enable();
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
175 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
176 public void onSuccess(Artifact artifact) {
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
177 GWT.log("Successfully set area params to " + artifact);
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
178 requestRedraw();
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
179 updateCollection();
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
180 updateGrid();
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
181 enable();
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
182 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
183 });
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
184 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
185
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
186 /**
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
187 * sets currentMasterUUID.
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
188 */
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
189 public String findCurrentMaster() {
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
190 ThemeList themeList = getThemeList();
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
191 int count = getThemeList().getThemeCount();
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
192 String firstCSUuid = null;
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
193 for (int i = 1; i <= count; i++) {
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
194 Theme theme = themeList.getThemeAt(i);
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
195 String value = theme.getCollectionItem().getData().get("cross_section.master?");
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
196
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
197 if (value != null) {
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
198 if (firstCSUuid == null) {
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
199 firstCSUuid = theme.getArtifact();
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
200 }
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
201 if (!value.equals("0")) {
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
202 setCurrentMaster(theme.getArtifact());
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
203 GWT.log("found a master: " + currentMasterUUID + "/" + theme.getDescription());
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
204 return theme.getDescription();
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
205 }
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
206 }
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
207 }
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
208 // There is none selected. Take the first one.
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
209 if (firstCSUuid != null) {
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
210 setCurrentMaster(firstCSUuid);
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
211 feedTellMaster(firstCSUuid);
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
212 }
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
213 return null;
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
214 }
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
215
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
216
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
217 /**
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
218 * Create Layout, add a master selection box beneath.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
219 */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
220 @Override
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
221 protected VLayout createLayout() {
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
222 layout = super.createLayout();
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
223
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
224 // Create "set master" combobox.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
225 SelectItem cbItem = new SelectItem();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
226
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
227 cbItem.setTitle(MSG.chart_themepanel_set_master());
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
228 cbItem.setType("comboBox");
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
229 final LinkedHashMap<String, String> valueMap =
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
230 getThemeList().toMapArtifactUUIDDescription("cross_section");
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
231 cbItem.setValueMap(valueMap);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
232
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
233 final DynamicForm form = new DynamicForm();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
234 form.setWidth(200);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
235 form.setFields(cbItem);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
236 layout.addMember(form);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
237
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
238 Config config = Config.getInstance();
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
239 final String locale = config.getLocale();
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
240 findCurrentMaster();
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
241 cbItem.setValue(getCurrentMaster());
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
242
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
243 // Add Change Handler to first unset the old master and then set the
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
244 // new master.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
245 cbItem.addChangeHandler(new ChangeHandler() {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
246 public void onChange(ChangeEvent event) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
247 String selectedItem = (String) event.getValue();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
248 final String artifact = selectedItem;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
249
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
250 disable();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
251
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
252 // Tell current master that he is not master anymore.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
253 if (getCurrentMaster() != null) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
254 Data[] feedData = DefaultData.createSimpleStringDataArray(
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
255 "cross_section.master?", "0");
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
256 feedService.feed(
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
257 locale,
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
258 new DefaultArtifact(getCurrentMaster(), "TODO:hash"),
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
259 feedData,
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
260 new AsyncCallback<Artifact>() {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
261 public void onFailure(Throwable caught) {
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
262 GWT.log("Could not un-master artifact ("+getCurrentMaster()+"): " +
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
263 caught.getMessage());
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
264 SC.warn(MSG.getString(caught.getMessage()));
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
265 enable();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
266 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
267 public void onSuccess(Artifact oldMaster) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
268 GWT.log("Successfully un-mastered artifact.");
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
269 feedTellMaster(artifact);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
270 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
271 });
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
272 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
273 else {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
274 feedTellMaster(artifact);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
275 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
276 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
277 });
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
278
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
279 return layout;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
280 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
281
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
282
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
283 /** Disable the UI (becomes gray, inresponsive to user input). */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
284 public void disable() {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
285 this.layout.setDisabled(true);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
286 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
287
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
288
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
289 /** DisDisable the UI (becomes ungray, responsive to user input). */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
290 public void enable() {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
291 this.layout.setDisabled(false);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
292 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
293
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
294
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
295 /**
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
296 * Returns a double from the list that has the smallest distance to the
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
297 * given to value. In case of multiple values with the same difference,
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
298 * the last one is taken.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
299 * @param in possible return values.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
300 * @param to the value to be as close to as possible.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
301 * @return value from in that is closest to to, -1 if none.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
302 */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
303 public static double closest(Double[] in, double to) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
304 if (in == null || in.length == 0) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
305 return -1;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
306 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
307 if (in[0] == to) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
308 return to;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
309 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
310 double minDiff = Math.abs(to - in[0]);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
311 double bestMatch = in[0];
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
312 for (int i = 1; i < in.length; i++) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
313 if (in[i] == to) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
314 return to;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
315 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
316 double diff = Math.abs(to - in[0]);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
317 if (diff < minDiff) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
318 minDiff = diff;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
319 bestMatch = in[i];
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
320 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
321 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
322 return bestMatch;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
323 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
324
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
325
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
326 /** Feed a single artifact with the km of the crosssection to display. */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
327 public void sendFeed(FacetRecord facetRecord, double kmD) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
328 Config config = Config.getInstance();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
329 final String locale = config.getLocale();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
330
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
331 Data[] feedData =
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
332 DefaultData.createSimpleStringDataArray("cross_section.km",
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
333 Double.valueOf(kmD).toString());
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
334
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
335 disable();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
336 feedService.feed(
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
337 locale,
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
338 new DefaultArtifact(
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
339 facetRecord.getTheme().getArtifact(),
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
340 "TODO:hash"),
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
341 feedData,
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
342 new AsyncCallback<Artifact>() {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
343 @Override
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
344 public void onFailure(Throwable caught) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
345 GWT.log("Could not feed artifact " + caught.getMessage());
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
346 SC.warn(MSG.getString(caught.getMessage()));
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
347 enable();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
348 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
349 @Override
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
350 public void onSuccess(Artifact artifact) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
351 GWT.log("Successfully fed");
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
352 requestRedraw();
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
353 // TODO also feed the winfo/masterartifact? (for plot subtitle)
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
354 enable();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
355 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
356 });
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
357 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
358
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
359
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
360 /**
1379
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
361 * Create the handler for ChangeEvents on the Spinner in the
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
362 * facets that control km of cross section.
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
363 *
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
364 * @param feedService The FeedService to send (changed) data to.
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
365 * @param facetRecord The FacetRecord (~row in table) where this
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
366 * handler is added to (to a child, to be exact).
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
367 */
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
368 public final ChangedHandler createSpinnerHandler(
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
369 final FeedServiceAsync feedService,
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
370 final FacetRecord facetRecord)
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
371 {
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
372 Config config = Config.getInstance();
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
373 final String locale = config.getLocale();
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
374
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
375 ChangedHandler handler = new ChangedHandler()
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
376 {
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
377 @Override
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
378 public void onChanged(final ChangedEvent ce) {
1379
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
379 if (ce.getValue() == null) {
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
380 return;
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
381 }
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
382
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
383 // Now, query the value with the kmService.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
384 Map<Integer, Double> map = new HashMap<Integer,Double>();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
385 final double selected_km =
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
386 Double.parseDouble(ce.getValue().toString());
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
387
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
388 int _dbid = -1;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
389 try {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
390 _dbid = Integer.valueOf(facetRecord.getTheme()
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
391 .getCollectionItem()
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
392 .getData().get("cross_section.dbid"));
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
393 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
394 catch (NumberFormatException nfe) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
395 GWT.log("Could not extract cross-section db id from data.");
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
396 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
397 final int dbid = _dbid;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
398
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
399 map.put(dbid, Double.parseDouble(ce.getValue().toString()));
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
400
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
401 disable();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
402
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
403 kmService.getCrossSectionKMs(locale, map, 2,
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
404 new AsyncCallback<Map<Integer, Double[]>>() {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
405 @Override
1379
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
406 public void onFailure(Throwable caught) {
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
407 GWT.log("Could not get single km for "
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
408 + dbid + ": "+ caught.getMessage());
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
409 SC.warn(MSG.getString(caught.getMessage()));
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
410 updateCollection();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
411 updateGrid();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
412 enable();
1379
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
413 }
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
414 @Override
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
415 public void onSuccess(Map<Integer, Double[]> obj) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
416 Double[] kms = obj.get(dbid);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
417 double closest =
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
418 CrossSectionChartThemePanel.closest(kms,
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
419 selected_km);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
420 GWT.log("Got single km for " + dbid + ", it is "
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
421 + closest);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
422 SpinnerItem item = (SpinnerItem) ce.getItem();
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
423 item.setValue(closest);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
424 sendFeed(facetRecord, closest);
1379
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
425 }
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
426 });
1379
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
427 }
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
428 };
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
429 return handler;
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
430 }
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
431
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
432
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
433 /**
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
434 * Get the chosen km for given cross-section.
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
435 */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
436 final public double getKmForCrossSectionIdx(final int index) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
437 double km = 0d;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
438 int collIdx = 0;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
439 while (km == 0d) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
440 CollectionItem item = collection.getItem(collIdx++);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
441 if (item == null) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
442 break;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
443 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
444 if (item.getData() == null) continue;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
445 String d = item.getData().get("cross_section" + index + ".km");
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
446 if (d == null) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
447 continue;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
448 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
449 km = Double.valueOf(d);
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
450 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
451 return km;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
452 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
453
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
454
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
455 /**
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
456 * Create a "kilometer spinner" for CrossSection Facets.
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
457 * @param facetRecord The respective Facet/Theme.
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
458 * @return label, intialized SpinnerItem.
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
459 */
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
460 public SpinnerItem createSpinnerItem(FacetRecord facetRecord) {
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
461 SpinnerItem spinnerItem = new SpinnerItem();
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
462 spinnerItem.setShowTitle(false);
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
463 spinnerItem.setTitle("Waterlevel-Spinner");
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
464 spinnerItem.setWidth(45);
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
465 spinnerItem.setDefaultValue(facetRecord.getTheme()
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
466 .getCollectionItem()
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
467 .getData().get("cross_section.km"));
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
468
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
469 // TODO actually use crosssectionkmservice with
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
470 // min/max-extension
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
471 spinnerItem.setMin(0);
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
472 spinnerItem.setMax(1000);
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
473 spinnerItem.setStep(0.5f);
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
474 spinnerItem.setChangeOnKeypress(true);
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
475 return spinnerItem;
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
476 }
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
477
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
478
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
479 /**
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
480 * Create and configure the Grid to display.
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
481 * @return ListGrid with Themes and related controls inside.
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
482 */
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
483 @Override
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
484 protected ListGrid createGrid() {
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
485 ListGrid list = new ListGrid() {
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
486 @Override
1379
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
487 protected Canvas createRecordComponent(
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
488 final ListGridRecord record,
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
489 Integer colNum)
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
490 {
861
65204f30877b Display Action Widget only for cross_section theme/facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 858
diff changeset
491 // Only cross_section Facets display an action widget.
65204f30877b Display Action Widget only for cross_section theme/facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 858
diff changeset
492 final FacetRecord facetRecord = (FacetRecord) record;
65204f30877b Display Action Widget only for cross_section theme/facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 858
diff changeset
493 if (!facetRecord.getTheme().getFacet().equals(
1379
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
494 "cross_section"))
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
495 {
861
65204f30877b Display Action Widget only for cross_section theme/facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 858
diff changeset
496 return null;
65204f30877b Display Action Widget only for cross_section theme/facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 858
diff changeset
497 }
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
498
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
499 String fieldName = this.getFieldName(colNum);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
500
888
d6b88f8f88dd Fix issue flys/issue311 (i18n crossection).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 861
diff changeset
501 if (fieldName.equals(GRID_FIELD_ACTIONS)) {
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
502 HLayout recordCanvas = new HLayout(3);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
503 recordCanvas.setHeight(22);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
504 recordCanvas.setAlign(Alignment.CENTER);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
505 // TODO Refactor in createSpinner(data, artifact)
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
506 SpinnerItem spinnerItem = createSpinnerItem(facetRecord);
1379
546f7f890ffa Cosmetics, refactoring.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1378
diff changeset
507 spinnerItem.addChangedHandler(
1438
432180235caf Minor refactoring and fix initial settings when creating ui.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1436
diff changeset
508 createSpinnerHandler(feedService, facetRecord));
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
509
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
510 DynamicForm formWrap = new DynamicForm();
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
511 formWrap.setFields(spinnerItem);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
512 formWrap.setTitlePrefix("");
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
513 formWrap.setTitleSuffix("");
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
514 recordCanvas.addMember(formWrap);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
515 return recordCanvas;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
516 }
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
517 else {
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
518 return null;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
519 }
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
520 }
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
521 };
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
522 list.setCanResizeFields(true);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
523 list.setShowRecordComponents(true);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
524 list.setShowRecordComponentsByCell(true);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
525 list.setShowAllRecords(true);
1378
ebba8a8618e6 Fix flys/issue306 (CrossSections: Remove table header context menu).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 891
diff changeset
526 list.setShowHeaderContextMenu(false);
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
527 return list;
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
528 }
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
529
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
530
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
531 /**
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
532 * Initializes the components (columns) of the theme grid.
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
533 */
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
534 @Override
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
535 protected void initGrid() {
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
536 list.setCanEdit(true);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
537 list.setCanSort(false);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
538 list.setShowRecordComponents(true);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
539 list.setShowRecordComponentsByCell(true);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
540 list.setShowHeader(true);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
541 list.setWidth100();
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
542 list.setHeight100();
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
543
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
544 list.addEditCompleteHandler(this);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
545
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
546 ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
547 active.setType(ListGridFieldType.BOOLEAN);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
548
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
549 ListGridField name = new ListGridField(
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
550 GRID_FIELD_NAME, MSG.chart_themepanel_header_themes());
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
551 name.setType(ListGridFieldType.TEXT);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
552
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
553 ListGridField actions = new ListGridField(GRID_FIELD_ACTIONS,
891
f6c14ffdfd07 Rest for fix for flys/issue311 .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 890
diff changeset
554 MSG.chart_themepanel_header_actions(), 50);
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
555
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
556 list.setFields(active, name, actions);
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
557 }
1436
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
558
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
559
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
560 /** Get Current Cross-section Masters uuid. */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
561 public String getCurrentMaster() {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
562 return currentMasterUUID;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
563 }
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
564
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
565
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
566 /** Set Current Cross-section Masters uuid. */
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
567 public void setCurrentMaster(String currentMasterUuid) {
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
568 this.currentMasterUUID = currentMasterUuid;
29fc2d1dfe9b Client side of interactive cross section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
569 }
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
570
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
571
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
572 /**
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
573 * Create and parameterize a new area artifact.
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
574 * @param under
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
575 * @param over if null, something.
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
576 */
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
577 public void createAreaArtifact(
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
578 final Theme under,
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
579 final Theme over,
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
580 boolean between
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
581 ) {
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
582 Config config = Config.getInstance();
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
583 String locale = config.getLocale();
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
584
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
585 Recommendation area = new Recommendation(
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
586 "area",
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
587 "",
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
588 "",
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
589 null);
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
590 Recommendation[] recommendations = new Recommendation[] {area};
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
591
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
592 loadService.loadMany(
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
593 this.collection,
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
594 recommendations,
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
595 null, //use individual factories.
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
596 locale,
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
597 new AsyncCallback<Artifact[]>() {
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
598 public void onFailure(Throwable caught) {
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
599 GWT.log("Failed, no area artifact: " + caught.getMessage());
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
600 enable();
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
601 // TODO SC.warn
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
602 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
603 public void onSuccess(Artifact[] artifacts) {
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
604 GWT.log("Success, created area artifact: "
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
605 + artifacts[0].getUuid());
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
606 // Now, feed the artifact with the relevant data.
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
607 feedTellArea(artifacts[0].getUuid(), under, over);
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
608 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
609 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
610 );
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
611 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
612
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
613 /**
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
614 * Include area specific menu items.
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
615 */
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
616 protected Menu getSingleContextMenu(final ListGridRecord[] records) {
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
617 Menu menu = super.getSingleContextMenu(records);
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
618
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
619 final Theme facetTheme = ((FacetRecord)records[0]).getTheme();
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
620 String thisItem = facetTheme.getDescription();
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
621 if (facetTheme.getFacet().equals("area") ||
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
622 facetTheme.getFacet().equals("cross_section.area")
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
623 ) {
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
624 return menu;
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
625 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
626
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
627 menu.addItem(createSeparator());
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
628
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
629 // TODO i18n
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
630 //MenuItem properties = new MenuItem(MSG.properties());
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
631 MenuItem areaMenuItem = new MenuItem("New Area...");
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
632 Menu areaMenu = new Menu();
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
633
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
634 ThemeList themes = getThemeList();
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
635 int nThemes = themes.getThemeCount();
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
636
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
637 MenuItem underMenuItem = new MenuItem("Under ...");
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
638 Menu underMenu = new Menu();
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
639 for (int i = 0; i < nThemes; i++) {
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
640 final Theme theme = themes.getThemeAt(i+1);
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
641 if (theme.getDescription().equals(thisItem)
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
642 || theme.getFacet().equals("area")
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
643 || theme.getFacet().equals("cross_section.area")
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
644 ) {
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
645 continue;
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
646 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
647 MenuItem againster = new MenuItem(theme.getDescription());
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
648 underMenu.addItem(againster);
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
649
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
650 againster.addClickHandler(new ClickHandler() {
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
651 public void onClick(MenuItemClickEvent evt) {
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
652 disable();
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
653 createAreaArtifact(theme, facetTheme, false);
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
654 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
655 });
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
656 }
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
657
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
658 MenuItem overMenuItem = new MenuItem("Over ...");
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
659 Menu overMenu = new Menu();
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
660 for (int i = 0; i < nThemes; i++) {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
661 final Theme theme = themes.getThemeAt(i+1);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
662 if (theme.getDescription().equals(thisItem)
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
663 || theme.getFacet().equals("area")
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
664 || theme.getFacet().equals("cross_section.area")
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
665 ) {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
666 continue;
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
667 }
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
668 MenuItem againster = new MenuItem(theme.getDescription());
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
669 overMenu.addItem(againster);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
670
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
671 againster.addClickHandler(new ClickHandler() {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
672 public void onClick(MenuItemClickEvent evt) {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
673 disable();
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
674 createAreaArtifact(facetTheme, theme, false);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
675 }
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
676 });
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
677 }
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
678 overMenu.addItem(createSeparator());
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
679 MenuItem againstAxis = new MenuItem(MSG.getString("x_axis"));
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
680 againstAxis.addClickHandler(new ClickHandler() {
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
681 public void onClick(MenuItemClickEvent evt) {
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
682 disable();
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
683 createAreaArtifact(facetTheme, null, false);
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
684 }
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
685 });
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
686 overMenu.addItem(againstAxis);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
687
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
688 MenuItem betweenMenuItem = new MenuItem("Between ...");
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
689 Menu betweenMenu = new Menu();
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
690 for (int i = 0; i < nThemes; i++) {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
691 final Theme theme = themes.getThemeAt(i+1);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
692 if (theme.getDescription().equals(thisItem)
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
693 || theme.getFacet().equals("area")
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
694 || theme.getFacet().equals("cross_section.area")
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
695 ) {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
696 continue;
1445
df7ebcbff984 Bugfixing and feature-adding for cross-sections/areas.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1444
diff changeset
697 }
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
698 MenuItem againster = new MenuItem(theme.getDescription());
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
699 betweenMenu.addItem(againster);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
700
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
701 againster.addClickHandler(new ClickHandler() {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
702 public void onClick(MenuItemClickEvent evt) {
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
703 disable();
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
704 createAreaArtifact(facetTheme, theme, true);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
705 }
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
706 });
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
707 }
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
708 betweenMenu.addItem(createSeparator());
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
709 betweenMenu.addItem(againstAxis);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
710
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
711 overMenuItem.setSubmenu(overMenu);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
712 underMenuItem.setSubmenu(underMenu);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
713 betweenMenuItem.setSubmenu(betweenMenu);
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
714
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
715 areaMenu.addItem(overMenuItem);
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
716 areaMenu.addItem(underMenuItem);
1452
fa63366ba115 Improved area creation GUI.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1449
diff changeset
717 areaMenu.addItem(betweenMenuItem);
1444
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
718
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
719 areaMenuItem.setSubmenu(areaMenu);
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
720 menu.addItem(areaMenuItem);
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
721
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
722 return menu;
bdac8a72f7e6 Area creation UI update.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1438
diff changeset
723 }
858
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
724 }
9f07f67f60a5 Subclassed ChartThemePanel, trigger redraws of Chart when interaction with
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
725 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org