changeset 850:d02c3835df28

Set the 'typ' attribute of new features (digitized) in the map. flys-client/trunk@2634 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 01 Sep 2011 12:49:12 +0000
parents d0098fc8c40b
children aa83a6a864b4
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java
diffstat 2 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 <ingo@intevation.de>
+
+	* 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	<felix.wolfsteller@intevation.de> 
 
 	Added cross section translation.
--- 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();

http://dive4elements.wald.intevation.org