Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadPeriodPanel.java @ 4299:abd304085bd4
Added helper panel to sediment load UI to display sediemnt load overviews.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 29 Oct 2012 13:16:03 +0100 |
parents | 015b219a97af |
children | b195fede1c3b |
comparison
equal
deleted
inserted
replaced
4298:1f98a3a89e13 | 4299:abd304085bd4 |
---|---|
2 | 2 |
3 import java.util.ArrayList; | 3 import java.util.ArrayList; |
4 import java.util.List; | 4 import java.util.List; |
5 | 5 |
6 import com.google.gwt.core.client.GWT; | 6 import com.google.gwt.core.client.GWT; |
7 import com.google.gwt.user.client.rpc.AsyncCallback; | |
8 import com.smartgwt.client.types.ListGridFieldType; | |
9 import com.smartgwt.client.util.SC; | |
7 import com.smartgwt.client.widgets.Canvas; | 10 import com.smartgwt.client.widgets.Canvas; |
8 import com.smartgwt.client.widgets.Label; | 11 import com.smartgwt.client.widgets.Label; |
9 import com.smartgwt.client.widgets.form.DynamicForm; | 12 import com.smartgwt.client.widgets.form.DynamicForm; |
10 import com.smartgwt.client.widgets.form.fields.TextItem; | 13 import com.smartgwt.client.widgets.form.fields.TextItem; |
11 import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; | 14 import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; |
15 import com.smartgwt.client.widgets.grid.ListGrid; | |
16 import com.smartgwt.client.widgets.grid.ListGridField; | |
12 import com.smartgwt.client.widgets.layout.HLayout; | 17 import com.smartgwt.client.widgets.layout.HLayout; |
13 import com.smartgwt.client.widgets.layout.VLayout; | 18 import com.smartgwt.client.widgets.layout.VLayout; |
14 | 19 |
20 import de.intevation.flys.client.client.Config; | |
21 import de.intevation.flys.client.client.services.SedimentLoadInfoService; | |
22 import de.intevation.flys.client.client.services.SedimentLoadInfoServiceAsync; | |
15 import de.intevation.flys.client.client.ui.AbstractUIProvider; | 23 import de.intevation.flys.client.client.ui.AbstractUIProvider; |
16 import de.intevation.flys.client.client.ui.IntegerRangePanel; | 24 import de.intevation.flys.client.shared.model.ArtifactDescription; |
17 import de.intevation.flys.client.shared.model.Data; | 25 import de.intevation.flys.client.shared.model.Data; |
18 import de.intevation.flys.client.shared.model.DataItem; | 26 import de.intevation.flys.client.shared.model.DataItem; |
19 import de.intevation.flys.client.shared.model.DataList; | 27 import de.intevation.flys.client.shared.model.DataList; |
20 import de.intevation.flys.client.shared.model.DefaultData; | 28 import de.intevation.flys.client.shared.model.DefaultData; |
21 import de.intevation.flys.client.shared.model.DefaultDataItem; | 29 import de.intevation.flys.client.shared.model.DefaultDataItem; |
30 import de.intevation.flys.client.shared.model.SedimentLoadInfoObject; | |
31 import de.intevation.flys.client.shared.model.SedimentLoadInfoRecord; | |
22 | 32 |
23 | 33 |
24 public class SedLoadPeriodPanel | 34 public class SedLoadPeriodPanel |
25 extends AbstractUIProvider | 35 extends AbstractUIProvider |
26 //extends SedLoadPanel | |
27 { | 36 { |
37 protected SedimentLoadInfoServiceAsync sedLoadInfoService = | |
38 GWT.create(SedimentLoadInfoService.class); | |
28 | 39 |
29 private TextItem start; | 40 private TextItem start; |
30 private TextItem end; | 41 private TextItem end; |
42 | |
43 private ListGrid sedLoadTable; | |
31 | 44 |
32 public SedLoadPeriodPanel () { | 45 public SedLoadPeriodPanel () { |
33 } | 46 } |
34 | 47 |
35 @Override | 48 @Override |
70 | 83 |
71 @Override | 84 @Override |
72 public Canvas create(DataList data) { | 85 public Canvas create(DataList data) { |
73 VLayout layout = new VLayout(); | 86 VLayout layout = new VLayout(); |
74 | 87 |
75 // Canvas helper = createHelper(); | 88 Canvas helper = createHelper(); |
76 // this.helperContainer.addMember(helper); | 89 this.helperContainer.addMember(helper); |
77 | 90 |
78 Canvas submit = getNextButton(); | 91 Canvas submit = getNextButton(); |
79 Canvas widget = createWidget(data); | 92 Canvas widget = createWidget(data); |
80 | 93 |
81 layout.addMember(widget); | 94 layout.addMember(widget); |
82 layout.addMember(submit); | 95 layout.addMember(submit); |
96 | |
97 fetchSedimentLoadData(); | |
98 | |
83 return layout; | 99 return layout; |
100 } | |
101 | |
102 private Canvas createHelper() { | |
103 sedLoadTable = new ListGrid(); | |
104 sedLoadTable.setShowHeaderContextMenu(false); | |
105 sedLoadTable.setWidth100(); | |
106 sedLoadTable.setShowRecordComponents(true); | |
107 sedLoadTable.setShowRecordComponentsByCell(true); | |
108 sedLoadTable.setHeight100(); | |
109 sedLoadTable.setEmptyMessage(MSG.empty_table()); | |
110 sedLoadTable.setCanReorderFields(false); | |
111 | |
112 ListGridField date = new ListGridField("date", MSG.year()); | |
113 date.setType(ListGridFieldType.TEXT); | |
114 date.setWidth(100); | |
115 | |
116 ListGridField descr = | |
117 new ListGridField("description", MSG.description()); | |
118 descr.setType(ListGridFieldType.TEXT); | |
119 descr.setWidth("*"); | |
120 | |
121 sedLoadTable.setFields(date, descr); | |
122 return sedLoadTable; | |
84 } | 123 } |
85 | 124 |
86 public Canvas createWidget(DataList data) { | 125 public Canvas createWidget(DataList data) { |
87 VLayout layout = new VLayout(); | 126 VLayout layout = new VLayout(); |
88 | 127 |
147 return true; | 186 return true; |
148 } | 187 } |
149 return false; | 188 return false; |
150 } | 189 } |
151 | 190 |
191 protected void fetchSedimentLoadData() { | |
192 Config config = Config.getInstance(); | |
193 String locale = config.getLocale (); | |
194 | |
195 ArtifactDescription adescr = artifact.getArtifactDescription(); | |
196 DataList[] data = adescr.getOldData(); | |
197 | |
198 double[] km = artifact.getArtifactDescription().getKMRange(); | |
199 String river = artifact.getArtifactDescription().getRiver(); | |
200 | |
201 sedLoadInfoService.getSedimentLoadInfo(locale, river, "single", km[0], km[1], | |
202 new AsyncCallback<SedimentLoadInfoObject[]>() { | |
203 public void onFailure(Throwable caught) { | |
204 GWT.log("Could not recieve sediment load informations."); | |
205 SC.warn(caught.getMessage()); | |
206 } | |
207 | |
208 public void onSuccess(SedimentLoadInfoObject[] sedLoad) { | |
209 int num = sedLoad != null ? sedLoad.length :0; | |
210 GWT.log("Recieved " + num + " sediment load informations."); | |
211 | |
212 if (num == 0) { | |
213 return; | |
214 } | |
215 | |
216 addSedimentLoadInfo(sedLoad); | |
217 } | |
218 } | |
219 ); | |
220 } | |
221 | |
222 | |
223 protected void addSedimentLoadInfo (SedimentLoadInfoObject[] sedLoad) { | |
224 for(SedimentLoadInfoObject sl: sedLoad) { | |
225 SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl); | |
226 sedLoadTable.addData(rec); | |
227 } | |
228 } | |
152 | 229 |
153 } | 230 } |