Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Fri Jan 13 09:50:39 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Fri Jan 13 10:07:09 2012 +0000 @@ -1,8 +1,10 @@ package de.intevation.flys.client.client.ui.chart; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.LinkedHashMap; +import java.util.List; import com.google.gwt.core.client.GWT; @@ -28,6 +30,11 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; +import com.smartgwt.client.widgets.menu.Menu; +import com.smartgwt.client.widgets.menu.MenuItem; +import com.smartgwt.client.widgets.menu.events.ClickHandler; +import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; + import de.intevation.flys.client.client.Config; import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; @@ -76,6 +83,9 @@ /** Data item name for CrossSections selected km. */ protected static String CS_IS_MASTER = "cross_section.master?"; + /** Whether or not to move through all cross sections synchronously. */ + protected boolean synchronNavigation; + /** * Trivial constructor. @@ -273,6 +283,36 @@ return bestMatch; } + /** Feed a single artifact with the km of the crosssection to display. + * If its the selected master, also feed the collectionmaster. */ + public void sendFeed(final List<Artifact> artifacts, final double kmD) { + Config config = Config.getInstance(); + final String locale = config.getLocale(); + + Data[] feedData = + DefaultData.createSimpleStringDataArray(CS_KM, + Double.valueOf(kmD).toString()); + + disable(); + feedService.feedMany( + locale, + artifacts, + feedData, + new AsyncCallback<List<Artifact>>() { + @Override + public void onFailure(Throwable caught) { + GWT.log("Could not feed many artifacts " + caught.getMessage()); + SC.warn(MSG.getString(caught.getMessage())); + enable(); + } + @Override + public void onSuccess(List<Artifact> artifact) { + GWT.log("Successfully fed many with km"); + requestRedraw(); + enable(); + } + }); + } /** Feed a single artifact with the km of the crosssection to display. * If its the selected master, also feed the collectionmaster. */ @@ -370,10 +410,28 @@ + closest); SpinnerItem item = (SpinnerItem) ce.getItem(); item.setValue(closest); - sendFeed(facetRecord.getTheme().getArtifact(), + if (synchronNavigation) { + // Feed many ... + // Find all activated cross section themes + ThemeList themes = getThemeList(); + int nThemes = themes.getThemeCount(); + List<Artifact> artifacts = new ArrayList<Artifact>(); + for (int i = 0; i < nThemes; i++) { + final Theme theme = themes.getThemeAt(i+1); + if (theme.getFacet().equals("cross_section") && + theme.getActive() == 1) { + artifacts.add(artifactReference(theme.getArtifact())); + } + } + sendFeed(artifacts, closest); + } + else { + sendFeed(facetRecord.getTheme().getArtifact(), + closest); + } } - }); + }); } }; return handler; @@ -525,5 +583,31 @@ return a.getFacet().equals("cross_section") || a.getFacet().equals("cross_section_water_line"); } + + + /** + * Include synchron navigation item. + */ + @Override + protected Menu getSingleContextMenu(final ListGridRecord[] records) { + Menu contextMenu = super.getSingleContextMenu(records); + + // Synchron checking. + MenuItem synchronNavigationMenuItem = new MenuItem(); + if (synchronNavigation == true) { + synchronNavigationMenuItem.setTitle("Einzeln navigieren"); + } + else { + synchronNavigationMenuItem.setTitle("Synchron navigieren"); + } + synchronNavigationMenuItem.addClickHandler(new ClickHandler() { + public void onClick(MenuItemClickEvent evt) { + synchronNavigation = !synchronNavigation; + } + }); + contextMenu.addItem(synchronNavigationMenuItem); + + return contextMenu; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :