changeset 275:8264b02091ef

ISSUE-56 Display download buttons to export the computed data. flys-client/trunk@1901 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 11 May 2011 14:29:35 +0000
parents 71a7533555d0
children f4c8ce11df33
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/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ExportPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultOutputMode.java flys-client/src/main/java/de/intevation/flys/client/shared/model/OutputMode.java flys-client/src/main/webapp/FLYS.css flys-client/src/main/webapp/images/save.gif
diffstat 11 files changed, 238 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed May 11 14:23:08 2011 +0000
+++ b/flys-client/ChangeLog	Wed May 11 14:29:35 2011 +0000
@@ -1,3 +1,34 @@
+2011-05-11  Ingo Weinzierl <ingo@intevation.de>
+
+	  ISSUE-56
+
+	* src/main/java/de/intevation/flys/client/shared/model/DefaultOutputMode.java,
+	  src/main/java/de/intevation/flys/client/shared/model/OutputMode.java:
+	  Added a further method that returns all available facets.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ExportPanel.java: New.
+	  This panel is used to serve download links for each export mode / type
+	  of a collection.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ParameterList.java:
+	  Implements the CollectionChangeHandler interface now. If a Collection
+	  changes, the available output modes are analyzed. If there are export
+	  modes available, those modes are displayed in a so called 'ExportPanel'.
+
+	* src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
+	  Registered the ParameterList as CollectionChange handler.
+
+	* src/main/webapp/FLYS.css: Added a stylesheet for the export panels
+	  title.
+
+	* src/main/webapp/images/save.gif: New. This image is displayed in the
+	  export panel.
+
+	* src/main/java/de/intevation/flys/client/client/FLYSConstants.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.java: New
+	  i18n strings for the export panel.
+
 2011-05-11  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Wed May 11 14:23:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Wed May 11 14:29:35 2011 +0000
@@ -132,6 +132,8 @@
 
     String imageBack();
 
+    String imageSave();
+
     // OUTPUT TYPES
 
     String discharge_curve();
@@ -152,6 +154,12 @@
 
     String discharge_longitudinal_section();
 
+    // EXPORTS
+
+    String dataexport();
+
+    String csv();
+
     // ERRORS
 
     String error_create_artifact();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Wed May 11 14:23:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Wed May 11 14:29:35 2011 +0000
@@ -65,6 +65,7 @@
 
 buttonNext = Next
 imageBack = images/back_en.png
+imageSave = images/save.gif
 
 discharge_curve = Discharge Curves at Gauges
 computed_discharge_curve = Discharge Curve
@@ -73,6 +74,9 @@
 waterlevel_export = Waterlevel Export
 discharge_longitudinal_section = Discharge Longitudinal Section
 
+dataexport = Datenexport
+csv = CSV
+
 error_create_artifact = Error while creating new project.
 error_describe_artifact = Error while loading the parameterization.
 error_feed_data = Error while inserting new data.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Wed May 11 14:23:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Wed May 11 14:29:35 2011 +0000
@@ -65,6 +65,7 @@
 
 buttonNext = Übernehmen
 imageBack = images/back_de.png
+imageSave = images/save.gif
 
 discharge_curve = Abflusskurven an Pegeln
 computed_discharge_curve = Abflusskurve
@@ -73,6 +74,9 @@
 waterlevel_export = Wasserstand/Wasserspiegellagen Export
 discharge_longitudinal_section = W bei ungleichwertigem Abflussl\u00e4ngsschnitt
 
+dataexport = Datenexport
+csv = CSV
+
 error_create_artifact = Fehler beim Erstellen eines neuen Projekts.
 error_describe_artifact = Fehler beim Laden der Parametrisierung.
 error_feed_data = Fehler beim Hinzuf\u00fcgen neuer Daten.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed May 11 14:23:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed May 11 14:29:35 2011 +0000
@@ -101,6 +101,7 @@
             flys, this, messages.new_project());
 
         addCollectionChangeHandler(this);
+        addCollectionChangeHandler(parameterList);
 
         parameterList.addParameterChangeHandler(this);
 
@@ -121,6 +122,7 @@
             artifact);
 
         addCollectionChangeHandler(this);
