changeset 5774:496c8c9d4913

issue1260, issue1259: Improve multi-gauge w/q input.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 19 Apr 2013 12:44:55 +0200
parents cdc47534a970
children 300c0270c576
files flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/QDTable.java
diffstat 2 files changed, 39 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java	Fri Apr 19 11:47:27 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java	Fri Apr 19 12:44:55 2013 +0200
@@ -216,21 +216,34 @@
                     double val = r.getAttributeAsDouble("value");
 
                     doubleArrayPanels.get(fi).setValues(new double[]{val});
-                    // Focus next.
-                    if (fi != doubleArrayPanels.size()-1) {
-                        doubleArrayPanels.get(fi+1).focusInItem(1);
+                    // If a named value for first gauge is chosen, try to find and set
+                    // the values to the other panels too.
+                    if (fi == 0) {
+                        String valueName = r.getAttribute("name");
+                        int oi = 0;
+                        // TODO instead of oi use random access.
+                        for (QDTable otherQDTable: qdTables) {
+                            if (oi == 0) {
+                                oi++;
+                                continue;
+                            }
+                            Double value = otherQDTable.findRecordValue(valueName);
+                            if (value == null) {
+                                // TODO i18n
+                                SC.warn("No Value for <name> at <gauge>");
+                            }
+                            else {
+                                doubleArrayPanels.get(oi).setValues(new double[]{value});
+                            }
+                            oi++;
+                        }
                     }
-
-                    /*if (itemWithFocus != null) {
-                        itemWithFocus.setValues(new double[]{val});
-                        int i = doubleArrayPanels.indexOf(itemWithFocus);
-                        if (i == doubleArrayPanels.size()-1) {
-                            doubleArrayPanels.get(0).focusInItem(1);
+                    else {
+                        // Focus next.
+                        if (fi != doubleArrayPanels.size()-1) {
+                            doubleArrayPanels.get(fi+1).focusInItem(1);
                         }
-                        else {
-                            doubleArrayPanels.get(i+1).focusInItem(1);
-                        }
-                    }*/
+                    }
                 }
             };
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/QDTable.java	Fri Apr 19 11:47:27 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/QDTable.java	Fri Apr 19 12:44:55 2013 +0200
@@ -109,5 +109,18 @@
     public boolean isLocked() {
         return lockClick;
     }
+
+    /**
+     * Search all records for one with attribute name equals to given name.
+     * @return null if none found.
+     * */
+    public Double findRecordValue(String name) {
+        for (ListGridRecord record : getRecords()) {
+            if (record.getAttribute("name").equals(name)) {
+                return record.getAttributeAsDouble("value");
+            }
+        }
+        return null;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org