Mercurial > dive4elements > river
changeset 8234:b6371be363b1
(issue1448) Carry sq_ti_date in artifact description anf fix sqtipanel
The sq ti panel no longer inherits from SQOffEpoch panel as it
is now to different for that to make sense. This commit also implements
createOld for the SQ Ti panel.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 08 Sep 2014 17:52:52 +0200 (2014-09-08) |
parents | e3fdca2c4850 |
children | c0da2514f4ce |
files | gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadOffEpochPanel.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadSQTiPanel.java gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SedimentLoadInfoRecord.java |
diffstat | 3 files changed, 93 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadOffEpochPanel.java Mon Sep 08 17:50:10 2014 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadOffEpochPanel.java Mon Sep 08 17:52:52 2014 +0200 @@ -191,10 +191,6 @@ SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl); sedLoadTable.addData(rec); } - if (sedLoad.length == 1) { - /* Preselect lists with only one load. */ - sedLoadTable.selectRecords(new int[] {0}); - } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadSQTiPanel.java Mon Sep 08 17:50:10 2014 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadSQTiPanel.java Mon Sep 08 17:52:52 2014 +0200 @@ -41,10 +41,71 @@ /** Show input to select an official epoch. */ public class SedLoadSQTiPanel -extends SedLoadOffEpochPanel +extends PeriodPanel { + protected SedimentLoadInfoServiceAsync sedLoadInfoService = + GWT.create(SedimentLoadInfoService.class); + + protected ListGrid sedLoadTable; + + /** Creates layout with title. */ + public Canvas createWidget(DataList data) { + VLayout root = new VLayout(); + + Label title = new Label(data.get(0).getDescription()); + title.setHeight("25px"); + + root.addMember(title); + + return root; + } + + /** Create layout for data entered previously. */ + @Override + public Canvas createOld(DataList dataList) { + 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, "sq_ti_date"); + DataItem[] strItems = str.getItems(); + + String dateString = strItems[0].getStringValue(); + Label dateLabel = new Label(dateString); + dateLabel.setHeight(20); + vLayout.addMember(dateLabel); + Canvas back = getBackButton(dataList.getState()); + layout.addMember(label); + layout.addMember(vLayout); + layout.addMember(back); + + GWT.log("Old data: " + strItems[0].getDescription() + " label " + strItems[0].getLabel() + " value: " + strItems[0].getStringValue()); + + return layout; + } + + public Canvas create(DataList data) { + VLayout layout = new VLayout(); + Canvas helper = createHelper(); + this.helperContainer.addMember(helper); + + Canvas submit = getNextButton(); + Canvas widget = createWidget(data); + + layout.addMember(widget); + layout.addMember(submit); + + fetchSedimentLoadData(); + + return layout; + } + /** Creates the helper grid in which off epochs can be selected. */ - @Override protected Canvas createHelper() { sedLoadTable = new ListGrid(); sedLoadTable.setShowHeaderContextMenu(false); @@ -57,7 +118,7 @@ sedLoadTable.setSelectionAppearance(SelectionAppearance.CHECKBOX); sedLoadTable.setSelectionType(SelectionStyle.SINGLE); - ListGridField date = new ListGridField("sq_date", MSG.year()); + ListGridField date = new ListGridField("sq_ti_date", MSG.year()); date.setType(ListGridFieldType.TEXT); date.setWidth(100); @@ -76,23 +137,30 @@ return new Data[0]; } String d = ""; + String desc = ""; for (int i = 0; i < lgr.length; i++) { /* Should only be one item as this is single selection */ Record r = (Record) lgr[i]; d = r.getAttribute("sq_ti_id"); - GWT.log("Got attribute sq_ti_id : " + d); + desc = r.getAttribute("sq_ti_date"); + GWT.log("Got attribute sq_ti_id : " + d + " desc: " + desc); } - DataItem item = new DefaultDataItem("sq_ti_id", "sq_ti_id", d); - data.add(new DefaultData( - "sq_ti_id", - null, - null, - new DataItem[] { item })); + DataItem item = new DefaultDataItem("sq_ti_id", "this is ignored", d); + DataItem dateLabel = new DefaultDataItem("sq_ti_date", "this is ignored", desc); + data.add(new DefaultData( + "sq_ti_id", + null, + null, + new DataItem[] { item })); + data.add(new DefaultData( + "sq_ti_date", + null, + null, + new DataItem[] { dateLabel })); return data.toArray(new Data[data.size()]); } /** Fetch load info from service and populate table. */ - @Override protected void fetchSedimentLoadData() { Config config = Config.getInstance(); String locale = config.getLocale (); @@ -123,5 +191,17 @@ } ); } + + /** Add record to input helper listgrid. */ + protected void addSedimentLoadInfo (SedimentLoadInfoObject[] sedLoad) { + for(SedimentLoadInfoObject sl: sedLoad) { + SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl); + sedLoadTable.addData(rec); + } + if (sedLoad.length == 1) { + /* Preselect lists with only one load. */ + sedLoadTable.selectRecords(new int[] {0}); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SedimentLoadInfoRecord.java Mon Sep 08 17:50:10 2014 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SedimentLoadInfoRecord.java Mon Sep 08 17:52:52 2014 +0200 @@ -33,7 +33,7 @@ } public void setSQTiDate(String date) { - setAttribute("sq_date", date); + setAttribute("sq_ti_date", date); } public void setSQTiId(String id) { @@ -53,6 +53,6 @@ } public String getSQTiDate() { - return getAttribute("sq_date"); + return getAttribute("sq_ti_date"); } }