Mercurial > dive4elements > river
diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapOutputTab.java @ 9483:992c188b7330
wms uinfo.inundation
author | gernotbelger |
---|---|
date | Thu, 13 Sep 2018 18:22:05 +0200 |
parents | 5e38e2924c07 |
children | 5397555d74c9 |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapOutputTab.java Wed Sep 12 12:50:28 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapOutputTab.java Thu Sep 13 18:22:05 2018 +0200 @@ -8,19 +8,8 @@ package org.dive4elements.river.client.client.ui.map; -import com.google.gwt.core.client.GWT; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.AbsolutePanel; -import com.smartgwt.client.util.SC; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.events.ParentMovedEvent; -import com.smartgwt.client.widgets.events.ParentMovedHandler; -import com.smartgwt.client.widgets.events.ResizedEvent; -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.TabSelectedEvent; -import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; +import java.util.HashMap; +import java.util.List; import org.dive4elements.river.client.client.Config; import org.dive4elements.river.client.client.FLYSConstants; @@ -52,10 +41,6 @@ import org.dive4elements.river.client.shared.model.Theme; import org.dive4elements.river.client.shared.model.ThemeList; import org.dive4elements.river.client.shared.model.WMSLayer; - -import java.util.HashMap; -import java.util.List; - import org.gwtopenmaps.openlayers.client.Bounds; import org.gwtopenmaps.openlayers.client.Map; import org.gwtopenmaps.openlayers.client.MapWidget; @@ -70,11 +55,21 @@ import org.gwtopenmaps.openlayers.client.layer.WMSOptions; import org.gwtopenmaps.openlayers.client.layer.WMSParams; +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.AbsolutePanel; +import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.events.ParentMovedEvent; +import com.smartgwt.client.widgets.events.ParentMovedHandler; +import com.smartgwt.client.widgets.events.ResizedEvent; +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.TabSelectedEvent; +import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; -public class MapOutputTab -extends OutputTab -implements RedrawRequestHandler, ExternalWMSWindow.LayerLoader, - TabSelectedHandler, OutputParameterChangeHandler { +public class MapOutputTab extends OutputTab implements RedrawRequestHandler, ExternalWMSWindow.LayerLoader, TabSelectedHandler, OutputParameterChangeHandler { public static final String DEFAULT_SRID = "4326"; @@ -84,179 +79,151 @@ public static final String EXTERNAL_WMS_FACTORY = "externalwmsfactory"; + protected StepForwardServiceAsync feedService = GWT.create(StepForwardService.class); - protected StepForwardServiceAsync feedService = - GWT.create(StepForwardService.class); - - protected MapOutputServiceAsync mapService = - GWT.create(MapOutputService.class); + protected MapOutputServiceAsync mapService = GWT.create(MapOutputService.class); /** Service handle to clone and add artifacts to collection. */ - protected LoadArtifactServiceAsync loadArtifactService = - GWT.create(LoadArtifactService.class); + protected LoadArtifactServiceAsync loadArtifactService = GWT.create(LoadArtifactService.class); protected FLYSConstants MSG = GWT.create(FLYSConstants.class); protected MapToolbar controlPanel; protected ThemePanel themePanel; - protected Canvas themePanelCanvas; - protected MapWidget mapPanel; + protected Canvas themePanelCanvas; + protected MapWidget mapPanel; protected Canvas mapPanelCanvas; protected VLayout rootLayout = new VLayout(); protected AbsolutePanel absPan = new AbsolutePanel(); protected FloodMap floodMap; - protected java.util.Map<String, String> wmsUrls = - new HashMap<String, String>(); - - public MapOutputTab( - String title, - Collection collection, - OutputMode mode, - CollectionView collectionView - ){ + private final java.util.Map<String, String> wmsUrls = new HashMap<String, String>(); + + public MapOutputTab(final String title, final Collection collection, final OutputMode mode, final CollectionView collectionView) { super(title, collection, collectionView, mode); collectionView.registerTabHandler(this); - mapService.doOut(collection, new AsyncCallback<MapConfig>() { - @Override - public void onFailure(Throwable caught) { - GWT.log("MAP ERROR: " + caught.getMessage()); + this.mapService.doOut(collection, new AsyncCallback<MapConfig>() { + @Override + public void onFailure(final Throwable caught) { + GWT.log("MAP ERROR: " + caught.getMessage()); + } + + @Override + public void onSuccess(final MapConfig c) { + GWT.log("MAP SUCCESS!"); + + final Bounds max = boundsFromString(c.getMaxExtent()); + Bounds initial = boundsFromString(c.getInitialExtent()); + + if (initial == null) { + GWT.log("Warning: No initial extent set."); + initial = max; } - @Override - public void onSuccess(MapConfig c) { - GWT.log("MAP SUCCESS!"); - - Bounds max = boundsFromString(c.getMaxExtent()); - Bounds initial = boundsFromString(c.getInitialExtent()); + setFloodmap(new FloodMap(c.getSrid(), max, 640, 480)); - if (initial == null) { - GWT.log("Warning: No initial extent set."); - initial = max; - } - - setFloodmap(new FloodMap(c.getSrid(), max, 640, 480)); + initLayout(); + initBarriers(); - initLayout(); - initBarriers(); - - GWT.log("MAX EXTENT: " + max); - GWT.log("ZOOM TO: " + initial); - getMap().zoomToExtent(initial); - } + GWT.log("MAX EXTENT: " + max); + GWT.log("ZOOM TO: " + initial); + getMap().zoomToExtent(initial); } - ); + }); } - protected void initLayout() { - rootLayout.setHeight100(); - rootLayout.setWidth100(); - rootLayout.setMembersMargin(2); + this.rootLayout.setHeight100(); + this.rootLayout.setWidth100(); + this.rootLayout.setMembersMargin(2); - HLayout hlayout = new HLayout(); + final HLayout hlayout = new HLayout(); hlayout.setMembersMargin(0); this.themePanelCanvas = createThemePanel(); - controlPanel = createControlPanel(); - mapPanel = floodMap.getMapWidget(); + this.controlPanel = createControlPanel(); + this.mapPanel = this.floodMap.getMapWidget(); - rootLayout.addMember(controlPanel); - rootLayout.addMember(absPan); - absPan.setWidth("100%"); - absPan.setHeight("100%"); - absPan.add(themePanelCanvas); - absPan.add(mapPanel); + this.rootLayout.addMember(this.controlPanel); + this.rootLayout.addMember(this.absPan); + this.absPan.setWidth("100%"); + this.absPan.setHeight("100%"); + this.absPan.add(this.themePanelCanvas); + this.absPan.add(this.mapPanel); - rootLayout.addResizedHandler(new ResizedHandler() { + this.rootLayout.addResizedHandler(new ResizedHandler() { @Override - public void onResized(ResizedEvent e) { + public void onResized(final ResizedEvent e) { doLayout(); } }); - rootLayout.addParentMovedHandler(new ParentMovedHandler() { + this.rootLayout.addParentMovedHandler(new ParentMovedHandler() { @Override - public void onParentMoved(ParentMovedEvent event) { - mapPanel.getMap().updateSize(); + public void onParentMoved(final ParentMovedEvent event) { + MapOutputTab.this.mapPanel.getMap().updateSize(); } }); - setPane(rootLayout); + setPane(this.rootLayout); } - protected void doLayout() { - if(!rootLayout.isVisible()) { + if (!this.rootLayout.isVisible()) { return; } // Manually set the height of the AbsolutePanel, // somehow this is necessary - absPan.setHeight(String.valueOf( - rootLayout.getHeight() - controlPanel.getHeight() - 2) + "px"); + this.absPan.setHeight(String.valueOf(this.rootLayout.getHeight() - this.controlPanel.getHeight() - 2) + "px"); // Calculate bounds of Map - int height = rootLayout.getHeight() - - controlPanel.getHeight() - 6; - int width = controlPanel.getWidth() - - (themePanelCanvas.isVisible() - ? themePanelCanvas.getWidth() + 4 - : 2); + final int height = this.rootLayout.getHeight() - this.controlPanel.getHeight() - 6; + final int width = this.controlPanel.getWidth() - (this.themePanelCanvas.isVisible() ? this.themePanelCanvas.getWidth() + 4 : 2); // Set size and position of Map - String w = String.valueOf(width) + "px"; - String h = String.valueOf(height) + "px"; + final String w = String.valueOf(width) + "px"; + final String h = String.valueOf(height) + "px"; GWT.log("width=" + w); - mapPanel.setSize(w, h); - mapPanel.getMap().updateSize(); - if(themePanelCanvas.isVisible()) { - absPan.setWidgetPosition( - mapPanel, themePanelCanvas.getWidth() + 2, 0); - } - else { - absPan.setWidgetPosition(mapPanel, 0, 0); + this.mapPanel.setSize(w, h); + this.mapPanel.getMap().updateSize(); + if (this.themePanelCanvas.isVisible()) { + this.absPan.setWidgetPosition(this.mapPanel, this.themePanelCanvas.getWidth() + 2, 0); + } else { + this.absPan.setWidgetPosition(this.mapPanel, 0, 0); } // Set bounds of ThemePanelCanvas - themePanelCanvas.setSize( - themePanelCanvas.getWidthAsString(), - String.valueOf(height + 2) + "px"); + this.themePanelCanvas.setSize(this.themePanelCanvas.getWidthAsString(), String.valueOf(height + 2) + "px"); } - protected void initBarriers() { - Vector vector = floodMap.getBarrierLayer(); - vector.addVectorFeatureAddedListener( - new VectorFeatureAddedListener() { - @Override - public void onFeatureAdded(FeatureAddedEvent e) { - saveBarriers(); - } + final Vector vector = this.floodMap.getBarrierLayer(); + vector.addVectorFeatureAddedListener(new VectorFeatureAddedListener() { + @Override + public void onFeatureAdded(final FeatureAddedEvent e) { + saveBarriers(); } - ); + }); - vector.addVectorFeatureRemovedListener( - new VectorFeatureRemovedListener() { - @Override - public void onFeatureRemoved(FeatureRemovedEvent e) { - saveBarriers(); - } + vector.addVectorFeatureRemovedListener(new VectorFeatureRemovedListener() { + @Override + public void onFeatureRemoved(final FeatureRemovedEvent e) { + saveBarriers(); } - ); + }); - - Artifact artifact = getArtifact(); + final Artifact artifact = getArtifact(); if (artifact == null) { return; } - ArtifactDescription desc = artifact.getArtifactDescription(); + final ArtifactDescription desc = artifact.getArtifactDescription(); String geojson = getGeoJSONFromStatic(desc); geojson = geojson != null ? geojson : getGeoJSONFromDynamic(desc); @@ -266,128 +233,122 @@ return; } - GeoJSON reader = new GeoJSON(); - VectorFeature[] features = reader.read(geojson); + final GeoJSON reader = new GeoJSON(); + final VectorFeature[] features = reader.read(geojson); vector.addFeatures(features); } + public void addLayer(final Theme newTheme) { - public void addLayer(Layer layer) { - FloodMap map = getFloodmap(); + final Layer layer = createWMSLayer(newTheme); + + final FloodMap map = getFloodmap(); if (map != null) { GWT.log("Add new layer '" + layer.getName() + "' to map."); map.addLayer(layer); if (layer instanceof WMS) { - wmsUrls.put(layer.getName(), - ((WMS)layer).getFullRequestString(new WMSParams(), null)); + this.wmsUrls.put(layer.getName(), ((WMS) layer).getFullRequestString(new WMSParams(), null)); } } } - - public void removeLayer(String name) { - Map map = getMap(); + public void removeLayer(final Theme theme) { - Layer[] layers = map.getLayers(); + final String layerId = getLayerId(theme); - for (Layer layer: layers) { - if (name.equals(layer.getName())) { + final Map map = getMap(); + + final Layer[] layers = map.getLayers(); + + for (final Layer layer : layers) { + if (layerId.equals(layer.getName())) { map.removeLayer(layer); } } } - @Override - public void onRedrawRequest(RedrawRequestEvent event) { - mapService.doOut(collection, new AsyncCallback<MapConfig>() { + public void onRedrawRequest(final RedrawRequestEvent event) { + this.mapService.doOut(this.collection, new AsyncCallback<MapConfig>() { @Override - public void onFailure(Throwable caught) { + public void onFailure(final Throwable caught) { GWT.log("MAP ERROR: " + caught.getMessage()); } @Override - public void onSuccess(MapConfig c) { + public void onSuccess(final MapConfig c) { GWT.log("We want to refresh the map now!"); - themePanel.updateCollection(); + MapOutputTab.this.themePanel.updateCollection(); getFloodmap().update(); } }); } - @Override - public void load(List<WMSLayer> toLoad) { + public void load(final List<WMSLayer> toLoad) { GWT.log("The user wants to add " + toLoad.size() + " new WMS layers."); - int len = toLoad.size(); + final int len = toLoad.size(); - Recommendation[] recom = new Recommendation[len]; + final Recommendation[] recom = new Recommendation[len]; for (int i = 0; i < len; i++) { - WMSLayer w = toLoad.get(i); + final WMSLayer w = toLoad.get(i); - String ids = w.getServer() + ";" + w.getName() + ";" + w.getTitle(); + final String ids = w.getServer() + ";" + w.getName() + ";" + w.getTitle(); recom[i] = new Recommendation(EXTERNAL_WMS_FACTORY, ids); } - Collection c = getCollection(); - - Config config = Config.getInstance(); - String locale = config.getLocale(); - - loadArtifactService.loadMany(c, recom, EXTERNAL_WMS_FACTORY, locale, - new AsyncCallback<Artifact[]>() { + final Collection c = getCollection(); - @Override - public void onFailure(Throwable throwable) { - SC.warn(MSG.getString(throwable.getMessage())); - } + final Config config = Config.getInstance(); + final String locale = config.getLocale(); - @Override - public void onSuccess(Artifact[] newArtifacts) { - getThemePanel().updateCollection(); - } + this.loadArtifactService.loadMany(c, recom, EXTERNAL_WMS_FACTORY, locale, new AsyncCallback<Artifact[]>() { + + @Override + public void onFailure(final Throwable throwable) { + SC.warn(MapOutputTab.this.MSG.getString(throwable.getMessage())); } - ); + + @Override + public void onSuccess(final Artifact[] newArtifacts) { + getThemePanel().updateCollection(); + } + }); } - - protected void setFloodmap(FloodMap floodMap) { + protected void setFloodmap(final FloodMap floodMap) { this.floodMap = floodMap; } - protected FloodMap getFloodmap() { - return floodMap; + return this.floodMap; } - protected Map getMap() { - return floodMap.getMap(); + return this.floodMap.getMap(); } - protected ThemePanel getThemePanel() { - return themePanel; + return this.themePanel; } - - protected String getGeoJSONFromDynamic(ArtifactDescription desc) { - DataList list = desc.getCurrentData(); + protected String getGeoJSONFromDynamic(final ArtifactDescription desc) { + final DataList list = desc.getCurrentData(); if (list == null) { return null; } - List<Data> datas = list.getAll(); - for (Data data: datas) { - String key = data.getLabel(); + final List<Data> datas = list.getAll(); + for (final Data data : datas) { + final String key = data.getLabel(); if (key != null && key.equals(BARRIERS_PARAMETER_KEY)) { - DataItem def = data.getDefault(); + final DataItem def = data.getDefault(); if (def != null) { return def.getStringValue(); @@ -398,32 +359,29 @@ return null; } - - protected String getGeoJSONFromStatic(ArtifactDescription desc) { + protected String getGeoJSONFromStatic(final ArtifactDescription desc) { // TODO Implement this method, if there are reachable states right after // the floodmap state - which is currently not the case. return null; } - public ThemeList getThemeList() { - return collection.getThemeList(mode.getName()); + return this.collection.getThemeList(this.mode.getName()); } - public String getSrid() { - ThemeList themeList = getThemeList(); + final ThemeList themeList = getThemeList(); - int num = themeList.getThemeCount(); + final int num = themeList.getThemeCount(); for (int i = 1; i <= num; i++) { - AttributedTheme theme = (AttributedTheme) themeList.getThemeAt(i); + final AttributedTheme theme = (AttributedTheme) themeList.getThemeAt(i); if (theme == null) { continue; } - String srid = theme.getAttr("srid"); + final String srid = theme.getAttr("srid"); if (srid != null && srid.length() > 0) { return srid; @@ -433,63 +391,60 @@ return DEFAULT_SRID; } - - protected Bounds boundsFromString(String bounds) { + protected Bounds boundsFromString(final String bounds) { GWT.log("Create Bounds from String: '" + bounds + "'"); if (bounds == null || bounds.length() == 0) { return null; } - String[] values = bounds.split(" "); + final String[] values = bounds.split(" "); if (values == null || values.length < 4) { return null; } try { - return new Bounds( - Double.valueOf(values[0]), - Double.valueOf(values[1]), - Double.valueOf(values[2]), - Double.valueOf(values[3])); + return new Bounds(Double.valueOf(values[0]), Double.valueOf(values[1]), Double.valueOf(values[2]), Double.valueOf(values[3])); } - catch (NumberFormatException nfe) {} + catch (final NumberFormatException nfe) { + } return null; } - - public Layer createWMSLayer(Theme theme) { + private Layer createWMSLayer(final Theme theme) { if (!(theme instanceof AttributedTheme)) { return null; } - AttributedTheme at = (AttributedTheme) theme; + final AttributedTheme at = (AttributedTheme) theme; - String name = at.getAttr("name"); - String desc = at.getAttr("description"); - String url = at.getAttr("url"); - String layers = at.getAttr("layers"); + // final String desc = at.getAttr("description"); + final String url = at.getAttr("url"); + final String layers = at.getAttr("layers"); + + final String layerId = getLayerId(theme); if (url == null || layers == null) { return null; } - WMSParams params = new WMSParams(); + final WMSParams params = new WMSParams(); params.setLayers(layers); params.setFormat("image/png"); params.setIsTransparent(true); - WMSOptions opts = new WMSOptions(); + final WMSOptions opts = new WMSOptions(); + opts.setProjection("EPSG:" + getSrid()); opts.setSingleTile(true); opts.setRatio(1); if (layers.equals("OSM-WMS-Dienst")) { - opts.setAttribution(MSG.attribution()); + opts.setAttribution(this.MSG.attribution()); opts.setSingleTile(true); opts.setTransitionEffect(TransitionEffect.RESIZE); } - WMS wms = new WMS(layers, url, params, opts); + final WMS wms = new WMS(layerId, url, params, opts); wms.setIsVisible(at.getActive() == 1); wms.setIsBaseLayer(false); // We can't set the full_url attribute here because map is not set @@ -497,156 +452,145 @@ return wms; } + private String getLayerId(final Theme theme) { - public java.util.Map<String, String> wmsUrls() { - return this.wmsUrls; + final AttributedTheme at = (AttributedTheme) theme; + + final String name = at.getAttr("name"); + final String layers = at.getAttr("layers"); + + return name + "_" + layers; } - protected MapToolbar createControlPanel() { - return new MapToolbar(this, floodMap, false); + return new MapToolbar(this, this.floodMap, false); } - protected Canvas createThemePanel() { - Canvas c = new Canvas(); + final Canvas c = new Canvas(); c.setMinWidth(300); c.setWidth(200); c.setHeight100(); c.setCanDragResize(true); c.setBorder("1px solid black"); - themePanel = new MapThemePanel( - this.getCollectionView(), - mode, - this, - new MapThemePanel.ActivateCallback() { - @Override - public void activate(Theme theme, boolean active) { - fireActivateTheme(theme, active); - } - }, - new MapThemePanel.ThemeMovedCallback() { - @Override - public void onThemeMoved(Theme theme, int oldIdx, int newIdx) { - // this code synchronizes the ThemePanel and the OpenLayers - // internal order of layers. - AttributedTheme at = (AttributedTheme) theme; - - String name = at.getAttr("layers"); - Map map = getMap(); - Layer[] layers = map.getLayersByName(name); + this.themePanel = new MapThemePanel(this.getCollectionView(), this.mode, this, new MapThemePanel.ActivateCallback() { + @Override + public void activate(final Theme theme, final boolean active) { + fireActivateTheme(theme, active); + } + }, new MapThemePanel.ThemeMovedCallback() { + @Override + public void onThemeMoved(final Theme theme, final int oldIdx, final int newIdx) { + // this code synchronizes the ThemePanel and the OpenLayers + // internal order of layers. + final AttributedTheme at = (AttributedTheme) theme; - if (layers == null || layers.length == 0) { - GWT.log("Error: Cannot find layer '" + name + "'"); - return; - } + final String layerId = getLayerId(theme); - map.raiseLayer(layers[0], (newIdx-oldIdx)*-1); - map.zoomTo(map.getZoom()-1); - map.zoomTo(map.getZoom()+1); + final Map map = getMap(); + final Layer[] layers = map.getLayersByName(layerId); + + if (layers == null || layers.length == 0) { + GWT.log("Error: Cannot find layer '" + layerId + "'"); + return; } - }, - new MapThemePanel.LayerZoomCallback() { - @Override - public void onLayerZoom(Theme theme, String extent) { - Bounds zoomTo = boundsFromString(extent); - if (zoomTo == null) { - GWT.log("WARNING: No valid bounds for zooming found!"); - return; - } + map.raiseLayer(layers[0], (newIdx - oldIdx) * -1); + map.zoomTo(map.getZoom() - 1); + map.zoomTo(map.getZoom() + 1); + } + }, new MapThemePanel.LayerZoomCallback() { + @Override + public void onLayerZoom(final Theme theme, final String extent) { + final Bounds zoomTo = boundsFromString(extent); - getMap().zoomToExtent(zoomTo); + if (zoomTo == null) { + GWT.log("WARNING: No valid bounds for zooming found!"); + return; } + + getMap().zoomToExtent(zoomTo); } - ); - themePanel.addRedrawRequestHandler(this); - themePanel.addOutputParameterChangeHandler(this); - c.addChild(themePanel); + }); + this.themePanel.addRedrawRequestHandler(this); + this.themePanel.addOutputParameterChangeHandler(this); + c.addChild(this.themePanel); return c; } - - private void fireActivateTheme(Theme theme, boolean active) { + private void fireActivateTheme(final Theme theme, final boolean active) { activateTheme(theme, active); } - - protected void activateTheme(Theme theme, boolean active) { - AttributedTheme at = (AttributedTheme) theme; + protected void activateTheme(final Theme theme, final boolean active) { - String name = at.getAttr("layers"); - Layer layer = floodMap.getMap().getLayerByName(name); + final String layerId = getLayerId(theme); - GWT.log("Set visibility of '" + name + "': " + active); + final Layer layer = this.floodMap.getMap().getLayerByName(layerId); + + GWT.log("Set visibility of '" + layerId + "': " + active); if (layer != null) { layer.setIsVisible(active); } } - protected void saveBarriers() { - Vector layer = floodMap.getBarrierLayer(); - - GeoJSON format = new GeoJSON(); - String features = format.write(layer.getFeatures()); - - DataItem item = new DefaultDataItem( - BARRIERS_PARAMETER_KEY, BARRIERS_PARAMETER_KEY, features); - - Data data = new DefaultData( - BARRIERS_PARAMETER_KEY, BARRIERS_PARAMETER_KEY, "String", - new DataItem[] {item} ); + final Vector layer = this.floodMap.getBarrierLayer(); - Config config = Config.getInstance(); - String locale = config.getLocale(); + final GeoJSON format = new GeoJSON(); + final String features = format.write(layer.getFeatures()); - feedService.go(locale, getArtifact(), new Data[] { data }, - new AsyncCallback<Artifact>() { - @Override - public void onFailure(Throwable caught) { - GWT.log("Could not save barrier geometries: " + - caught.getMessage()); - } + final DataItem item = new DefaultDataItem(BARRIERS_PARAMETER_KEY, BARRIERS_PARAMETER_KEY, features); - @Override - public void onSuccess(Artifact artifact) { - GWT.log("Successfully saved barrier geometries."); - } + final Data data = new DefaultData(BARRIERS_PARAMETER_KEY, BARRIERS_PARAMETER_KEY, "String", new DataItem[] { item }); + + final Config config = Config.getInstance(); + final String locale = config.getLocale(); + + this.feedService.go(locale, getArtifact(), new Data[] { data }, new AsyncCallback<Artifact>() { + @Override + public void onFailure(final Throwable caught) { + GWT.log("Could not save barrier geometries: " + caught.getMessage()); } - ); + + @Override + public void onSuccess(final Artifact artifact) { + GWT.log("Successfully saved barrier geometries."); + } + }); } - @Override - public void onTabSelected(TabSelectedEvent tse) { - if(floodMap == null) { + public void onTabSelected(final TabSelectedEvent tse) { + if (this.floodMap == null) { return; } - if(this.equals(tse.getTab())) { - floodMap.activateScaleLine(true); - } - else { - controlPanel.activateMeasureControl(false); - floodMap.activateScaleLine(false); + if (this.equals(tse.getTab())) { + this.floodMap.activateScaleLine(true); + } else { + this.controlPanel.activateMeasureControl(false); + this.floodMap.activateScaleLine(false); } } public void toogleThemePanel() { - this.themePanelCanvas.setVisible(!themePanelCanvas.isVisible()); + this.themePanelCanvas.setVisible(!this.themePanelCanvas.isVisible()); // Trigger resize event handler doLayout(); } - @Override - public void onOutputParameterChanged(OutputParameterChangeEvent evt) { + public void onOutputParameterChanged(final OutputParameterChangeEvent evt) { GWT.log("OutputParameterChanged"); - controlPanel.updateThemes(getThemePanel().getThemeList()); + this.controlPanel.updateThemes(getThemePanel().getThemeList()); } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : + + public String getWMSUrl(final Theme theme) { + final String layerId = getLayerId(theme); + return this.wmsUrls.get(layerId); + } +} \ No newline at end of file