Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
9453:9e471031cc1e | 9454:4cccbd32b680 |
---|---|
67 private static final String VALUE_SEPARATOR = ","; | 67 private static final String VALUE_SEPARATOR = ","; |
68 | 68 |
69 /** Stores the input panels related to their keys. */ | 69 /** Stores the input panels related to their keys. */ |
70 protected Map<String, DoubleArrayPanel> wqranges; | 70 protected Map<String, DoubleArrayPanel> wqranges; |
71 | 71 |
72 protected Map<String, Double> UDMap = new HashMap<String, Double>(); | |
73 | |
72 /** [startkm,endkm] per gauge in selected range. */ | 74 /** [startkm,endkm] per gauge in selected range. */ |
73 protected List<Double[]> gaugeRanges; | 75 protected List<Double[]> gaugeRanges; |
74 | 76 |
75 /** Stores the min/max values for each q range (gauge). */ | 77 /** Stores the min/max values for each q range (gauge). */ |
76 protected Map<String, double[]> qranges; | 78 protected Map<String, double[]> qranges; |
111 final VLayout layout = new VLayout(); | 113 final VLayout layout = new VLayout(); |
112 this.tabs = new TabSet(); | 114 this.tabs = new TabSet(); |
113 this.tabs.setWidth100(); | 115 this.tabs.setWidth100(); |
114 this.tabs.setHeight100(); | 116 this.tabs.setHeight100(); |
115 final String msg = this.getWQInfoMsg(); | 117 final String msg = this.getWQInfoMsg(); |
116 final Label test = PanelHelper.getValidationLabel(); | |
117 test.setText(msg); | |
118 test.getElement().getStyle().setColor("black"); | |
119 test.getElement().getStyle().setPadding(1, Unit.MM); | |
120 | 118 |
121 // For each gauge, add two tabs with helper tables. | 119 // For each gauge, add two tabs with helper tables. |
122 createTabs(); | 120 createTabs(); |
123 layout.addMember(this.tabs); | 121 layout.addMember(this.tabs); |
124 if (msg != null) | 122 |
125 layout.addMember(test); | 123 if (msg != null) { |
126 | 124 final Label additionalMsg = new Label(msg); // PanelHelper.getValidationLabel(); |
125 additionalMsg.setHeight("15px"); | |
126 additionalMsg.getElement().getStyle().setPadding(1, Unit.MM); | |
127 layout.addMember(additionalMsg); | |
128 } | |
127 this.helperContainer.addMember(layout); | 129 this.helperContainer.addMember(layout); |
128 // DOM.setStyleAttribute(test.getElement(), "color", "red"); | |
129 | |
130 } | 130 } |
131 | 131 |
132 /** Create labels, canvasses, layouts. */ | 132 /** Create labels, canvasses, layouts. */ |
133 @Override | 133 @Override |
134 public Canvas create(final DataList data) { | 134 public Canvas create(final DataList data) { |
408 } | 408 } |
409 } | 409 } |
410 return results; | 410 return results; |
411 } | 411 } |
412 | 412 |
413 private final String createKeyForWQValues(final String gaugeName, final String UD) { | |
414 final Double[] fromTo = this.gaugeNamesRange.get(gaugeName); | |
415 assert (fromTo.length == 2); | |
416 return new StringBuilder().append(fromTo[0]).append(GAUGE_PART_SEPARATOR).append(fromTo[1]).append(GAUGE_PART_SEPARATOR).append(gaugeName) | |
417 .append(GAUGE_PART_SEPARATOR).append(UD).toString(); | |
418 } | |
419 | |
413 protected final Data getWQValues(final String dataKey) { | 420 protected final Data getWQValues(final String dataKey) { |
414 String wqvalue = null; | 421 String wqvalue = null; |
415 | |
416 for (final Map.Entry<String, DoubleArrayPanel> entry : this.wqranges.entrySet()) { | 422 for (final Map.Entry<String, DoubleArrayPanel> entry : this.wqranges.entrySet()) { |
417 final String key = entry.getKey(); | 423 final String key = getKeyFromDap(entry); |
418 final DoubleArrayPanel dap = entry.getValue(); | 424 final double[] values = entry.getValue().getInputValues(); |
419 final String label = dap.getItemTitle(); | 425 wqvalue = appendValueStr(createValueString(key, values), wqvalue); |
420 | 426 } |
421 final double[] values = dap.getInputValues(); | 427 return getValueItem(dataKey, wqvalue); |
422 if (wqvalue == null) { | 428 } |
423 wqvalue = createValueString(key + ";" + label, values); | 429 |
424 } else { | 430 protected final Data getWQValuesForUD(final String dataKey, final String udValue) { |
425 wqvalue += GAUGE_SEPARATOR + createValueString(key + ";" + label, values); | 431 String wqvalue = null; |
426 } | 432 for (final Map.Entry<String, DoubleArrayPanel> entry : this.wqranges.entrySet()) { |
427 } | 433 final String keyBasic = getKeyFromDap(entry); |
428 | 434 final Double value = this.UDMap.get(keyBasic + GAUGE_PART_SEPARATOR + udValue); |
435 if (value != null) | |
436 wqvalue = appendValueStr(createValueString(keyBasic, new double[] { value }), wqvalue); | |
437 } | |
438 return getValueItem(dataKey, wqvalue); | |
439 } | |
440 | |
441 private Data getValueItem(final String dataKey, final String wqvalue) { | |
429 final DataItem valueItem = new DefaultDataItem(dataKey, dataKey, wqvalue); | 442 final DataItem valueItem = new DefaultDataItem(dataKey, dataKey, wqvalue); |
430 final Data values = new DefaultData(dataKey, null, null, new DataItem[] { valueItem }); | 443 final Data values = new DefaultData(dataKey, null, null, new DataItem[] { valueItem }); |
431 | 444 |
432 return values; | 445 return values; |
446 } | |
447 | |
448 private String appendValueStr(final String appendStr, String oldStr) { | |
449 if (oldStr == null) { | |
450 oldStr = appendStr; | |
451 } else { | |
452 oldStr += GAUGE_SEPARATOR + appendStr; | |
453 } | |
454 return oldStr; | |
455 } | |
456 | |
457 private String getKeyFromDap(final Map.Entry<String, DoubleArrayPanel> entry) { | |
458 final String keyRange = entry.getKey(); | |
459 final DoubleArrayPanel dap = entry.getValue(); | |
460 final String label = dap.getItemTitle(); | |
461 return new StringBuilder().append(keyRange).append(GAUGE_PART_SEPARATOR).append(label).toString(); | |
433 } | 462 } |
434 | 463 |
435 protected String createValueString(final String key, final double[] values) { | 464 protected String createValueString(final String key, final double[] values) { |
436 final StringBuilder sb = new StringBuilder(); | 465 final StringBuilder sb = new StringBuilder(); |
437 | 466 |
439 | 468 |
440 for (final double value : values) { | 469 for (final double value : values) { |
441 if (!first) { | 470 if (!first) { |
442 sb.append(","); | 471 sb.append(","); |
443 } | 472 } |
444 | |
445 sb.append(Double.toString(value)); | 473 sb.append(Double.toString(value)); |
446 | |
447 first = false; | 474 first = false; |
448 } | 475 } |
449 | 476 |
450 return key + ";" + sb.toString(); | 477 return key + ";" + sb.toString(); |
451 } | 478 } |
463 dap.validateForm(event.getItem()); | 490 dap.validateForm(event.getItem()); |
464 } | 491 } |
465 | 492 |
466 /** Get the WQD data from service and stuck them up that tables. */ | 493 /** Get the WQD data from service and stuck them up that tables. */ |
467 protected abstract void fetchWQData(); | 494 protected abstract void fetchWQData(); |
468 | |
469 // protected abstract void callMainValuesService(String locale, String river, double start, double end, | |
470 // AsyncCallback<WQInfoObject[]> cb); | |
471 | 495 |
472 /** Add Info to helper table for gauge at index gaugeIdx. */ | 496 /** Add Info to helper table for gauge at index gaugeIdx. */ |
473 public void addWQInfo(final WQInfoObject[] wqi, final int gaugeIdx, final GaugeInfoObject gauge) { | 497 public void addWQInfo(final WQInfoObject[] wqi, final int gaugeIdx, final GaugeInfoObject gauge) { |
474 if (wqi == null) { | 498 if (wqi == null) { |
475 // this.wTables.get(gaugeIdx).setLoadingDataMessage(""); (keine W-tables vorhanden - wo W-Table benutzt werden, gibt es | 499 // this.wTables.get(gaugeIdx).setLoadingDataMessage(""); (keine W-tables vorhanden - wo W-Table benutzt werden, gibt es |
479 table.setEmptyMessage(emptyMsg == null ? "" : emptyMsg); | 503 table.setEmptyMessage(emptyMsg == null ? "" : emptyMsg); |
480 table.redraw(); | 504 table.redraw(); |
481 } else { | 505 } else { |
482 for (final WQInfoObject wi : wqi) { | 506 for (final WQInfoObject wi : wqi) { |
483 final WQInfoRecord rec = new WQInfoRecord(wi); | 507 final WQInfoRecord rec = new WQInfoRecord(wi); |
484 | 508 final String type = wi.getType(); |
485 if (wi.getType().equals("W")) { | 509 if (!type.contains("INVISIBLE")) { |
486 if (gaugeIdx < this.wTables.size()) | 510 if (type.equals("W")) { |
487 this.wTables.get(gaugeIdx).addData(rec); | 511 if (gaugeIdx < this.wTables.size()) |
488 } else { // Q,D,- alle gehören hier rein! | 512 this.wTables.get(gaugeIdx).addData(rec); |
489 if (gaugeIdx < this.qdTables.size()) | 513 } else { // Q,D,- alle gehören hier rein! |
490 this.qdTables.get(gaugeIdx).addData(rec); | 514 if (gaugeIdx < this.qdTables.size()) |
515 this.qdTables.get(gaugeIdx).addData(rec); | |
516 } | |
517 } | |
518 if ((type.equals("D") || type.equals("INVISIBLE_D")) && gauge != null) { | |
519 final String key = this.createKeyForWQValues(gauge.getName(), wi.getName()); | |
520 this.UDMap.put(key, wi.getValue()); | |
491 } | 521 } |
492 } | 522 } |
493 } | 523 } |
494 if (gauge != null) | 524 if (gauge != null) |
495 AbstractWQAdaptedInputPanel.this.doubleArrayPanels.get(gaugeIdx).setError(gauge.getErrorMsg()); | 525 AbstractWQAdaptedInputPanel.this.doubleArrayPanels.get(gaugeIdx).setError(gauge.getErrorMsg()); |