changeset 259:50a95db68e66

Build a dynamic table for the CSV data. flys-client/trunk@1873 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 10 May 2011 10:03:00 +0000
parents 5091675676d6
children dd1dad2ff94e
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java flys-client/src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java
diffstat 4 files changed, 51 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue May 10 06:48:46 2011 +0000
+++ b/flys-client/ChangeLog	Tue May 10 10:03:00 2011 +0000
@@ -1,3 +1,15 @@
+2011-05-10  Raimund Renkert <rrenkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
+	  Use the name instead of the description to determine the output mode.
+
+	* src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java:
+	  Removed obsolete code.
+
+	* src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java:
+	  Build up a dynamic table for different header count. The first line of CSV
+	  data is used to set the header title.
+
 2011-05-10  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Tue May 10 06:48:46 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Tue May 10 10:03:00 2011 +0000
@@ -356,7 +356,7 @@
         if (out.getMimeType().equals("text/plain")) {
             TableDataPanel p = new TableDataPanel();
             p.setUuid(collection.identifier());
-            p.setName(out.getDescription());
+            p.setName(out.getName());
             parameterList.setPanel (p);
             return;
         }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java	Tue May 10 06:48:46 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java	Tue May 10 10:03:00 2011 +0000
@@ -68,12 +68,7 @@
         Config config    = Config.getInstance();
         String url       = config.getServerUrl();
         String locale    = config.getLocale ();
-        ListGridField flusskm = new ListGridField("km", MESSAGES.river_km());
-        ListGridField w = new ListGridField("w", MESSAGES.unitWNN());
-        ListGridField q = new ListGridField("q", MESSAGES.wqQ());
-        ListGridField desc = new ListGridField("descr", MESSAGES.description());
 
-        dataTable.setFields(flusskm, w, q, desc);
         exportService.getCSV(url, locale, uuid, name,
             new AsyncCallback<List>() {
                 public void onFailure(Throwable caught) {
@@ -116,14 +111,45 @@
         return null;
     }
 
-    public void setData(List list){
-        for(Object item: list) {
-            String[] sItem = (String[])item;
+
+    /**
+     * This method sets the data to a dynmic table.
+     *
+     * @param list List if String[] containing the data.
+     */
+    public void setData(List list) {
+        String[] header = (String[])list.get(0);
+        ListGridField[] fields = new ListGridField[header.length];
+        for(int i = 0; i < header.length; i++) {
+            ListGridField f = new ListGridField(String.valueOf(i));
+            fields[i] = f;
+            f.setTitle(header[i]);
+        }
+
+        if (header.length == 2) {
+            dataTable.setFields(fields[0], fields[1]);
+        }
+        else if(header.length == 3) {
+            dataTable.setFields(fields[0], fields[1], fields[2]);
+        }
+        else if(header.length == 4) {
+            dataTable.setFields(fields[0], fields[1], fields[2], fields[3]);
+        }
+        else if(header.length == 5) {
+            dataTable.setFields(
+                fields[0],
+                fields[1],
+                fields[2],
+                fields[3],
+                fields[4]);
+        }
+
+        for(int i = 1; i < list.size(); i++) {
+            GWT.log ("items" + list.size());
+            String[] sItem = (String[])list.get(i);
             ListGridRecord r = new ListGridRecord();
-            if (sItem.length == 3) {
-                r.setAttribute("km", sItem[0]);
-                r.setAttribute("w", sItem[1]);
-                r.setAttribute("q", sItem[2]);
+            for(int j = 0; j < sItem.length; j++) {
+                r.setAttribute(String.valueOf(j), sItem[j]);
             }
             dataTable.addData(r);
         }
--- a/flys-client/src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java	Tue May 10 06:48:46 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/CSVExportServiceImpl.java	Tue May 10 10:03:00 2011 +0000
@@ -50,10 +50,6 @@
             ArtifactNamespaceContext.NAMESPACE_URI,
             ArtifactNamespaceContext.NAMESPACE_PREFIX);
 
-        if (name.startsWith("output.")) {
-            name = name.substring(name.indexOf(".") + 1);
-        }
-
         Element action = ec.create("action");
         ec.addAttr(action, "type", "csv", true);
         ec.addAttr(action, "name", name, true);

http://dive4elements.wald.intevation.org