comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java @ 1519:a6f6c61b18be

Implemented synchronous navigation through cross section profiles. flys-client/trunk@3672 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 13 Jan 2012 10:07:09 +0000
parents a882297ce63d
children 7fcec57c2f2c
comparison
equal deleted inserted replaced
1518:e8706fec0ee9 1519:a6f6c61b18be
1 package de.intevation.flys.client.client.ui.chart; 1 package de.intevation.flys.client.client.ui.chart;
2 2
3 import java.util.ArrayList;
3 import java.util.HashMap; 4 import java.util.HashMap;
4 import java.util.Map; 5 import java.util.Map;
5 import java.util.LinkedHashMap; 6 import java.util.LinkedHashMap;
7 import java.util.List;
6 8
7 import com.google.gwt.core.client.GWT; 9 import com.google.gwt.core.client.GWT;
8 10
9 import com.google.gwt.user.client.rpc.AsyncCallback; 11 import com.google.gwt.user.client.rpc.AsyncCallback;
10 12
25 import com.smartgwt.client.widgets.form.fields.SelectItem; 27 import com.smartgwt.client.widgets.form.fields.SelectItem;
26 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; 28 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
27 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; 29 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
28 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; 30 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
29 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; 31 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
32
33 import com.smartgwt.client.widgets.menu.Menu;
34 import com.smartgwt.client.widgets.menu.MenuItem;
35 import com.smartgwt.client.widgets.menu.events.ClickHandler;
36 import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
30 37
31 import de.intevation.flys.client.client.Config; 38 import de.intevation.flys.client.client.Config;
32 import de.intevation.flys.client.shared.model.Artifact; 39 import de.intevation.flys.client.shared.model.Artifact;
33 import de.intevation.flys.client.shared.model.Collection; 40 import de.intevation.flys.client.shared.model.Collection;
34 import de.intevation.flys.client.shared.model.Data; 41 import de.intevation.flys.client.shared.model.Data;
73 /** Data item name for CrossSections selected km. */ 80 /** Data item name for CrossSections selected km. */
74 protected static String CS_KM = "cross_section.km"; 81 protected static String CS_KM = "cross_section.km";
75 82
76 /** Data item name for CrossSections selected km. */ 83 /** Data item name for CrossSections selected km. */
77 protected static String CS_IS_MASTER = "cross_section.master?"; 84 protected static String CS_IS_MASTER = "cross_section.master?";
85
86 /** Whether or not to move through all cross sections synchronously. */
87 protected boolean synchronNavigation;
78 88
79 89
80 /** 90 /**
81 * Trivial constructor. 91 * Trivial constructor.
82 */ 92 */
271 } 281 }
272 } 282 }
273 return bestMatch; 283 return bestMatch;
274 } 284 }
275 285
286 /** Feed a single artifact with the km of the crosssection to display.
287 * If its the selected master, also feed the collectionmaster. */
288 public void sendFeed(final List<Artifact> artifacts, final double kmD) {
289 Config config = Config.getInstance();
290 final String locale = config.getLocale();
291
292 Data[] feedData =
293 DefaultData.createSimpleStringDataArray(CS_KM,
294 Double.valueOf(kmD).toString());
295
296 disable();
297 feedService.feedMany(
298 locale,
299 artifacts,
300 feedData,
301 new AsyncCallback<List<Artifact>>() {
302 @Override
303 public void onFailure(Throwable caught) {
304 GWT.log("Could not feed many artifacts " + caught.getMessage());
305 SC.warn(MSG.getString(caught.getMessage()));
306 enable();
307 }
308 @Override
309 public void onSuccess(List<Artifact> artifact) {
310 GWT.log("Successfully fed many with km");
311 requestRedraw();
312 enable();
313 }
314 });
315 }
276 316
277 /** Feed a single artifact with the km of the crosssection to display. 317 /** Feed a single artifact with the km of the crosssection to display.
278 * If its the selected master, also feed the collectionmaster. */ 318 * If its the selected master, also feed the collectionmaster. */
279 public void sendFeed(final String artUUID, final double kmD) { 319 public void sendFeed(final String artUUID, final double kmD) {
280 Config config = Config.getInstance(); 320 Config config = Config.getInstance();
368 selected_km); 408 selected_km);
369 GWT.log("Got single km for " + dbid + ", it is " 409 GWT.log("Got single km for " + dbid + ", it is "
370 + closest); 410 + closest);
371 SpinnerItem item = (SpinnerItem) ce.getItem(); 411 SpinnerItem item = (SpinnerItem) ce.getItem();
372 item.setValue(closest); 412 item.setValue(closest);
373 sendFeed(facetRecord.getTheme().getArtifact(), 413 if (synchronNavigation) {
414 // Feed many ...
415 // Find all activated cross section themes
416 ThemeList themes = getThemeList();
417 int nThemes = themes.getThemeCount();
418 List<Artifact> artifacts = new ArrayList<Artifact>();
419 for (int i = 0; i < nThemes; i++) {
420 final Theme theme = themes.getThemeAt(i+1);
421 if (theme.getFacet().equals("cross_section") &&
422 theme.getActive() == 1) {
423 artifacts.add(artifactReference(theme.getArtifact()));
424 }
425 }
426 sendFeed(artifacts,
374 closest); 427 closest);
428 }
429 else {
430 sendFeed(facetRecord.getTheme().getArtifact(),
431 closest);
432 }
375 } 433 }
376 }); 434 });
377 } 435 }
378 }; 436 };
379 return handler; 437 return handler;
380 } 438 }
381 439
523 */ 581 */
524 protected boolean canArea(Theme a) { 582 protected boolean canArea(Theme a) {
525 return a.getFacet().equals("cross_section") 583 return a.getFacet().equals("cross_section")
526 || a.getFacet().equals("cross_section_water_line"); 584 || a.getFacet().equals("cross_section_water_line");
527 } 585 }
586
587
588 /**
589 * Include synchron navigation item.
590 */
591 @Override
592 protected Menu getSingleContextMenu(final ListGridRecord[] records) {
593 Menu contextMenu = super.getSingleContextMenu(records);
594
595 // Synchron checking.
596 MenuItem synchronNavigationMenuItem = new MenuItem();
597 if (synchronNavigation == true) {
598 synchronNavigationMenuItem.setTitle("Einzeln navigieren");
599 }
600 else {
601 synchronNavigationMenuItem.setTitle("Synchron navigieren");
602 }
603 synchronNavigationMenuItem.addClickHandler(new ClickHandler() {
604 public void onClick(MenuItemClickEvent evt) {
605 synchronNavigation = !synchronNavigation;
606 }
607 });
608 contextMenu.addItem(synchronNavigationMenuItem);
609
610 return contextMenu;
611 }
528 } 612 }
529 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 613 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org