# HG changeset patch # User Felix Wolfsteller # Date 1366368295 -7200 # Node ID 496c8c9d49135c8ec319ed6c3b68cb523555e1a4 # Parent cdc47534a9709cd53929a86dc3852af4018e5a9a issue1260, issue1259: Improve multi-gauge w/q input. diff -r cdc47534a970 -r 496c8c9d4913 flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java --- 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 at "); + } + 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); - } - }*/ + } } }; diff -r cdc47534a970 -r 496c8c9d4913 flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/QDTable.java --- 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 :