comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java @ 2983:725470fc57d2

Add "Manage themes" button to ChartToolbar and MapToolbar. flys-client/trunk@4991 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Fri, 13 Jul 2012 11:31:25 +0000
parents c057ef91b268
children 6d749af6a9c2
comparison
equal deleted inserted replaced
2982:d2a54ae0016b 2983:725470fc57d2
1 package de.intevation.flys.client.client.ui.map; 1 package de.intevation.flys.client.client.ui.map;
2
3 import java.util.List;
4 2
5 import com.google.gwt.core.client.GWT; 3 import com.google.gwt.core.client.GWT;
6 import com.google.gwt.user.client.rpc.AsyncCallback; 4 import com.google.gwt.user.client.rpc.AsyncCallback;
7 import com.google.gwt.user.client.ui.HorizontalPanel; 5 import com.google.gwt.user.client.ui.HorizontalPanel;
8 import com.google.gwt.user.client.ui.Widget; 6 import com.google.gwt.user.client.ui.Widget;
9
10 import com.smartgwt.client.util.SC; 7 import com.smartgwt.client.util.SC;
11 import com.smartgwt.client.widgets.Canvas; 8 import com.smartgwt.client.widgets.Canvas;
12 import com.smartgwt.client.widgets.events.ResizedEvent; 9 import com.smartgwt.client.widgets.events.ResizedEvent;
13 import com.smartgwt.client.widgets.events.ResizedHandler; 10 import com.smartgwt.client.widgets.events.ResizedHandler;
14 import com.smartgwt.client.widgets.layout.HLayout; 11 import com.smartgwt.client.widgets.layout.HLayout;
15 import com.smartgwt.client.widgets.layout.VLayout; 12 import com.smartgwt.client.widgets.layout.VLayout;
13 import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
16 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; 14 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
17 import com.smartgwt.client.widgets.tab.events.TabSelectedEvent; 15
18 16 import de.intevation.flys.client.client.Config;
19 import org.gwtopenmaps.openlayers.client.Bounds; 17 import de.intevation.flys.client.client.FLYSConstants;
20 import org.gwtopenmaps.openlayers.client.Map; 18 import de.intevation.flys.client.client.event.RedrawRequestEvent;
21 import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener; 19 import de.intevation.flys.client.client.event.RedrawRequestHandler;
22 import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener.FeatureAddedEvent; 20 import de.intevation.flys.client.client.services.LoadArtifactService;
23 import org.gwtopenmaps.openlayers.client.event.VectorFeatureRemovedListener; 21 import de.intevation.flys.client.client.services.LoadArtifactServiceAsync;
24 import org.gwtopenmaps.openlayers.client.event.VectorFeatureRemovedListener.FeatureRemovedEvent; 22 import de.intevation.flys.client.client.services.MapOutputService;
25 import org.gwtopenmaps.openlayers.client.feature.VectorFeature; 23 import de.intevation.flys.client.client.services.MapOutputServiceAsync;
26 import org.gwtopenmaps.openlayers.client.format.GeoJSON; 24 import de.intevation.flys.client.client.services.StepForwardService;
27 import org.gwtopenmaps.openlayers.client.layer.Layer; 25 import de.intevation.flys.client.client.services.StepForwardServiceAsync;
28 import org.gwtopenmaps.openlayers.client.layer.Vector; 26 import de.intevation.flys.client.client.ui.CollectionView;
29 import org.gwtopenmaps.openlayers.client.layer.WMS; 27 import de.intevation.flys.client.client.ui.OutputTab;
30 import org.gwtopenmaps.openlayers.client.layer.WMSParams; 28 import de.intevation.flys.client.client.ui.ThemePanel;
31 import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
32
33 import de.intevation.flys.client.shared.model.Artifact; 29 import de.intevation.flys.client.shared.model.Artifact;
34 import de.intevation.flys.client.shared.model.ArtifactDescription; 30 import de.intevation.flys.client.shared.model.ArtifactDescription;
35 import de.intevation.flys.client.shared.model.AttributedTheme; 31 import de.intevation.flys.client.shared.model.AttributedTheme;
36 import de.intevation.flys.client.shared.model.Collection; 32 import de.intevation.flys.client.shared.model.Collection;
37 import de.intevation.flys.client.shared.model.Data; 33 import de.intevation.flys.client.shared.model.Data;
38 import de.intevation.flys.client.shared.model.DataItem; 34 import de.intevation.flys.client.shared.model.DataItem;
39 import de.intevation.flys.client.shared.model.DataList; 35 import de.intevation.flys.client.shared.model.DataList;
40 import de.intevation.flys.client.shared.model.DefaultData; 36 import de.intevation.flys.client.shared.model.DefaultData;
41 import de.intevation.flys.client.shared.model.DefaultDataItem; 37 import de.intevation.flys.client.shared.model.DefaultDataItem;
42 import de.intevation.flys.client.shared.model.MapConfig; 38 import de.intevation.flys.client.shared.model.MapConfig;
39 import de.intevation.flys.client.shared.model.OutputMode;
43 import de.intevation.flys.client.shared.model.Recommendation; 40 import de.intevation.flys.client.shared.model.Recommendation;
44 import de.intevation.flys.client.shared.model.Theme; 41 import de.intevation.flys.client.shared.model.Theme;
45 import de.intevation.flys.client.shared.model.ThemeList; 42 import de.intevation.flys.client.shared.model.ThemeList;
46 import de.intevation.flys.client.shared.model.OutputMode;
47 import de.intevation.flys.client.shared.model.WMSLayer; 43 import de.intevation.flys.client.shared.model.WMSLayer;
48 44
49 import de.intevation.flys.client.client.Config; 45 import java.util.List;
50 import de.intevation.flys.client.client.FLYSConstants; 46
51 import de.intevation.flys.client.client.services.LoadArtifactService; 47 import org.gwtopenmaps.openlayers.client.Bounds;
52 import de.intevation.flys.client.client.services.LoadArtifactServiceAsync; 48 import org.gwtopenmaps.openlayers.client.Map;
53 import de.intevation.flys.client.client.services.StepForwardService; 49 import org.gwtopenmaps.openlayers.client.event.VectorFeatureAddedListener;
54 import de.intevation.flys.client.client.services.StepForwardServiceAsync; 50 import org.gwtopenmaps.openlayers.client.event.VectorFeatureRemovedListener;
55 import de.intevation.flys.client.client.services.MapOutputService; 51 import org.gwtopenmaps.openlayers.client.feature.VectorFeature;
56 import de.intevation.flys.client.client.services.MapOutputServiceAsync; 52 import org.gwtopenmaps.openlayers.client.format.GeoJSON;
57 import de.intevation.flys.client.client.event.RedrawRequestHandler; 53 import org.gwtopenmaps.openlayers.client.layer.Layer;
58 import de.intevation.flys.client.client.event.RedrawRequestEvent; 54 import org.gwtopenmaps.openlayers.client.layer.Vector;
59 import de.intevation.flys.client.client.ui.CollectionView; 55 import org.gwtopenmaps.openlayers.client.layer.WMS;
60 import de.intevation.flys.client.client.ui.OutputTab; 56 import org.gwtopenmaps.openlayers.client.layer.WMSOptions;
61 import de.intevation.flys.client.client.ui.ThemePanel; 57 import org.gwtopenmaps.openlayers.client.layer.WMSParams;
62 58
63 59
64 public class MapOutputTab 60 public class MapOutputTab
65 extends OutputTab 61 extends OutputTab
66 implements RedrawRequestHandler, ExternalWMSWindow.LayerLoader, TabSelectedHandler { 62 implements RedrawRequestHandler, ExternalWMSWindow.LayerLoader, TabSelectedHandler {
86 82
87 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); 83 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
88 84
89 protected MapToolbar controlPanel; 85 protected MapToolbar controlPanel;
90 protected ThemePanel themePanel; 86 protected ThemePanel themePanel;
87 protected Canvas themePanelCanvas;
91 protected Widget mapPanel; 88 protected Widget mapPanel;
92 89
93 protected FloodMap floodMap; 90 protected FloodMap floodMap;
94 91
95 92
102 super(title, collection, collectionView, mode); 99 super(title, collection, collectionView, mode);
103 100
104 collectionView.registerTabHandler(this); 101 collectionView.registerTabHandler(this);
105 102
106 mapService.doOut(collection, new AsyncCallback<MapConfig>() { 103 mapService.doOut(collection, new AsyncCallback<MapConfig>() {
104 @Override
107 public void onFailure(Throwable caught) { 105 public void onFailure(Throwable caught) {
108 GWT.log("MAP ERROR: " + caught.getMessage()); 106 GWT.log("MAP ERROR: " + caught.getMessage());
109 } 107 }
110 108
109 @Override
111 public void onSuccess(MapConfig c) { 110 public void onSuccess(MapConfig c) {
112 GWT.log("MAP SUCCESS!"); 111 GWT.log("MAP SUCCESS!");
113 112
114 Bounds max = boundsFromString(c.getMaxExtent()); 113 Bounds max = boundsFromString(c.getMaxExtent());
115 Bounds initial = boundsFromString(c.getInitialExtent()); 114 Bounds initial = boundsFromString(c.getInitialExtent());
142 final HLayout hlayout = new HLayout(); 141 final HLayout hlayout = new HLayout();
143 hlayout.setHeight("*"); 142 hlayout.setHeight("*");
144 hlayout.setWidth100(); 143 hlayout.setWidth100();
145 hlayout.setMembersMargin(2); 144 hlayout.setMembersMargin(2);
146 145
147 final Canvas themePanelWrapper = createThemePanel(); 146 this.themePanelCanvas = createThemePanel();
148 147
149 controlPanel = createControlPanel(); 148 controlPanel = createControlPanel();
150 mapPanel = floodMap.getMapWidget(); 149 mapPanel = floodMap.getMapWidget();
151 final HorizontalPanel layout = new HorizontalPanel(); 150 final HorizontalPanel layout = new HorizontalPanel();
152 layout.setWidth("99%"); 151 layout.setWidth("99%");
153 layout.setHeight("99%"); 152 layout.setHeight("99%");
154 layout.add(mapPanel); 153 layout.add(mapPanel);
155 154
156 hlayout.addMember(themePanelWrapper); 155 hlayout.addMember(themePanelCanvas);
157 hlayout.addMember(layout); 156 hlayout.addMember(layout);
158 157
159 rootLayout.addMember(controlPanel); 158 rootLayout.addMember(controlPanel);
160 rootLayout.addMember(hlayout); 159 rootLayout.addMember(hlayout);
161 160
162 hlayout.addResizedHandler(new ResizedHandler() { 161 hlayout.addResizedHandler(new ResizedHandler() {
162 @Override
163 public void onResized(ResizedEvent e) { 163 public void onResized(ResizedEvent e) {
164 Integer height = hlayout.getHeight(); 164 Integer height = hlayout.getHeight();
165 Integer width = hlayout.getWidth() - themePanelWrapper.getWidth(); 165 Integer width = hlayout.getWidth() - themePanelCanvas.getWidth();
166 166
167 height = height * 99 / 100; 167 height = height * 99 / 100;
168 width = width * 99 / 100; 168 width = width * 99 / 100;
169 169
170 String w = String.valueOf(width) + "px"; 170 String w = String.valueOf(width) + "px";
180 180
181 protected void initBarriers() { 181 protected void initBarriers() {
182 Vector vector = floodMap.getBarrierLayer(); 182 Vector vector = floodMap.getBarrierLayer();
183 vector.addVectorFeatureAddedListener( 183 vector.addVectorFeatureAddedListener(
184 new VectorFeatureAddedListener() { 184 new VectorFeatureAddedListener() {
185 @Override
185 public void onFeatureAdded(FeatureAddedEvent e) { 186 public void onFeatureAdded(FeatureAddedEvent e) {
186 saveBarriers(); 187 saveBarriers();
187 } 188 }
188 } 189 }
189 ); 190 );
190 191
191 vector.addVectorFeatureRemovedListener( 192 vector.addVectorFeatureRemovedListener(
192 new VectorFeatureRemovedListener() { 193 new VectorFeatureRemovedListener() {
194 @Override
193 public void onFeatureRemoved(FeatureRemovedEvent e) { 195 public void onFeatureRemoved(FeatureRemovedEvent e) {
194 saveBarriers(); 196 saveBarriers();
195 } 197 }
196 } 198 }
197 ); 199 );
244 246
245 247
246 @Override 248 @Override
247 public void onRedrawRequest(RedrawRequestEvent event) { 249 public void onRedrawRequest(RedrawRequestEvent event) {
248 mapService.doOut(collection, new AsyncCallback<MapConfig>() { 250 mapService.doOut(collection, new AsyncCallback<MapConfig>() {
251 @Override
249 public void onFailure(Throwable caught) { 252 public void onFailure(Throwable caught) {
250 GWT.log("MAP ERROR: " + caught.getMessage()); 253 GWT.log("MAP ERROR: " + caught.getMessage());
251 } 254 }
252 255
256 @Override
253 public void onSuccess(MapConfig c) { 257 public void onSuccess(MapConfig c) {
254 GWT.log("We want to refresh the map now!"); 258 GWT.log("We want to refresh the map now!");
255 themePanel.updateCollection(); 259 themePanel.updateCollection();
256 getFloodmap().update(); 260 getFloodmap().update();
257 } 261 }
405 return null; 409 return null;
406 } 410 }
407 411
408 AttributedTheme at = (AttributedTheme) theme; 412 AttributedTheme at = (AttributedTheme) theme;
409 413
410 String type = at.getAttr("name"); 414 //String type = at.getAttr("name");
411 String desc = at.getAttr("description"); 415 //String desc = at.getAttr("description");
412 String url = at.getAttr("url"); 416 String url = at.getAttr("url");
413 String layers = at.getAttr("layers"); 417 String layers = at.getAttr("layers");
414 418
415 if (url == null || layers == null) { 419 if (url == null || layers == null) {
416 return null; 420 return null;
452 themePanel = new MapThemePanel( 456 themePanel = new MapThemePanel(
453 this.getCollectionView(), 457 this.getCollectionView(),
454 mode, 458 mode,
455 this, 459 this,
456 new MapThemePanel.ActivateCallback() { 460 new MapThemePanel.ActivateCallback() {
461 @Override
457 public void activate(Theme theme, boolean active) { 462 public void activate(Theme theme, boolean active) {
458 activateTheme(theme, active); 463 activateTheme(theme, active);
459 } 464 }
460 }, 465 },
461 new MapThemePanel.ThemeMovedCallback() { 466 new MapThemePanel.ThemeMovedCallback() {
467 @Override
462 public void onThemeMoved(Theme theme, int oldIdx, int newIdx) { 468 public void onThemeMoved(Theme theme, int oldIdx, int newIdx) {
463 // this code synchronizes the ThemePanel and the OpenLayers 469 // this code synchronizes the ThemePanel and the OpenLayers
464 // internal order of layers. 470 // internal order of layers.
465 AttributedTheme at = (AttributedTheme) theme; 471 AttributedTheme at = (AttributedTheme) theme;
466 472
477 map.zoomTo(map.getZoom()-1); 483 map.zoomTo(map.getZoom()-1);
478 map.zoomTo(map.getZoom()+1); 484 map.zoomTo(map.getZoom()+1);
479 } 485 }
480 }, 486 },
481 new MapThemePanel.LayerZoomCallback() { 487 new MapThemePanel.LayerZoomCallback() {
488 @Override
482 public void onLayerZoom(Theme theme, String extent) { 489 public void onLayerZoom(Theme theme, String extent) {
483 Bounds zoomTo = boundsFromString(extent); 490 Bounds zoomTo = boundsFromString(extent);
484 491
485 if (zoomTo == null) { 492 if (zoomTo == null) {
486 GWT.log("WARNING: No valid bounds for zooming found!"); 493 GWT.log("WARNING: No valid bounds for zooming found!");
528 Config config = Config.getInstance(); 535 Config config = Config.getInstance();
529 final String locale = config.getLocale(); 536 final String locale = config.getLocale();
530 537
531 feedService.go(locale, getArtifact(), new Data[] { data }, 538 feedService.go(locale, getArtifact(), new Data[] { data },
532 new AsyncCallback<Artifact>() { 539 new AsyncCallback<Artifact>() {
540 @Override
533 public void onFailure(Throwable caught) { 541 public void onFailure(Throwable caught) {
534 GWT.log("Could not save barrier geometries: " + 542 GWT.log("Could not save barrier geometries: " +
535 caught.getMessage()); 543 caught.getMessage());
536 } 544 }
537 545
546 @Override
538 public void onSuccess(Artifact artifact) { 547 public void onSuccess(Artifact artifact) {
539 GWT.log("Successfully saved barrier geometries."); 548 GWT.log("Successfully saved barrier geometries.");
540 } 549 }
541 } 550 }
542 ); 551 );
543 } 552 }
544 553
545 554
555 @Override
546 public void onTabSelected(TabSelectedEvent tse) { 556 public void onTabSelected(TabSelectedEvent tse) {
547 if(floodMap == null) { 557 if(floodMap == null) {
548 return; 558 return;
549 } 559 }
550 if(this.equals(tse.getTab())) { 560 if(this.equals(tse.getTab())) {
553 else { 563 else {
554 controlPanel.activateMeasureControl(false); 564 controlPanel.activateMeasureControl(false);
555 floodMap.activateScaleLine(false); 565 floodMap.activateScaleLine(false);
556 } 566 }
557 } 567 }
568
569 public void toogleThemePanel() {
570 this.themePanelCanvas.setVisible(!themePanelCanvas.isVisible());
571 }
558 } 572 }
559 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 573 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org