comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/DrawControl.java @ 5609:80e8ef91223c

Fix for #802: digitized pipes and dikes should be visible now
author Christian Lins <christian.lins@intevation.de>
date Tue, 09 Apr 2013 12:44:57 +0200
parents 8af500d62098
children
comparison
equal deleted inserted replaced
5608:62513c9183ba 5609:80e8ef91223c
1 package de.intevation.flys.client.client.ui.map; 1 package de.intevation.flys.client.client.ui.map;
2 2
3 import com.google.gwt.core.client.GWT; 3 import com.google.gwt.core.client.GWT;
4
5 import com.smartgwt.client.types.SelectionType; 4 import com.smartgwt.client.types.SelectionType;
6 import com.smartgwt.client.widgets.ImgButton; 5 import com.smartgwt.client.widgets.ImgButton;
7 import com.smartgwt.client.widgets.events.ClickEvent; 6 import com.smartgwt.client.widgets.events.ClickEvent;
8 import com.smartgwt.client.widgets.events.ClickHandler; 7 import com.smartgwt.client.widgets.events.ClickHandler;
9 import com.smartgwt.client.widgets.form.DynamicForm; 8 import com.smartgwt.client.widgets.form.DynamicForm;
28 import org.gwtopenmaps.openlayers.client.handler.PathHandler; 27 import org.gwtopenmaps.openlayers.client.handler.PathHandler;
29 import org.gwtopenmaps.openlayers.client.handler.PolygonHandler; 28 import org.gwtopenmaps.openlayers.client.handler.PolygonHandler;
30 import org.gwtopenmaps.openlayers.client.layer.Vector; 29 import org.gwtopenmaps.openlayers.client.layer.Vector;
31 import org.gwtopenmaps.openlayers.client.util.Attributes; 30 import org.gwtopenmaps.openlayers.client.util.Attributes;
32 31
33 32 /**
33 * Widget that handles the drawing of pipes and dikes in the DigitizePanel (MapPanel).
34 */
34 public class DrawControl extends HLayout implements VectorFeatureAddedListener { 35 public class DrawControl extends HLayout implements VectorFeatureAddedListener {
35 36
36 public static final String BARRIER_PIPE1 = "pipe1"; 37 public static final String BARRIER_PIPE1 = "pipe1";
37 public static final String BARRIER_PIPE2 = "pipe2"; 38 public static final String BARRIER_PIPE2 = "pipe2";
38 public static final String BARRIER_DITCH = "ditch"; 39 public static final String BARRIER_DITCH = "ditch";
39 public static final String BARRIER_DAM = "dam"; 40 public static final String BARRIER_DAM = "dam";
40 public static final String BARRIER_RINGDIKE = "ring_dike"; 41 public static final String BARRIER_RINGDIKE = "ring_dike";
41 42
43 // FIXME: i18n
42 public static final String BARRIER_PIPE1_VALUE = "Rohr 1"; 44 public static final String BARRIER_PIPE1_VALUE = "Rohr 1";
43 public static final String BARRIER_PIPE2_VALUE = "Rohr 2"; 45 public static final String BARRIER_PIPE2_VALUE = "Rohr 2";
44 public static final String BARRIER_DITCH_VALUE = "Graben"; 46 public static final String BARRIER_DITCH_VALUE = "Graben";
45 public static final String BARRIER_DAM_VALUE = "Damm"; 47 public static final String BARRIER_DAM_VALUE = "Damm";
46 public static final String BARRIER_RINGDIKE_VALUE = "Ringdeich"; 48 public static final String BARRIER_RINGDIKE_VALUE = "Ringdeich";
74 setWidth(100); 76 setWidth(100);
75 setMembersMargin(0); 77 setMembersMargin(0);
76 78
77 button = new ImgButton(); 79 button = new ImgButton();
78 80
79 String baseUrl = GWT.getHostPageBaseURL(); 81 final String baseUrl = GWT.getHostPageBaseURL();
80 button.setSrc(baseUrl + MSG.digitize()); 82 button.setSrc(baseUrl + MSG.digitize());
81 button.setActionType(SelectionType.CHECKBOX); 83 button.setActionType(SelectionType.CHECKBOX);
82 button.setSize(20); 84 button.setSize(20);
83 button.setShowRollOver(false); 85 button.setShowRollOver(false);
84 button.setSelected(false); 86 button.setSelected(false);
99 form = new DynamicForm(); 101 form = new DynamicForm();
100 form.setWidth(100); 102 form.setWidth(100);
101 form.setTitlePrefix(""); 103 form.setTitlePrefix("");
102 form.setTitleSuffix(""); 104 form.setTitleSuffix("");
103 105
104 LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); 106 final LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
105 map.put(BARRIER_PIPE1, MSG.getString(BARRIER_PIPE1)); 107 map.put(BARRIER_PIPE1, MSG.getString(BARRIER_PIPE1));
106 map.put(BARRIER_PIPE2, MSG.getString(BARRIER_PIPE2)); 108 map.put(BARRIER_PIPE2, MSG.getString(BARRIER_PIPE2));
107 map.put(BARRIER_DITCH, MSG.getString(BARRIER_DITCH)); 109 map.put(BARRIER_DITCH, MSG.getString(BARRIER_DITCH));
108 map.put(BARRIER_DAM, MSG.getString(BARRIER_DAM)); 110 map.put(BARRIER_DAM, MSG.getString(BARRIER_DAM));
109 map.put(BARRIER_RINGDIKE, MSG.getString(BARRIER_RINGDIKE)); 111 map.put(BARRIER_RINGDIKE, MSG.getString(BARRIER_RINGDIKE));
110 112
111 LinkedHashMap<String, String> ics = new LinkedHashMap<String, String>(); 113 final LinkedHashMap<String, String> ics = new LinkedHashMap<String, String>();
112 ics.put(BARRIER_PIPE1, BARRIER_PIPE1); 114 ics.put(BARRIER_PIPE1, BARRIER_PIPE1);
113 ics.put(BARRIER_PIPE2, BARRIER_PIPE2); 115 ics.put(BARRIER_PIPE2, BARRIER_PIPE2);
114 ics.put(BARRIER_DITCH, BARRIER_DITCH); 116 ics.put(BARRIER_DITCH, BARRIER_DITCH);
115 ics.put(BARRIER_DAM, BARRIER_DAM); 117 ics.put(BARRIER_DAM, BARRIER_DAM);
116 ics.put(BARRIER_RINGDIKE, BARRIER_RINGDIKE); 118 ics.put(BARRIER_RINGDIKE, BARRIER_RINGDIKE);
117 119
118 SelectItem box = new SelectItem(FIELD_BARRIER_TYPE); 120 final SelectItem box = new SelectItem(FIELD_BARRIER_TYPE);
119 box.setTitle(""); 121 box.setTitle("");
120 box.setWidth(100); 122 box.setWidth(100);
121 box.setValueMap(map); 123 box.setValueMap(map);
122 box.setImageURLSuffix(".png"); 124 box.setImageURLSuffix(".png");
123 box.setValueIcons(ics); 125 box.setValueIcons(ics);
150 setCurrentType(evt.getVectorFeature()); 152 setCurrentType(evt.getVectorFeature());
151 } 153 }
152 154
153 155
154 protected void setCurrentType(VectorFeature feature) { 156 protected void setCurrentType(VectorFeature feature) {
155 Attributes attrs = feature.getAttributes(); 157 final Attributes attrs = feature.getAttributes();
156 String type = attrs.getAttributeAsString("typ"); 158 String type = attrs.getAttributeAsString("typ");
157 159
158 if (type == null || type.length() == 0) { 160 if (type == null || type.length() == 0) {
159 type = getSelectedType(); 161 type = getSelectedType();
160 162
161 Style style = FloodMap.getStyle(type); 163 final Style style = FloodMap.getStyle(type);
162 if (style != null) { 164 if (style != null) {
163 feature.setStyle(style); 165 feature.setStyle(style);
164 } 166 }
165 167
166 if (type.equals(BARRIER_PIPE1)) { 168 if (type.equals(BARRIER_PIPE1)) {
193 195
194 196
195 protected void setSelectedControl() { 197 protected void setSelectedControl() {
196 removeControl(); 198 removeControl();
197 199
198 String type = getSelectedType(); 200 final String type = getSelectedType();
199 201
200 if (type == null || type.length() == 0) { 202 if (type == null || type.length() == 0) {
201 return; 203 return;
202 } 204 }
203 205
208 control = createDrawLineControl(); 210 control = createDrawLineControl();
209 } 211 }
210 212
211 map.addControl(control); 213 map.addControl(control);
212 control.activate(); 214 control.activate();
215
216 // Make sure the barrier layer is on top; sometime it looses it z-index...
217 layer.setZIndex(1000);
213 } 218 }
214 219
215 220
216 protected Control createDrawControl(Handler handler) { 221 protected Control createDrawControl(Handler handler) {
217 return new DrawFeature(layer, handler); 222 return new DrawFeature(layer, handler);
227 return createDrawControl(new PathHandler()); 232 return createDrawControl(new PathHandler());
228 } 233 }
229 234
230 235
231 public void activate(boolean activate) { 236 public void activate(boolean activate) {
232 FormItem item = form.getField(FIELD_BARRIER_TYPE); 237 final FormItem item = form.getField(FIELD_BARRIER_TYPE);
233 238
234 if (activate) { 239 if (activate) {
235 button.select(); 240 button.select();
236 item.enable(); 241 item.enable();
237 setSelectedControl(); 242 setSelectedControl();

http://dive4elements.wald.intevation.org