# HG changeset patch # User Ingo Weinzierl # Date 1320061962 0 # Node ID b0fe35d4ce6bb3448628041d45c62ced15aa76e0 # Parent 28eb4dfe2cbfcf5cd2aee7b2ec5a06248f148df1 Added a 'zoom to layer' menu item to the map theme panel which triggers a zoom to the specific layer/theme. flys-client/trunk@3122 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 28eb4dfe2cbf -r b0fe35d4ce6b flys-client/ChangeLog --- a/flys-client/ChangeLog Fri Oct 28 06:12:51 2011 +0000 +++ b/flys-client/ChangeLog Mon Oct 31 11:52:42 2011 +0000 @@ -1,3 +1,21 @@ +2011-10-31 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java: + Override getSingleContextMenu() to add a "zoom to layer" menu item which + is specific to the map. This menu item is displayed if the specific theme + has an "extent" attribute set. If the item is clicked, the + LayerZoomCallback is called. + + * src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java: + Implements the LayerZoomCallback to zoom to the extent of a specific + layer. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java: Added + strings for the "zoom to layer" menu item. + 2011-10-28 Ingo Weinzierl * src/main/java/de/intevation/flys/client/server/MapHelper.java: New. It diff -r 28eb4dfe2cbf -r b0fe35d4ce6b 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 Fri Oct 28 06:12:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Oct 31 11:52:42 2011 +0000 @@ -456,6 +456,8 @@ String map_themepanel_header_style(); + String zoomToLayer(); + // data cage String old_calculations(); diff -r 28eb4dfe2cbf -r b0fe35d4ce6b 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 Fri Oct 28 06:12:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Oct 31 11:52:42 2011 +0000 @@ -230,6 +230,7 @@ measureDistance = Measure line measureArea = Measure area map_themepanel_header_style = Style +zoomToLayer = Layer-Zoom # data cage old_calculations = Alte Berechnungen diff -r 28eb4dfe2cbf -r b0fe35d4ce6b 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 Fri Oct 28 06:12:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Oct 31 11:52:42 2011 +0000 @@ -231,6 +231,7 @@ measureDistance = L\u00e4ngenmessung measureArea = Streckenmessung map_themepanel_header_style = Stil +zoomToLayer = Layer-Zoom # data cage old_calculations = Alte Berechnungen diff -r 28eb4dfe2cbf -r b0fe35d4ce6b 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 Fri Oct 28 06:12:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Oct 31 11:52:42 2011 +0000 @@ -225,6 +225,7 @@ measureDistance = Measure line measureArea = Measure area map_themepanel_header_style = Style +zoomToLayer = Layer-Zoom # data cage old_calculations = Former calculations diff -r 28eb4dfe2cbf -r b0fe35d4ce6b flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Fri Oct 28 06:12:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Mon Oct 31 11:52:42 2011 +0000 @@ -401,6 +401,18 @@ map.zoomTo(map.getZoom()-1); map.zoomTo(map.getZoom()+1); } + }, + new MapThemePanel.LayerZoomCallback() { + public void onLayerZoom(Theme theme, String extent) { + Bounds zoomTo = boundsFromString(extent); + + if (zoomTo == null) { + GWT.log("WARNING: No valid bounds for zooming found!"); + return; + } + + getMap().zoomToExtent(zoomTo); + } } ); c.addChild(themePanel); diff -r 28eb4dfe2cbf -r b0fe35d4ce6b flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java Fri Oct 28 06:12:51 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java Mon Oct 31 11:52:42 2011 +0000 @@ -12,6 +12,10 @@ import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.menu.Menu; +import com.smartgwt.client.widgets.menu.MenuItem; +import com.smartgwt.client.widgets.menu.events.ClickHandler; +import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; import de.intevation.flys.client.shared.MapUtils; import de.intevation.flys.client.shared.model.AttributedTheme; @@ -42,6 +46,10 @@ void onThemeMoved(Theme theme, int oldIdx, int newIdx); } + public interface LayerZoomCallback { + void onLayerZoom(Theme theme, String extent); + } + private FLYSConstants MSG = GWT.create(FLYSConstants.class); @@ -49,6 +57,7 @@ protected ActivateCallback activateCallback; protected ThemeMovedCallback themeMovedCallback; + protected LayerZoomCallback layerZoomCallback; public static final String GRID_FIELD_ACTIVE = "active"; @@ -64,7 +73,7 @@ OutputMode mode, ActivateCallback activateCallback ) { - this(collection, mode, activateCallback, null); + this(collection, mode, activateCallback, null, null); } @@ -72,12 +81,14 @@ Collection collection, OutputMode mode, ActivateCallback activateCallback, - ThemeMovedCallback themeMovedCallback + ThemeMovedCallback themeMovedCallback, + LayerZoomCallback layerZoomCallback ) { super(collection, mode); this.activateCallback = activateCallback; this.themeMovedCallback = themeMovedCallback; + this.layerZoomCallback = layerZoomCallback; initGrid(); initLayout(); @@ -173,6 +184,43 @@ @Override + protected Menu getSingleContextMenu(final ListGridRecord[] records) { + Menu menu = super.getSingleContextMenu(records); + + MenuItem layerZoom = createLayerZoomItem(records); + if (layerZoom != null) { + menu.addItem(layerZoom); + } + + return menu; + } + + + protected MenuItem createLayerZoomItem(final ListGridRecord[] recs) { + final FacetRecord fr = (FacetRecord) recs[0]; + final AttributedTheme at = (AttributedTheme) fr.getTheme(); + + final String extent = at.getAttr("extent"); + + if (extent == null || extent.length() == 0) { + return null; + } + + MenuItem zoom = new MenuItem(MSG.zoomToLayer()); + zoom.addClickHandler(new ClickHandler() { + @Override + public void onClick(MenuItemClickEvent evt) { + if (layerZoomCallback != null) { + layerZoomCallback.onLayerZoom(at, extent); + } + } + }); + + return zoom; + } + + + @Override public void activateTheme(Theme theme, boolean active) { if (activateCallback != null) { activateCallback.activate(theme, active);