changeset 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 e8706fec0ee9
children 77fdb2359ef4
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java
diffstat 6 files changed, 109 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Jan 13 09:50:39 2012 +0000
+++ b/flys-client/ChangeLog	Fri Jan 13 10:07:09 2012 +0000
@@ -1,3 +1,16 @@
+2012-01-13  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Implemented synchronous navigationi of cross section profiles..
+
+	* src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.java,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties:
+	  Added translation for synchronous navigation.
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java:
+	  Allow switching of manyfeed/synchronous navigation via context menu.
+
 2012-01-13  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Added feedMany() function to FeedService to feed multiple artifacts
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri Jan 13 09:50:39 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri Jan 13 10:07:09 2012 +0000
@@ -384,6 +384,10 @@
 
     String chart_themepanel_header_actions();
 
+    String chart_themepanel_snychron();
+
+    String chart_themepanel_asnychron();
+
     String chart_themepanel_set_master();
 
     String chart_themepanel_new_area();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri Jan 13 09:50:39 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri Jan 13 10:07:09 2012 +0000
@@ -189,6 +189,8 @@
 
 chart_themepanel_header_themes = Theme
 chart_themepanel_header_actions = Actions
+chart_themepanel_snychron = Navigate synchronously
+chart_themepanel_asnychron = Navigate independently
 chart_themepanel_set_master = Reference
 chart_themepanel_new_area = New Area...
 chart_themepanel_area_under = under ...
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri Jan 13 09:50:39 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri Jan 13 10:07:09 2012 +0000
@@ -189,6 +189,8 @@
 
 chart_themepanel_header_themes = Thema
 chart_themepanel_header_action = Aktionen
+chart_themepanel_snychron = Synchron navigieren
+chart_themepanel_asnychron = Einzeln navigieren
 chart_themepanel_set_master = Referenz
 chart_themepanel_new_area = Erzeuge Fl\u00e4che ...
 chart_themepanel_area_under = unter ...
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri Jan 13 09:50:39 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri Jan 13 10:07:09 2012 +0000
@@ -189,6 +189,8 @@
 
 chart_themepanel_header_themes = Theme
 chart_themepanel_header_actions = Actions
+chart_themepanel_snychron = Navigate synchronously
+chart_themepanel_asnychron = Navigate independently
 chart_themepanel_set_master = Reference
 chart_themepanel_new_area = New Area...
 chart_themepanel_area_under = under ...
--- 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 :

http://dive4elements.wald.intevation.org