comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationListGrid.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationListGrid.java@821a02bbfb4e
children 172338b1407f
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.client.client.ui.stationinfo;
2
3 import com.google.gwt.core.client.GWT;
4
5 import com.smartgwt.client.types.ListGridFieldType;
6 import com.smartgwt.client.widgets.Canvas;
7 import com.smartgwt.client.widgets.WidgetCanvas;
8 import com.smartgwt.client.widgets.grid.ListGridField;
9 import com.smartgwt.client.widgets.grid.ListGridRecord;
10 import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
11 import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
12
13 import org.dive4elements.river.client.client.FLYS;
14 import org.dive4elements.river.client.shared.model.MeasurementStation;
15 import org.dive4elements.river.client.shared.model.RiverInfo;
16
17 import java.util.ArrayList;
18 import java.util.List;
19
20 /**
21 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a>
22 */
23 public class MeasurementStationListGrid
24 extends InfoListGrid
25 implements RecordClickHandler {
26
27 public MeasurementStationListGrid(FLYS flys) {
28 super(flys);
29 ListGridField nfield = new ListGridField("name", "Messtelle");
30 ListGridField sfield = new ListGridField("kmstart", "Start [km]", 60);
31 ListGridField efield = new ListGridField("kmend", "Ende [km]", 60);
32 ListGridField stfield = new ListGridField("station", "Station [km]");
33 ListGridField lfield = new ListGridField("link", "Link");
34 lfield.setType(ListGridFieldType.LINK);
35 ListGridField cfield = new ListGridField("curvelink", "SQ");
36 cfield.addRecordClickHandler(this);
37 this.setFields(nfield, sfield, efield, stfield, lfield, cfield);
38 }
39
40 /**
41 * Resets the items of the tree.
42 * If the list of gauges is empty or null the tree will be empty.
43 */
44 @Override
45 public void setRiverInfo(RiverInfo riverinfo) {
46 List<MeasurementStation> stations = riverinfo.getMeasurementStations();
47 GWT.log("MeasurmentStationListGrid - setRiverInfo " + stations);
48
49 if (stations != null && !stations.isEmpty()) {
50
51 ArrayList<MeasurementStation> emptystations =
52 new ArrayList<MeasurementStation>();
53
54 if (!riverinfo.isKmUp()) {
55 for (MeasurementStation station : stations) {
56 addStation(station, emptystations);
57 }
58 }
59 else {
60 for (int i = stations.size()-1; i >= 0; i--) {
61 MeasurementStation station = stations.get(i);
62 addStation(station, emptystations);
63 }
64 }
65
66 // put empty stations to the end
67 for (MeasurementStation station : emptystations) {
68 addStation(station);
69 }
70 }
71 }
72
73 private void addStation(MeasurementStation station,
74 List<MeasurementStation> empty) {
75 if (station.getKmStart() != null && station.getKmEnd() != null) {
76 addStation(station);
77 }
78 else {
79 empty.add(station);
80 }
81 }
82
83 private void addStation(MeasurementStation station) {
84 ListGridRecord record = new MeasurementStationRecord(station);
85 this.addData(record);
86 }
87
88 @Override
89 public void open() {
90 }
91
92 @Override
93 protected Canvas getExpandPanel(ListGridRecord record) {
94 MeasurementStationRecord station = (MeasurementStationRecord)record;
95 return new WidgetCanvas(new MeasurementStationInfoPanel(station));
96 }
97
98 @Override
99 public void onRecordClick(RecordClickEvent event) {
100 MeasurementStationRecord station =
101 (MeasurementStationRecord)event.getRecord();
102 flys.newSQRelation(station.getRiverName(), station.getID());
103 }
104
105 }

http://dive4elements.wald.intevation.org