# HG changeset patch # User Ingo Weinzierl # Date 1314881352 0 # Node ID d02c3835df2899161e4d76fbcce117ace8965825 # Parent d0098fc8c40bae7866b0b99a76cfc1db261ff444 Set the 'typ' attribute of new features (digitized) in the map. flys-client/trunk@2634 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d0098fc8c40b -r d02c3835df28 flys-client/ChangeLog --- a/flys-client/ChangeLog Wed Aug 31 10:28:28 2011 +0000 +++ b/flys-client/ChangeLog Thu Sep 01 12:49:12 2011 +0000 @@ -1,3 +1,10 @@ +2011-09-01 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java: + Set the 'typ' attribute of a feature that is added to the vector layer. + Features, that are loaded into the layer from GeoJSON file keep their + existing 'typ' attribute. New features get the attribute from combo box. + 2011-08-31 Felix Wolfsteller Added cross section translation. diff -r d0098fc8c40b -r d02c3835df28 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java Wed Aug 31 10:28:28 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java Thu Sep 01 12:49:12 2011 +0000 @@ -18,16 +18,20 @@ import org.gwtopenmaps.openlayers.client.Map; import org.gwtopenmaps.openlayers.client.control.Control; import org.gwtopenmaps.openlayers.client.control.DrawFeature; +import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener; +import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener.FeatureAddedEvent; +import org.gwtopenmaps.openlayers.client.feature.VectorFeature; import org.gwtopenmaps.openlayers.client.handler.Handler; import org.gwtopenmaps.openlayers.client.handler.PathHandler; import org.gwtopenmaps.openlayers.client.handler.PolygonHandler; import org.gwtopenmaps.openlayers.client.layer.Vector; +import org.gwtopenmaps.openlayers.client.util.Attributes; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.utils.EnableDisableCmd; -public class DrawControl extends HLayout { +public class DrawControl extends HLayout implements VectorFeatureAddedListener { public static final String BARRIER_PIPE1 = "pipe1"; public static final String BARRIER_PIPE2 = "pipe2"; @@ -111,6 +115,8 @@ addMember(button); addMember(form); + layer.addVectorFeatureAddedListener(this); + activate(false); } @@ -120,6 +126,22 @@ } + public void onFeatureAdded(FeatureAddedEvent evt) { + setCurrentType(evt.getVectorFeature()); + } + + + protected void setCurrentType(VectorFeature feature) { + Attributes attrs = feature.getAttributes(); + String type = attrs.getAttributeAsString("typ"); + + if (type == null || type.length() == 0) { + type = getSelectedType(); + attrs.setAttribute("typ", type); + } + } + + protected void removeControl() { if (control != null) { control.deactivate();