Mercurial > dive4elements > river
changeset 2898:242b5c230707
Added UI for S-Q-relation parameters in minfo module.
flys-client/trunk@4636 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 11 Jun 2012 12:33:22 +0000 (2012-06-11) |
parents | 133820d1e6bf |
children | 93302bd16f42 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleInputPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/MultiPeriodPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/PeriodPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java |
diffstat | 10 files changed, 635 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Thu Jun 07 16:13:55 2012 +0000 +++ b/flys-client/ChangeLog Mon Jun 11 12:33:22 2012 +0000 @@ -1,3 +1,24 @@ +2012-06-11 Raimund Renkert <raimund.renkert@intevation.de> + + Added UI for S-Q-relation parameters. + + * src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java: + Use different filter strings for annotations. + + * src/main/java/de/intevation/flys/client/client/ui/PeriodPanel.java, + src/main/java/de/intevation/flys/client/client/ui/DoubleInputPanel.java, + src/main/java/de/intevation/flys/client/client/ui/MultiPeriodPanel.java: + New. UIProvider for S-Q-relation parameters. + + * src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java: + Added new states for S-Q-relation. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants.java, + 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: + Added i18n strings. + 2012-06-07 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Jun 07 16:13:55 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Jun 11 12:33:22 2012 +0000 @@ -900,5 +900,9 @@ String selection(); String fix_deltawt_export(); + + String select(); + + String add_date(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Jun 07 16:13:55 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Jun 11 12:33:22 2012 +0000 @@ -468,3 +468,5 @@ reference_endpoint = Point(s) of projection fix_deltawt_export = \u0394 W/t +select=Selected +add_date=Add
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Jun 07 16:13:55 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Jun 11 12:33:22 2012 +0000 @@ -468,3 +468,5 @@ reference_endpoint = Zielort/pegel fix_deltawt_export = \u0394 W/t +select=Ausgewählt +add_date=Hinzuf\u00fcgen
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Thu Jun 07 16:13:55 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Jun 11 12:33:22 2012 +0000 @@ -470,3 +470,5 @@ reference_endpoint = Point(s) of projection fix_deltawt_export = \u0394 W/t +select=Selected +add_date=Add
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleInputPanel.java Mon Jun 11 12:33:22 2012 +0000 @@ -0,0 +1,157 @@ +package de.intevation.flys.client.client.ui; + +import java.util.List; +import java.util.ArrayList; +import java.util.Date; +import java.lang.NumberFormatException; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.NumberFormat; + +import com.smartgwt.client.util.SC; + +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; + +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.TextItem; + +import de.intevation.flys.client.client.FLYSConstants; + +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.DefaultData; +import de.intevation.flys.client.shared.model.DefaultDataItem; +import de.intevation.flys.client.shared.model.FixingsOverviewInfo.FixEvent; + +/** + * This UIProvider creates a panel for location or distance input. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class DoubleInputPanel +extends AbstractUIProvider +{ + /** The message class that provides i18n strings. */ + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + + private TextItem inputPanel; + + private double value; + + public DoubleInputPanel() { + } + + + public Canvas create(DataList list) { + VLayout layout = new VLayout(); + + Canvas helper = createHelper(); + this.helperContainer.addMember(helper); + + Canvas submit = getNextButton(); + Canvas widget = createWidget(list); + + layout.addMember(widget); + layout.addMember(submit); + return layout; + } + + + public Canvas createWidget(DataList data) { + VLayout layout = new VLayout(); + + Label title = new Label(data.get(0).getDescription()); + title.setHeight("25px"); + + DynamicForm form = new DynamicForm(); + inputPanel = new TextItem(); + inputPanel.setTitle("outliers"); + inputPanel.setShowTitle(false); + form.setFields(inputPanel); + + layout.addMember(title); + layout.addMember(form); + + return layout; + } + + protected Canvas createHelper() { + return new VLayout(); + } + + @Override + public Canvas createOld(DataList dataList) { + List<Data> items = dataList.getAll(); + + Data d = getData(items, "outliers"); + DataItem[] item = d.getItems(); + + String v = item[0].getLabel(); + + Label old = new Label(v); + old.setWidth(130); + + HLayout layout = new HLayout(); + layout.setWidth("400px"); + + Label label = new Label(dataList.getLabel()); + label.setWidth("200px"); + + Canvas back = getBackButton(dataList.getState()); + + layout.addMember(label); + layout.addMember(old); + layout.addMember(back); + + return layout; + } + + + /** + * This method returns the selected data. + * + * @return the selected/inserted data. + */ + public Data[] getData() { + List<Data> data = new ArrayList<Data>(); + + boolean valid = saveDataValues(); + if(valid) { + + String vs = Double.valueOf(this.value).toString(); + DataItem item = new DefaultDataItem("outliers", "outliers", vs); + data.add(new DefaultData( + "outliers", + null, + null, + new DataItem[] { item })); + } + + return (Data[]) data.toArray(new Data[data.size()]); + } + + + protected boolean saveDataValues() { + String st = inputPanel.getValueAsString(); + if (st == null) { + SC.warn("fehler... TODO"); + return false; + } + + try { + NumberFormat nf = NumberFormat.getDecimalFormat(); + double d = nf.parse(st); + this.value = d; + } + catch(NumberFormatException nfe) { + SC.warn("fehler... nfe... TODO"); + return false; + } + return true; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultiPeriodPanel.java Mon Jun 11 12:33:22 2012 +0000 @@ -0,0 +1,238 @@ +package de.intevation.flys.client.client.ui; + +import java.util.List; +import java.util.ArrayList; +import java.util.Date; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.DateTimeFormat; + +import com.smartgwt.client.data.Record; + +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.Button; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler; + +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +import com.smartgwt.client.types.ListGridFieldType; + +import com.smartgwt.client.widgets.grid.events.RecordClickEvent; +import com.smartgwt.client.widgets.grid.events.RecordClickHandler; + +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.DefaultData; +import de.intevation.flys.client.shared.model.DefaultDataItem; + +/** + * This UIProvider creates a panel for location or distance input. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class MultiPeriodPanel +extends PeriodPanel +{ + + protected ListGrid elements; + + protected String values; + + public MultiPeriodPanel() { + this("", ""); + } + + public MultiPeriodPanel(String startName, String endName) { + super(startName, endName); + } + + public Canvas createWidget(DataList data) { + HLayout input = new HLayout(); + VLayout root = new VLayout(); + VLayout grid = new VLayout(); + VLayout layout = (VLayout) super.createWidget(data); + Button add = new Button(MSG.add_date()); + elements = new ListGrid(); + + add.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent ce) { + Date f = inputPanel.getFromDate(); + Date t = inputPanel.getToDate(); + if (f == null || t == null) { + return; + } + DateRangeRecord drr = new DateRangeRecord(f, t); + elements.addData(drr); + } + }); + layout.addMember(add); + + Label sel = new Label(MSG.select()); + sel.setHeight(25); + elements.setWidth(185); + elements.setHeight(120); + elements.setShowHeaderContextMenu(false); + elements.setCanReorderFields(false); + elements.setCanSort(false); + elements.setCanEdit(false); + ListGridField from = new ListGridField("from", MSG.from()); + ListGridField to = new ListGridField("to", MSG.to()); + from.setWidth(70); + to.setWidth(70); + + final ListGridField removeField = + new ListGridField("_removeRecord", "Remove Record"){{ + setType(ListGridFieldType.ICON); + setIcon(GWT.getHostPageBaseURL() + MSG.removeFeature()); + setCanEdit(false); + setCanFilter(false); + setCanSort(false); + setCanGroupBy(false); + setCanFreeze(false); + setWidth(25); + }}; + + elements.addRecordClickHandler(new RecordClickHandler() { + public void onRecordClick(final RecordClickEvent event) { + // Just handle remove-clicks + if(!event.getField().getName().equals(removeField.getName())) { + return; + } + event.getViewer().removeData(event.getRecord()); + } + }); + + elements.setFields(from, to, removeField); + + grid.addMember(sel); + grid.addMember(elements); + input.addMember(layout); + input.addMember(grid); + root.addMember(input); + + return root; + } + + @Override + public Canvas createOld(DataList dataList) { + GWT.log("old............................"); + HLayout layout = new HLayout(); + layout.setWidth("400px"); + VLayout vLayout = new VLayout(); + vLayout.setWidth(130); + Label label = new Label(dataList.getLabel()); + label.setWidth("200px"); + label.setHeight(25); + + List<Data> items = dataList.getAll(); + Data str = getData(items, "periods"); + DataItem[] strItems = str.getItems(); + + String[] pairs = strItems[0].getLabel().split(";"); + for (int i = 0; i < pairs.length; i++) { + String[] vals = pairs[i].split(","); + long f = Long.valueOf(vals[0]).longValue(); + long t = Long.valueOf(vals[1]).longValue(); + Date from = new Date(f); + Date to = new Date(t); + String fromString = + DateTimeFormat.getMediumDateFormat().format(from); + String toString = + DateTimeFormat.getMediumDateFormat().format(to); + + Label dateLabel = new Label(fromString + " - " + toString); + dateLabel.setHeight(20); + vLayout.addMember(dateLabel); + } + Canvas back = getBackButton(dataList.getState()); + layout.addMember(label); + layout.addMember(vLayout); + layout.addMember(back); + + return layout; + } + + + /** + * This method returns the selected data. + * + * @return the selected/inserted data. + */ + public Data[] getData() { + List<Data> data = new ArrayList<Data>(); + + boolean valid = saveDateValues(); + if(valid) { + DataItem item = new DefaultDataItem("periods", null, this.values); + data.add(new DefaultData( + "periods", + null, + null, + new DataItem[] { item })); + } + return (Data[]) data.toArray(new Data[data.size()]); + } + + + protected boolean saveDateValues() { + ListGridRecord[] lgr = elements.getRecords(); + if (lgr.length == 0) { + return false; + } + String data = ""; + for (int i = 0; i < lgr.length; i++) { + DateRangeRecord drr = (DateRangeRecord) lgr[i]; + data += drr.getFrom() + "," + drr.getTo(); + data += ";"; + } + values = data; + return true; + } + + + protected static class DateRangeRecord extends ListGridRecord { + protected Date from; + protected Date to; + + protected final static String FROM_FIELD = "from"; + protected final static String TO_FIELD = "to"; + + public DateRangeRecord (Date from, Date to) { + setFrom(from); + setTo(to); + } + + public void setFrom(Date from) { + this.from = from; + setAttribute( + FROM_FIELD, + DateTimeFormat.getMediumDateFormat().format(from)); + } + + + public void setTo(Date to) { + this.to = to; + setAttribute( + TO_FIELD, + DateTimeFormat.getMediumDateFormat().format(to)); + } + + + public long getFrom() { + return this.from.getTime(); + } + + + public long getTo() { + return this.to.getTime(); + } + } +}
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java Thu Jun 07 16:13:55 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java Mon Jun 11 12:33:22 2012 +0000 @@ -271,11 +271,16 @@ // Try to find a "river" data item to set the source for the // list grid. + String dataFilter = "locations"; if (data != null && data.length > 0) { for (int i = 0; i < data.length; i++) { DataList dl = data[i]; + if (dl.getState().equals("state.minfo.river")) { + dataFilter = "measuringpoint"; + } if (dl.getState().equals("state.winfo.river") || - dl.getState().equals("state.chart.river")) { + dl.getState().equals("state.chart.river") || + dl.getState().equals("state.minfo.river")) { for (int j = 0; j < dl.size(); j++) { Data d = dl.get(j); DataItem[] di = d.getItems(); @@ -289,7 +294,7 @@ } picker.getLocationTable().setDataSource(new DistanceInfoDataSource( - url, river, "locations")); + url, river, dataFilter)); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/PeriodPanel.java Mon Jun 11 12:33:22 2012 +0000 @@ -0,0 +1,196 @@ +package de.intevation.flys.client.client.ui; + +import java.util.List; +import java.util.ArrayList; +import java.util.Date; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.DateTimeFormat; +import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; + +import com.smartgwt.client.util.SC; + +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; + +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.DateRangeItem; + +import de.intevation.flys.client.client.FLYSConstants; + +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.DefaultData; +import de.intevation.flys.client.shared.model.DefaultDataItem; +import de.intevation.flys.client.shared.model.FixingsOverviewInfo.FixEvent; + +/** + * This UIProvider creates a panel for location or distance input. + * + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class PeriodPanel +extends AbstractUIProvider +{ + /** The message class that provides i18n strings. */ + protected FLYSConstants MSG = GWT.create(FLYSConstants.class); + + DateRangeItem inputPanel; + + long start; + long end; + + protected String startName; + protected String endName; + + public PeriodPanel() { + this("start", "end"); + } + + public PeriodPanel(String startName, String endName) { + this.startName = startName; + this.endName = endName; + } + + + public Canvas create(DataList list) { + VLayout layout = new VLayout(); + + Canvas helper = createHelper(); + this.helperContainer.addMember(helper); + + Canvas submit = getNextButton(); + Canvas widget = createWidget(list); + + layout.addMember(widget); + layout.addMember(submit); + return layout; + } + + + public Canvas createWidget(DataList data) { + VLayout layout = new VLayout(); + + Label title = new Label(data.get(0).getDescription()); + title.setHeight("25px"); + + DynamicForm form = new DynamicForm(); + inputPanel = new DateRangeItem(); + inputPanel.setToTitle(MSG.to()); + inputPanel.setFromTitle(MSG.from()); + inputPanel.setShowTitle(false); + form.setFields(inputPanel); + + layout.addMember(title); + layout.addMember(form); + + return layout; + } + + protected Canvas createHelper() { + return new VLayout(); + } + + @Override + public Canvas createOld(DataList dataList) { + List<Data> items = dataList.getAll(); + + Data start = getData(items, startName); + Data end = getData(items, endName); + DataItem[] startItem = start.getItems(); + DataItem[] endItem = end.getItems(); + + String v1 = startItem[0].getStringValue(); + String v2 = endItem[0].getStringValue(); + + long v1l = 0; + long v2l = 0; + try { + v1l = Long.parseLong(v1); + v2l = Long.parseLong(v2); + } + catch(NumberFormatException nfe) { + GWT.log(nfe.toString()); + } + Date d1 = new Date(v1l); + Date d2 = new Date(v2l); + + DateTimeFormat f = + DateTimeFormat.getFormat( + DateTimeFormat.PredefinedFormat.DATE_MEDIUM); + StringBuilder sb = new StringBuilder(); + sb.append(f.format(d1) + " - "); + sb.append(f.format(d2)); + + Label old = new Label(sb.toString()); + old.setWidth(130); + + HLayout layout = new HLayout(); + layout.setWidth("400px"); + + Label label = new Label(dataList.getLabel()); + label.setWidth("200px"); + + Canvas back = getBackButton(dataList.getState()); + + layout.addMember(label); + layout.addMember(old); + layout.addMember(back); + + return layout; + } + + + /** + * This method returns the selected data. + * + * @return the selected/inserted data. + */ + public Data[] getData() { + List<Data> data = new ArrayList<Data>(); + + boolean valid = saveDateValues(); + if(valid) { + String start = Long.valueOf(this.start).toString(); + String end = Long.valueOf(this.end).toString(); + DataItem startItem = new DefaultDataItem(startName, startName, start); + DataItem endItem = new DefaultDataItem(endName, endName, end); + data.add(new DefaultData( + startName, + null, + null, + new DataItem[] { startItem })); + data.add(new DefaultData( + endName, + null, + null, + new DataItem[] { endItem })); + } + + return (Data[]) data.toArray(new Data[data.size()]); + } + + + protected boolean saveDateValues() { + Date st = inputPanel.getFromDate(); + Date en = inputPanel.getToDate(); + if (st == null || en == null) { + SC.warn(MSG.error_wrong_date()); + return false; + } + + long start = st.getTime(); + long end = en.getTime(); + + if (start <= end) { + this.start = start; + this.end = end; + return true; + } + return false; + } +}
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Thu Jun 07 16:13:55 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Mon Jun 11 12:33:22 2012 +0000 @@ -107,6 +107,12 @@ else if (uiProvider.equals("fix.preprocessing_panel")) { return new BooleanPanel(); } + else if (uiProvider.equals("periods_select")) { + return new MultiPeriodPanel(); + } + else if (uiProvider.equals("outliers_input")) { + return new DoubleInputPanel(); + } else if (uiProvider.equals("parameter-matrix")) { return new ParameterMatrixPanel(); }