Mercurial > dive4elements > river
diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractWQAdaptedInputPanel.java @ 9404:bc9a45d2b1fa
common time range for gauges incl. error messages
author | gernotbelger |
---|---|
date | Wed, 15 Aug 2018 13:59:09 +0200 |
parents | 6174daaf5e56 |
children | 43c975f8ab92 |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractWQAdaptedInputPanel.java Wed Aug 15 13:22:00 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractWQAdaptedInputPanel.java Wed Aug 15 13:59:09 2018 +0200 @@ -13,7 +13,6 @@ import java.util.List; import java.util.Map; -import org.dive4elements.river.client.client.Config; import org.dive4elements.river.client.client.FLYSConstants; import org.dive4elements.river.client.client.ui.wq.QDTable; import org.dive4elements.river.client.client.ui.wq.WTable; @@ -23,12 +22,12 @@ import org.dive4elements.river.client.shared.model.DataList; import org.dive4elements.river.client.shared.model.DefaultData; import org.dive4elements.river.client.shared.model.DefaultDataItem; +import org.dive4elements.river.client.shared.model.GaugeInfoObject; import org.dive4elements.river.client.shared.model.WQDataItem; import org.dive4elements.river.client.shared.model.WQInfoObject; import org.dive4elements.river.client.shared.model.WQInfoRecord; import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.Record; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; @@ -85,6 +84,11 @@ /** Tabs in inputhelper area. */ protected TabSet tabs; + private Canvas submit; + + private final List<String> gaugeNames = new ArrayList<String>(); + private final Map<String, Double[]> gaugeNamesRange = new HashMap<String, Double[]>(); + public AbstractWQAdaptedInputPanel() { this.wqranges = new HashMap<String, DoubleArrayPanel>(); this.qranges = new HashMap<String, double[]>(); @@ -92,6 +96,14 @@ this.qdTables = new ArrayList<QDTable>(); } + protected final Map<String, Double[]> getGaugeNamesRange() { + return this.gaugeNamesRange; + } + + protected final String[] getGaugeNames() { + return this.gaugeNames.toArray(new String[this.gaugeNames.size()]); + } + /** Inits the helper panel. */ // TODO duplicate in WQInputPanel protected void initHelperPanel() { @@ -113,7 +125,7 @@ readGaugeRanges(data); initHelperPanel(); - final Canvas submit = getNextButton(); + this.submit = getNextButton(); final Canvas widget = createWidget(data); final Label label = new Label(this.MSG.wqadaptedTitle()); @@ -125,7 +137,7 @@ layout.addMember(label); layout.addMember(widget); - layout.addMember(submit); + layout.addMember(this.submit); fetchWQData(); @@ -136,6 +148,10 @@ return layout; } + protected final Canvas getSubmitBtn() { + return this.submit; + } + protected abstract void createTabs(); protected abstract void beforeCreate(final DataList data); @@ -359,6 +375,9 @@ final String[] startEndKm = item.getLabel().split(";"); final Double[] kvp = new Double[] { Double.parseDouble(startEndKm[0]), Double.parseDouble(startEndKm[1]) }; this.gaugeRanges.add(kvp); + final String gaugeName = item.getStringValue(); + this.gaugeNames.add(gaugeName); + this.gaugeNamesRange.put(gaugeName, kvp); } } } @@ -433,64 +452,41 @@ } /** Get the WQD data from service and stuck them up that tables. */ - protected void fetchWQData() { - final Config config = Config.getInstance(); - final String locale = config.getLocale(); - - final ArtifactDescription adescr = this.artifact.getArtifactDescription(); - final DataList[] data = adescr.getOldData(); - - final String river = getRiverName(data); - - int i = 0; - - // Get Data for respective gauge. - for (final Double[] range : this.gaugeRanges) { - // Gauge ranges overlap, move start and end a bit closer - // to each other. - final double rDiff = (range[1] - range[0]) / 10d; - final int fi = i; + protected abstract void fetchWQData(); - final AsyncCallback<WQInfoObject[]> cb = new AsyncCallback<WQInfoObject[]>() { - @Override - public void onFailure(final Throwable caught) { - GWT.log("Could not recieve wq informations."); - SC.warn(caught.getMessage()); - } - - @Override - public void onSuccess(final WQInfoObject[] wqi) { - final int num = wqi != null ? wqi.length : 0; - GWT.log("Received " + num + " wq informations (" + fi + "."); + // protected abstract void callMainValuesService(String locale, String river, double start, double end, + // AsyncCallback<WQInfoObject[]> cb); - if (num == 0) { - return; - } + /** 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) { + // this.wTables.get(gaugeIdx).setLoadingDataMessage(""); (keine W-tables vorhanden - wo W-Table benutzt werden, gibt es + // ein Popup) + final String emptyMsg = gauge.getErrorMessage(); + final QDTable table = this.qdTables.get(gaugeIdx); + table.setEmptyMessage(emptyMsg == null ? "" : emptyMsg); + table.redraw(); + } else { + for (final WQInfoObject wi : wqi) { + final WQInfoRecord rec = new WQInfoRecord(wi); - addWQInfo(wqi, fi); + 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); } - }; - - callMainValuesService(locale, river, range[0] + rDiff, range[1] - rDiff, cb); - - i++; + } } + if (gauge != null) + AbstractWQAdaptedInputPanel.this.doubleArrayPanels.get(gaugeIdx).setError(gauge.getErrorMessage()); } - 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. */ - private void addWQInfo(final WQInfoObject[] wqi, final int gaugeIdx) { - 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); - } + public void resetLoadingMessageOfQTable(final String msg) { + for (final QDTable table : this.qdTables) { + table.setEmptyMessage(msg); + table.redraw(); } }