changeset 2392:8112ec686a9a

Picked rev4066,4075 from trunk. flys-client/tags/2.6.1@4082 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 17 Feb 2012 12:58:38 +0000
parents 3c8ae5605a51
children 092e519ff461
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java
diffstat 3 files changed, 124 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Feb 17 11:33:03 2012 +0000
+++ b/flys-client/ChangeLog	Fri Feb 17 12:58:38 2012 +0000
@@ -1,3 +1,12 @@
+2012-02-17  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java:
+	  Renamed state data fields: wq_mode      -> wq_isq
+	                             wq_free      -> wq_isfree
+	                             wq_selection -> wq_isrange
+	  Removed some logs.
+
 2012-02-17  Ingo Weinzierl <ingo@intevation.de>
 
 	flys/issue459 (Diagramm-Export hat nicht die gleiche Axenskalierung wie
@@ -31,6 +40,15 @@
 	  Refactored the wq input data fields. The data fields wq_mode, wq_free
 	  and wq_selection are now of type 'boolean'.
 
+2012-02-16  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Refactored the wq input data fields.
+
+	* src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java:
+	  Refactored the wq input data fields. The data fields wq_mode, wq_free
+	  and wq_selection are now of type 'boolean'.
+
 2012-02-16  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java	Fri Feb 17 11:33:03 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java	Fri Feb 17 12:58:38 2012 +0000
@@ -44,7 +44,7 @@
 extends      AbstractUIProvider
 implements   ChangeHandler, BlurHandler
 {
-    public static final String FIELD_WQ_MODE = "wq_mode";
+    public static final String FIELD_WQ_MODE = "wq_isq";
     public static final String FIELD_WQ_W    = "W";
     public static final String FIELD_WQ_Q    = "Q";
 
@@ -103,7 +103,7 @@
     public Canvas createOld(DataList dataList) {
         List<Data> all = dataList.getAll();
         Data    wqData = getData(all, "wq_values");
-        Data    wqMode = getData(all, "wq_mode");
+        Data    wqMode = getData(all, "wq_isq");
 
         Canvas back = getBackButton(dataList.getState());
 
@@ -499,9 +499,13 @@
 
     protected Data getWQMode() {
         String wqMode = modes.getValueAsString(FIELD_WQ_MODE);
-        DataItem item = new DefaultDataItem("wq_mode", "wq_mode", wqMode);
+        String value = "false";
+        if (wqMode.equals("Q")) {
+            value = "true";
+        }
+        DataItem item = new DefaultDataItem("wq_isq", "wq_isq", value);
         Data mode = new DefaultData(
-            "wq_mode", null, null, new DataItem[] { item });
+            "wq_isq", null, null, new DataItem[] { item });
 
         return mode;
     }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java	Fri Feb 17 11:33:03 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java	Fri Feb 17 12:58:38 2012 +0000
@@ -72,7 +72,7 @@
     public static final String FIELD_WQ_Q = "Q";
 
     /** The constant field value for Q input mode.*/
-    public static final String FIELD_WQ_Q_GAUGE = "Q_GAUGE";
+    public static final String FIELD_WQ_Q_FREE = "QFREE";
 
     /** The constant field name for choosing single values or range.*/
     public static final String FIELD_MODE = "mode";
@@ -275,9 +275,9 @@
     public Canvas createOld(DataList dataList) {
         List<Data> items = dataList.getAll();
 
-        Data dMode      = getData(items, "wq_mode");
-        Data dFree      = getData(items, "wq_free");
-        Data dSelection = getData(items, "wq_selection");
+        Data dMode      = getData(items, "wq_isq");
+        Data dFree      = getData(items, "wq_isfree");
+        Data dSelection = getData(items, "wq_isrange");
         Data dSingle    = getData(items, "wq_single");
         Data dFrom      = getData(items, "wq_from");
         Data dTo        = getData(items, "wq_to");
@@ -285,7 +285,7 @@
 
         DataItem[] mode = dMode.getItems();
         String strMode  = mode[0].getStringValue();
-        boolean wMode   = strMode.equals(FIELD_WQ_W);
+        boolean isQMode   = Boolean.valueOf(strMode);
 
         DataItem[] free = dFree.getItems();
         String  strFree = free[0].getStringValue();
@@ -300,14 +300,14 @@
         VLayout vLabel = null;
 
         DataItem[] selItem = dSelection.getItems();
-        String     sel     = selItem != null
-            ? selItem[0].getStringValue()
-            : "";
+        boolean    isRange = selItem != null
+            ? Boolean.valueOf(selItem[0].getStringValue())
+            : false;
 
-        if (sel.equals("single")) {
+        if (!isRange) {
             DataItem[] single = dSingle.getItems();
 
-            vLabel = wMode
+            vLabel = !isQMode
                 ? createWString(single[0])
                 : createQString(single[0]);
         }
@@ -316,7 +316,7 @@
             DataItem[] to   = dTo.getItems();
             DataItem[] step = dStep.getItems();
 
-            vLabel = wMode
+            vLabel = !isQMode
                 ? createWString(from[0], to[0], step[0])
                 : createQString(from[0], to[0], step[0]);
         }
@@ -324,7 +324,7 @@
         VLayout selectedLayout = new VLayout();
         String  wqMode         = null;
 
-        if (wMode) {
+        if (!isQMode) {
             wqMode = MESSAGE.wqW();
         }
         else {
@@ -404,44 +404,41 @@
     protected void initUserDefaults(DataList list) {
         List<Data> allData = list.getAll();
 
-        Data     m        = getData(allData, "wq_mode");
+        Data     m        = getData(allData, "wq_isq");
         DataItem modeItem = m != null ? m.getDefault() : null;
-        String   theMode  = modeItem != null
-            ? modeItem.getStringValue()
-            : "";
+        boolean isQ  = modeItem != null
+            ? Boolean.valueOf(modeItem.getStringValue())
+            : false;
 
-        Data     f        = getData(allData, "wq_free");
+        Data     f        = getData(allData, "wq_isfree");
         DataItem freeItem = f != null ? f.getDefault() : null;
-        String   theFree  = freeItem != null
-            ? freeItem.getStringValue()
-            : null;
+        boolean  isFree   = freeItem != null
+            ? Boolean.valueOf(freeItem.getStringValue())
+            : false;
 
-        Data     s            = getData(allData, "wq_selection");
+        Data     s            = getData(allData, "wq_isrange");
         DataItem sI           = s != null ? s.getDefault() : null;
-        String   theSelection = sI != null ? sI.getStringValue() : null;
+        boolean   isRange      = sI != null
+            ? Boolean.valueOf(sI.getStringValue())
+            : false;
 
-        if (theMode == null || theMode.length() == 0) {
-            return;
+        initUserSingleValues(list, isQ);
+        initUserRangeValues(list, isQ);
+
+        if (isQ) {
+            modes.setValue(FIELD_WQ, isQ);
+        }
+        else {
+            modes.setValue(FIELD_WQ, isFree ? FIELD_WQ_Q_FREE : FIELD_WQ_Q);
         }
 
-        boolean isW     = theMode.equals(FIELD_WQ_W);
-        boolean isFree  = Boolean.valueOf(theFree);
-        boolean isWFree = theMode.equals(FIELD_WQ_W_FREE);
-
-        initUserSingleValues(list, theMode);
-        initUserRangeValues(list, theMode);
-
-        if (isW || isWFree) {
-            modes.setValue(FIELD_WQ, theMode);
+        if(isRange) {
+            modes.setValue(FIELD_MODE, FIELD_MODE_RANGE);
         }
         else {
-            modes.setValue(FIELD_WQ, isFree ? FIELD_WQ_Q : FIELD_WQ_Q_GAUGE);
+            modes.setValue(FIELD_MODE, FIELD_MODE_SINGLE);
         }
-
-        if (theSelection != null || theSelection.length() > 0) {
-            modes.setValue(FIELD_MODE, theSelection);
-            updatePanels(theMode, theSelection);
-        }
+        updatePanels(isQ, isFree, isRange);
     }
 
 
@@ -451,11 +448,13 @@
      * @param list The DataList that contains the 'wq_single' object.
      * @param theMode The W or Q mode.
      */
-    protected void initUserSingleValues(DataList list, String theMode) {
+    protected void initUserSingleValues(DataList list, boolean isQ) {
         List<Data> allData = list.getAll();
 
+
         Data     s = getData(allData, "wq_single");
         DataItem i = s != null ? s.getDefault() : null;
+        GWT.log("init values: " + i.getStringValue());
 
         if (i != null) {
             String   value = i.getStringValue();
@@ -474,7 +473,7 @@
                 }
             }
 
-            if (theMode.equals("W")) {
+            if (!isQ) {
                 setSingleW(values);
             }
             else {
@@ -490,7 +489,7 @@
      * @param list The DataList that contains the 'wq_single' object.
      * @param theMode The W or Q mode.
      */
-    protected void initUserRangeValues(DataList list, String theMode) {
+    protected void initUserRangeValues(DataList list, boolean isQ) {
         List<Data> allData = list.getAll();
 
         // init range mode values
@@ -512,7 +511,7 @@
                 double to   = Double.valueOf(tS);
                 double step = Double.valueOf(sS);
 
-                if (theMode.equals("W")) {
+                if (!isQ) {
                     setWRangeValues(from, to, step);
                 }
                 else {
@@ -659,8 +658,8 @@
         LinkedHashMap wqValues = new LinkedHashMap();
         wqValues.put(FIELD_WQ_W, MESSAGE.wqW());
         wqValues.put(FIELD_WQ_W_FREE, MESSAGE.wqWFree());
-        wqValues.put(FIELD_WQ_Q, MESSAGE.wqQ());
-        wqValues.put(FIELD_WQ_Q_GAUGE, MESSAGE.wqQGauge());
+        wqValues.put(FIELD_WQ_Q_FREE, MESSAGE.wqQ());
+        wqValues.put(FIELD_WQ_Q, MESSAGE.wqQGauge());
 
         LinkedHashMap modeValues = new LinkedHashMap();
         modeValues.put(FIELD_MODE_SINGLE, MESSAGE.wqSingle());
@@ -678,7 +677,7 @@
         modes.setNumCols(1);
 
         LinkedHashMap initial = new LinkedHashMap();
-        initial.put(FIELD_WQ, FIELD_WQ_Q_GAUGE);
+        initial.put(FIELD_WQ, FIELD_WQ_Q);
         initial.put(FIELD_MODE, FIELD_MODE_SINGLE);
         modes.setValues(initial);
 
@@ -884,7 +883,7 @@
 
         return new Data[] {
                 getDataMode(),
-                getQMode(),
+                getFree(),
                 getDataSelectionMode(),
                 getDataSingle(),
                 new DefaultData(
@@ -914,7 +913,7 @@
 
         return new Data[] {
                 getDataMode(),
-                getQMode(),
+                getFree(),
                 getDataSelectionMode(),
                 getDataFrom(),
                 getDataTo(),
@@ -936,22 +935,18 @@
         String wqMode = modes.getValueAsString(FIELD_WQ);
 
         String value = null;
-        if (wqMode.equals(FIELD_WQ_Q) || wqMode.equals(FIELD_WQ_Q_GAUGE)) {
-            GWT.log("getData: FIELD_WQ_Q || FIELD_WQ_Q_GAUGE");
-            value = FIELD_WQ_Q;
-        }
-        else if (wqMode.equals(FIELD_WQ_W_FREE)) {
-            GWT.log("getData: FIELD_WQ_W_FREE");
-            value = FIELD_WQ_W_FREE;
+        if (wqMode.equals(FIELD_WQ_Q_FREE) || wqMode.equals(FIELD_WQ_Q)) {
+            GWT.log("getData: FIELD_WQ_Q || FIELD_WQ_Q_FREE");
+            value = "true";
         }
         else {
             GWT.log("getData: FIELD_WQ_W");
-            value = FIELD_WQ_W;
+            value = "false";
         }
 
-        DataItem item = new DefaultDataItem("wq_mode", "wq_mode", value);
+        DataItem item = new DefaultDataItem("wq_isq", "wq_isq", value);
         return new DefaultData(
-            "wq_mode", null, null, new DataItem[] { item });
+            "wq_isq", null, null, new DataItem[] { item });
     }
 
 
@@ -962,12 +957,17 @@
      *
      * @return the Data object for the 'wq_free' attribute.
      */
-    protected Data getQMode() {
-        String value = isQFree() ? "true" : "false";
-
-        DataItem item = new DefaultDataItem("wq_free", "wq_free", value);
+    protected Data getFree() {
+        String value = "";
+        if(!isWMode()) {
+            value = isQFree() ? "true" : "false";
+        }
+        else {
+            value = isWFree() ? "true" : "false";
+        }
+        DataItem item = new DefaultDataItem("wq_isfree", "wq_isfree", value);
         return new DefaultData(
-            "wq_free", null, null, new DataItem[] { item });
+            "wq_isfree", null, null, new DataItem[] { item });
     }
 
 
@@ -978,11 +978,16 @@
      */
     protected Data getDataSelectionMode() {
         String wqSelection = modes.getValueAsString(FIELD_MODE);
+
+        String isRange = "true";
+        if (wqSelection.equals(FIELD_MODE_SINGLE)) {
+            isRange = "false";
+        }
         DataItem item = new DefaultDataItem(
-            "wq_selection", "wq_selection", wqSelection);
+            "wq_isrange", "wq_isrange", isRange);
 
         return new DefaultData(
-            "wq_selection", null, null, new DataItem[] { item });
+            "wq_isrange", null, null, new DataItem[] { item });
     }
 
 
@@ -1194,13 +1199,13 @@
      */
     public boolean isWMode() {
         String wq = modes.getValueAsString(FIELD_WQ);
-        return wq.equals(FIELD_WQ_W);
+        return wq.contains("W");
     }
 
 
     public boolean isQFree() {
         String wqMode = modes.getValueAsString(FIELD_WQ);
-        return wqMode.equals(FIELD_WQ_Q);
+        return wqMode.equals(FIELD_WQ_Q_FREE);
     }
 
     protected boolean isWFree() {
@@ -1219,34 +1224,40 @@
         DynamicForm form = event.getForm();
         FormItem    item = event.getItem();
 
-        String wqMode    = null;
-        String inputMode = null;
+        boolean isQ     = false;
+        boolean isFree  = false;
+        boolean isRange = false;
 
         if (item.getFieldName().equals(FIELD_MODE)) {
-            wqMode    = form.getValueAsString(FIELD_WQ);
-            inputMode = (String) event.getValue();
+            String wq = form.getValueAsString(FIELD_WQ);
+            isQ     = wq.contains("Q");
+            isFree  = wq.contains("FREE");
+            isRange = ((String) event.getValue()).equals(FIELD_MODE_RANGE);
         }
         else {
-            wqMode    = (String) event.getValue();
-            inputMode = form.getValueAsString(FIELD_MODE);
+            String wq = ((String) event.getValue());
+            isQ       = wq.contains("Q");
+            isFree    = wq.contains("FREE");
+            isRange   =
+                form.getValueAsString(FIELD_MODE).equals(FIELD_MODE_RANGE);
         }
 
-        if (wqMode.equals("Q")) {
+        if (isQ && isFree) {
             qdTable.hideIconFields();
         }
         else {
             qdTable.showIconFields();
         }
 
-        updatePanels(wqMode, inputMode);
+        updatePanels(isQ, isFree, isRange);
     }
 
 
-    protected void updatePanels(String wqMode, String inputMode) {
+    protected void updatePanels(boolean isQ, boolean isFree, boolean isRange) {
         container.removeMembers(container.getMembers());
 
-        if (wqMode.equals(FIELD_WQ_W) || wqMode.equals(FIELD_WQ_W_FREE)) {
-            if (inputMode.equals(FIELD_MODE_SINGLE)) {
+        if (!isQ) {
+            if (!isRange) {
                 // Single W mode
                 double[] values = getSingleW();
 
@@ -1271,8 +1282,8 @@
 
             tabs.selectTab(0);
         }
-        else if (wqMode.equals(FIELD_WQ_Q)) {
-            if (inputMode.equals(FIELD_MODE_SINGLE)) {
+        else if (isQ && isFree) {
+            if (!isRange) {
                 // Single Q mode
                 double[] values = getSingleQFree();
 
@@ -1297,7 +1308,7 @@
             tabs.selectTab(1);
         }
         else {
-            if (inputMode.equals(FIELD_MODE_SINGLE)) {
+            if (!isRange) {
                 // Single Q mode
                 double[] values = getSingleQ();
 
@@ -1655,7 +1666,12 @@
 
                     String wq = (String) modes.getValue(FIELD_WQ);
                     String sr = (String) modes.getValue(FIELD_MODE);
-                    updatePanels(wq, sr);
+                    GWT.log("sending: " + wq + ", " + sr);
+                    boolean isQ = wq.contains("Q");
+                    boolean isFree = wq.contains("FREE");
+                    boolean isRange = sr.equals(FIELD_MODE_RANGE);
+
+                    updatePanels(isQ, isFree, isRange);
                 }
             }
         );

http://dive4elements.wald.intevation.org