# HG changeset patch # User Raimund Renkert # Date 1351512963 -3600 # Node ID abd304085bd457c2d6a7f6a9943a8a0c582e7481 # Parent 1f98a3a89e130f632bc4ed2706d2f731b54de5c8 Added helper panel to sediment load UI to display sediemnt load overviews. diff -r 1f98a3a89e13 -r abd304085bd4 flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Mon Oct 29 13:13:23 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Mon Oct 29 13:16:03 2012 +0100 @@ -171,7 +171,7 @@ else if (uiProvider.equals("minfo.sedimentload_epoch_select")) { return new SedLoadEpochPanel(); } - else if (uiProvider.equals("minfo.sedimentload_epoch_select")) { + else if (uiProvider.equals("minfo.sedimentload_offepoch_select")) { return new SedLoadOffEpochPanel(); } else { diff -r 1f98a3a89e13 -r abd304085bd4 flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadEpochPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadEpochPanel.java Mon Oct 29 13:13:23 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadEpochPanel.java Mon Oct 29 13:16:03 2012 +0100 @@ -4,8 +4,10 @@ import java.util.List; import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.Record; import com.smartgwt.client.types.ListGridFieldType; +import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; @@ -22,20 +24,30 @@ import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.services.SedimentLoadInfoService; +import de.intevation.flys.client.client.services.SedimentLoadInfoServiceAsync; import de.intevation.flys.client.client.ui.AbstractUIProvider; +import de.intevation.flys.client.shared.model.ArtifactDescription; 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.SedimentLoadInfoObject; +import de.intevation.flys.client.shared.model.SedimentLoadInfoRecord; public class SedLoadEpochPanel extends AbstractUIProvider { + protected SedimentLoadInfoServiceAsync sedLoadInfoService = + GWT.create(SedimentLoadInfoService.class); + protected ListGrid elements; private TextItem start; private TextItem end; + private ListGrid sedLoadTable; public Canvas createWidget(DataList data) { HLayout input = new HLayout(); @@ -129,9 +141,9 @@ return root; } + @Override public Canvas createOld(DataList dataList) { - GWT.log("old............................"); HLayout layout = new HLayout(); layout.setWidth("400px"); VLayout vLayout = new VLayout(); @@ -162,14 +174,43 @@ @Override 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; } + private Canvas createHelper() { + sedLoadTable = new ListGrid(); + sedLoadTable.setShowHeaderContextMenu(false); + sedLoadTable.setWidth100(); + sedLoadTable.setShowRecordComponents(true); + sedLoadTable.setShowRecordComponentsByCell(true); + sedLoadTable.setHeight100(); + sedLoadTable.setEmptyMessage(MSG.empty_table()); + sedLoadTable.setCanReorderFields(false); + + ListGridField date = new ListGridField("date", MSG.year()); + date.setType(ListGridFieldType.TEXT); + date.setWidth(100); + + ListGridField descr = + new ListGridField("description", MSG.description()); + descr.setType(ListGridFieldType.TEXT); + descr.setWidth("*"); + + sedLoadTable.setFields(date, descr); + return sedLoadTable; + } + @Override protected Data[] getData() { List data = new ArrayList(); @@ -194,4 +235,43 @@ return data.toArray(new Data[data.size()]); } + protected void fetchSedimentLoadData() { + Config config = Config.getInstance(); + String locale = config.getLocale (); + + ArtifactDescription adescr = artifact.getArtifactDescription(); + DataList[] data = adescr.getOldData(); + + double[] km = artifact.getArtifactDescription().getKMRange(); + String river = artifact.getArtifactDescription().getRiver(); + + sedLoadInfoService.getSedimentLoadInfo(locale, river, "single", km[0], km[1], + new AsyncCallback() { + public void onFailure(Throwable caught) { + GWT.log("Could not recieve sediment load informations."); + SC.warn(caught.getMessage()); + } + + public void onSuccess(SedimentLoadInfoObject[] sedLoad) { + int num = sedLoad != null ? sedLoad.length :0; + GWT.log("Recieved " + num + " sediment load informations."); + + if (num == 0) { + return; + } + + addSedimentLoadInfo(sedLoad); + } + } + ); + } + + + protected void addSedimentLoadInfo (SedimentLoadInfoObject[] sedLoad) { + for(SedimentLoadInfoObject sl: sedLoad) { + SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl); + sedLoadTable.addData(rec); + } + } + } diff -r 1f98a3a89e13 -r abd304085bd4 flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadOffEpochPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadOffEpochPanel.java Mon Oct 29 13:13:23 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadOffEpochPanel.java Mon Oct 29 13:16:03 2012 +0100 @@ -1,10 +1,187 @@ package de.intevation.flys.client.client.ui.minfo; +import java.util.ArrayList; +import java.util.List; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.data.Record; +import com.smartgwt.client.types.ListGridFieldType; +import com.smartgwt.client.types.SelectionAppearance; +import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +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 de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.services.SedimentLoadInfoService; +import de.intevation.flys.client.client.services.SedimentLoadInfoServiceAsync; import de.intevation.flys.client.client.ui.PeriodPanel; +import de.intevation.flys.client.shared.model.ArtifactDescription; +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.SedimentLoadInfoObject; +import de.intevation.flys.client.shared.model.SedimentLoadInfoRecord; public class SedLoadOffEpochPanel extends PeriodPanel { + protected SedimentLoadInfoServiceAsync sedLoadInfoService = + GWT.create(SedimentLoadInfoService.class); + + private ListGrid sedLoadTable; + + 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; + } + + @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 items = dataList.getAll(); + Data str = getData(items, "epochs"); + DataItem[] strItems = str.getItems(); + + String[] pairs = strItems[0].getLabel().split(";"); + for (int i = 0; i < pairs.length; i++) { + String[] vals = pairs[i].split(","); + Label dateLabel = new Label(vals[0] + " - " + vals[1]); + dateLabel.setHeight(20); + vLayout.addMember(dateLabel); + } + Canvas back = getBackButton(dataList.getState()); + layout.addMember(label); + layout.addMember(vLayout); + layout.addMember(back); + + return layout; + } + + @Override + 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; + } + + protected Canvas createHelper() { + sedLoadTable = new ListGrid(); + sedLoadTable.setShowHeaderContextMenu(false); + sedLoadTable.setWidth100(); + sedLoadTable.setShowRecordComponents(true); + sedLoadTable.setShowRecordComponentsByCell(true); + sedLoadTable.setHeight100(); + sedLoadTable.setEmptyMessage(MSG.empty_table()); + sedLoadTable.setCanReorderFields(false); + sedLoadTable.setSelectionAppearance(SelectionAppearance.CHECKBOX); + + ListGridField date = new ListGridField("date", MSG.year()); + date.setType(ListGridFieldType.TEXT); + date.setWidth(100); + + ListGridField descr = + new ListGridField("description", MSG.description()); + descr.setType(ListGridFieldType.TEXT); + descr.setWidth("*"); + + sedLoadTable.setFields(date, descr); + return sedLoadTable; + } + + @Override + public Data[] getData() { + List data = new ArrayList(); + + ListGridRecord[] lgr = sedLoadTable.getSelectedRecords(); + if (lgr.length == 0) { + return new Data[0]; + } + String d = ""; + for (int i = 0; i < lgr.length; i++) { + Record r = (Record) lgr[i]; + String date = r.getAttribute("date"); + String[] range = date.split(" - "); + d += range[0] + "," + range[1]; + d += ";"; + } + DataItem item = new DefaultDataItem("epochs", null, d); + data.add(new DefaultData( + "epochs", + null, + null, + new DataItem[] { item })); + return data.toArray(new Data[data.size()]); + } + + protected void fetchSedimentLoadData() { + Config config = Config.getInstance(); + String locale = config.getLocale (); + + ArtifactDescription adescr = artifact.getArtifactDescription(); + DataList[] data = adescr.getOldData(); + + double[] km = artifact.getArtifactDescription().getKMRange(); + String river = artifact.getArtifactDescription().getRiver(); + + sedLoadInfoService.getSedimentLoadInfo(locale, river, "epoch", km[0], km[1], + new AsyncCallback() { + public void onFailure(Throwable caught) { + GWT.log("Could not recieve sediment load informations."); + SC.warn(caught.getMessage()); + } + + public void onSuccess(SedimentLoadInfoObject[] sedLoad) { + int num = sedLoad != null ? sedLoad.length :0; + GWT.log("Recieved " + num + " sediment load informations."); + + if (num == 0) { + return; + } + + addSedimentLoadInfo(sedLoad); + } + } + ); + } + + + protected void addSedimentLoadInfo (SedimentLoadInfoObject[] sedLoad) { + for(SedimentLoadInfoObject sl: sedLoad) { + SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl); + sedLoadTable.addData(rec); + } + } } diff -r 1f98a3a89e13 -r abd304085bd4 flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadPeriodPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadPeriodPanel.java Mon Oct 29 13:13:23 2012 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadPeriodPanel.java Mon Oct 29 13:16:03 2012 +0100 @@ -4,31 +4,44 @@ import java.util.List; import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.types.ListGridFieldType; +import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.services.SedimentLoadInfoService; +import de.intevation.flys.client.client.services.SedimentLoadInfoServiceAsync; import de.intevation.flys.client.client.ui.AbstractUIProvider; -import de.intevation.flys.client.client.ui.IntegerRangePanel; +import de.intevation.flys.client.shared.model.ArtifactDescription; 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.SedimentLoadInfoObject; +import de.intevation.flys.client.shared.model.SedimentLoadInfoRecord; public class SedLoadPeriodPanel extends AbstractUIProvider -//extends SedLoadPanel { + protected SedimentLoadInfoServiceAsync sedLoadInfoService = + GWT.create(SedimentLoadInfoService.class); private TextItem start; private TextItem end; + private ListGrid sedLoadTable; + public SedLoadPeriodPanel () { } @@ -72,17 +85,43 @@ public Canvas create(DataList data) { VLayout layout = new VLayout(); -// Canvas helper = createHelper(); -// this.helperContainer.addMember(helper); + Canvas helper = createHelper(); + this.helperContainer.addMember(helper); Canvas submit = getNextButton(); Canvas widget = createWidget(data); layout.addMember(widget); layout.addMember(submit); + + fetchSedimentLoadData(); + return layout; } + private Canvas createHelper() { + sedLoadTable = new ListGrid(); + sedLoadTable.setShowHeaderContextMenu(false); + sedLoadTable.setWidth100(); + sedLoadTable.setShowRecordComponents(true); + sedLoadTable.setShowRecordComponentsByCell(true); + sedLoadTable.setHeight100(); + sedLoadTable.setEmptyMessage(MSG.empty_table()); + sedLoadTable.setCanReorderFields(false); + + ListGridField date = new ListGridField("date", MSG.year()); + date.setType(ListGridFieldType.TEXT); + date.setWidth(100); + + ListGridField descr = + new ListGridField("description", MSG.description()); + descr.setType(ListGridFieldType.TEXT); + descr.setWidth("*"); + + sedLoadTable.setFields(date, descr); + return sedLoadTable; + } + public Canvas createWidget(DataList data) { VLayout layout = new VLayout(); @@ -149,5 +188,43 @@ return false; } + protected void fetchSedimentLoadData() { + Config config = Config.getInstance(); + String locale = config.getLocale (); + + ArtifactDescription adescr = artifact.getArtifactDescription(); + DataList[] data = adescr.getOldData(); + + double[] km = artifact.getArtifactDescription().getKMRange(); + String river = artifact.getArtifactDescription().getRiver(); + + sedLoadInfoService.getSedimentLoadInfo(locale, river, "single", km[0], km[1], + new AsyncCallback() { + public void onFailure(Throwable caught) { + GWT.log("Could not recieve sediment load informations."); + SC.warn(caught.getMessage()); + } + + public void onSuccess(SedimentLoadInfoObject[] sedLoad) { + int num = sedLoad != null ? sedLoad.length :0; + GWT.log("Recieved " + num + " sediment load informations."); + + if (num == 0) { + return; + } + + addSedimentLoadInfo(sedLoad); + } + } + ); + } + + + protected void addSedimentLoadInfo (SedimentLoadInfoObject[] sedLoad) { + for(SedimentLoadInfoObject sl: sedLoad) { + SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl); + sedLoadTable.addData(rec); + } + } } diff -r 1f98a3a89e13 -r abd304085bd4 flys-client/src/main/java/de/intevation/flys/client/shared/model/SedimentLoadInfoRecord.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/SedimentLoadInfoRecord.java Mon Oct 29 13:16:03 2012 +0100 @@ -0,0 +1,32 @@ +package de.intevation.flys.client.shared.model; + +import com.smartgwt.client.widgets.grid.ListGridRecord; + + +public class SedimentLoadInfoRecord +extends ListGridRecord +{ + protected SedimentLoadInfoObject sedimentLoadInfo; + + public SedimentLoadInfoRecord(SedimentLoadInfoObject info) { + this.sedimentLoadInfo = info; + setDescription(info.getDescription()); + setDate(info.getDate()); + } + + public void setDescription(String description) { + setAttribute("description", description); + } + + public void setDate(String date) { + setAttribute("date", date); + } + + public String getDescription() { + return getAttribute("description"); + } + + public String getDate() { + return getAttribute("date"); + } +}