Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java @ 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 | 95cc560ce7c4 |
children | f5855350fc03 |
comparison
equal
deleted
inserted
replaced
849:d0098fc8c40b | 850:d02c3835df28 |
---|---|
16 import com.smartgwt.client.widgets.layout.HLayout; | 16 import com.smartgwt.client.widgets.layout.HLayout; |
17 | 17 |
18 import org.gwtopenmaps.openlayers.client.Map; | 18 import org.gwtopenmaps.openlayers.client.Map; |
19 import org.gwtopenmaps.openlayers.client.control.Control; | 19 import org.gwtopenmaps.openlayers.client.control.Control; |
20 import org.gwtopenmaps.openlayers.client.control.DrawFeature; | 20 import org.gwtopenmaps.openlayers.client.control.DrawFeature; |
21 import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener; | |
22 import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener.FeatureAddedEvent; | |
23 import org.gwtopenmaps.openlayers.client.feature.VectorFeature; | |
21 import org.gwtopenmaps.openlayers.client.handler.Handler; | 24 import org.gwtopenmaps.openlayers.client.handler.Handler; |
22 import org.gwtopenmaps.openlayers.client.handler.PathHandler; | 25 import org.gwtopenmaps.openlayers.client.handler.PathHandler; |
23 import org.gwtopenmaps.openlayers.client.handler.PolygonHandler; | 26 import org.gwtopenmaps.openlayers.client.handler.PolygonHandler; |
24 import org.gwtopenmaps.openlayers.client.layer.Vector; | 27 import org.gwtopenmaps.openlayers.client.layer.Vector; |
28 import org.gwtopenmaps.openlayers.client.util.Attributes; | |
25 | 29 |
26 import de.intevation.flys.client.client.FLYSConstants; | 30 import de.intevation.flys.client.client.FLYSConstants; |
27 import de.intevation.flys.client.client.utils.EnableDisableCmd; | 31 import de.intevation.flys.client.client.utils.EnableDisableCmd; |
28 | 32 |
29 | 33 |
30 public class DrawControl extends HLayout { | 34 public class DrawControl extends HLayout implements VectorFeatureAddedListener { |
31 | 35 |
32 public static final String BARRIER_PIPE1 = "pipe1"; | 36 public static final String BARRIER_PIPE1 = "pipe1"; |
33 public static final String BARRIER_PIPE2 = "pipe2"; | 37 public static final String BARRIER_PIPE2 = "pipe2"; |
34 public static final String BARRIER_DITCH = "ditch"; | 38 public static final String BARRIER_DITCH = "ditch"; |
35 public static final String BARRIER_DAM = "dam"; | 39 public static final String BARRIER_DAM = "dam"; |
109 form.setFields(box); | 113 form.setFields(box); |
110 | 114 |
111 addMember(button); | 115 addMember(button); |
112 addMember(form); | 116 addMember(form); |
113 | 117 |
118 layer.addVectorFeatureAddedListener(this); | |
119 | |
114 activate(false); | 120 activate(false); |
115 } | 121 } |
116 | 122 |
117 | 123 |
118 protected String getSelectedType() { | 124 protected String getSelectedType() { |
119 return form.getValueAsString(FIELD_BARRIER_TYPE); | 125 return form.getValueAsString(FIELD_BARRIER_TYPE); |
126 } | |
127 | |
128 | |
129 public void onFeatureAdded(FeatureAddedEvent evt) { | |
130 setCurrentType(evt.getVectorFeature()); | |
131 } | |
132 | |
133 | |
134 protected void setCurrentType(VectorFeature feature) { | |
135 Attributes attrs = feature.getAttributes(); | |
136 String type = attrs.getAttributeAsString("typ"); | |
137 | |
138 if (type == null || type.length() == 0) { | |
139 type = getSelectedType(); | |
140 attrs.setAttribute("typ", type); | |
141 } | |
120 } | 142 } |
121 | 143 |
122 | 144 |
123 protected void removeControl() { | 145 protected void removeControl() { |
124 if (control != null) { | 146 if (control != null) { |