changeset 255:e4f0bef52689

Added radio buttons to choose between W/Q modes in the adapted WQ panel. flys-client/trunk@1867 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 09 May 2011 13:51:39 +0000
parents 6838e4112eeb
children 5e1c1b7d6516
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java
diffstat 2 files changed, 86 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon May 09 11:21:50 2011 +0000
+++ b/flys-client/ChangeLog	Mon May 09 13:51:39 2011 +0000
@@ -1,3 +1,8 @@
+2011-05-09  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java:
+	  Added radio buttons to choose between W/Q mode.
+
 2011-05-09  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java	Mon May 09 11:21:50 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java	Mon May 09 13:51:39 2011 +0000
@@ -2,6 +2,7 @@
 
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -11,6 +12,8 @@
 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.RadioGroupItem;
 import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
 import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
@@ -38,6 +41,8 @@
 implements   ChangeHandler, BlurHandler
 {
     public static final String FIELD_WQ_MODE = "wq_mode";
+    public static final String FIELD_WQ_W    = "W";
+    public static final String FIELD_WQ_Q    = "Q";
 
     public static final String GAUGE_SEPARATOR = ":";
 
@@ -45,6 +50,8 @@
 
     public static final String VALUE_SEPARATOR = ",";
 
+    public static final int ROW_HEIGHT = 20;
+
 
     /** The message class that provides i18n strings.*/
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
@@ -52,6 +59,9 @@
     /** Stores the input panels related to their keys.*/
     protected Map<String, DoubleArrayPanel> wqranges;
 
+    /** The RadioGroupItem that determines the w/q input mode.*/
+    protected DynamicForm modes;
+
 
 
     public WQAdaptedInputPanel() {
@@ -68,6 +78,7 @@
 
         VLayout layout = new VLayout();
         layout.setMembersMargin(10);
+        layout.setWidth(350);
 
         layout.addMember(label);
         layout.addMember(widget);
@@ -157,6 +168,48 @@
     protected Canvas createWidget(DataList dataList) {
         VLayout layout = new VLayout();
 
+        Canvas mode = createMode(dataList);
+        Canvas list = createList(dataList);
+
+        DataItem[] items = getWQItems(dataList);
+        int listHeight   = ROW_HEIGHT * items.length;
+
+        mode.setHeight(25);
+        mode.setWidth(200);
+
+        layout.addMember(mode);
+        layout.addMember(list);
+
+        layout.setHeight(25 + listHeight);
+        layout.setWidth(350);
+
+        return layout;
+    }
+
+
+    protected Canvas createList(DataList dataList) {
+        VLayout layout = new VLayout();
+
+        DataItem[] items = getWQItems(dataList);
+
+        for (DataItem item: items) {
+            String title = item.getLabel();
+
+            DoubleArrayPanel dap = new DoubleArrayPanel(
+                createLineTitle(title), null, this, TitleOrientation.LEFT);
+
+            wqranges.put(title, dap);
+
+            layout.addMember(dap);
+        }
+
+        layout.setHeight(items.length * ROW_HEIGHT);
+
+        return layout;
+    }
+
+
+    protected DataItem[] getWQItems(DataList dataList) {
         List<Data> data = dataList.getAll();
 
         for (Data d: data) {
@@ -166,21 +219,34 @@
                 continue;
             }
 
-            DataItem[] items = d.getItems();
-
-            for (DataItem item: items) {
-                String title = item.getLabel();
-
-                DoubleArrayPanel dap = new DoubleArrayPanel(
-                    createLineTitle(title), null, this, TitleOrientation.LEFT);
-
-                wqranges.put(title, dap);
-
-                layout.addMember(dap);
-            }
+            return d.getItems();
         }
 
-        return layout;
+        return null;
+    }
+
+
+    protected Canvas createMode(DataList dataList) {
+        RadioGroupItem wq = new RadioGroupItem(FIELD_WQ_MODE);
+        wq.setShowTitle(false);
+        wq.setVertical(false);
+        wq.setWidth(200);
+
+        LinkedHashMap wqValues = new LinkedHashMap();
+        wqValues.put(FIELD_WQ_W, MSG.wqW());
+        wqValues.put(FIELD_WQ_Q, MSG.wqQ());
+
+        wq.setValueMap(wqValues);
+
+        modes = new DynamicForm();
+        modes.setFields(wq);
+        modes.setWidth(200);
+
+        LinkedHashMap initial = new LinkedHashMap();
+        initial.put(FIELD_WQ_MODE, FIELD_WQ_W);
+        modes.setValues(initial);
+
+        return modes;
     }
 
 
@@ -200,8 +266,8 @@
 
 
     protected Data getWQMode() {
-        // TODO Search for the correct value!
-        DataItem item = new DefaultDataItem("wq_mode", "wq_mode", "q");
+        String wqMode = modes.getValueAsString(FIELD_WQ_MODE);
+        DataItem item = new DefaultDataItem("wq_mode", "wq_mode", wqMode);
         Data mode = new DefaultData(
             "wq_mode", null, null, new DataItem[] { item });
 

http://dive4elements.wald.intevation.org