# HG changeset patch # User Ingo Weinzierl # Date 1304587995 0 # Node ID 4a684d29404ffeb78fbe79ba56a71fe375052332 # Parent ccba1a0b743e95923a5cd317194f2a077b949159 Implemented the createOld() of WQAdaptedInputPanel. flys-client/trunk@1832 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r ccba1a0b743e -r 4a684d29404f flys-client/ChangeLog --- a/flys-client/ChangeLog Thu May 05 08:09:03 2011 +0000 +++ b/flys-client/ChangeLog Thu May 05 09:33:15 2011 +0000 @@ -1,3 +1,14 @@ +2011-05-05 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java, + src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java: + Moved functions getData() and getDataItem() from WQInputPanel to + AbstractUIProvider to make it accessible in all UIProvider that inherit + from AbstractUIProvider. + + * src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java: + Implemented the methods to create the old widget of thi panel. + 2011-05-05 Ingo Weinzierl * src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, diff -r ccba1a0b743e -r 4a684d29404f flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java Thu May 05 08:09:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java Thu May 05 09:33:15 2011 +0000 @@ -19,6 +19,7 @@ import de.intevation.flys.client.client.event.StepForwardEvent; import de.intevation.flys.client.client.event.StepForwardHandler; import de.intevation.flys.client.shared.model.Data; +import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.Artifact; @@ -177,6 +178,45 @@ /** + * This method greps the Data with name name from the list and + * returns it. + * + * @param items A list of Data. + * @param name The name of the Data that we are searching for. + * + * @return the Data with the name name. + */ + protected Data getData(List data, String name) { + for (Data d: data) { + if (name.equals(d.getLabel())) { + return d; + } + } + + return null; + } + + /** + * This method greps the DataItem with name name from the list and + * returns it. + * + * @param items A list of DataItems. + * @param name The name of the DataItem that we are searching for. + * + * @return the DataItem with the name name. + */ + protected DataItem getDataItem(DataItem[] items, String name) { + for (DataItem item: items) { + if (name.equals(item.getLabel())) { + return item; + } + } + + return null; + } + + + /** * This method needs to be implemented by concrete subclasses. It should * create a new Canvas object with a representation of data. * diff -r ccba1a0b743e -r 4a684d29404f 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 Thu May 05 08:09:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java Thu May 05 09:33:15 2011 +0000 @@ -8,12 +8,14 @@ import com.google.gwt.core.client.GWT; import com.smartgwt.client.types.TitleOrientation; +import com.smartgwt.client.types.VerticalAlignment; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; +import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.shared.model.Data; @@ -37,6 +39,12 @@ { public static final String FIELD_WQ_MODE = "wq_mode"; + public static final String GAUGE_SEPARATOR = ":"; + + public static final String GAUGE_PART_SEPARATOR = ";"; + + public static final String VALUE_SEPARATOR = ","; + /** The message class that provides i18n strings.*/ protected FLYSConstants MSG = GWT.create(FLYSConstants.class); @@ -70,8 +78,79 @@ public Canvas createOld(DataList dataList) { - // TODO IMPLEMENT ME - return new Label("Ich hab schon was eingegeben."); + List all = dataList.getAll(); + Data wqData = getData(all, "wq_values"); + Data wqMode = getData(all, "wq_mode"); + + Canvas back = getBackButton(dataList.getState()); + + HLayout valLayout = new HLayout(); + HLayout modeLayout = new HLayout(); + VLayout vlayout = new VLayout(); + + Label wqLabel = new Label(dataList.getLabel()); + Label modeLabel = new Label(""); + + wqLabel.setValign(VerticalAlignment.TOP); + + wqLabel.setWidth(200); + wqLabel.setHeight(25); + modeLabel.setHeight(25); + modeLabel.setWidth(200); + + valLayout.addMember(wqLabel); + valLayout.addMember(createOldWQValues(wqData)); + valLayout.addMember(back); + modeLayout.addMember(modeLabel); + + vlayout.addMember(valLayout); + vlayout.addMember(modeLayout); + + return vlayout; + } + + + protected Canvas createOldWQValues(Data wqData) { + VLayout layout = new VLayout(); + + DataItem item = wqData.getItems()[0]; + String value = item.getStringValue(); + + String[] gauges = value.split(GAUGE_SEPARATOR); + + for (String gauge: gauges) { + HLayout h = new HLayout(); + + String[] parts = gauge.split(GAUGE_PART_SEPARATOR); + String[] values = parts[2].split(VALUE_SEPARATOR); + + Label l = new Label(parts[0] + " - " + parts[1] + ": "); + + StringBuilder sb = new StringBuilder(); + boolean first = true; + + for (String v: values) { + if (!first) { + sb.append(", "); + } + + sb.append(v); + + first = false; + } + + Label v = new Label(sb.toString()); + + l.setWidth(65); + v.setWidth(65); + + h.addMember(l); + h.addMember(v); + + layout.addMember(h); + } + + return layout; } @@ -143,7 +222,7 @@ wqvalue = createValueString(key, values); } else { - wqvalue += ":" + createValueString(key, values); + wqvalue += GAUGE_SEPARATOR + createValueString(key, values); } } diff -r ccba1a0b743e -r 4a684d29404f flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java Thu May 05 08:09:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java Thu May 05 09:33:15 2011 +0000 @@ -268,45 +268,6 @@ /** - * This method greps the Data with name name from the list and - * returns it. - * - * @param items A list of Data. - * @param name The name of the Data that we are searching for. - * - * @return the Data with the name name. - */ - protected Data getData(List data, String name) { - for (Data d: data) { - if (name.equals(d.getLabel())) { - return d; - } - } - - return null; - } - - /** - * This method greps the DataItem with name name from the list and - * returns it. - * - * @param items A list of DataItems. - * @param name The name of the DataItem that we are searching for. - * - * @return the DataItem with the name name. - */ - protected DataItem getDataItem(DataItem[] items, String name) { - for (DataItem item: items) { - if (name.equals(item.getLabel())) { - return item; - } - } - - return null; - } - - - /** * This method creates the whole widget. There is a panel on the left, that * allows the user to enter values manually by keyboard. On the right, there * is a table that allows the user to enter values by mouse click.