Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfoWindow.java @ 4269:0c766c475805
Add Panel and Tree UI classes for dispayling the measurement station info
The new ui classes are using the new extracted base class InfoPanel and InfoTree
which are in common with the gauge info.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 26 Oct 2012 12:22:06 +0200 |
parents | ffbdd093da74 |
children | 8af500d62098 |
line wrap: on
line source
package de.intevation.flys.client.client.ui.map; import com.google.gwt.core.client.GWT; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.shared.model.FeatureInfo; import java.util.List; import java.util.Map; import java.util.Set; import org.gwtopenmaps.openlayers.client.feature.VectorFeature; import org.gwtopenmaps.openlayers.client.util.Attributes; import org.gwtopenmaps.openlayers.client.util.JSObject; public class GetFeatureInfoWindow extends Window { protected FLYSConstants MSG = GWT.create(FLYSConstants.class); protected List<FeatureInfo> features; public static final int ROW_HEIGHT = 25; public GetFeatureInfoWindow(List<FeatureInfo> features) { super(); this.features = features; initLayout(); } protected void initLayout() { VLayout root = new VLayout(); int rows = 0; for (FeatureInfo feature: features) { root.addMember(createFeatureRow(feature)); rows++; } addItem(root); setWidth(500); setHeight(500); // + rows * ROW_HEIGHT); setTitle(MSG.getFeatureInfoWindowTitle()); setIsModal(true); setShowModalMask(true); centerInPage(); } protected HLayout createFeatureRow(FeatureInfo feature) { HLayout r = new HLayout(); r.setHeight(ROW_HEIGHT); r.setStyleName("featureinfo-row"); r.setMembersMargin(5); Label l = new Label("Layer: " + feature.getLayername()); l.setHeight(ROW_HEIGHT); l.setWrap(false); r.addMember(l); Map<String, String> attrs = feature.getAttrs(); Set<Map.Entry<String, String>> entries = attrs.entrySet(); for (Map.Entry<String, String> entry: entries) { Label attr = new Label(entry.getKey() + ": " + entry.getValue()); attr.setHeight(ROW_HEIGHT); r.addMember(attr); } return r; } protected String[][] extractProperties(VectorFeature feature) { Attributes tmp = feature.getAttributes(); JSObject jsobj = tmp.getJSObject(); String tmpNames = jsobj.getPropertyNames(); String[] allNames = tmpNames.split(","); String[][] attr = new String[allNames.length][]; for (int i = 0, n = attr.length; i < n; i++) { attr[i] = new String[] { allNames[i], jsobj.getPropertyAsString(allNames[i]) }; } return attr; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :