diff flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java @ 53:3d5d7788d471

The widgets in the static part of the parameter panel are created using UIProviders now. The ParameterList does not build widgets any longer. flys-client/trunk@1509 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 17 Mar 2011 18:34:20 +0000
parents a2923d63f530
children c9c19761a449
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java	Thu Mar 17 18:20:05 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java	Thu Mar 17 18:34:20 2011 +0000
@@ -1,6 +1,7 @@
 package de.intevation.flys.client.client.ui;
 
 import java.util.LinkedHashMap;
+import java.util.List;
 
 import com.google.gwt.core.client.GWT;
 
@@ -14,6 +15,7 @@
 import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.shared.model.Data;
@@ -120,6 +122,81 @@
     }
 
 
+    public Canvas createOld(DataList dataList) {
+        List<Data> items = dataList.getAll();
+
+        Data dMode = getData(items, "wq_mode");
+        Data dFrom = getData(items, "wq_from");
+        Data dTo   = getData(items, "wq_to");
+        Data dStep = getData(items, "wq_step");
+
+        DataItem[] mode = dMode.getItems();
+        DataItem[] from = dFrom.getItems();
+        DataItem[] to   = dTo.getItems();
+        DataItem[] step = dStep.getItems();
+
+        HLayout layout = new HLayout();
+        Label   label  = new Label(dataList.getLabel());
+
+        label.setWidth("50%");
+
+        String text = mode[0].getStringValue().equals(FIELD_WQ_W)
+            ? createWString(from[0], to[0], step[0])
+            : createQString(from[0], to[0], step[0]);
+
+        layout.addMember(label);
+        layout.addMember(new Label(text));
+
+        return layout;
+    }
+
+
+    protected String createWString(DataItem from, DataItem to, DataItem step) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(from.getLabel());
+        sb.append(" " + MSG.unitWFrom() + " ");
+        sb.append(to.getLabel());
+        sb.append(" " + MSG.unitWTo() + " ");
+        sb.append(step.getLabel());
+        sb.append(" " + MSG.unitWStep());
+
+        return sb.toString();
+    }
+
+
+    protected String createQString(DataItem from, DataItem to, DataItem step) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(from.getLabel());
+        sb.append(" " + MSG.unitQFrom() + " ");
+        sb.append(to.getLabel());
+        sb.append(" " + MSG.unitQTo() + " ");
+        sb.append(step.getLabel());
+        sb.append(" " + MSG.unitQStep());
+
+        return sb.toString();
+    }
+
+
+    /**
+     * This method greps the Data with name <i>name</i> from the list and
+     * returns it.
+     *
+     * @param items A list of Data.
+     * @param name The name of the Data that we are searching for.
+     *
+     * @return the Data with the name <i>name</i>.
+     */
+    protected Data getData(List<Data> data, String name) {
+        for (Data d: data) {
+            if (name.equals(d.getLabel())) {
+                return d;
+            }
+        }
+
+        return null;
+    }
+
+
     /**
      * This method creates the whole widget. There is a panel on the left, that
      * allows the user to enter values manually by keyboard. On the right, there

http://dive4elements.wald.intevation.org