diff flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java @ 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 65735765643d
children e92f7ef455d6
line wrap: on
line diff
--- 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.
      *

http://dive4elements.wald.intevation.org