# HG changeset patch # User Ingo Weinzierl # Date 1318501359 0 # Node ID 45b9b1fc26e2300058cdf0ff8aad6ec9d0af08c9 # Parent 956605001cfbcc903ad009afb36e4be5a393b36e Improved error handling while using the elevation control - Make selected features in the map visible. flys-client/trunk@2956 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 956605001cfb -r 45b9b1fc26e2 flys-client/ChangeLog --- a/flys-client/ChangeLog Thu Oct 13 09:46:03 2011 +0000 +++ b/flys-client/ChangeLog Thu Oct 13 10:22:39 2011 +0000 @@ -1,3 +1,20 @@ +2011-10-13 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java: + Moved code to mark features 'selected' to FloodMap. Display warnings if + elevation control is clicked but no feature is selected or more than one + feature is selected. + + * src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java: Do + the "select feature" stuff here. Selected features will now have a + fatter stroke. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties: + Added warning and error messages used when elevation control is used. + 2011-10-13 Sascha L, Teichmann Updated SmartGWT to 2.5 @@ -7,7 +24,7 @@ * src/main/java/de/intevation/flys/client/FLYS.gwt.xml: Using Enterprise instead of EnterpriseBlue theme. -2011-10-12 Ingo Weinzierl +2011-10-13 Ingo Weinzierl flys/issue297 (ÜSK: Eingabe von Höhen ermöglichen) diff -r 956605001cfb -r 45b9b1fc26e2 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Oct 13 09:46:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Oct 13 10:22:39 2011 +0000 @@ -390,6 +390,10 @@ String error_no_theme_styles_found(); + String error_no_feature_selected(); + + String warning_use_first_feature(); + String bottom_edge(); diff -r 956605001cfb -r 45b9b1fc26e2 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Oct 13 09:46:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Oct 13 10:22:39 2011 +0000 @@ -199,6 +199,8 @@ error_load_artifact = Error while adding data to the current project. error_no_calc_result=No calculation results found. error_no_theme_styles_found=No style for the selected theme found. +error_no_feature_selected = No object selected. +warning_use_first_feature = You have more that one object selected. The first one is used. ## map related strings digitize = images/digitize.png diff -r 956605001cfb -r 45b9b1fc26e2 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Oct 13 09:46:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Oct 13 10:22:39 2011 +0000 @@ -200,6 +200,8 @@ error_load_artifact = Fehler beim Hinzu\u00fcgen neuer Daten in das aktuelle Projekt. error_no_calc_result=Es wurden keine Berechnungsergebnisse gefunden. error_no_theme_styles_found=Es konnten keine Stile f\u00fcr das gew\u00e4hlte Thema gefunden werden. +error_no_feature_selected = Kein Objekt ausgew\u00e4hlt. +warning_use_first_feature = Sie haben mehr als ein Objekt ausgew\u00e4hlt. Das erste Objekt wird benutzt. ## map related strings digitize = images/digitize.png diff -r 956605001cfb -r 45b9b1fc26e2 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Thu Oct 13 09:46:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Thu Oct 13 10:22:39 2011 +0000 @@ -194,6 +194,8 @@ error_load_artifact = Error while adding data to the current project. error_no_calc_result=No calculation results found. error_no_theme_styles_found=No style for the selected theme found. +error_no_feature_selected = No object selected. +warning_use_first_feature = You have more that one object selected. The first one is used. ## map related strings digitize = images/digitize.png diff -r 956605001cfb -r 45b9b1fc26e2 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java Thu Oct 13 09:46:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java Thu Oct 13 10:22:39 2011 +0000 @@ -22,6 +22,8 @@ public static final String MARK_SELECTED = "mark.selected"; + public static final int SELECTED_STROKE_WIDTH = 2; + protected MapWidget mapWidget; protected Map map; protected Vector barrierLayer; @@ -158,6 +160,9 @@ public String getFeaturesAsGeoJSON() { + // disable features before exporting to GeoJSON + disableFeatures(); + VectorFeature[] features = barrierLayer.getFeatures(); if (features == null || features.length == 0) { @@ -185,5 +190,79 @@ barrierLayer.setIsVisible(true); } } + + + public void selectFeature(VectorFeature feature) { + if (feature != null) { + selectFeatures(new VectorFeature[] { feature } ); + } + } + + + public void selectFeatures(VectorFeature[] features) { + if (features == null || features.length == 0) { + return; + } + + for (VectorFeature feature: features) { + Attributes attr = feature.getAttributes(); + + if (attr.getAttributeAsInt(MARK_SELECTED) == 1) { + continue; + } + + attr.setAttribute(MARK_SELECTED, 1); + + Style style = feature.getStyle(); + double strokeWidth = style.getStrokeWidth(); + + style.setStrokeWidth(strokeWidth+SELECTED_STROKE_WIDTH); + } + + getBarrierLayer().redraw(); + } + + + public void disableFeatures() { + Vector barriers = getBarrierLayer(); + VectorFeature[] features = barriers.getFeatures(); + + if (features == null || features.length == 0) { + return; + } + + disableFeatures(features); + } + + + public void disableFeature(VectorFeature feature) { + if (feature != null) { + disableFeatures(new VectorFeature[] { feature }); + } + } + + + public void disableFeatures(VectorFeature[] features) { + if (features == null || features.length == 0) { + return; + } + + for (VectorFeature feature: features) { + Attributes attr = feature.getAttributes(); + + if (attr.getAttributeAsInt(MARK_SELECTED) == 0) { + continue; + } + + attr.setAttribute(FloodMap.MARK_SELECTED, 0); + + Style style = feature.getStyle(); + double strokeWidth = style.getStrokeWidth(); + + style.setStrokeWidth(strokeWidth-SELECTED_STROKE_WIDTH); + } + + getBarrierLayer().redraw(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 956605001cfb -r 45b9b1fc26e2 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java Thu Oct 13 09:46:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java Thu Oct 13 10:22:39 2011 +0000 @@ -311,15 +311,13 @@ // still has no selected features. opts.onSelect(new SelectFeature.SelectFeatureListener() { public void onFeatureSelected(VectorFeature feature) { - Attributes attr = feature.getAttributes(); - attr.setAttribute(FloodMap.MARK_SELECTED, 1); + floodMap.selectFeature(feature); } }); opts.onUnSelect(new SelectFeature.UnselectFeatureListener() { public void onFeatureUnselected(VectorFeature feature) { - Attributes attr = feature.getAttributes(); - attr.setAttribute(FloodMap.MARK_SELECTED, 0); + floodMap.disableFeature(feature); } }); @@ -337,6 +335,7 @@ public void disable() { activateSelectFeature(false); + floodMap.disableFeatures(); } }; @@ -386,10 +385,12 @@ VectorFeature feature = null; if (features == null || features.length == 0) { - SC.warn("No Feature selected!"); + SC.warn(MSG.error_no_feature_selected()); return; } + boolean multipleFeatures = false; + for (VectorFeature f: features) { Attributes attr = f.getAttributes(); if (attr.getAttributeAsInt(FloodMap.MARK_SELECTED) == 1) { @@ -397,12 +398,21 @@ feature = f; } else { - SC.warn("More than 1 Feature selected!"); + multipleFeatures = true; } } } + if (feature == null) { + SC.warn(MSG.error_no_feature_selected()); + return; + } + new ElevationWindow(floodMap, feature).show(); + + if (multipleFeatures) { + SC.warn(MSG.warning_use_first_feature()); + } } });