Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java @ 4568:bbd82bd8e541
flys-client: Cosmetics and warnings.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Mon, 19 Nov 2012 00:07:53 +0100 |
parents | 51ed89b754ae |
children |
comparison
equal
deleted
inserted
replaced
4567:5e6e89f19a37 | 4568:bbd82bd8e541 |
---|---|
1 package de.intevation.flys.client.client.ui.chart; | 1 package de.intevation.flys.client.client.ui.chart; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
4 | |
5 import com.google.gwt.user.client.rpc.AsyncCallback; | 4 import com.google.gwt.user.client.rpc.AsyncCallback; |
6 | 5 |
7 import com.smartgwt.client.types.ListGridFieldType; | 6 import com.smartgwt.client.types.ListGridFieldType; |
8 | 7 import com.smartgwt.client.util.SC; |
9 import com.smartgwt.client.widgets.grid.ListGridField; | 8 import com.smartgwt.client.widgets.grid.ListGridField; |
10 import com.smartgwt.client.widgets.grid.ListGridRecord; | 9 import com.smartgwt.client.widgets.grid.ListGridRecord; |
11 import com.smartgwt.client.widgets.layout.VLayout; | 10 import com.smartgwt.client.widgets.layout.VLayout; |
12 import com.smartgwt.client.widgets.menu.events.ClickHandler; | |
13 | |
14 import com.smartgwt.client.widgets.menu.Menu; | 11 import com.smartgwt.client.widgets.menu.Menu; |
15 import com.smartgwt.client.widgets.menu.MenuItem; | 12 import com.smartgwt.client.widgets.menu.MenuItem; |
13 import com.smartgwt.client.widgets.menu.events.ClickHandler; | |
16 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; | 14 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; |
17 | 15 |
18 import com.smartgwt.client.util.SC; | 16 import de.intevation.flys.client.client.Config; |
19 | 17 import de.intevation.flys.client.client.FLYSConstants; |
18 import de.intevation.flys.client.client.services.FeedServiceAsync; | |
19 import de.intevation.flys.client.client.services.LoadArtifactService; | |
20 import de.intevation.flys.client.client.services.LoadArtifactServiceAsync; | |
21 import de.intevation.flys.client.client.ui.CollectionView; | |
22 import de.intevation.flys.client.client.ui.ThemePanel; | |
20 import de.intevation.flys.client.shared.model.Artifact; | 23 import de.intevation.flys.client.shared.model.Artifact; |
21 import de.intevation.flys.client.shared.model.Data; | 24 import de.intevation.flys.client.shared.model.Data; |
25 import de.intevation.flys.client.shared.model.DefaultArtifact; | |
22 import de.intevation.flys.client.shared.model.DefaultData; | 26 import de.intevation.flys.client.shared.model.DefaultData; |
23 import de.intevation.flys.client.shared.model.DefaultArtifact; | |
24 import de.intevation.flys.client.shared.model.FacetRecord; | 27 import de.intevation.flys.client.shared.model.FacetRecord; |
25 import de.intevation.flys.client.shared.model.OutputMode; | 28 import de.intevation.flys.client.shared.model.OutputMode; |
26 import de.intevation.flys.client.shared.model.Recommendation; | 29 import de.intevation.flys.client.shared.model.Recommendation; |
27 import de.intevation.flys.client.shared.model.Theme; | 30 import de.intevation.flys.client.shared.model.Theme; |
28 import de.intevation.flys.client.shared.model.ThemeList; | 31 import de.intevation.flys.client.shared.model.ThemeList; |
29 | |
30 import de.intevation.flys.client.client.Config; | |
31 import de.intevation.flys.client.client.FLYSConstants; | |
32 import de.intevation.flys.client.client.ui.CollectionView; | |
33 import de.intevation.flys.client.client.ui.ThemePanel; | |
34 | |
35 import de.intevation.flys.client.client.services.FeedService; | |
36 import de.intevation.flys.client.client.services.FeedServiceAsync; | |
37 | |
38 import de.intevation.flys.client.client.services.LoadArtifactService; | |
39 import de.intevation.flys.client.client.services.LoadArtifactServiceAsync; | |
40 | 32 |
41 | 33 |
42 /** | 34 /** |
43 * ThemePanel on the left in CollectionView. | 35 * ThemePanel on the left in CollectionView. |
44 * Contains control widgets for "themes", which are plotted in a diagram (chart). | 36 * Contains control widgets for "themes", which are plotted in a diagram (chart). |
206 feedService.feed( | 198 feedService.feed( |
207 Config.getInstance().getLocale(), | 199 Config.getInstance().getLocale(), |
208 new DefaultArtifact(artifact, "TODO:hash"), | 200 new DefaultArtifact(artifact, "TODO:hash"), |
209 feedData, | 201 feedData, |
210 new AsyncCallback<Artifact>() { | 202 new AsyncCallback<Artifact>() { |
203 @Override | |
211 public void onFailure(Throwable caught) { | 204 public void onFailure(Throwable caught) { |
212 GWT.log("Could not feed artifact (" + artifact | 205 GWT.log("Could not feed artifact (" + artifact |
213 + ") with area info: " + caught.getMessage()); | 206 + ") with area info: " + caught.getMessage()); |
214 SC.warn(MSG.getString(caught.getMessage())); | 207 SC.warn(MSG.getString(caught.getMessage())); |
215 enable(); | 208 enable(); |
216 } | 209 } |
210 @Override | |
217 public void onSuccess(Artifact fartifact) { | 211 public void onSuccess(Artifact fartifact) { |
218 GWT.log("Successfully set area params to " + artifact); | 212 GWT.log("Successfully set area params to " + artifact); |
219 requestRedraw(); | 213 requestRedraw(); |
220 updateCollection(); | 214 updateCollection(); |
221 updateGrid(); | 215 updateGrid(); |
250 this.getCollection(), | 244 this.getCollection(), |
251 recommendations, | 245 recommendations, |
252 null, //use individual factories. | 246 null, //use individual factories. |
253 locale, | 247 locale, |
254 new AsyncCallback<Artifact[]>() { | 248 new AsyncCallback<Artifact[]>() { |
249 @Override | |
255 public void onFailure(Throwable caught) { | 250 public void onFailure(Throwable caught) { |
256 GWT.log("Failed, no area artifact: " + caught.getMessage()); | 251 GWT.log("Failed, no area artifact: " + caught.getMessage()); |
257 enable(); | 252 enable(); |
258 // TODO SC.warn | 253 // TODO i18n |
259 } | 254 SC.warn("Failed, no area artifact: " + caught.getMessage()); |
255 } | |
256 @Override | |
260 public void onSuccess(Artifact[] artifacts) { | 257 public void onSuccess(Artifact[] artifacts) { |
261 GWT.log("Success, created area artifact: " | 258 GWT.log("Success, created area artifact: " |
262 + artifacts[0].getUuid()); | 259 + artifacts[0].getUuid()); |
263 // Now, feed the artifact with the relevant data. | 260 // Now, feed the artifact with the relevant data. |
264 feedTellArea(artifacts[0].getUuid(), under, over, between); | 261 feedTellArea(artifacts[0].getUuid(), under, over, between); |
305 protected void attachManualPointsMenu(Menu menu) { | 302 protected void attachManualPointsMenu(Menu menu) { |
306 menu.addItem(createSeparator()); | 303 menu.addItem(createSeparator()); |
307 MenuItem editManualPoints = new MenuItem(MSG.editpoints()); | 304 MenuItem editManualPoints = new MenuItem(MSG.editpoints()); |
308 | 305 |
309 editManualPoints.addClickHandler(new ClickHandler() { | 306 editManualPoints.addClickHandler(new ClickHandler() { |
307 @Override | |
310 public void onClick(MenuItemClickEvent evt) { | 308 public void onClick(MenuItemClickEvent evt) { |
311 if(mode.getName().equals("historical_discharge")) { | 309 if(mode.getName().equals("historical_discharge")) { |
312 new ManualDatePointsEditor(view.getCollection(), | 310 new ManualDatePointsEditor(view.getCollection(), |
313 redrawRequestHandlers.get(0), | 311 redrawRequestHandlers.get(0), |
314 mode.getName()).show(); | 312 mode.getName()).show(); |
326 | 324 |
327 /** | 325 /** |
328 * Include area specific menu items and manual point editor, depending | 326 * Include area specific menu items and manual point editor, depending |
329 * on facet. | 327 * on facet. |
330 */ | 328 */ |
329 @Override | |
331 protected Menu getSingleContextMenu(final ListGridRecord[] records) { | 330 protected Menu getSingleContextMenu(final ListGridRecord[] records) { |
332 Menu menu = super.getSingleContextMenu(records); | 331 Menu menu = super.getSingleContextMenu(records); |
333 | 332 |
334 final Theme facetTheme = ((FacetRecord)records[0]).getTheme(); | 333 final Theme facetTheme = ((FacetRecord)records[0]).getTheme(); |
335 String thisItem = facetTheme.getDescription(); | 334 |
336 if (!canArea(facetTheme)) { | 335 if (!canArea(facetTheme)) { |
337 if (facetTheme.getFacet().endsWith("manualpoints")) { | 336 if (facetTheme.getFacet().endsWith("manualpoints")) { |
338 attachManualPointsMenu(menu); | 337 attachManualPointsMenu(menu); |
339 return menu; | 338 return menu; |
340 } | 339 } |
367 | 366 |
368 MenuItem againster = new MenuItem(theme.getDescription()); | 367 MenuItem againster = new MenuItem(theme.getDescription()); |
369 underMenu.addItem(againster); | 368 underMenu.addItem(againster); |
370 | 369 |
371 againster.addClickHandler(new ClickHandler() { | 370 againster.addClickHandler(new ClickHandler() { |
371 @Override | |
372 public void onClick(MenuItemClickEvent evt) { | 372 public void onClick(MenuItemClickEvent evt) { |
373 disable(); | 373 disable(); |
374 createAreaArtifact(theme, facetTheme, false); | 374 createAreaArtifact(theme, facetTheme, false); |
375 } | 375 } |
376 }); | 376 }); |
389 } | 389 } |
390 MenuItem againster = new MenuItem(theme.getDescription()); | 390 MenuItem againster = new MenuItem(theme.getDescription()); |
391 overMenu.addItem(againster); | 391 overMenu.addItem(againster); |
392 | 392 |
393 againster.addClickHandler(new ClickHandler() { | 393 againster.addClickHandler(new ClickHandler() { |
394 @Override | |
394 public void onClick(MenuItemClickEvent evt) { | 395 public void onClick(MenuItemClickEvent evt) { |
395 disable(); | 396 disable(); |
396 createAreaArtifact(facetTheme, theme, false); | 397 createAreaArtifact(facetTheme, theme, false); |
397 } | 398 } |
398 }); | 399 }); |
399 } | 400 } |
400 overMenu.addItem(createSeparator()); | 401 overMenu.addItem(createSeparator()); |
401 MenuItem againstAxis = new MenuItem(MSG.getString("x_axis")); | 402 MenuItem againstAxis = new MenuItem(MSG.getString("x_axis")); |
402 againstAxis.addClickHandler(new ClickHandler() { | 403 againstAxis.addClickHandler(new ClickHandler() { |
404 @Override | |
403 public void onClick(MenuItemClickEvent evt) { | 405 public void onClick(MenuItemClickEvent evt) { |
404 disable(); | 406 disable(); |
405 createAreaArtifact(null, facetTheme, false); | 407 createAreaArtifact(null, facetTheme, false); |
406 } | 408 } |
407 }); | 409 }); |
420 } | 422 } |
421 MenuItem againster = new MenuItem(theme.getDescription()); | 423 MenuItem againster = new MenuItem(theme.getDescription()); |
422 betweenMenu.addItem(againster); | 424 betweenMenu.addItem(againster); |
423 | 425 |
424 againster.addClickHandler(new ClickHandler() { | 426 againster.addClickHandler(new ClickHandler() { |
427 @Override | |
425 public void onClick(MenuItemClickEvent evt) { | 428 public void onClick(MenuItemClickEvent evt) { |
426 disable(); | 429 disable(); |
427 createAreaArtifact(facetTheme, theme, true); | 430 createAreaArtifact(facetTheme, theme, true); |
428 } | 431 } |
429 }); | 432 }); |
439 areaMenu.addItem(overMenuItem); | 442 areaMenu.addItem(overMenuItem); |
440 areaMenu.addItem(underMenuItem); | 443 areaMenu.addItem(underMenuItem); |
441 areaMenu.addItem(createSeparator()); | 444 areaMenu.addItem(createSeparator()); |
442 MenuItem standAloneAgainstAxis = new MenuItem(MSG.getString("against_x_axis")); | 445 MenuItem standAloneAgainstAxis = new MenuItem(MSG.getString("against_x_axis")); |
443 standAloneAgainstAxis.addClickHandler(new ClickHandler() { | 446 standAloneAgainstAxis.addClickHandler(new ClickHandler() { |
447 @Override | |
444 public void onClick(MenuItemClickEvent evt) { | 448 public void onClick(MenuItemClickEvent evt) { |
445 disable(); | 449 disable(); |
446 createAreaArtifact(null, facetTheme, false); | 450 createAreaArtifact(null, facetTheme, false); |
447 } | 451 } |
448 }); | 452 }); |