# HG changeset patch # User Ingo Weinzierl # Date 1304582943 0 # Node ID ccba1a0b743e95923a5cd317194f2a077b949159 # Parent 1e73d5a4859ca62bf96e9390a86707645379803c The WQAdaptedInputPanel displays input fields for each gauge and returns the correct w/q values now. flys-client/trunk@1831 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 1e73d5a4859c -r ccba1a0b743e flys-client/ChangeLog --- a/flys-client/ChangeLog Wed May 04 14:54:38 2011 +0000 +++ b/flys-client/ChangeLog Thu May 05 08:09:03 2011 +0000 @@ -1,3 +1,21 @@ +2011-05-05 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java: Added + new i18n displayed in the WQAdaptedInputPanel. + + * src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java: + The list of input fields for each intersected gauge is created now. The + correct w/q values will be returned after the submit button has been + clicked. + + * src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java: + The orientation of the field label might be adjusted using a new + constructor parameter. Furthermore, there is a new method (which has no + parameters) that returns the double values inserted in this panel. + 2011-05-04 Raimund Renkert * src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java, diff -r 1e73d5a4859c -r ccba1a0b743e flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed May 04 14:54:38 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu May 05 08:09:03 2011 +0000 @@ -88,6 +88,8 @@ String wqTitle(); + String wqadaptedTitle(); + String wqW(); String wqQ(); diff -r 1e73d5a4859c -r ccba1a0b743e flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed May 04 14:54:38 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu May 05 08:09:03 2011 +0000 @@ -39,6 +39,7 @@ riverside = Riverside wqTitle = Input for W/Q Data +wqadaptedTitle = Input for W/Q Data wqW = W at Gauge [cm] wqQ = Q [m³/s] wqSingle = Single values diff -r 1e73d5a4859c -r ccba1a0b743e flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed May 04 14:54:38 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu May 05 08:09:03 2011 +0000 @@ -39,6 +39,7 @@ riverside = Flussseite wqTitle = Eingabe für W/Q Daten +wqadaptedTitle = Eingabe für W/Q Daten wqW = W am Pegel [cm] wqQ = Q [m³/s] wqSingle = Einzelwerte diff -r 1e73d5a4859c -r ccba1a0b743e flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Wed May 04 14:54:38 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Thu May 05 08:09:03 2011 +0000 @@ -39,6 +39,7 @@ riverside = Riverside wqTitle = Input for W/Q Data +wqadaptedTitle = Input for W/Q Data wqW = W at Gauge [cm] wqQ = Q [m³/s] wqSingle = Single values diff -r 1e73d5a4859c -r ccba1a0b743e flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java Wed May 04 14:54:38 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java Thu May 05 08:09:03 2011 +0000 @@ -26,6 +26,15 @@ public static final String FIELD_NAME = "doublearray"; + public DoubleArrayPanel( + String title, + double[] values, + BlurHandler handler) + { + this(title, values, handler, TitleOrientation.RIGHT); + } + + /** * Creates a new form with a single input field that displays an array of * double values. @@ -38,7 +47,8 @@ public DoubleArrayPanel( String title, double[] values, - BlurHandler handler) + BlurHandler handler, + TitleOrientation titleOrientation) { ti = new TextItem(FIELD_NAME); StaticTextItem sti = new StaticTextItem("staticarray"); @@ -49,8 +59,14 @@ ti.addBlurHandler(handler); - setFields(ti, sti); - setTitleOrientation(TitleOrientation.RIGHT); + if (titleOrientation == TitleOrientation.RIGHT) { + setFields(ti, sti); + } + else { + setFields(sti, ti); + } + + setTitleOrientation(titleOrientation); setNumCols(2); if (values == null) { @@ -187,5 +203,15 @@ return values; } + + + /** + * Returns the double values of this panel. + * + * @return the double values of this panel. + */ + public double[] getInputValues() { + return getInputValues(ti); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 1e73d5a4859c -r ccba1a0b743e 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 Wed May 04 14:54:38 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java Thu May 05 08:09:03 2011 +0000 @@ -1,7 +1,13 @@ package de.intevation.flys.client.client.ui; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import com.google.gwt.core.client.GWT; +import com.smartgwt.client.types.TitleOrientation; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; @@ -16,6 +22,8 @@ import de.intevation.flys.client.shared.model.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; +import de.intevation.flys.client.client.FLYSConstants; + /** * This UIProvider creates a widget to enter W or Q data for discharge @@ -27,17 +35,34 @@ extends AbstractUIProvider implements ChangeHandler, BlurHandler { + public static final String FIELD_WQ_MODE = "wq_mode"; + + + /** The message class that provides i18n strings.*/ + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + + /** Stores the input panels related to their keys.*/ + protected Map wqranges; + + + public WQAdaptedInputPanel() { + wqranges = new HashMap(); } public Canvas create(DataList data) { - GWT.log("HELLO INGO"); Canvas submit = getNextButton(); + Canvas widget = createWidget(data); + Label label = new Label(MSG.wqadaptedTitle()); + + label.setHeight(25); VLayout layout = new VLayout(); layout.setMembersMargin(10); + layout.addMember(label); + layout.addMember(widget); layout.addMember(submit); return layout; @@ -50,19 +75,103 @@ } + protected Canvas createWidget(DataList dataList) { + VLayout layout = new VLayout(); + + List data = dataList.getAll(); + + for (Data d: data) { + String name = d.getLabel(); + + if (name.equals(FIELD_WQ_MODE)) { + continue; + } + + DataItem[] items = d.getItems(); + + for (DataItem item: items) { + String title = item.getLabel(); + + DoubleArrayPanel dap = new DoubleArrayPanel( + createLineTitle(title), null, this, TitleOrientation.LEFT); + + wqranges.put(title, dap); + + layout.addMember(dap); + } + } + + return layout; + } + + + public String createLineTitle(String key) { + String[] splitted = key.split(";"); + + return splitted[0] + " - " + splitted[1]; + } + + public Data[] getData() { - DataItem item = new DefaultDataItem("wq_mode", "wq_mode", "bla"); + Data mode = getWQMode(); + Data values = getWQValues(); + return new Data[] { mode, values }; + } + + + protected Data getWQMode() { + // TODO Search for the correct value! + DataItem item = new DefaultDataItem("wq_mode", "wq_mode", "q"); Data mode = new DefaultData( "wq_mode", null, null, new DataItem[] { item }); + return mode; + } + + + protected Data getWQValues() { + String wqvalue = null; + + Iterator iter = wqranges.keySet().iterator(); + while (iter.hasNext()) { + String key = iter.next(); + DoubleArrayPanel dap = wqranges.get(key); + + double[] values = dap.getInputValues(); + if (wqvalue == null) { + wqvalue = createValueString(key, values); + } + else { + wqvalue += ":" + createValueString(key, values); + } + } + DataItem valueItem = new DefaultDataItem( - "wq_values", "wq_values", - "0.0;70.2;9.6"); + "wq_values", "wq_values", wqvalue); Data values = new DefaultData( "wq_values", null, null, new DataItem[] { valueItem }); - return new Data[] { mode, values }; + return values; + } + + + protected String createValueString(String key, double[] values) { + StringBuilder sb = new StringBuilder(); + + boolean first = true; + + for (double value: values) { + if (!first) { + sb.append(","); + } + + sb.append(Double.toString(value)); + + first = false; + } + + return key + ";" + sb.toString(); } @@ -72,7 +181,8 @@ public void onBlur(BlurEvent event) { - // TODO IMPLEMENT ME + DoubleArrayPanel dap = (DoubleArrayPanel) event.getForm(); + dap.validateForm(event.getItem()); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :