Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfoWindow.java @ 1402:15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
flys-client/trunk@3287 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 18 Nov 2011 11:39:10 +0000 |
parents | 96708d81eaf6 |
children | 656df7c0bdda |
comparison
equal
deleted
inserted
replaced
1401:047a44270348 | 1402:15ef3d3081b7 |
---|---|
1 package de.intevation.flys.client.client.ui.map; | 1 package de.intevation.flys.client.client.ui.map; |
2 | |
3 import java.util.List; | |
4 import java.util.Map; | |
5 import java.util.Set; | |
2 | 6 |
3 import com.google.gwt.core.client.GWT; | 7 import com.google.gwt.core.client.GWT; |
4 | 8 |
5 import com.smartgwt.client.widgets.Label; | 9 import com.smartgwt.client.widgets.Label; |
6 import com.smartgwt.client.widgets.Window; | 10 import com.smartgwt.client.widgets.Window; |
7 import com.smartgwt.client.widgets.layout.HLayout; | 11 import com.smartgwt.client.widgets.layout.HLayout; |
8 import com.smartgwt.client.widgets.layout.VLayout; | 12 import com.smartgwt.client.widgets.layout.VLayout; |
9 | 13 |
10 import org.gwtopenmaps.openlayers.client.feature.VectorFeature; | 14 import org.gwtopenmaps.openlayers.client.feature.VectorFeature; |
11 import org.gwtopenmaps.openlayers.client.format.GML; | |
12 import org.gwtopenmaps.openlayers.client.util.Attributes; | 15 import org.gwtopenmaps.openlayers.client.util.Attributes; |
13 import org.gwtopenmaps.openlayers.client.util.JSObject; | 16 import org.gwtopenmaps.openlayers.client.util.JSObject; |
17 | |
18 import de.intevation.flys.client.shared.model.FeatureInfo; | |
14 | 19 |
15 import de.intevation.flys.client.client.FLYSConstants; | 20 import de.intevation.flys.client.client.FLYSConstants; |
16 | 21 |
17 | 22 |
18 public class GetFeatureInfoWindow extends Window { | 23 public class GetFeatureInfoWindow extends Window { |
19 | 24 |
20 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | 25 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); |
21 | 26 |
22 protected VectorFeature[] features; | 27 protected List<FeatureInfo> features; |
23 | 28 |
24 | 29 |
25 public GetFeatureInfoWindow(String gml) { | 30 public static final int ROW_HEIGHT = 25; |
31 | |
32 | |
33 public GetFeatureInfoWindow(List<FeatureInfo> features) { | |
26 super(); | 34 super(); |
27 features = new GML().read(gml); | 35 this.features = features; |
36 | |
28 initLayout(); | 37 initLayout(); |
29 } | 38 } |
30 | 39 |
31 | 40 |
32 protected void initLayout() { | 41 protected void initLayout() { |
33 VLayout root = new VLayout(); | 42 VLayout root = new VLayout(); |
34 | 43 |
35 for (VectorFeature feature: features) { | 44 int rows = 0; |
45 | |
46 for (FeatureInfo feature: features) { | |
36 root.addMember(createFeatureRow(feature)); | 47 root.addMember(createFeatureRow(feature)); |
48 rows++; | |
37 } | 49 } |
38 | 50 |
39 addItem(root); | 51 addItem(root); |
40 | 52 |
41 setWidth(400); | 53 setWidth(400); |
42 setHeight(200); | 54 setHeight(50 + rows * ROW_HEIGHT); |
43 setTitle(MSG.getFeatureInfoWindowTitle()); | 55 setTitle(MSG.getFeatureInfoWindowTitle()); |
44 | 56 |
45 centerInPage(); | 57 centerInPage(); |
46 } | 58 } |
47 | 59 |
48 | 60 |
49 protected HLayout createFeatureRow(VectorFeature feature) { | 61 protected HLayout createFeatureRow(FeatureInfo feature) { |
50 HLayout r = new HLayout(); | 62 HLayout r = new HLayout(); |
51 r.setHeight(25); | 63 r.setHeight(ROW_HEIGHT); |
64 r.setStyleName("featureinfo-row"); | |
52 | 65 |
53 String[][] attrs = extractProperties(feature); | 66 Label l = new Label("Layer: " + feature.getLayername()); |
67 l.setHeight(ROW_HEIGHT); | |
54 | 68 |
55 for (String[] attr: attrs) { | 69 r.addMember(l); |
56 Label l = new Label(attr[0] + ": " + attr[1]); | 70 |
57 l.setHeight(25); | 71 Map<String, String> attrs = feature.getAttrs(); |
58 l.setBorder("1px solid black"); | 72 Set<Map.Entry<String, String>> entries = attrs.entrySet(); |
59 r.addMember(l); | 73 |
74 for (Map.Entry entry: entries) { | |
75 Label attr = new Label(entry.getKey() + ": " + entry.getValue()); | |
76 attr.setHeight(ROW_HEIGHT); | |
77 | |
78 r.addMember(attr); | |
60 } | 79 } |
61 | 80 |
62 return r; | 81 return r; |
63 } | 82 } |
64 | 83 |