# HG changeset patch # User Raimund Renkert # Date 1327481406 0 # Node ID 3e2ef8e0a0dc4a50a6e3ca29cbe7091468f848e5 # Parent 959e1d0df9417eb67123b74ae3fd5cbc4f6762f4 Issue 265. Deactivate measure control and scale line if the map output tab is not selected. flys-client/trunk@3761 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 959e1d0df941 -r 3e2ef8e0a0dc flys-client/ChangeLog --- a/flys-client/ChangeLog Wed Jan 25 08:42:46 2012 +0000 +++ b/flys-client/ChangeLog Wed Jan 25 08:50:06 2012 +0000 @@ -1,3 +1,16 @@ +2012-01-25 Raimund Renkert + + Issue 265. + + * src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java: + Added method to activate/deactivate scale line. The method removes the + control on deactivation and adds the control on activation. + + * src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java: + Implements TabSelectedHandler now. If the tab is selected, the scale line + and measure control are deactivated. Scale line is activated if the tab is + selected. + 2012-01-25 Felix Wolfsteller * src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java: diff -r 959e1d0df941 -r 3e2ef8e0a0dc 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 Wed Jan 25 08:42:46 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java Wed Jan 25 08:50:06 2012 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.client.client.ui.map; +import com.google.gwt.core.client.GWT; + import org.gwtopenmaps.openlayers.client.Bounds; import org.gwtopenmaps.openlayers.client.Map; @@ -19,6 +21,7 @@ import org.gwtopenmaps.openlayers.client.util.JObjectArray; import org.gwtopenmaps.openlayers.client.util.JSObject; import org.gwtopenmaps.openlayers.client.LonLat; +import org.gwtopenmaps.openlayers.client.ZIndexBase; public class FloodMap implements VectorFeatureAddedListener { @@ -34,7 +37,7 @@ protected Vector barrierLayer; protected String srid; protected Bounds maxExtent; - + protected ScaleLine scaleLine; public FloodMap(String srid, Bounds maxExtent) { this.srid = srid; @@ -51,14 +54,6 @@ mapWidget = new MapWidget("510px", "635px", opts); map = mapWidget.getMap(); - ScaleLineOptions slOpts = new ScaleLineOptions(); - slOpts.setBottomInUnits("m"); - slOpts.setBottomOutUnits("km"); - slOpts.setTopInUnits(""); - slOpts.setTopOutUnits(""); - - map.addControl(new ScaleLine(slOpts)); - getBarrierLayer(); } @@ -305,5 +300,22 @@ l.redraw(); } } + + + public void activateScaleLine(boolean activate) { + if (activate) { + ScaleLineOptions slOpts = new ScaleLineOptions(); + slOpts.setBottomInUnits("m"); + slOpts.setBottomOutUnits("km"); + slOpts.setTopInUnits(""); + slOpts.setTopOutUnits(""); + + scaleLine = new ScaleLine(slOpts); + this.map.addControl(scaleLine); + } + else if (!activate && scaleLine != null){ + this.map.removeControl(scaleLine); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 959e1d0df941 -r 3e2ef8e0a0dc 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 Wed Jan 25 08:42:46 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Wed Jan 25 08:50:06 2012 +0000 @@ -13,6 +13,8 @@ import com.smartgwt.client.widgets.events.ResizedHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; +import com.smartgwt.client.widgets.tab.events.TabSelectedEvent; import org.gwtopenmaps.openlayers.client.Bounds; import org.gwtopenmaps.openlayers.client.Map; @@ -61,7 +63,7 @@ public class MapOutputTab extends OutputTab -implements RedrawRequestHandler, ExternalWMSWindow.LayerLoader { +implements RedrawRequestHandler, ExternalWMSWindow.LayerLoader, TabSelectedHandler { public static final String DEFAULT_SRID = "4326"; @@ -99,6 +101,8 @@ ){ super(title, collection, collectionView, mode); + collectionView.registerTabHandler(this); + mapService.doOut(collection, new AsyncCallback() { public void onFailure(Throwable caught) { GWT.log("MAP ERROR: " + caught.getMessage()); @@ -537,5 +541,19 @@ } ); } + + + public void onTabSelected(TabSelectedEvent tse) { + if(floodMap == null) { + return; + } + if(this.equals(tse.getTab())) { + floodMap.activateScaleLine(true); + } + else { + controlPanel.activateMeasureControl(false); + floodMap.activateScaleLine(false); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :