changeset 7826:982382d9ea8b minfo-opt

Display the additional information extracted from multiattribute data.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 20 Mar 2014 13:36:59 +0100
parents b9decb8bfb21
children 8faa8cfd2385
files gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrix.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java
diffstat 2 files changed, 61 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrix.java	Thu Mar 20 13:36:20 2014 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrix.java	Thu Mar 20 13:36:59 2014 +0100
@@ -25,6 +25,8 @@
 import org.dive4elements.river.client.client.FLYSConstants;
 import org.dive4elements.river.client.shared.model.DataItem;
 import org.dive4elements.river.client.shared.model.IntegerOptionsData;
+import org.dive4elements.river.client.shared.model.MultiAttributeData;
+import org.dive4elements.river.client.shared.model.MultiDataItem;
 import org.dive4elements.river.client.shared.model.StringOptionsData;
 
 import java.io.Serializable;
@@ -79,6 +81,7 @@
     private Map<String, Column> columns;
     private List<String>        columnNames;
     private List<String>        valueNames;
+    private Map<String, List<String>> attributes;
 
     /** Maps column names to list of rows' first fields. */
     private Map<String, List<String>> selected;
@@ -89,6 +92,7 @@
         this.columnNames = new ArrayList<String>();
         this.valueNames  = new ArrayList<String>();
         this.selected    = new HashMap<String, List<String>>();
+        this.attributes  = new HashMap<String, List<String>>();
     }
 
 
@@ -148,6 +152,49 @@
         columns.put(groupTitle, col);
     }
 
+    public void addColumn(MultiAttributeData options) {
+        GWT.log("Add Columns for MultiAttribute data");
+        String groupTitle = options.getLabel();
+
+        Column     col   = new Column(groupTitle);
+        DataItem[] items = options.getItems();
+
+        if (items == null) {
+            GWT.log("No items found in StringOptionsData '" + groupTitle + "'");
+            return;
+        }
+
+        MultiDataItem mItem = (MultiDataItem)items[0];
+        for (Map.Entry<String, String> entry: mItem.getValue().entrySet()) {
+            if (entry.getKey().equals("art:value") ||
+                entry.getKey().equals("art:label")) {
+                continue;
+            }
+            attributes.put(entry.getKey(), new ArrayList<String>());
+        }
+        for (DataItem item: items) {
+            GWT.log("multidataitem: " + item.getLabel());
+            String title = item.getLabel();
+
+            if (valueNames.indexOf(title) < 0) {
+                valueNames.add(title);
+            }
+            MultiDataItem mi = (MultiDataItem)item;
+            Map<String, String> vs = mi.getValue();
+            for (Map.Entry<String, String>e: vs.entrySet()) {
+                if (e.getKey().equals("art:value") ||
+                    e.getKey().equals("art:label")) {
+                    continue;
+                }
+                List<String> data = attributes.get(e.getKey());
+                data.add(e.getValue());
+            }
+            col.addValue(item.getLabel(), mi.getValue().get("art:value"));
+        }
+
+        columnNames.add(groupTitle);
+        columns.put(groupTitle, col);
+    }
 
     public Widget createParameterGrid() {
         listGrid = new ListGrid();
@@ -155,7 +202,7 @@
         listGrid.setWrapCells(true);
         listGrid.setShowHeaderContextMenu(false);
         listGrid.setCanReorderFields(false);
-        listGrid.setCanSort(false);
+//        listGrid.setCanSort(false);
         //listGrid.setAutoFitData(Autofit.VERTICAL);
         listGrid.setFixedRecordHeights(false);
         // TODO: Then also need "autofit" (when wrapping)
@@ -164,6 +211,12 @@
         ArrayList<ListGridField> fields = new ArrayList<ListGridField>();
         fields.add(itemNameField);
 
+        for (Map.Entry<String, List<String>> entry: attributes.entrySet()) {
+            ListGridField attrField = new ListGridField(
+                entry.getKey(), MESSAGE.getString(entry.getKey()));
+            fields.add(attrField);
+        }
+
         for (int i = 0, n = columnNames.size(); i < n; i++) {
             ListGridField field = new ListGridField(columnNames.get(i), MESSAGE.getString(columnNames.get(i)));
             field.setType(ListGridFieldType.BOOLEAN);
@@ -189,6 +242,9 @@
                 record.setAttribute(columnName, false);
                 record.setAttribute(columnName+"-value", value);
             }
+            for (Map.Entry<String, List<String>> entry: attributes.entrySet()) {
+                record.setAttribute(entry.getKey(), entry.getValue().get(j));
+            }
             records.add(record);
         }
 
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java	Thu Mar 20 13:36:20 2014 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrixPanel.java	Thu Mar 20 13:36:59 2014 +0100
@@ -23,6 +23,7 @@
 import org.dive4elements.river.client.shared.model.DefaultData;
 import org.dive4elements.river.client.shared.model.DefaultDataItem;
 import org.dive4elements.river.client.shared.model.IntegerOptionsData;
+import org.dive4elements.river.client.shared.model.MultiAttributeData;
 import org.dive4elements.river.client.shared.model.StringOptionsData;
 
 import java.util.ArrayList;
@@ -169,6 +170,9 @@
             else if (data instanceof StringOptionsData) {
                 matrix.addColumn((StringOptionsData) data);
             }
+            else if (data instanceof MultiAttributeData) {
+                matrix.addColumn((MultiAttributeData)data);
+            }
         }
 
         // If too many items are shown, show it in the helper Panel.

http://dive4elements.wald.intevation.org