# HG changeset patch # User Ingo Weinzierl # Date 1319463330 0 # Node ID 9981ba2ee13ab22b4171ceaeaabdb0d1af65bba8 # Parent 9da7fdfbb80e95b3842ea4f708fb620fdc039882 Display the datacage button in the map toolbar. flys-client/trunk@3063 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 9da7fdfbb80e -r 9981ba2ee13a flys-client/ChangeLog --- a/flys-client/ChangeLog Mon Oct 24 10:53:39 2011 +0000 +++ b/flys-client/ChangeLog Mon Oct 24 13:35:30 2011 +0000 @@ -1,3 +1,21 @@ +2011-10-24 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/Toolbar.java: New. An + abstract toolbar that acts as parent for ChartToolbar and MapToolbar. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java, + src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java: + Subclass Toolbar which now makes the datacage stuff. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java, + src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java: + Adjusted the constructor call of OutputTab which now takes an instance + of CollectionView. + + * src/main/java/de/intevation/flys/client/client/ui/OutputTab.java: Stores + an instance of CollectionView and implements methods to retrieve the + current user and artifact. + 2011-10-24 Felix Wolfsteller Replaced icons white by a transparent background. diff -r 9da7fdfbb80e -r 9981ba2ee13a flys-client/src/main/java/de/intevation/flys/client/client/ui/OutputTab.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/OutputTab.java Mon Oct 24 10:53:39 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/OutputTab.java Mon Oct 24 13:35:30 2011 +0000 @@ -3,6 +3,7 @@ import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.tab.Tab; +import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.OutputMode; @@ -15,6 +16,9 @@ /** The Collection that should be displayed in this tab.*/ protected Collection collection; + /** The CollectionView. */ + protected CollectionView collectionView; + /** * The default constructor that creates a new Tab for displaying a specific @@ -24,18 +28,34 @@ * @param collection The collection that need to be displayed. * @param outputmode The OutputMode that need to be displayed. */ - public OutputTab(String title, Collection collection, OutputMode mode) { + public OutputTab( + String title, + Collection collection, + CollectionView collectionView, + OutputMode mode + ) { super(title); - this.collection = collection; - this.mode = mode; + this.collection = collection; + this.mode = mode; + this.collectionView = collectionView; setPane(new Label("Implement concrete subclasses to vary the output.")); } + public CollectionView getCollectionView() { + return collectionView; + } + + public String getOutputName() { return mode.getName(); } + + + public Artifact getArtifact() { + return getCollectionView().getArtifact(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 9da7fdfbb80e -r 9981ba2ee13a flys-client/src/main/java/de/intevation/flys/client/client/ui/Toolbar.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/Toolbar.java Mon Oct 24 13:35:30 2011 +0000 @@ -0,0 +1,57 @@ +package de.intevation.flys.client.client.ui; + +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.events.CloseClickHandler; +import com.smartgwt.client.widgets.events.CloseClientEvent; + +import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.shared.model.User; + +import de.intevation.flys.client.client.event.RedrawRequestHandler; + + +public abstract class Toolbar extends HLayout { + + protected OutputTab outputTab; + + + public Toolbar(OutputTab outputTab) { + super(); + + this.outputTab = outputTab; + } + + + public OutputTab getOutputTab() { + return outputTab; + } + + + public Artifact getArtifact() { + return outputTab.getCollectionView().getArtifact(); + } + + + public User getUser() { + return outputTab.getCollectionView().getUser(); + } + + + protected void openDatacageWindow(RedrawRequestHandler handler) { + Artifact artifact = getArtifact(); + User user = getUser(); + + String outs = getOutputTab().getOutputName(); + + final DatacageWindow dc = new DatacageWindow( + artifact, user, outs, outputTab.getCollectionView()); + dc.addRedrawRequestHandler(handler); + dc.addCloseClickHandler(new CloseClickHandler() { + public void onCloseClick(CloseClientEvent event) { + dc.destroy(); + } + }); + dc.show(); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 9da7fdfbb80e -r 9981ba2ee13a flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Mon Oct 24 10:53:39 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java Mon Oct 24 13:35:30 2011 +0000 @@ -109,7 +109,7 @@ OutputMode mode, CollectionView collectionView ){ - super(title, collection, mode); + super(title, collection, collectionView, mode); view = collectionView; left = new Canvas(); diff -r 9da7fdfbb80e -r 9981ba2ee13a flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java Mon Oct 24 10:53:39 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java Mon Oct 24 13:35:30 2011 +0000 @@ -6,26 +6,20 @@ import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.ImgButton; import com.smartgwt.client.widgets.Label; -import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.events.CloseClickHandler; -import com.smartgwt.client.widgets.events.CloseClientEvent; - -import de.intevation.flys.client.shared.model.Artifact; -import de.intevation.flys.client.shared.model.User; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.FLYSImages; import de.intevation.flys.client.client.ui.CollectionView; -import de.intevation.flys.client.client.ui.DatacageWindow; import de.intevation.flys.client.client.ui.ImgLink; +import de.intevation.flys.client.client.ui.Toolbar; /** * @author Ingo Weinzierl */ -public class ChartToolbar extends HLayout { +public class ChartToolbar extends Toolbar { protected static FLYSConstants MSG = GWT.create(FLYSConstants.class); @@ -35,8 +29,6 @@ public static final int PANEL_HEIGHT = 30; - protected CollectionView view; - protected ChartOutputTab chartTab; @@ -63,11 +55,9 @@ public ChartToolbar(CollectionView view, ChartOutputTab chartTab) { - super(); + super(chartTab); - this.view = view; this.chartTab = chartTab; - datacage = new Button(MSG.databasket()); position = new MousePositionPanel(chartTab); zoombox = new ZoomboxControl(chartTab, MSG.zoom_in()); @@ -79,7 +69,7 @@ datacage.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { GWT.log("Clicked 'datacage' button."); - openDatacageWindow(); + openDatacageWindow((ChartOutputTab) getOutputTab()); } }); @@ -166,15 +156,6 @@ } - public Artifact getArtifact() { - return view.getArtifact(); - } - - public User getUser() { - return view.getUser(); - } - - public ChartOutputTab getChartOutputTab() { return chartTab; } @@ -204,23 +185,5 @@ addMember(spacer); addMember(position); } - - - protected void openDatacageWindow() { - Artifact artifact = getArtifact(); - User user = getUser(); - - String outs = chartTab.getOutputName(); - - final DatacageWindow dc = new DatacageWindow( - artifact, user, outs, view); - dc.addRedrawRequestHandler(chartTab); - dc.addCloseClickHandler(new CloseClickHandler() { - public void onCloseClick(CloseClientEvent event) { - dc.destroy(); - } - }); - dc.show(); - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 9da7fdfbb80e -r 9981ba2ee13a 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 Mon Oct 24 10:53:39 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Mon Oct 24 13:35:30 2011 +0000 @@ -43,12 +43,14 @@ import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.services.StepForwardService; import de.intevation.flys.client.client.services.StepForwardServiceAsync; +import de.intevation.flys.client.client.event.RedrawRequestHandler; +import de.intevation.flys.client.client.event.RedrawRequestEvent; import de.intevation.flys.client.client.ui.CollectionView; import de.intevation.flys.client.client.ui.OutputTab; import de.intevation.flys.client.client.ui.ThemePanel; -public class MapOutputTab extends OutputTab { +public class MapOutputTab extends OutputTab implements RedrawRequestHandler { public static final String DEFAULT_SRID = "4326"; @@ -60,8 +62,6 @@ protected StepForwardServiceAsync feedService = GWT.create(StepForwardService.class); - protected CollectionView parent; - protected MapToolbar controlPanel; protected ThemePanel themePanel; protected Widget mapPanel; @@ -75,8 +75,7 @@ OutputMode mode, CollectionView collectionView ){ - super(title, collection, mode); - this.parent = collectionView; + super(title, collection, collectionView, mode); floodMap = new FloodMap(getSrid(), getMaxExtent()); @@ -231,6 +230,13 @@ } + @Override + public void onRedrawRequest(RedrawRequestEvent event) { + // TODO FILL ME + GWT.log("TODO: Request redraw."); + } + + protected Map getMap() { return floodMap.getMap(); } @@ -267,11 +273,6 @@ } - public Artifact getArtifact() { - return parent.getArtifact(); - } - - public ThemeList getThemeList() { return collection.getThemeList(mode.getName()); } @@ -395,7 +396,7 @@ protected MapToolbar createControlPanel(Canvas wrapper) { - return new MapToolbar(floodMap, wrapper, false); + return new MapToolbar(this, floodMap, wrapper, false); } diff -r 9da7fdfbb80e -r 9981ba2ee13a 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 Mon Oct 24 10:53:39 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java Mon Oct 24 13:35:30 2011 +0000 @@ -4,11 +4,11 @@ import com.smartgwt.client.types.SelectionType; import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.ImgButton; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; -import com.smartgwt.client.widgets.layout.HLayout; import org.gwtopenmaps.openlayers.client.Map; import org.gwtopenmaps.openlayers.client.control.DragPan; @@ -20,13 +20,14 @@ import org.gwtopenmaps.openlayers.client.util.Attributes; import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.ui.Toolbar; import de.intevation.flys.client.client.utils.EnableDisableCmd; /** * @author Ingo Weinzierl */ -public class MapToolbar extends HLayout { +public class MapToolbar extends Toolbar { protected FLYSConstants MSG = GWT.create(FLYSConstants.class); @@ -35,6 +36,8 @@ protected ZoomBox zoomBox; protected SelectFeature selectFeature; + protected Button datacageButton; + protected ImgButton zoomToMaxButton; protected ImgButton zoomBoxButton; protected ImgButton zoomOutButton; @@ -49,13 +52,23 @@ protected Canvas position; - public MapToolbar(FloodMap floodMap, Canvas wrapper) { - this(floodMap, wrapper, true); + public MapToolbar(MapOutputTab mapTab, FloodMap floodMap, Canvas wrapper) { + this(mapTab, floodMap, wrapper, true); } public MapToolbar(FloodMap floodMap, Canvas wrapper, boolean digitize) { - super(); + this(null, floodMap, wrapper, digitize); + } + + + public MapToolbar( + MapOutputTab mapTab, + FloodMap floodMap, + Canvas wrapper, + boolean digitize) + { + super(mapTab); setWidth100(); setHeight(30); @@ -79,6 +92,11 @@ removeButton = createRemoveFeatureControl(); elevationButton = createElevationControl(); + if (mapTab != null) { + datacageButton = createDatacageControl(); + addMember(datacageButton); + } + addMember(zoomToMaxButton); addMember(zoomBoxButton); addMember(zoomOutButton); @@ -443,5 +461,17 @@ return new MeasureControl(floodMap, cmd); } + + + protected Button createDatacageControl() { + Button btn = new Button(MSG.databasket()); + btn.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent evt) { + openDatacageWindow((MapOutputTab) getOutputTab()); + } + }); + + return btn; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :