[Dive4elements-commits] [PATCH 2 of 2] Merged

Wald Commits scm-commit at wald.intevation.org
Tue Nov 27 14:25:31 CET 2012


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1354023008 -3600
# Node ID a46dc120afd70423560cdeba704812c6a97c02ef
# Parent  585374987c5cb0bf168f7e8374e4127c4fab972c
# Parent  32a4651eef93b4ff5546ec34ebaf6be773cfbea5
Merged.

diff -r 585374987c5c -r a46dc120afd7 flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java	Tue Nov 27 14:29:24 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java	Tue Nov 27 14:30:08 2012 +0100
@@ -108,6 +108,7 @@
 
             if (FLOODMAP_WSPLGEN.equals(name)) {
                 setInitialExtent(extent);
+                logger.debug("MapGenerator.doOut(): attr = " + XMLUtils.toString(attr));
                 createWSPLGENLayer(flys, wms, attr);
             }
             else if (FLOODMAP_BARRIERS.equals(name)) {
diff -r 585374987c5c -r a46dc120afd7 flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Tue Nov 27 14:29:24 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Tue Nov 27 14:30:08 2012 +0100
@@ -1,5 +1,12 @@
 package de.intevation.flys.utils;
 
+import de.intevation.artifacts.common.utils.XMLUtils;
+import de.intevation.flys.artifacts.model.MapserverStyle;
+import de.intevation.flys.artifacts.model.MapserverStyle.Clazz;
+import de.intevation.flys.artifacts.model.MapserverStyle.Expression;
+import de.intevation.flys.artifacts.model.MapserverStyle.Label;
+import de.intevation.flys.artifacts.model.MapserverStyle.Style;
+
 import java.awt.Color;
 import java.awt.Font;
 
@@ -10,13 +17,6 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
-import de.intevation.artifacts.common.utils.XMLUtils;
-import de.intevation.flys.artifacts.model.MapserverStyle;
-import de.intevation.flys.artifacts.model.MapserverStyle.Clazz;
-import de.intevation.flys.artifacts.model.MapserverStyle.Expression;
-import de.intevation.flys.artifacts.model.MapserverStyle.Label;
-import de.intevation.flys.artifacts.model.MapserverStyle.Style;
-
 
 /**
  * Utility to deal with themes and their representations.
@@ -627,6 +627,12 @@
         return createWSPLGENStyle(categories).toString();
     }
 
+    /**
+     * Creates a style for the Mapfile template used by MapfileGenerator
+     * to generate floodmaps.
+     * @param categories
+     * @return
+     */
     protected static MapserverStyle createWSPLGENStyle(NodeList categories) {
         MapserverStyle ms = new MapserverStyle();
 
diff -r 585374987c5c -r a46dc120afd7 flys-artifacts/src/main/java/de/intevation/flys/wsplgen/WSPLGENCallable.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/wsplgen/WSPLGENCallable.java	Tue Nov 27 14:29:24 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/wsplgen/WSPLGENCallable.java	Tue Nov 27 14:30:08 2012 +0100
@@ -1,14 +1,14 @@
 package de.intevation.flys.wsplgen;
 
+import de.intevation.artifacts.CallContext;
+import de.intevation.flys.artifacts.model.map.WSPLGENJob;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.concurrent.Callable;
 
 import org.apache.log4j.Logger;
 
-import de.intevation.artifacts.CallContext;
-import de.intevation.flys.artifacts.model.map.WSPLGENJob;
-
 
 /**
  * A Callable that is used to start and observe an external Process for WSPLGEN.
@@ -63,8 +63,6 @@
     protected void execute(String[] args, File dir) {
         logger.info("Start JobExecutor for artifact: " + dir.getName());
 
-        String errorMsg = null;
-
         try {
             synchronized (this) {
                 process = Runtime.getRuntime().exec(args, null, dir);
diff -r 585374987c5c -r a46dc120afd7 flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java	Tue Nov 27 14:29:24 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DigitizePanel.java	Tue Nov 27 14:30:08 2012 +0100
@@ -2,7 +2,6 @@
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
-
 import com.smartgwt.client.types.Encoding;
 import com.smartgwt.client.types.VerticalAlignment;
 import com.smartgwt.client.util.SC;
@@ -204,6 +203,7 @@
             layout.addMember(uploadLabel);
             layout.addMember(uploadForm);
             layout.addMember(submit);
+            layout.addMember(getNextButton());
         }
 
         form.setValues(initial);
diff -r 585374987c5c -r a46dc120afd7 flys-client/src/main/java/de/intevation/flys/client/client/ui/LinkSelection.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LinkSelection.java	Tue Nov 27 14:29:24 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LinkSelection.java	Tue Nov 27 14:30:08 2012 +0100
@@ -36,9 +36,6 @@
     /** The message class that provides i18n strings.*/
     protected FLYSConstants messages = GWT.create(FLYSConstants.class);
 
-    /** The combobox.*/
-    protected DynamicForm form;
-
     /** The selected river*/
     protected Data river;
 
@@ -117,8 +114,6 @@
         layout.setAlign(VerticalAlignment.TOP);
         layout.setHeight(25);
 
-
-        form = new DynamicForm();
         VLayout formLayout = new VLayout();
 
         formLayout.setLayoutLeftMargin(60);
diff -r 585374987c5c -r a46dc120afd7 flys-client/src/main/java/de/intevation/flys/client/client/ui/MapSelection.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MapSelection.java	Tue Nov 27 14:29:24 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MapSelection.java	Tue Nov 27 14:30:08 2012 +0100
@@ -49,7 +49,7 @@
         moduleSelection = new ModuleSelection();
 
         Canvas form  = moduleSelection.create(data);
-        form.setWidth(250);
+        form.setWidth(400);
         form.setLayoutAlign(VerticalAlignment.TOP);
 
         // TODO implement event handling in the river map (here? or in LinkSelection)
diff -r 585374987c5c -r a46dc120afd7 flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java	Tue Nov 27 14:29:24 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SelectProvider.java	Tue Nov 27 14:30:08 2012 +0100
@@ -1,22 +1,28 @@
 package de.intevation.flys.client.client.ui;
 
 import com.google.gwt.core.client.GWT;
-
 import com.smartgwt.client.types.VerticalAlignment;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
 import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.client.FLYSConstants;
+import de.intevation.flys.client.client.event.StepForwardEvent;
 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 java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -36,7 +42,9 @@
     protected FLYSConstants messages = GWT.create(FLYSConstants.class);
 
     /** The combobox.*/
-    protected DynamicForm form;
+    protected DynamicForm form = new DynamicForm();
+
+    public static final int COMBOBOX_THRESHOLD = 20;
 
 
     /**
@@ -52,14 +60,21 @@
     public Canvas create(DataList data) {
         VLayout v = new VLayout();
         v.setMembersMargin(10);
+        v.addMember(createWidget(data));
+        if(data.size() > COMBOBOX_THRESHOLD) {
+            v.addMember(getNextButton());
+        }
+        return v;
+    }
 
-        Canvas content = createWidget(data);
-        Canvas button  = getNextButton();
 
-        v.addMember(content);
-        v.addMember(button);
-
-        return v;
+    protected Canvas createWidget(DataList data) {
+        if (data.size() > COMBOBOX_THRESHOLD) {
+            return createComboboxWidget(data);
+        }
+        else {
+            return createListWidget(data);
+        }
     }
 
 
@@ -98,15 +113,83 @@
     }
 
 
-    /**
-     * This method creates the content of the widget.
-     *
-     * @param data The {@link DataList} object.
-     *
-     * @return a combobox.
-     */
-    protected Canvas createWidget(DataList data) {
-        GWT.log("SelectProvider - create()");
+    protected Canvas createListWidget(DataList data) {
+        VLayout layout = new VLayout();
+        layout.setAlign(VerticalAlignment.TOP);
+        layout.setHeight(25);
+        layout.setWidth("100%");
+
+        VLayout formLayout = new VLayout();
+        formLayout.setLayoutTopMargin(20);
+        formLayout.setLayoutLeftMargin(50);
+
+        ClickHandler handler = new ClickHandler() {
+            @Override
+            public void onClick(ClickEvent event) {
+                LinkItem li = (LinkItem)event.getItem();
+                String attr = li.getAttribute(li.getName());
+                GWT.log("li.getTarget: " + attr + " " + li.getName());
+                DataItem item = new DefaultDataItem(
+                    attr,
+                    null,
+                    attr);
+
+                Data d = new DefaultData(
+                    li.getName(),
+                    null,
+                    null,
+                    new DataItem [] { item });
+
+                Data [] odata = getData();
+                Data [] ndata = new Data[odata.length+1];
+                System.arraycopy(odata, 0, ndata, 0, odata.length);
+                ndata[odata.length] = d;
+
+                fireStepForwardEvent(new StepForwardEvent(ndata));
+            }
+        };
+
+        for (int i = 0, size = data.size(); i < size; i++) {
+            Data d = data.get(i);
+
+            Label label = new Label(d.getDescription());
+            label.setValign(VerticalAlignment.TOP);
+            label.setHeight(20);
+            label.setWidth(400);
+
+            LinkedHashMap<String, String> initial = new LinkedHashMap<String, String>();
+            ArrayList<FormItem> formItems = new ArrayList<FormItem>();
+
+            for (DataItem item: d.getItems()) {
+                initial.put(item.getLabel().replace(' ', '_'), item.getStringValue());
+                GWT.log("put: " + item.getLabel().replace(' ', '_') + "=" + item.getStringValue());
+
+                LinkItem link = new LinkItem(d.getLabel());
+                link.setLinkTitle(item.getLabel());    // i18n text of the link
+                link.setAttribute(d.getLabel(), item.getStringValue()); // e.g. "calculation_mode":"foo"
+                link.setShowTitle(false);
+                link.setEndRow(true);
+                link.setWidth("350px");
+
+                SpacerItem space = new SpacerItem();
+                space.setWidth(15);
+                formItems.add(space);
+                formItems.add(link);
+
+                link.addClickHandler(handler);
+            }
+
+            form.setFields(formItems.toArray(new FormItem[0]));
+            form.setValues(initial);
+
+            layout.addMember(label);
+            layout.addMember(form);
+        }
+        return layout;
+    }
+
+    protected Canvas createComboboxWidget(DataList data) {
+        GWT.log("SelectProvider.createComboboxWidget()");
 
         VLayout layout   = new VLayout();
         layout.setAlign(VerticalAlignment.TOP);
@@ -114,8 +197,6 @@
 
         LinkedHashMap<String, String> initial = new LinkedHashMap<String, String>();
 
-        form = new DynamicForm();
-
         int size = data.size();
 
         for (int i = 0; i < size; i++) {
@@ -142,7 +223,6 @@
                 defaultSet = true;
             }
 
-            // I was here. Me 2.
             for (DataItem item: d.getItems()) {
                 if (!defaultSet && first) {
                     initial.put(d.getLabel(), item.getStringValue());
@@ -178,7 +258,7 @@
         int       i = 0;
 
         while (keys.hasNext()) {
-            String fieldname = (String) keys.next();
+            String fieldname = ((String) keys.next()).replace('_', ' ');
             String selection = (String) values.get(fieldname);
 
             DataItem item    = new DefaultDataItem(fieldname, null, selection);


More information about the Dive4elements-commits mailing list