Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java @ 1315:cf0f906921de
#297 Implemented a window to adjust elevations of geometries in the map.
flys-client/trunk@2954 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 13 Oct 2011 09:08:43 +0000 |
parents | 22dc88b17253 |
children | 45b9b1fc26e2 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java Wed Oct 12 12:42:53 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java Thu Oct 13 09:08:43 2011 +0000 @@ -3,6 +3,7 @@ import com.google.gwt.core.client.GWT; import com.smartgwt.client.types.SelectionType; +import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.ImgButton; import com.smartgwt.client.widgets.events.ClickEvent; @@ -27,8 +28,6 @@ */ public class MapToolbar extends HLayout { - public static final String MARK_TO_DELETE = "mark.delete"; - protected FLYSConstants MSG = GWT.create(FLYSConstants.class); protected FloodMap floodMap; @@ -42,6 +41,7 @@ protected ImgButton panButton; protected ImgButton selectButton; protected ImgButton removeButton; + protected ImgButton elevationButton; protected DrawControl drawControl; protected MeasureControl measureControl; @@ -77,6 +77,7 @@ measureControl = createMeasureControl(); position = createMousePosition(wrapper); removeButton = createRemoveFeatureControl(); + elevationButton = createElevationControl(); addMember(zoomToMaxButton); addMember(zoomBoxButton); @@ -87,6 +88,7 @@ addMember(drawControl); addMember(selectButton); addMember(removeButton); + addMember(elevationButton); } addMember(measureControl); @@ -310,14 +312,14 @@ opts.onSelect(new SelectFeature.SelectFeatureListener() { public void onFeatureSelected(VectorFeature feature) { Attributes attr = feature.getAttributes(); - attr.setAttribute(MARK_TO_DELETE, 1); + attr.setAttribute(FloodMap.MARK_SELECTED, 1); } }); opts.onUnSelect(new SelectFeature.UnselectFeatureListener() { public void onFeatureUnselected(VectorFeature feature) { Attributes attr = feature.getAttributes(); - attr.setAttribute(MARK_TO_DELETE, 0); + attr.setAttribute(FloodMap.MARK_SELECTED, 0); } }); @@ -359,7 +361,7 @@ VectorFeature feature = features[i]; Attributes attr = feature.getAttributes(); - int del = attr.getAttributeAsInt(MARK_TO_DELETE); + int del = attr.getAttributeAsInt(FloodMap.MARK_SELECTED); if (del == 1) { barriers.removeFeature(feature); @@ -375,6 +377,41 @@ } + protected ImgButton createElevationControl() { + ImgButton btn = createButton(MSG.adjustElevation(), new ClickHandler() { + public void onClick(ClickEvent evt) { + Vector barriers = floodMap.getBarrierLayer(); + VectorFeature[] features = barriers.getFeatures(); + + VectorFeature feature = null; + + if (features == null || features.length == 0) { + SC.warn("No Feature selected!"); + return; + } + + for (VectorFeature f: features) { + Attributes attr = f.getAttributes(); + if (attr.getAttributeAsInt(FloodMap.MARK_SELECTED) == 1) { + if (feature == null) { + feature = f; + } + else { + SC.warn("More than 1 Feature selected!"); + } + } + } + + new ElevationWindow(floodMap, feature).show(); + } + }); + + btn.setTooltip(MSG.adjustElevationTooltip()); + + return btn; + } + + protected Canvas createMousePosition(Canvas mapWrapper) { return new MapPositionPanel(floodMap.getMapWidget(), mapWrapper); }