Mercurial > dive4elements > river
diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractWQAdaptedInputPanel.java @ 9454:4cccbd32b680
Bundu.wst.UD -> Q-Values are set on Client side now
author | gernotbelger |
---|---|
date | Thu, 23 Aug 2018 16:32:28 +0200 |
parents | 0fb76f2d4e5b |
children | a41f5f7c0b4a |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractWQAdaptedInputPanel.java Thu Aug 23 11:02:47 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractWQAdaptedInputPanel.java Thu Aug 23 16:32:28 2018 +0200 @@ -69,6 +69,8 @@ /** Stores the input panels related to their keys. */ protected Map<String, DoubleArrayPanel> wqranges; + protected Map<String, Double> UDMap = new HashMap<String, Double>(); + /** [startkm,endkm] per gauge in selected range. */ protected List<Double[]> gaugeRanges; @@ -113,20 +115,18 @@ this.tabs.setWidth100(); this.tabs.setHeight100(); final String msg = this.getWQInfoMsg(); - final Label test = PanelHelper.getValidationLabel(); - test.setText(msg); - test.getElement().getStyle().setColor("black"); - test.getElement().getStyle().setPadding(1, Unit.MM); // For each gauge, add two tabs with helper tables. createTabs(); layout.addMember(this.tabs); - if (msg != null) - layout.addMember(test); + if (msg != null) { + final Label additionalMsg = new Label(msg); // PanelHelper.getValidationLabel(); + additionalMsg.setHeight("15px"); + additionalMsg.getElement().getStyle().setPadding(1, Unit.MM); + layout.addMember(additionalMsg); + } this.helperContainer.addMember(layout); - // DOM.setStyleAttribute(test.getElement(), "color", "red"); - } /** Create labels, canvasses, layouts. */ @@ -410,28 +410,57 @@ return results; } + private final String createKeyForWQValues(final String gaugeName, final String UD) { + final Double[] fromTo = this.gaugeNamesRange.get(gaugeName); + assert (fromTo.length == 2); + return new StringBuilder().append(fromTo[0]).append(GAUGE_PART_SEPARATOR).append(fromTo[1]).append(GAUGE_PART_SEPARATOR).append(gaugeName) + .append(GAUGE_PART_SEPARATOR).append(UD).toString(); + } + protected final Data getWQValues(final String dataKey) { String wqvalue = null; - for (final Map.Entry<String, DoubleArrayPanel> entry : this.wqranges.entrySet()) { - final String key = entry.getKey(); - final DoubleArrayPanel dap = entry.getValue(); - final String label = dap.getItemTitle(); + final String key = getKeyFromDap(entry); + final double[] values = entry.getValue().getInputValues(); + wqvalue = appendValueStr(createValueString(key, values), wqvalue); + } + return getValueItem(dataKey, wqvalue); + } - final double[] values = dap.getInputValues(); - if (wqvalue == null) { - wqvalue = createValueString(key + ";" + label, values); - } else { - wqvalue += GAUGE_SEPARATOR + createValueString(key + ";" + label, values); - } + protected final Data getWQValuesForUD(final String dataKey, final String udValue) { + String wqvalue = null; + for (final Map.Entry<String, DoubleArrayPanel> entry : this.wqranges.entrySet()) { + final String keyBasic = getKeyFromDap(entry); + final Double value = this.UDMap.get(keyBasic + GAUGE_PART_SEPARATOR + udValue); + if (value != null) + wqvalue = appendValueStr(createValueString(keyBasic, new double[] { value }), wqvalue); } + return getValueItem(dataKey, wqvalue); + } + private Data getValueItem(final String dataKey, final String wqvalue) { final DataItem valueItem = new DefaultDataItem(dataKey, dataKey, wqvalue); final Data values = new DefaultData(dataKey, null, null, new DataItem[] { valueItem }); return values; } + private String appendValueStr(final String appendStr, String oldStr) { + if (oldStr == null) { + oldStr = appendStr; + } else { + oldStr += GAUGE_SEPARATOR + appendStr; + } + return oldStr; + } + + private String getKeyFromDap(final Map.Entry<String, DoubleArrayPanel> entry) { + final String keyRange = entry.getKey(); + final DoubleArrayPanel dap = entry.getValue(); + final String label = dap.getItemTitle(); + return new StringBuilder().append(keyRange).append(GAUGE_PART_SEPARATOR).append(label).toString(); + } + protected String createValueString(final String key, final double[] values) { final StringBuilder sb = new StringBuilder(); @@ -441,9 +470,7 @@ if (!first) { sb.append(","); } - sb.append(Double.toString(value)); - first = false; } @@ -466,9 +493,6 @@ /** Get the WQD data from service and stuck them up that tables. */ protected abstract void fetchWQData(); - // protected abstract void callMainValuesService(String locale, String river, double start, double end, - // AsyncCallback<WQInfoObject[]> cb); - /** Add Info to helper table for gauge at index gaugeIdx. */ public void addWQInfo(final WQInfoObject[] wqi, final int gaugeIdx, final GaugeInfoObject gauge) { if (wqi == null) { @@ -481,13 +505,19 @@ } else { for (final WQInfoObject wi : wqi) { final WQInfoRecord rec = new WQInfoRecord(wi); - - if (wi.getType().equals("W")) { - if (gaugeIdx < this.wTables.size()) - this.wTables.get(gaugeIdx).addData(rec); - } else { // Q,D,- alle gehören hier rein! - if (gaugeIdx < this.qdTables.size()) - this.qdTables.get(gaugeIdx).addData(rec); + final String type = wi.getType(); + if (!type.contains("INVISIBLE")) { + if (type.equals("W")) { + if (gaugeIdx < this.wTables.size()) + this.wTables.get(gaugeIdx).addData(rec); + } else { // Q,D,- alle gehören hier rein! + if (gaugeIdx < this.qdTables.size()) + this.qdTables.get(gaugeIdx).addData(rec); + } + } + if ((type.equals("D") || type.equals("INVISIBLE_D")) && gauge != null) { + final String key = this.createKeyForWQValues(gauge.getName(), wi.getName()); + this.UDMap.put(key, wi.getValue()); } } }