+        addCollectionChangeHandler(parameterList);
 
         parameterList.addParameterChangeHandler(this);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ExportPanel.java	Wed May 11 14:29:35 2011 +0000
@@ -0,0 +1,121 @@
+package de.intevation.flys.client.client.ui;
+
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLPane;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.shared.model.ExportMode;
+import de.intevation.flys.client.shared.model.Facet;
+import de.intevation.flys.client.client.Config;
+import de.intevation.flys.client.client.FLYSConstants;
+
+
+/**
+ * A panel that displays an download icon for all available export modes of a
+ * Collection.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class ExportPanel extends VLayout {
+
+    /** The message class that provides i18n strings.*/
+    protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
+
+    protected Collection       c;
+    protected List<ExportMode> exports;
+
+    /** This layout will store a list of available export types.*/
+    protected HLayout container;
+
+
+    public ExportPanel(Collection c, List<ExportMode> exports) {
+        super();
+
+        this.c         = c;
+        this.exports   = exports;
+        this.container = new HLayout();
+
+        Label title = new Label(MSG.dataexport());
+        title.setHeight(15);
+        title.setStyleName("fontNormalSmallUnderlined");
+
+        addMember(title);
+        addMember(createExportItems());
+
+        setHeight(25);
+        setMembersMargin(5);
+    }
+
+
+    /**
+     * This method is used to create an item (created by createExportButton) for
+     * each facet for each export mode.
+     *
+     * @return a horizontal list of buttons.
+     */
+    protected HLayout createExportItems() {
+        HLayout layout = new HLayout();
+
+        for (ExportMode mode: exports) {
+            String      name   = mode.getName();
+            List<Facet> facets = mode.getFacets();
+
+            for (Facet facet: facets) {
+                layout.addMember(createExportButton(name, facet.getName()));
+            }
+        }
+
+        return layout;
+    }
+
+
+    /**
+     * This method is used to create a button (with click handler) for a
+     * concrete export mode / type.
+     *
+     * @param name The name of the export.
+     * @param facet The name of the export type (e.g. CSV, WST).
+     *
+     * @return an image with click handler.
+     */
+    protected Canvas createExportButton(String name, String facet) {
+        String url  = getExportUrl(name, facet);
+        String iUrl = GWT.getHostPageBaseURL() + MSG.imageSave();
+
+        HTMLPane pane = new HTMLPane();
+        pane.setContents("<a href='" + url + "'><img src='" + iUrl + "'></a>");
+
+        return pane;
+    }
+
+
+    /**
+     * Creates the URL used to trigger an export.
+     *
+     * @param name The name of the export.
+     * @param facet The name of the export type (e.g. CSV, WST).
+     *
+     * @return the export URL.
+     */
+    protected String getExportUrl(String name, String facet) {
+        Config config = Config.getInstance();
+
+        String url = GWT.getModuleBaseURL();
+        url += "export";
+        url += "?uuid=" + c.identifier();
+        url += "&mode=" + name;
+        url += "&type=" + facet;
+        url += "&server=" + config.getServerUrl();
+        url += "&locale=" + config.getLocale();
+
+        return url;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Wed May 11 14:23:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java	Wed May 11 14:29:35 2011 +0000
@@ -2,6 +2,8 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -15,15 +17,20 @@
 
 import de.intevation.flys.client.shared.model.Artifact;
 import de.intevation.flys.client.shared.model.ArtifactDescription;
+import de.intevation.flys.client.shared.model.Collection;
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
 import de.intevation.flys.client.shared.model.DataList;
 import de.intevation.flys.client.shared.model.DefaultData;
 import de.intevation.flys.client.shared.model.DefaultDataItem;
+import de.intevation.flys.client.shared.model.ExportMode;
+import de.intevation.flys.client.shared.model.OutputMode;
 import de.intevation.flys.client.shared.model.River;
 import de.intevation.flys.client.client.Config;
 import de.intevation.flys.client.client.FLYS;
 import de.intevation.flys.client.client.FLYSConstants;
+import de.intevation.flys.client.client.event.CollectionChangeEvent;
+import de.intevation.flys.client.client.event.CollectionChangeHandler;
 import de.intevation.flys.client.client.event.HasParameterChangeHandler;
 import de.intevation.flys.client.client.event.HasStepBackHandlers;
 import de.intevation.flys.client.client.event.HasStepForwardHandlers;
@@ -44,7 +51,7 @@
 public class ParameterList
 extends      Tab
 implements   StepBackHandler, StepForwardHandler, ParameterChangeHandler,
-             HasParameterChangeHandler
+             HasParameterChangeHandler, CollectionChangeHandler
 {
     /** The message class that provides i18n strings.*/
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
@@ -79,6 +86,7 @@
     protected VLayout topLayout;
     protected VLayout oldItems;
     protected VLayout currentItems;
+    protected VLayout exportModes;
     protected Canvas  helperPanel;
     protected Canvas  tablePanel;
 
@@ -93,6 +101,7 @@
         topLayout         = new VLayout();
         oldItems          = new VLayout();
         currentItems      = new VLayout();
+        exportModes       = new VLayout();
 
         addParameterChangeHandler(this);
 
@@ -117,6 +126,7 @@
         topLayout         = new VLayout();
         oldItems          = new VLayout();
         currentItems      = new VLayout();
+        exportModes       = new VLayout();
 
         init();
 
@@ -145,6 +155,7 @@
 
         left.addMember(oldItems);
         left.addMember(currentItems);
+        left.addMember(exportModes);
 
         // This canvas is used to render helper widgets
         helperPanel = new Canvas();
@@ -373,6 +384,9 @@
 
             currentItems.addMember(c);
         }
+        else {
+            currentItems.setHeight(1);
+        }
     }
 
 
