Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/MeasurementStationTree.java @ 4270:cde9a6fe1844
Refactor ParameterList to use new InfoPanel base class
By using the base class it will be possible to show either a gauge info or a
measurement station info with only small adjustments.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 26 Oct 2012 12:26:01 +0200 |
parents | 0c766c475805 |
children | 6aa8cd8da224 |
rev | line source |
---|---|
4269
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client.ui; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
2 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
3 import com.google.gwt.core.client.GWT; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
4 import com.google.gwt.event.dom.client.ClickEvent; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
5 import com.google.gwt.event.dom.client.ClickHandler; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
6 import com.google.gwt.i18n.client.NumberFormat; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
7 import com.google.gwt.user.client.ui.Anchor; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
8 import com.google.gwt.user.client.ui.DecoratorPanel; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
9 import com.google.gwt.user.client.ui.Grid; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
10 import com.google.gwt.user.client.ui.Label; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
11 import com.google.gwt.user.client.ui.Tree; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
12 import com.google.gwt.user.client.ui.TreeItem; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
13 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
14 import com.smartgwt.client.widgets.layout.HLayout; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
15 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.flys.client.client.FLYS; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.flys.client.shared.model.Data; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.flys.client.shared.model.DataItem; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.flys.client.shared.model.DataList; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.client.shared.model.MeasurementStation; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.client.shared.model.RiverInfo; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
22 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
23 import java.util.ArrayList; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
24 import java.util.Iterator; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
25 import java.util.List; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
26 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
27 /** |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
28 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 */ |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
30 public class MeasurementStationTree extends InfoTree { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
31 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
32 public MeasurementStationTree(FLYS flys) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
33 this.flys = flys; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
34 tree = new Tree(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
35 setWidget(tree); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
36 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
37 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
38 /** |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
39 * Resets the items of the tree. |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
40 * If the list of gauges is empty or null the tree will be empty. |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
41 */ |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
42 @Override |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
43 public void setRiverInfo(RiverInfo riverinfo) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
44 tree.clear(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
45 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
46 List<MeasurementStation> stations = riverinfo.getMeasurementStations(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
47 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
48 if (stations != null && !stations.isEmpty()) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
49 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
50 ArrayList<MeasurementStation> emptystations = |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
51 new ArrayList<MeasurementStation>(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
52 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
53 if (!riverinfo.isKmUp()) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
54 for (MeasurementStation station : stations) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
55 addStation(station, emptystations); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
56 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
57 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
58 else { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
59 for (int i = stations.size()-1; i >= 0; i--) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
60 MeasurementStation station = stations.get(i); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
61 addStation(station, emptystations); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
62 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
63 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
64 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
65 // put empty stations to the end |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
66 for (MeasurementStation station : emptystations) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
67 addStation(station); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
68 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
69 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
70 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
71 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
72 private void addStation(MeasurementStation station, |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
73 List<MeasurementStation> empty) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
74 if (station.getKmStart() != null && station.getKmEnd() != null) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
75 addStation(station); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
76 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
77 else { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
78 empty.add(station); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
79 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
80 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
81 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
82 private void addStation(MeasurementStation station) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
83 MeasurementStationItem sitem = |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
84 new MeasurementStationItem(flys, station); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
85 tree.addItem(sitem); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
86 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
87 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
88 class MeasurementStationItem extends TreeItem { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
89 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
90 private MeasurementStation station; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
91 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
92 public MeasurementStationItem(FLYS flys, MeasurementStation station) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
93 MeasurementStationHead head = |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
94 new MeasurementStationHead(flys, station); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
95 MeasurementStationDecoratorPanel |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
96 panel = new MeasurementStationDecoratorPanel(station); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
97 setWidget(head); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
98 addItem(panel); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
99 this.station = station; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
100 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
101 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
102 public Double getStart() { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
103 return station.getKmStart(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
104 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
105 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
106 public Double getEnd() { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
107 return station.getKmEnd(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
108 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
109 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
110 public Integer getID() { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
111 return station.getID(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
112 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
113 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
114 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
115 class MeasurementStationHead extends HLayout { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
116 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
117 public MeasurementStationHead(FLYS flys, MeasurementStation station) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
118 setStyleName("infohead"); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
119 setAutoHeight(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
120 setAutoWidth(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
121 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
122 NumberFormat nf = NumberFormat.getDecimalFormat(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
123 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
124 Label label = new Label(station.getName(), true); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
125 addMember(label); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
126 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
127 Double start; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
128 Double end; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
129 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
130 if (!station.isKmUp()) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
131 start = station.getKmStart(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
132 end = station.getKmEnd(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
133 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
134 else { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
135 start = station.getKmEnd(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
136 end = station.getKmStart(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
137 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
138 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
139 String kmtext = ""; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
140 if (start != null) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
141 kmtext += nf.format(start); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
142 kmtext += " - "; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
143 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
144 if (end != null) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
145 kmtext += nf.format(end); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
146 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
147 if (start != null || end != null) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
148 kmtext += " km"; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
149 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
150 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
151 label = new Label(kmtext); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
152 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
153 addMember(label); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
154 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
155 Double dstation = station.getStation(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
156 if (dstation != null) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
157 String stext = nf.format(dstation); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
158 stext += " km"; |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
159 label = new Label(stext); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
160 addMember(label); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
161 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
162 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
163 /* Long number = gauge.getOfficialNumber(); */ |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
164 /* String url = number != null ? */ |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
165 /* MSG.gauge_url() + number : */ |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
166 /* MSG.gauge_url(); */ |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
167 /* Anchor anchor = new Anchor(MSG.gauge_info_link(), url, "_blank"); */ |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
168 /* addMember(anchor); */ |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
169 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
170 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
171 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
172 class MeasurementStationDecoratorPanel extends DecoratorPanel { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
173 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
174 public MeasurementStationDecoratorPanel(MeasurementStation station) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
175 setStyleName("infopanel"); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
176 Grid grid = new Grid(4, 2); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
177 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
178 NumberFormat nf = NumberFormat.getDecimalFormat(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
179 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
180 String riverside = station.getRiverSide(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
181 if (riverside != null) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
182 grid.setText(0, 0, MSG.riverside()); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
183 grid.setText(0, 1, riverside); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
184 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
185 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
186 String type = station.getMeasurementType(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
187 if (type != null) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
188 grid.setText(1, 0, MSG.measurement_station_type()); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
189 grid.setText(1, 1, type); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
190 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
191 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
192 String moperator = station.getOperator(); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
193 if (moperator != null) { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
194 grid.setText(2, 0, MSG.measurement_station_operator()); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
195 grid.setText(2, 1, moperator); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
196 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
197 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
198 setWidget(grid); |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
199 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
200 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
201 |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
202 @Override |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
203 public void open() { |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
204 } |
0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
Björn Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
205 } |