Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java @ 1414:3484cbfaf369
Create new Artifacts for selected WMS layers of the ExternalWMSWindow.
flys-client/trunk@3304 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 22 Nov 2011 20:13:16 +0000 |
parents | 659a488243da |
children | dfa2d4753fc0 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Tue Nov 22 20:08:41 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java Tue Nov 22 20:13:16 2011 +0000 @@ -7,6 +7,7 @@ import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Widget; +import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.events.ResizedEvent; import com.smartgwt.client.widgets.events.ResizedHandler; @@ -37,12 +38,15 @@ import de.intevation.flys.client.shared.model.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; import de.intevation.flys.client.shared.model.MapConfig; +import de.intevation.flys.client.shared.model.Recommendation; import de.intevation.flys.client.shared.model.Theme; import de.intevation.flys.client.shared.model.ThemeList; import de.intevation.flys.client.shared.model.OutputMode; import de.intevation.flys.client.shared.model.WMSLayer; import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.services.LoadArtifactService; +import de.intevation.flys.client.client.services.LoadArtifactServiceAsync; import de.intevation.flys.client.client.services.StepForwardService; import de.intevation.flys.client.client.services.StepForwardServiceAsync; import de.intevation.flys.client.client.services.MapOutputService; @@ -64,6 +68,8 @@ public static final String WSPLGEN_FACET = "floodmap.wsplgen"; + public static final String EXTERNAL_WMS_FACTORY = "externalwmsfactory"; + protected StepForwardServiceAsync feedService = GWT.create(StepForwardService.class); @@ -71,6 +77,10 @@ protected MapOutputServiceAsync mapService = GWT.create(MapOutputService.class); + /** Service handle to clone and add artifacts to collection. */ + protected LoadArtifactServiceAsync loadArtifactService = + GWT.create(LoadArtifactService.class); + protected MapToolbar controlPanel; protected ThemePanel themePanel; protected Widget mapPanel; @@ -245,7 +255,37 @@ @Override public void load(List<WMSLayer> toLoad) { GWT.log("The user wants to add " + toLoad.size() + " new WMS layers."); - // TODO + + int len = toLoad.size(); + + Recommendation[] recom = new Recommendation[len]; + + for (int i = 0; i < len; i++) { + WMSLayer w = toLoad.get(i); + + 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[]>() { + + @Override + public void onFailure(Throwable throwable) { + SC.warn(throwable.getMessage()); + } + + @Override + public void onSuccess(Artifact[] newArtifacts) { + SC.warn("SUCCESS!"); + } + } + ); }