@@ -475,6 +489,39 @@
         addOldDatas(desc.getOldData());
     }
 
+
+    public void onCollectionChange(CollectionChangeEvent event) {
+        Collection c = event.getNewValue();
+
+        Map<String, OutputMode> outs = c.getOutputModes();
+        Set<String>             keys = outs.keySet();
+
+        List<ExportMode> exports = new ArrayList<ExportMode>();
+
+        for (String outname: keys) {
+            OutputMode out = outs.get(outname);
+
+            if (out instanceof ExportMode) {
+                exports.add((ExportMode) out);
+            }
+        }
+
+        updateExportModes(c, exports);
+    }
+
+
+    protected void updateExportModes(Collection c, List<ExportMode> exports) {
+        int num = exports != null ? exports.size() : 0;
+        GWT.log("Update export modes: " + num);
+
+        exportModes.removeMembers(exportModes.getMembers());
+
+        if (exports.size() > 0) {
+            exportModes.addMember(new ExportPanel(c, exports));
+        }
+    }
+
+
     /**
      * Adds a table to the parameterlist to show calculated data.
      *
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultOutputMode.java	Wed May 11 14:23:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultOutputMode.java	Wed May 11 14:29:35 2011 +0000
@@ -115,5 +115,10 @@
 
         return null;
     }
+
+
+    public List<Facet> getFacets() {
+        return facets;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/OutputMode.java	Wed May 11 14:23:08 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/OutputMode.java	Wed May 11 14:29:35 2011 +0000
@@ -1,6 +1,7 @@
 package de.intevation.flys.client.shared.model;
 
 import java.io.Serializable;
+import java.util.List;
 
 
 /**
@@ -69,5 +70,13 @@
      * @return a facet or null if no such facet is available.
      */
     Facet getFacet(String name);
+
+
+    /**
+     * Returns all facets of this mode.
+     *
+     * @return all facets.
+     */
+    List<Facet> getFacets();
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/webapp/FLYS.css	Wed May 11 14:23:08 2011 +0000
+++ b/flys-client/src/main/webapp/FLYS.css	Wed May 11 14:29:35 2011 +0000
@@ -88,3 +88,9 @@
   font-size: 18pt;
   color: #a9c9e6;
 }
+
+.fontNormalSmallUnderlined {
+  font-family: Arial,Verdana,sans-serif;
+  font-size: 10pt;
+  text-decoration: underline;
+}
Binary file flys-client/src/main/webapp/images/save.gif has changed

http://dive4elements.wald.intevation.org