Mercurial > dive4elements > river
changeset 1602:f30919997e57
Added helper input table to state 'timerange' input in hist. discharge curves.
flys-client/trunk@3940 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 06 Feb 2012 16:11:10 +0000 (2012-02-06) |
parents | 42543705a857 |
children | dd612a1348d2 |
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/GaugeTimeRangePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java flys-client/src/main/java/de/intevation/flys/client/client/ui/range/DischargeInfoDataSource.java |
diffstat | 8 files changed, 251 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Mon Feb 06 16:02:53 2012 +0000 +++ b/flys-client/ChangeLog Mon Feb 06 16:11:10 2012 +0000 @@ -1,3 +1,21 @@ +2012-02-06 Raimund Renkert <raimund.renkert@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java: + New. Shows the integer input fields and a helper table containing discharge + informations. + + * src/main/java/de/intevation/flys/client/client/ui/range/DischargeInfoDataSource.java: + New. Data source container for discharge infos. + + * src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java: + Create a GaugeTimeRangePanel. + + * 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 for table header. + 2012-02-06 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Feb 06 16:02:53 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Feb 06 16:11:10 2012 +0000 @@ -314,6 +314,9 @@ String resultCount(); + String start_year(); + + String end_year(); // Elevation window String ele_window_title();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Feb 06 16:02:53 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Feb 06 16:11:10 2012 +0000 @@ -77,6 +77,8 @@ calculationCanceled = The calculation has been canceled. range = Range resultCount = Hits +start_year = Start +end_year = End # Header images flysLogo = images/flys_logo.gif
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Feb 06 16:02:53 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Feb 06 16:11:10 2012 +0000 @@ -77,6 +77,9 @@ calculationCanceled = Die Berechnung wurde abgebrochen. range = Bereich resultCount = Treffer +start_year = Start +end_year = Ende + # Header images flysLogo = images/flys_logo.gif bfgLogo = images/bfg_logo.gif
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Feb 06 16:02:53 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Feb 06 16:11:10 2012 +0000 @@ -77,6 +77,8 @@ calculationCanceled = The calculation has been canceled. range = Range resultCount = Hits +start_year = Start +end_year = end # Header images flysLogo = images/flys_logo.gif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java Mon Feb 06 16:11:10 2012 +0000 @@ -0,0 +1,177 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.types.ListGridFieldType; + +import com.smartgwt.client.data.Record; + +import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.ListGridRecord; +import com.smartgwt.client.widgets.grid.events.RecordClickHandler; +import com.smartgwt.client.widgets.grid.events.RecordClickEvent; + +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.Config; + +import de.intevation.flys.client.shared.model.DataList; +import de.intevation.flys.client.shared.model.DataItem; +import de.intevation.flys.client.shared.model.ArtifactDescription; +import de.intevation.flys.client.shared.model.Data; + +import de.intevation.flys.client.client.ui.range.DischargeInfoDataSource; + +/** + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class GaugeTimeRangePanel extends IntegerRangePanel { + + /** The message class that provides i18n strings. */ + protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); + + protected ListGrid yearTable; + + public GaugeTimeRangePanel() { + GWT.log("Creating YearInputPanel"); + yearTable = new ListGrid(); + yearTable.setAutoFetchData(true); + yearTable.setShowHeaderContextMenu(false); + + } + + public Canvas create(DataList data) { + setDataName(data); + + VLayout root = new VLayout(); + + root.addMember(createLabel(data)); + root.addMember(createForm(data)); + root.addMember(getNextButton()); + + initDefaults(data); + + + initYearTable(); + + long gauge = getGaugeNumber(); + + Config config = Config.getInstance(); + String url = config.getServerUrl(); + yearTable.setDataSource(new DischargeInfoDataSource(url, gauge)); + + helperContainer.addMember(yearTable); + return root; + } + + + protected ListGrid initYearTable() { + String baseUrl = GWT.getHostPageBaseURL(); + + yearTable.setWidth100(); + yearTable.setHeight100(); + yearTable.setShowRecordComponents(true); + yearTable.setShowRecordComponentsByCell(true); + yearTable.setEmptyMessage(MESSAGES.empty_filter()); + yearTable.setCanReorderFields(false); + + CellFormatter cf = new CellFormatter() { + public String format( + Object value, + ListGridRecord record, + int rowNum, int colNum) { + if (value == null) return null; + if (value.toString().equals("-1")) { + return ""; + } + return value.toString(); + } + }; + + + ListGridField addstart = new ListGridField ("", ""); + addstart.setType (ListGridFieldType.ICON); + addstart.setWidth (20); + addstart.setCellIcon(baseUrl + MESSAGES.markerGreen()); + addstart.addRecordClickHandler(new RecordClickHandler() { + public void onRecordClick(RecordClickEvent e) { + Record r = e.getRecord(); + if (r.getAttribute("start").equals("-1")) { + return; + } + else { + setLower(r.getAttribute("start")); + } + } + }); + + ListGridField addend = new ListGridField ("", ""); + addend.setType (ListGridFieldType.ICON); + addend.setWidth (20); + addend.setCellIcon(baseUrl + MESSAGES.markerRed()); + addend.addRecordClickHandler(new RecordClickHandler() { + public void onRecordClick(RecordClickEvent e) { + Record r = e.getRecord(); + if (r.getAttribute("end").equals("-1")) { + return; + } + else { + setUpper(r.getAttribute("end")); + } + } + }); + + ListGridField desc = + new ListGridField("description", MESSAGES.description()); + desc.setType(ListGridFieldType.TEXT); + desc.setWidth("*"); + + ListGridField start = + new ListGridField("start", MESSAGES.start_year()); + start.setType(ListGridFieldType.INTEGER); + start.setWidth(50); + start.setCellFormatter(cf); + + ListGridField end = + new ListGridField("end", MESSAGES.end_year()); + end.setType(ListGridFieldType.INTEGER); + end.setWidth(50); + end.setCellFormatter(cf); + + yearTable.setFields(addstart, addend, desc, start, end); + + return yearTable; + } + + + protected long getGaugeNumber() { + ArtifactDescription adescr = artifact.getArtifactDescription(); + DataList[] data = adescr.getOldData(); + + String gauge = ""; + if (data != null && data.length > 0) { + for (int i = 0; i < data.length; i++) { + DataList dl = data[i]; + if (dl.getState().equals("state.winfo.historicalq.reference_gauge")) { + for (int j = 0; j < dl.size(); j++) { + Data d = dl.get(j); + DataItem[] di = d.getItems(); + if (di != null && di.length == 1) { + gauge = d.getItems()[0].getStringValue(); + } + } + } + } + } + try { + return Long.parseLong(gauge); + } + catch (NumberFormatException nfe) { + GWT.log("Error parsing gauge."); + return 0; + } + } +}
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Mon Feb 06 16:02:53 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Mon Feb 06 16:11:10 2012 +0000 @@ -68,6 +68,9 @@ else if (uiProvider.equals("wq_simple_array")) { return new WQSimpleArrayPanel(); } + else if (uiProvider.equals("gaugetimerange")) { + return new GaugeTimeRangePanel(); + } else { return new SelectProvider(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/range/DischargeInfoDataSource.java Mon Feb 06 16:11:10 2012 +0000 @@ -0,0 +1,43 @@ +package de.intevation.flys.client.client.ui.range; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.data.DataSource; +import com.smartgwt.client.data.DataSourceField; +import com.smartgwt.client.types.DSDataFormat; +import com.smartgwt.client.types.FieldType; + + +public class DischargeInfoDataSource extends DataSource { + + public static final String XPATH_DISCHARGE_DEFAULT = "/discharges/discharge"; + + + public DischargeInfoDataSource(String url, long gauge) { + setDataFormat(DSDataFormat.XML); + setRecordXPath(XPATH_DISCHARGE_DEFAULT); + + DataSourceField desc = new DataSourceField( + "description", FieldType.TEXT, "description"); + + DataSourceField start = new DataSourceField( + "start", FieldType.INTEGER, "start"); + + DataSourceField end = new DataSourceField( + "end", FieldType.INTEGER, "end"); + + setFields(desc, start, end); + setDataURL(getServiceURL(url, gauge)); + } + + + protected String getServiceURL(String server, long gauge) { + String url = GWT.getModuleBaseURL(); + url += "dischargeinfoxml"; + url += "?server=" + server; + url += "&gauge=" + String.valueOf(gauge); + + return url; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :