comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/chart/ChartThemePanel.java @ 9416:05405292a7ca

Navigationtheme panel now shows themes of dWt and WQ charts grayed out, if the current station is outside the valid range of the theme.
author gernotbelger
date Thu, 16 Aug 2018 16:28:03 +0200
parents 5e38e2924c07
children
comparison
equal deleted inserted replaced
9415:9744ce3c3853 9416:05405292a7ca
6 * documentation coming with Dive4Elements River for details. 6 * documentation coming with Dive4Elements River for details.
7 */ 7 */
8 8
9 package org.dive4elements.river.client.client.ui.chart; 9 package org.dive4elements.river.client.client.ui.chart;
10 10
11 import com.google.gwt.core.client.GWT;
12 import com.google.gwt.user.client.rpc.AsyncCallback;
13
14 import com.smartgwt.client.types.ListGridFieldType;
15 import com.smartgwt.client.util.SC;
16 import com.smartgwt.client.widgets.grid.ListGridField;
17 import com.smartgwt.client.widgets.grid.ListGridRecord;
18 import com.smartgwt.client.widgets.layout.VLayout;
19 import com.smartgwt.client.widgets.menu.Menu;
20 import com.smartgwt.client.widgets.menu.MenuItem;
21 import com.smartgwt.client.widgets.menu.events.ClickHandler;
22 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
23
24 import org.dive4elements.river.client.client.Config; 11 import org.dive4elements.river.client.client.Config;
25 import org.dive4elements.river.client.client.FLYSConstants;
26 import org.dive4elements.river.client.client.services.FeedServiceAsync; 12 import org.dive4elements.river.client.client.services.FeedServiceAsync;
27 import org.dive4elements.river.client.client.services.LoadArtifactService; 13 import org.dive4elements.river.client.client.services.LoadArtifactService;
28 import org.dive4elements.river.client.client.services.LoadArtifactServiceAsync; 14 import org.dive4elements.river.client.client.services.LoadArtifactServiceAsync;
29 import org.dive4elements.river.client.client.ui.CollectionView; 15 import org.dive4elements.river.client.client.ui.CollectionView;
16 import org.dive4elements.river.client.client.ui.IThemeRecordHandler;
30 import org.dive4elements.river.client.client.ui.ThemePanel; 17 import org.dive4elements.river.client.client.ui.ThemePanel;
31 import org.dive4elements.river.client.shared.model.Artifact; 18 import org.dive4elements.river.client.shared.model.Artifact;
32 import org.dive4elements.river.client.shared.model.Data; 19 import org.dive4elements.river.client.shared.model.Data;
33 import org.dive4elements.river.client.shared.model.DefaultArtifact; 20 import org.dive4elements.river.client.shared.model.DefaultArtifact;
34 import org.dive4elements.river.client.shared.model.DefaultData; 21 import org.dive4elements.river.client.shared.model.DefaultData;
36 import org.dive4elements.river.client.shared.model.OutputMode; 23 import org.dive4elements.river.client.shared.model.OutputMode;
37 import org.dive4elements.river.client.shared.model.Recommendation; 24 import org.dive4elements.river.client.shared.model.Recommendation;
38 import org.dive4elements.river.client.shared.model.Theme; 25 import org.dive4elements.river.client.shared.model.Theme;
39 import org.dive4elements.river.client.shared.model.ThemeList; 26 import org.dive4elements.river.client.shared.model.ThemeList;
40 27
28 import com.google.gwt.core.client.GWT;
29 import com.google.gwt.user.client.rpc.AsyncCallback;
30 import com.smartgwt.client.types.ListGridFieldType;
31 import com.smartgwt.client.util.SC;
32 import com.smartgwt.client.widgets.grid.CellFormatter;
33 import com.smartgwt.client.widgets.grid.ListGridField;
34 import com.smartgwt.client.widgets.grid.ListGridRecord;
35 import com.smartgwt.client.widgets.layout.VLayout;
36 import com.smartgwt.client.widgets.menu.Menu;
37 import com.smartgwt.client.widgets.menu.MenuItem;
38 import com.smartgwt.client.widgets.menu.events.ClickHandler;
39 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
41 40
42 /** 41 /**
43 * ThemePanel on the left in CollectionView. 42 * ThemePanel on the left in CollectionView.
44 * Contains control widgets for "themes", which are plotted 43 * Contains control widgets for "themes", which are plotted
45 * in a diagram (chart). 44 * in a diagram (chart).
46 * 45 *
47 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 46 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
48 */ 47 */
49 public class ChartThemePanel extends ThemePanel { 48 public class ChartThemePanel extends ThemePanel {
50 /** Artifact Clone/Creation service. */ 49 /** Artifact Clone/Creation service. */
51 protected LoadArtifactServiceAsync loadService = 50 private final LoadArtifactServiceAsync loadService = GWT.create(LoadArtifactService.class);
52 GWT.create(LoadArtifactService.class); 51
53 52 protected static final String GRID_FIELD_ACTIVE = "active";
54 /** The interface that provides i18n messages. */ 53 protected static final String GRID_FIELD_NAME = "name";
55 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); 54 protected static final String GRID_FIELD_ACTIONS = "actions";
56 55
57 public static final String GRID_FIELD_ACTIVE = "active"; 56 protected final FeedServiceAsync feedService = GWT.create(org.dive4elements.river.client.client.services.FeedService.class);
58 public static final String GRID_FIELD_NAME = "name"; 57
59 public static final String GRID_FIELD_ACTIONS = "actions"; 58 /** Constructor for a ChartThemePanel.
60 59 * @param recordHandler */
61 FeedServiceAsync feedService = GWT.create( 60 public ChartThemePanel(final OutputMode mode, final CollectionView view, final IThemeRecordHandler recordHandler) {
62 org.dive4elements.river.client.client.services.FeedService.class); 61 super(mode, view, recordHandler);
63 62
64 63 initGrid(recordHandler);
65 /** Constructor for a ChartThemePanel. */
66 public ChartThemePanel(
67 OutputMode mode,
68 CollectionView view
69 ) {
70 super(mode, view);
71
72 initGrid();
73 initLayout(); 64 initLayout();
74 65
75 updateGrid(); 66 updateGrid();
76 } 67 }
77
78 68
79 /** Creates Layout with theme list and navigation bar inside. */ 69 /** Creates Layout with theme list and navigation bar inside. */
80 protected VLayout createLayout() { 70 protected VLayout createLayout() {
81 VLayout layout = new VLayout(); 71 final VLayout layout = new VLayout();
82 layout.setWidth100(); 72 layout.setWidth100();
83 layout.setHeight100(); 73 layout.setHeight100();
84 74
85 layout.addMember(list); 75 layout.addMember(this.list);
86 layout.addMember(navigation); 76 layout.addMember(this.navigation);
87 77
88 return layout; 78 return layout;
89 } 79 }
90 80
91
92 /** 81 /**
93 * Initializes the layout of this panel. 82 * Initializes the layout of this panel.
94 */ 83 */
95 protected void initLayout() { 84 private void initLayout() {
96 setWidth100(); 85 setWidth100();
97 setHeight100(); 86 setHeight100();
98 87
99 addChild(createLayout()); 88 addChild(createLayout());
100 } 89 }
101 90
102
103 /** 91 /**
104 * Initializes the components (columns) of the theme grid. 92 * Initializes the components (columns) of the theme grid.
105 */ 93 * @param recordHandler
106 protected void initGrid() { 94 */
107 list.setCanEdit(true); 95 protected void initGrid( final IThemeRecordHandler recordHandler ) {
108 list.setCanSort(false); 96 this.list.setCanEdit(true);
109 list.setShowRecordComponents(false); 97 this.list.setCanSort(false);
110 list.setShowRecordComponentsByCell(true); 98 this.list.setShowRecordComponents(false);
111 list.setShowHeader(true); 99 this.list.setShowRecordComponentsByCell(true);
112 list.setShowHeaderContextMenu(false); 100 this.list.setShowHeader(true);
113 list.setWidth100(); 101 this.list.setShowHeaderContextMenu(false);
114 list.setHeight100(); 102 this.list.setWidth100();
115 103 this.list.setHeight100();
116 list.addEditCompleteHandler(this); 104
117 105 this.list.addEditCompleteHandler(this);
118 ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20); 106
107 final ListGridField active = new ListGridField(GRID_FIELD_ACTIVE, " ", 20);
119 active.setType(ListGridFieldType.BOOLEAN); 108 active.setType(ListGridFieldType.BOOLEAN);
120 109
121 ListGridField name = new ListGridField( 110 final ListGridField name = new ListGridField(GRID_FIELD_NAME, this.MSG.chart_themepanel_header_themes());
122 GRID_FIELD_NAME, MSG.chart_themepanel_header_themes());
123 name.setType(ListGridFieldType.TEXT); 111 name.setType(ListGridFieldType.TEXT);
124 112
125 list.setFields(active, name); 113 if( recordHandler instanceof CellFormatter)
126 } 114 name.setCellFormatter((CellFormatter) recordHandler);
127 115
116 this.list.setFields(active, name);
117 }
128 118
129 /** Set theme active/inactive. */ 119 /** Set theme active/inactive. */
130 @Override 120 @Override
131 public void activateTheme(Theme theme, boolean active) { 121 public void activateTheme(final Theme theme, final boolean active) {
132 theme.setActive(active ? 1 : 0); 122 theme.setActive(active ? 1 : 0);
133 } 123 }
134
135 124
136 /** Returns name of longitudinal section area facets. */ 125 /** Returns name of longitudinal section area facets. */
137 protected String getAreaFacetName() { 126 protected String getAreaFacetName() {
138 return "longitudinal_section.area"; 127 return "longitudinal_section.area";
139 } 128 }
140 129
141
142 /** Create the DataProvider ('Blackboard') key for a theme. */ 130 /** Create the DataProvider ('Blackboard') key for a theme. */
143 public static String areaKey(Theme theme) { 131 public static String areaKey(final Theme theme) {
144 return theme.getArtifact() + ":" + theme.getFacet() + ":" 132 return theme.getArtifact() + ":" + theme.getFacet() + ":" + theme.getIndex();
145 + theme.getIndex(); 133 }
146 }
147
148 134
149 /** 135 /**
150 * Tell an area artifact where to get the upper and lower curve from. 136 * Tell an area artifact where to get the upper and lower curve from.
151 * @param artifact UUID of area-artifact. 137 *
152 */ 138 * @param artifact
153 public void feedTellArea( 139 * UUID of area-artifact.
154 final String artifact, 140 */
155 Theme under, 141 public void feedTellArea(final String artifact, final Theme under, final Theme over, final boolean between) {
156 Theme over,
157 boolean between
158 ) {
159 Data[] feedData; 142 Data[] feedData;
160 143
161 if (over != null && under != null) { 144 if (over != null && under != null) {
162 feedData = new Data[] { 145 feedData = new Data[] { DefaultData.createSimpleStringData("area.curve_under", areaKey(under)),
163 DefaultData.createSimpleStringData("area.curve_under", 146 DefaultData.createSimpleStringData("area.curve_over", areaKey(over)),
164 areaKey(under)), 147 DefaultData.createSimpleStringData("area.name", over.getDescription() + " / " + under.getDescription()),
165 DefaultData.createSimpleStringData("area.curve_over", 148 DefaultData.createSimpleStringData("area.facet", getAreaFacetName()),
166 areaKey(over)), 149 DefaultData.createSimpleStringData("area.between", (between) ? "true" : "false") };
167 DefaultData.createSimpleStringData("area.name",
168 over.getDescription() + " / " + under.getDescription()),
169 DefaultData.createSimpleStringData("area.facet",
170 getAreaFacetName()),
171 DefaultData.createSimpleStringData("area.between",
172 (between)? "true" : "false")
173 };
174 GWT.log("Have 'over' and 'under' curve"); 150 GWT.log("Have 'over' and 'under' curve");
175 } 151 } else if (over == null && under != null) {
176 else if (over == null && under != null) { 152 feedData = new Data[] { DefaultData.createSimpleStringData("area.curve_under", areaKey(under)),
177 feedData = new Data[] { 153 DefaultData.createSimpleStringData("area.name", under.getDescription() + " / " + this.MSG.getString("x_axis")),
178 DefaultData.createSimpleStringData("area.curve_under", 154 DefaultData.createSimpleStringData("area.facet", getAreaFacetName()),
179 areaKey(under)), 155 DefaultData.createSimpleStringData("area.between", (between) ? "true" : "false") };
180 DefaultData.createSimpleStringData("area.name",
181 under.getDescription() + " / " + MSG.getString("x_axis")),
182 DefaultData.createSimpleStringData("area.facet",
183 getAreaFacetName()),
184 DefaultData.createSimpleStringData("area.between",
185 (between)? "true" : "false")
186 };
187 GWT.log("Have 'under' curve only"); 156 GWT.log("Have 'under' curve only");
188 } 157 } else if (over != null && under == null) {
189 else if (over != null && under == null) { 158 feedData = new Data[] { DefaultData.createSimpleStringData("area.curve_over", areaKey(over)),
190 feedData = new Data[] { 159 DefaultData.createSimpleStringData("area.name", this.MSG.getString("x_axis") + " / " + over.getDescription()),
191 DefaultData.createSimpleStringData("area.curve_over", 160 DefaultData.createSimpleStringData("area.facet", getAreaFacetName()),
192 areaKey(over)), 161 DefaultData.createSimpleStringData("area.between", (between) ? "true" : "false") };
193 DefaultData.createSimpleStringData("area.name",
194 MSG.getString("x_axis") + " / " + over.getDescription()),
195 DefaultData.createSimpleStringData("area.facet",
196 getAreaFacetName()),
197 DefaultData.createSimpleStringData("area.between",
198 (between)? "true" : "false")
199 };
200 GWT.log("Have 'over' curve only"); 162 GWT.log("Have 'over' curve only");
201 } 163 } else {
202 else {
203 GWT.log("Missing Data for area painting."); 164 GWT.log("Missing Data for area painting.");
204 return; 165 return;
205 } 166 }
206 167
207 feedService.feed( 168 this.feedService.feed(Config.getInstance().getLocale(), new DefaultArtifact(artifact, "TODO:hash"), feedData, new AsyncCallback<Artifact>() {
208 Config.getInstance().getLocale(), 169 @Override
209 new DefaultArtifact(artifact, "TODO:hash"), 170 public void onFailure(final Throwable caught) {
210 feedData, 171 GWT.log("Could not feed artifact (" + artifact + ") with area info: " + caught.getMessage());
211 new AsyncCallback<Artifact>() { 172 SC.warn(ChartThemePanel.this.MSG.getString(caught.getMessage()));
212 @Override 173 enable();
213 public void onFailure(Throwable caught) { 174 }
214 GWT.log("Could not feed artifact (" + artifact 175
215 + ") with area info: " + caught.getMessage()); 176 @Override
216 SC.warn(MSG.getString(caught.getMessage())); 177 public void onSuccess(final Artifact fartifact) {
217 enable(); 178 GWT.log("Successfully set area params to " + artifact);
218 } 179 requestRedraw();
219 @Override 180 updateCollection();
220 public void onSuccess(Artifact fartifact) { 181 updateGrid();
221 GWT.log("Successfully set area params to " + artifact); 182 enable();
222 requestRedraw(); 183 }
223 updateCollection(); 184 });
224 updateGrid(); 185 }
225 enable();
226 }
227 });
228 }
229
230 186
231 /** 187 /**
232 * Create and parameterize a new area artifact. 188 * Create and parameterize a new area artifact.
189 *
233 * @param under 190 * @param under
234 * @param over if null, against axis. 191 * @param over
235 * @param between if true, ignore under/over order. 192 * if null, against axis.
236 */ 193 * @param between
237 public void createAreaArtifact( 194 * if true, ignore under/over order.
238 final Theme over, 195 */
239 final Theme under, 196 public void createAreaArtifact(final Theme over, final Theme under, final boolean between) {
240 final boolean between 197 final Config config = Config.getInstance();
241 ) { 198 final String locale = config.getLocale();
242 Config config = Config.getInstance(); 199
243 String locale = config.getLocale(); 200 final Recommendation area = new Recommendation("area", "", "", null);
244
245 Recommendation area = new Recommendation(
246 "area",
247 "",
248 "",
249 null);
250 201
251 // Set target out dynamically. 202 // Set target out dynamically.
252 area.setTargetOut(getMode().getName()); 203 area.setTargetOut(getMode().getName());
253 204
254 Recommendation[] recommendations = new Recommendation[] {area}; 205 final Recommendation[] recommendations = new Recommendation[] { area };
255 206
256 loadService.loadMany( 207 this.loadService.loadMany(this.getCollection(), recommendations, null, // use individual factories.
257 this.getCollection(), 208 locale, new AsyncCallback<Artifact[]>() {
258 recommendations, 209 @Override
259 null, //use individual factories. 210 public void onFailure(final Throwable caught) {
260 locale, 211 GWT.log("Failed, no area artifact: " + caught.getMessage());
261 new AsyncCallback<Artifact[]>() { 212 enable();
262 @Override 213 // TODO i18n
263 public void onFailure(Throwable caught) { 214 SC.warn("Failed, no area artifact: " + caught.getMessage());
264 GWT.log("Failed, no area artifact: " + caught.getMessage()); 215 }
265 enable(); 216
266 // TODO i18n 217 @Override
267 SC.warn("Failed, no area artifact: " + caught.getMessage()); 218 public void onSuccess(final Artifact[] artifacts) {
268 } 219 GWT.log("Success, created area artifact: " + artifacts[0].getUuid());
269 @Override 220 // Now, feed the artifact with the relevant data.
270 public void onSuccess(Artifact[] artifacts) { 221 feedTellArea(artifacts[0].getUuid(), under, over, between);
271 GWT.log("Success, created area artifact: " 222 }
272 + artifacts[0].getUuid()); 223 });
273 // Now, feed the artifact with the relevant data. 224 }
274 feedTellArea(artifacts[0].getUuid(), under, over, between);
275 }
276 }
277 );
278 }
279
280 225
281 /** 226 /**
282 * Return true if two themes are canditates for an area being 227 * Return true if two themes are canditates for an area being
283 * rendered between them. 228 * rendered between them.
284 * TODO join with canArea, generalize to allow easier modification 229 * TODO join with canArea, generalize to allow easier modification
285 * in subclasses. 230 * in subclasses.
286 */ 231 */
287 protected boolean areAreaCompatible(Theme a, Theme b) { 232 protected boolean areAreaCompatible(final Theme a, final Theme b) {
288 if (a.equals(b)) { 233 if (a.equals(b)) {
289 return false; 234 return false;
290 } 235 }
291 if (a.getFacet().equals("w_differences") && 236 if (a.getFacet().equals("w_differences") && b.getFacet().equals("w_differences")) {
292 b.getFacet().equals("w_differences")) {
293 return true; 237 return true;
294 } 238 }
295 if (a.getFacet().equals("longitudinal_section.w") || 239 if (a.getFacet().equals("longitudinal_section.w") || a.getFacet().equals("other.wqkms.w") || a.getFacet().equals("other.wqkms")
296 a.getFacet().equals("other.wqkms.w") || 240 || a.getFacet().equals("discharge_longitudinal_section.w") || a.getFacet().equals("discharge_longitudinal_section.c")
297 a.getFacet().equals("other.wqkms") || 241 || a.getFacet().equals("other.wkms")) {
298 a.getFacet().equals("discharge_longitudinal_section.w") || 242 return b.getFacet().equals("longitudinal_section.w") || b.getFacet().equals("other.wqkms") || b.getFacet().equals("other.wqkms.w")
299 a.getFacet().equals("discharge_longitudinal_section.c") || 243 || b.getFacet().equals("discharge_longitudinal_section.w") || b.getFacet().equals("discharge_longitudinal_section.c")
300 a.getFacet().equals("other.wkms")) { 244 || b.getFacet().equals("other.wkms");
301 return b.getFacet().equals("longitudinal_section.w") 245 } else if (a.getFacet().equals("longitudinal_section.q") || a.getFacet().equals("discharge_longitudinal_section.q")
302 || b.getFacet().equals("other.wqkms") 246 || a.getFacet().equals("other.wqkms.q")) {
303 || b.getFacet().equals("other.wqkms.w") 247 return b.getFacet().equals("longitudinal_section.q") || b.getFacet().equals("discharge_longitudinal_section.q")
304 || b.getFacet().equals("discharge_longitudinal_section.w")
305 || b.getFacet().equals("discharge_longitudinal_section.c")
306 || b.getFacet().equals("other.wkms");
307 }
308 else if (a.getFacet().equals("longitudinal_section.q") ||
309 a.getFacet().equals("discharge_longitudinal_section.q") ||
310 a.getFacet().equals("other.wqkms.q")) {
311 return b.getFacet().equals("longitudinal_section.q")
312 || b.getFacet().equals("discharge_longitudinal_section.q")
313 || b.getFacet().equals("other.wqkms.q"); 248 || b.getFacet().equals("other.wqkms.q");
314 } 249 }
315 return false; 250 return false;
316 } 251 }
317
318 252
319 /** 253 /**
320 * True if context menu should contain 'create area' submenu on 254 * True if context menu should contain 'create area' submenu on
321 * this theme. 255 * this theme.
322 */ 256 */
323 protected boolean canArea(Theme a) { 257 protected boolean canArea(final Theme a) {
324 return a.getFacet().equals("longitudinal_section.q") 258 return a.getFacet().equals("longitudinal_section.q") || a.getFacet().equals("longitudinal_section.w")
325 || a.getFacet().equals("longitudinal_section.w") 259 || a.getFacet().equals("discharge_longitudinal_section.w") || a.getFacet().equals("discharge_longitudinal_section.q")
326 || a.getFacet().equals("discharge_longitudinal_section.w") 260 || a.getFacet().equals("discharge_longitudinal_section.c") || a.getFacet().startsWith("other.wqkms") || a.getFacet().equals("other.wkms")
327 || a.getFacet().equals("discharge_longitudinal_section.q") 261 || a.getFacet().equals("w_differences");
328 || a.getFacet().equals("discharge_longitudinal_section.c") 262 }
329 || a.getFacet().startsWith("other.wqkms")
330 || a.getFacet().equals("other.wkms")
331 || a.getFacet().equals("w_differences");
332 }
333
334 263
335 /** Attach menu/item to open editor for Manual Points. */ 264 /** Attach menu/item to open editor for Manual Points. */
336 protected void attachManualPointsMenu(Menu menu) { 265 protected void attachManualPointsMenu(final Menu menu) {
337 menu.addItem(createSeparator()); 266 menu.addItem(createSeparator());
338 MenuItem editManualPoints = new MenuItem(MSG.editpoints()); 267 final MenuItem editManualPoints = new MenuItem(this.MSG.editpoints());
339 268
340 editManualPoints.addClickHandler(new ClickHandler() { 269 editManualPoints.addClickHandler(new ClickHandler() {
341 @Override 270 @Override
342 public void onClick(MenuItemClickEvent evt) { 271 public void onClick(final MenuItemClickEvent evt) {
343 if(mode.getName().equals("historical_discharge")) { 272 if (ChartThemePanel.this.mode.getName().equals("historical_discharge")) {
344 new ManualDatePointsEditor(view.getCollection(), 273 new ManualDatePointsEditor(ChartThemePanel.this.view.getCollection(), ChartThemePanel.this.redrawRequestHandlers.get(0),
345 redrawRequestHandlers.get(0), 274 ChartThemePanel.this.mode.getName()).show();
346 mode.getName()).show(); 275 } else {
347 } 276 new ManualPointsEditor(ChartThemePanel.this.view.getCollection(), ChartThemePanel.this.redrawRequestHandlers.get(0),
348 else { 277 ChartThemePanel.this.mode.getName()).show();
349 new ManualPointsEditor(view.getCollection(),
350 redrawRequestHandlers.get(0),
351 mode.getName()).show();
352 }
353 } 278 }
354 }); 279 }
280 });
355 menu.addItem(editManualPoints); 281 menu.addItem(editManualPoints);
356 } 282 }
357
358 283
359 /** 284 /**
360 * Include area specific menu items and manual point editor, depending 285 * Include area specific menu items and manual point editor, depending
361 * on facet. 286 * on facet.
362 */ 287 */
363 @Override 288 @Override
364 protected Menu getSingleContextMenu(final ListGridRecord[] records) { 289 protected Menu getSingleContextMenu(final ListGridRecord[] records) {
365 Menu menu = super.getSingleContextMenu(records); 290 final Menu menu = super.getSingleContextMenu(records);
366 291
367 final Theme facetTheme = ((FacetRecord)records[0]).getTheme(); 292 final Theme facetTheme = ((FacetRecord) records[0]).getTheme();
368 293
369 if (!canArea(facetTheme)) { 294 if (!canArea(facetTheme)) {
370 if (facetTheme.getFacet().endsWith("manualpoints")) { 295 if (facetTheme.getFacet().endsWith("manualpoints")) {
371 attachManualPointsMenu(menu); 296 attachManualPointsMenu(menu);
372 return menu; 297 return menu;
373 } 298 } else {
374 else {
375 return menu; 299 return menu;
376 } 300 }
377 } 301 }
378 302
379 menu.addItem(createSeparator()); 303 menu.addItem(createSeparator());
380 304
381 MenuItem areaMenuItem = new MenuItem(MSG.chart_themepanel_new_area()); 305 final MenuItem areaMenuItem = new MenuItem(this.MSG.chart_themepanel_new_area());
382 Menu areaMenu = new Menu(); 306 final Menu areaMenu = new Menu();
383 307
384 ThemeList themes = getThemeList(); 308 final ThemeList themes = getThemeList();
385 int nThemes = themes.getThemeCount(); 309 final int nThemes = themes.getThemeCount();
386 310
387 // Create the "under..." submenu. 311 // Create the "under..." submenu.
388 MenuItem underMenuItem = new MenuItem( 312 final MenuItem underMenuItem = new MenuItem(this.MSG.chart_themepanel_area_under());
389 MSG.chart_themepanel_area_under()); 313 final Menu underMenu = new Menu();
390 Menu underMenu = new Menu(); 314 for (int i = 0; i < nThemes; i++) {
391 for (int i = 0; i < nThemes; i++) { 315 final Theme theme = themes.getThemeAt(i + 1);
392 final Theme theme = themes.getThemeAt(i+1);
393 316
394 if (theme.getVisible() == 0) { 317 if (theme.getVisible() == 0) {
395 continue; 318 continue;
396 } 319 }
397 320
398 if (!areAreaCompatible(facetTheme, theme)) { 321 if (!areAreaCompatible(facetTheme, theme)) {
399 continue; 322 continue;
400 } 323 }
401 324
402 MenuItem againster = new MenuItem(theme.getDescription()); 325 final MenuItem againster = new MenuItem(theme.getDescription());
403 underMenu.addItem(againster); 326 underMenu.addItem(againster);
404 327
405 againster.addClickHandler(new ClickHandler() { 328 againster.addClickHandler(new ClickHandler() {
406 @Override 329 @Override
407 public void onClick(MenuItemClickEvent evt) { 330 public void onClick(final MenuItemClickEvent evt) {
408 disable(); 331 disable();
409 createAreaArtifact(theme, facetTheme, false); 332 createAreaArtifact(theme, facetTheme, false);
410 } 333 }
411 }); 334 });
412 } 335 }
413 336
414 // Create the "over..." submenu. 337 // Create the "over..." submenu.
415 MenuItem overMenuItem = new MenuItem(MSG.chart_themepanel_area_over()); 338 final MenuItem overMenuItem = new MenuItem(this.MSG.chart_themepanel_area_over());
416 Menu overMenu = new Menu(); 339 final Menu overMenu = new Menu();
417 for (int i = 0; i < nThemes; i++) { 340 for (int i = 0; i < nThemes; i++) {
418 final Theme theme = themes.getThemeAt(i+1); 341 final Theme theme = themes.getThemeAt(i + 1);
419 if (theme.getVisible() == 0) { 342 if (theme.getVisible() == 0) {
420 continue; 343 continue;
421 } 344 }
422 if (!areAreaCompatible(facetTheme, theme)) { 345 if (!areAreaCompatible(facetTheme, theme)) {
423 continue; 346 continue;
424 } 347 }
425 MenuItem againster = new MenuItem(theme.getDescription()); 348 final MenuItem againster = new MenuItem(theme.getDescription());
426 overMenu.addItem(againster); 349 overMenu.addItem(againster);
427 350
428 againster.addClickHandler(new ClickHandler() { 351 againster.addClickHandler(new ClickHandler() {
429 @Override 352 @Override
430 public void onClick(MenuItemClickEvent evt) { 353 public void onClick(final MenuItemClickEvent evt) {
431 disable(); 354 disable();
432 createAreaArtifact(facetTheme, theme, false); 355 createAreaArtifact(facetTheme, theme, false);
433 } 356 }
434 }); 357 });
435 } 358 }
436 overMenu.addItem(createSeparator()); 359 overMenu.addItem(createSeparator());
437 MenuItem againstAxis = new MenuItem(MSG.getString("x_axis")); 360 final MenuItem againstAxis = new MenuItem(this.MSG.getString("x_axis"));
438 againstAxis.addClickHandler(new ClickHandler() { 361 againstAxis.addClickHandler(new ClickHandler() {
439 @Override 362 @Override
440 public void onClick(MenuItemClickEvent evt) { 363 public void onClick(final MenuItemClickEvent evt) {
441 disable(); 364 disable();
442 createAreaArtifact(null, facetTheme, false); 365 createAreaArtifact(null, facetTheme, false);
443 } 366 }
444 }); 367 });
445 overMenu.addItem(againstAxis); 368 overMenu.addItem(againstAxis);
446 369
447 // Create the "between..." submenu. 370 // Create the "between..." submenu.
448 MenuItem betweenMenuItem = new MenuItem( 371 final MenuItem betweenMenuItem = new MenuItem(this.MSG.chart_themepanel_area_between());
449 MSG.chart_themepanel_area_between()); 372 final Menu betweenMenu = new Menu();
450 Menu betweenMenu = new Menu(); 373 for (int i = 0; i < nThemes; i++) {
451 for (int i = 0; i < nThemes; i++) { 374 final Theme theme = themes.getThemeAt(i + 1);
452 final Theme theme = themes.getThemeAt(i+1);
453 if (theme.getVisible() == 0) { 375 if (theme.getVisible() == 0) {
454 continue; 376 continue;
455 } 377 }
456 if (!areAreaCompatible(facetTheme, theme)) { 378 if (!areAreaCompatible(facetTheme, theme)) {
457 continue; 379 continue;
458 } 380 }
459 MenuItem againster = new MenuItem(theme.getDescription()); 381 final MenuItem againster = new MenuItem(theme.getDescription());
460 betweenMenu.addItem(againster); 382 betweenMenu.addItem(againster);
461 383
462 againster.addClickHandler(new ClickHandler() { 384 againster.addClickHandler(new ClickHandler() {
463 @Override 385 @Override
464 public void onClick(MenuItemClickEvent evt) { 386 public void onClick(final MenuItemClickEvent evt) {
465 disable(); 387 disable();
466 createAreaArtifact(facetTheme, theme, true); 388 createAreaArtifact(facetTheme, theme, true);
467 } 389 }
468 }); 390 });
469 } 391 }
476 398
477 areaMenu.addItem(betweenMenuItem); 399 areaMenu.addItem(betweenMenuItem);
478 areaMenu.addItem(overMenuItem); 400 areaMenu.addItem(overMenuItem);
479 areaMenu.addItem(underMenuItem); 401 areaMenu.addItem(underMenuItem);
480 areaMenu.addItem(createSeparator()); 402 areaMenu.addItem(createSeparator());
481 MenuItem standAloneAgainstAxis = new MenuItem( 403 final MenuItem standAloneAgainstAxis = new MenuItem(this.MSG.getString("against_x_axis"));
482 MSG.getString("against_x_axis"));
483 standAloneAgainstAxis.addClickHandler(new ClickHandler() { 404 standAloneAgainstAxis.addClickHandler(new ClickHandler() {
484 @Override 405 @Override
485 public void onClick(MenuItemClickEvent evt) { 406 public void onClick(final MenuItemClickEvent evt) {
486 disable(); 407 disable();
487 createAreaArtifact(null, facetTheme, false); 408 createAreaArtifact(null, facetTheme, false);
488 } 409 }
489 }); 410 });
490 areaMenu.addItem(standAloneAgainstAxis); 411 areaMenu.addItem(standAloneAgainstAxis);
493 menu.addItem(areaMenuItem); 414 menu.addItem(areaMenuItem);
494 415
495 return menu; 416 return menu;
496 } 417 }
497 } 418 }
498 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org