Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadEpochPanel.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 |
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; | |
7 import com.smartgwt.client.data.Record; | 8 import com.smartgwt.client.data.Record; |
8 import com.smartgwt.client.types.ListGridFieldType; | 9 import com.smartgwt.client.types.ListGridFieldType; |
10 import com.smartgwt.client.util.SC; | |
9 import com.smartgwt.client.widgets.Button; | 11 import com.smartgwt.client.widgets.Button; |
10 import com.smartgwt.client.widgets.Canvas; | 12 import com.smartgwt.client.widgets.Canvas; |
11 import com.smartgwt.client.widgets.Label; | 13 import com.smartgwt.client.widgets.Label; |
12 import com.smartgwt.client.widgets.events.ClickEvent; | 14 import com.smartgwt.client.widgets.events.ClickEvent; |
13 import com.smartgwt.client.widgets.events.ClickHandler; | 15 import com.smartgwt.client.widgets.events.ClickHandler; |
20 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; | 22 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; |
21 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; | 23 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; |
22 import com.smartgwt.client.widgets.layout.HLayout; | 24 import com.smartgwt.client.widgets.layout.HLayout; |
23 import com.smartgwt.client.widgets.layout.VLayout; | 25 import com.smartgwt.client.widgets.layout.VLayout; |
24 | 26 |
27 import de.intevation.flys.client.client.Config; | |
28 import de.intevation.flys.client.client.services.SedimentLoadInfoService; | |
29 import de.intevation.flys.client.client.services.SedimentLoadInfoServiceAsync; | |
25 import de.intevation.flys.client.client.ui.AbstractUIProvider; | 30 import de.intevation.flys.client.client.ui.AbstractUIProvider; |
31 import de.intevation.flys.client.shared.model.ArtifactDescription; | |
26 import de.intevation.flys.client.shared.model.Data; | 32 import de.intevation.flys.client.shared.model.Data; |
27 import de.intevation.flys.client.shared.model.DataItem; | 33 import de.intevation.flys.client.shared.model.DataItem; |
28 import de.intevation.flys.client.shared.model.DataList; | 34 import de.intevation.flys.client.shared.model.DataList; |
29 import de.intevation.flys.client.shared.model.DefaultData; | 35 import de.intevation.flys.client.shared.model.DefaultData; |
30 import de.intevation.flys.client.shared.model.DefaultDataItem; | 36 import de.intevation.flys.client.shared.model.DefaultDataItem; |
37 import de.intevation.flys.client.shared.model.SedimentLoadInfoObject; | |
38 import de.intevation.flys.client.shared.model.SedimentLoadInfoRecord; | |
31 | 39 |
32 | 40 |
33 public class SedLoadEpochPanel | 41 public class SedLoadEpochPanel |
34 extends AbstractUIProvider | 42 extends AbstractUIProvider |
35 { | 43 { |
44 protected SedimentLoadInfoServiceAsync sedLoadInfoService = | |
45 GWT.create(SedimentLoadInfoService.class); | |
46 | |
36 protected ListGrid elements; | 47 protected ListGrid elements; |
37 private TextItem start; | 48 private TextItem start; |
38 private TextItem end; | 49 private TextItem end; |
50 private ListGrid sedLoadTable; | |
39 | 51 |
40 public Canvas createWidget(DataList data) { | 52 public Canvas createWidget(DataList data) { |
41 HLayout input = new HLayout(); | 53 HLayout input = new HLayout(); |
42 VLayout root = new VLayout(); | 54 VLayout root = new VLayout(); |
43 VLayout grid = new VLayout(); | 55 VLayout grid = new VLayout(); |
127 root.addMember(title); | 139 root.addMember(title); |
128 root.addMember(input); | 140 root.addMember(input); |
129 | 141 |
130 return root; | 142 return root; |
131 } | 143 } |
144 | |
132 @Override | 145 @Override |
133 public Canvas createOld(DataList dataList) { | 146 public Canvas createOld(DataList dataList) { |
134 GWT.log("old............................"); | |
135 HLayout layout = new HLayout(); | 147 HLayout layout = new HLayout(); |
136 layout.setWidth("400px"); | 148 layout.setWidth("400px"); |
137 VLayout vLayout = new VLayout(); | 149 VLayout vLayout = new VLayout(); |
138 vLayout.setWidth(130); | 150 vLayout.setWidth(130); |
139 Label label = new Label(dataList.getLabel()); | 151 Label label = new Label(dataList.getLabel()); |
160 } | 172 } |
161 | 173 |
162 @Override | 174 @Override |
163 public Canvas create(DataList data) { | 175 public Canvas create(DataList data) { |
164 VLayout layout = new VLayout(); | 176 VLayout layout = new VLayout(); |
177 Canvas helper = createHelper(); | |
178 this.helperContainer.addMember(helper); | |
179 | |
165 Canvas submit = getNextButton(); | 180 Canvas submit = getNextButton(); |
166 Canvas widget = createWidget(data); | 181 Canvas widget = createWidget(data); |
167 | 182 |
168 layout.addMember(widget); | 183 layout.addMember(widget); |
169 layout.addMember(submit); | 184 layout.addMember(submit); |
185 | |
186 fetchSedimentLoadData(); | |
187 | |
170 return layout; | 188 return layout; |
189 } | |
190 | |
191 private Canvas createHelper() { | |
192 sedLoadTable = new ListGrid(); | |
193 sedLoadTable.setShowHeaderContextMenu(false); | |
194 sedLoadTable.setWidth100(); | |
195 sedLoadTable.setShowRecordComponents(true); | |
196 sedLoadTable.setShowRecordComponentsByCell(true); | |
197 sedLoadTable.setHeight100(); | |
198 sedLoadTable.setEmptyMessage(MSG.empty_table()); | |
199 sedLoadTable.setCanReorderFields(false); | |
200 | |
201 ListGridField date = new ListGridField("date", MSG.year()); | |
202 date.setType(ListGridFieldType.TEXT); | |
203 date.setWidth(100); | |
204 | |
205 ListGridField descr = | |
206 new ListGridField("description", MSG.description()); | |
207 descr.setType(ListGridFieldType.TEXT); | |
208 descr.setWidth("*"); | |
209 | |
210 sedLoadTable.setFields(date, descr); | |
211 return sedLoadTable; | |
171 } | 212 } |
172 | 213 |
173 @Override | 214 @Override |
174 protected Data[] getData() { | 215 protected Data[] getData() { |
175 List<Data> data = new ArrayList<Data>(); | 216 List<Data> data = new ArrayList<Data>(); |
192 null, | 233 null, |
193 new DataItem[] { item })); | 234 new DataItem[] { item })); |
194 return data.toArray(new Data[data.size()]); | 235 return data.toArray(new Data[data.size()]); |
195 } | 236 } |
196 | 237 |
238 protected void fetchSedimentLoadData() { | |
239 Config config = Config.getInstance(); | |
240 String locale = config.getLocale (); | |
241 | |
242 ArtifactDescription adescr = artifact.getArtifactDescription(); | |
243 DataList[] data = adescr.getOldData(); | |
244 | |
245 double[] km = artifact.getArtifactDescription().getKMRange(); | |
246 String river = artifact.getArtifactDescription().getRiver(); | |
247 | |
248 sedLoadInfoService.getSedimentLoadInfo(locale, river, "single", km[0], km[1], | |
249 new AsyncCallback<SedimentLoadInfoObject[]>() { | |
250 public void onFailure(Throwable caught) { | |
251 GWT.log("Could not recieve sediment load informations."); | |
252 SC.warn(caught.getMessage()); | |
253 } | |
254 | |
255 public void onSuccess(SedimentLoadInfoObject[] sedLoad) { | |
256 int num = sedLoad != null ? sedLoad.length :0; | |
257 GWT.log("Recieved " + num + " sediment load informations."); | |
258 | |
259 if (num == 0) { | |
260 return; | |
261 } | |
262 | |
263 addSedimentLoadInfo(sedLoad); | |
264 } | |
265 } | |
266 ); | |
267 } | |
268 | |
269 | |
270 protected void addSedimentLoadInfo (SedimentLoadInfoObject[] sedLoad) { | |
271 for(SedimentLoadInfoObject sl: sedLoad) { | |
272 SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl); | |
273 sedLoadTable.addData(rec); | |
274 } | |
275 } | |
276 | |
197 } | 277 } |