changeset 236:d12078053b59

Introduced two further parameters in the WQ panel to determine the selection mode (range/single, w/q). flys-client/trunk@1792 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 02 May 2011 14:54:11 +0000
parents d3f8d6966c20
children cf25f235b7b6
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java
diffstat 2 files changed, 103 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon May 02 14:47:12 2011 +0000
+++ b/flys-client/ChangeLog	Mon May 02 14:54:11 2011 +0000
@@ -1,3 +1,9 @@
+2011-05-02  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java:
+	  Introduced two further parameters to determine the selection mode of
+	  this panel.
+
 2011-05-02  Raimund Renkert <rrenkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java	Mon May 02 14:47:12 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java	Mon May 02 14:54:11 2011 +0000
@@ -141,25 +141,46 @@
     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");
+        Data dMode      = getData(items, "wq_mode");
+        Data dSelection = getData(items, "wq_selection");
+        Data dSingle    = getData(items, "wq_single");
+        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();
+        String strMode  = mode[0].getStringValue();
+        boolean wMode   = strMode.equals(FIELD_WQ_W);
 
         HLayout layout = new HLayout();
         layout.setWidth("400px");
 
-        Label   label  = new Label(dataList.getLabel());
+        Label label  = new Label(dataList.getLabel());
         label.setWidth("200px");
 
-        String text = mode[0].getStringValue().equals(FIELD_WQ_W)
-            ? createWString(from[0], to[0], step[0])
-            : createQString(from[0], to[0], step[0]);
+        String text = null;
+
+        DataItem[] selItem = dSelection.getItems();
+        String     sel     = selItem != null
+            ? selItem[0].getStringValue()
+            : "";
+
+        if (sel.equals("single")) {
+            DataItem[] single = dSingle.getItems();
+
+            text = wMode
+                ? createWString(single[0])
+                : createQString(single[0]);
+        }
+        else {
+            DataItem[] from = dFrom.getItems();
+            DataItem[] to   = dTo.getItems();
+            DataItem[] step = dStep.getItems();
+
+            text = wMode
+                ? createWString(from[0], to[0], step[0])
+                : createQString(from[0], to[0], step[0]);
+        }
 
         Label selected = new Label(text);
         selected.setWidth("130px");
@@ -223,6 +244,11 @@
     }
 
 
+    protected String createWString(DataItem single) {
+        return single.getLabel();
+    }
+
+
     protected String createQString(DataItem from, DataItem to, DataItem step) {
         StringBuilder sb = new StringBuilder();
         sb.append(from.getLabel());
@@ -236,6 +262,11 @@
     }
 
 
+    protected String createQString(DataItem single) {
+        return single.getLabel();
+    }
+
+
     /**
      * This method greps the Data with name <i>name</i> from the list and
      * returns it.
@@ -369,6 +400,11 @@
                     saveSingleQValues(form);
                 }
             }
+
+            return new Data[] {
+                getDataMode(),
+                getDataSelectionMode(),
+                getDataSingle() };
         }
         else {
             Canvas member = container.getMember(0);
@@ -382,13 +418,14 @@
                     saveRangeQValues(form);
                 }
             }
-        }
 
-        return new Data[] {
-            getDataMode(),
-            getDataFrom(),
-            getDataTo(),
-            getDataStep() };
+            return new Data[] {
+                getDataMode(),
+                getDataSelectionMode(),
+                getDataFrom(),
+                getDataTo(),
+                getDataStep() };
+        }
     }
 
 
@@ -406,6 +443,42 @@
 
 
     /**
+     * Returns the Data object for the 'mode' attribute.
+     *
+     * @return the Data object for the 'mode' attribute.
+     */
+    protected Data getDataSelectionMode() {
+        String wqSelection = modes.getValueAsString(FIELD_MODE);
+        DataItem item = new DefaultDataItem(
+            "wq_selection", "wq_selection", wqSelection);
+
+        return new DefaultData(
+            "wq_selection", null, null, new DataItem[] { item });
+    }
+
+
+    /**
+     * Returns the data object for the 'single' attribute.
+     *
+     * @return the Data object for the 'single' attribute.
+     */
+    protected Data getDataSingle() {
+        double[] values  = getFinalSingle();
+        StringBuilder sb = new StringBuilder();
+        for (double value: values) {
+            sb.append(Double.toString(value));
+            sb.append(" ");
+        }
+
+        DataItem item = new DefaultDataItem(
+            "wq_single", "wq_single", sb.toString());
+
+        return new DefaultData(
+            "wq_single", null, null, new DataItem[] { item });
+    }
+
+
+    /**
      * Returns the Data object for the 'from' attribute.
      *
      * @return the Data object for the 'from' attribute.
@@ -444,6 +517,13 @@
     }
 
 
+    protected double[] getFinalSingle() {
+        boolean wMode = isWMode();
+
+        return wMode ? getSingleW() : getSingleQ();
+    }
+
+
     /**
      * Returns the value of 'from' depending on the selected input mode.
      *

http://dive4elements.wald.intevation.org