diff --git a/src/main/java/org/gcube/portlets/user/gisviewer/client/Constants.java b/src/main/java/org/gcube/portlets/user/gisviewer/client/Constants.java index 6f430ba..62fdeb0 100644 --- a/src/main/java/org/gcube/portlets/user/gisviewer/client/Constants.java +++ b/src/main/java/org/gcube/portlets/user/gisviewer/client/Constants.java @@ -91,7 +91,8 @@ public class Constants { public static final int geoWindowMinHeight=300; public static final String geoWindowTitle="GIS Viewer "+ VERSION; public static final boolean geoWindowShadow = false; - public static final boolean geoWindowDataPanelOpenedAtStart = true; + public static final boolean geoWindowDataPanelOpenedAtStart = false; + public static final boolean geoWindowLayerPanelOpenedAtStart = false; public static String defaultProjection = "EPSG:4326"; public static final String hcafLegendWidth = "400px"; diff --git a/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerLayout.java b/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerLayout.java index 2546850..40e346f 100644 --- a/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerLayout.java +++ b/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerLayout.java @@ -53,14 +53,20 @@ public class GisViewerLayout extends LayoutContainer { private DataPanelHandler handler; private boolean openDataPanel; protected boolean started=false; - -// private boolean isOpenDataPanel = false; - - public GisViewerLayout(boolean openDataPanel, DataPanelHandler dataPanelHandler) { + private boolean openLayerPanel; + + /** + * Instantiates a new gis viewer layout. + * + * @param openDataPanel the open data panel + * @param openLayerPanel the open layer panel + * @param dataPanelHandler the data panel handler + */ + public GisViewerLayout(final boolean openDataPanel, final boolean openLayerPanel, DataPanelHandler dataPanelHandler) { super(); this.openDataPanel = openDataPanel; -// this.isOpenDataPanel = openDataPanel; + this.openLayerPanel = openLayerPanel; this.handler = dataPanelHandler; @@ -127,7 +133,10 @@ public class GisViewerLayout extends LayoutContainer { @Override public void execute() { - westPanel.collapse(); //I'm closing the panel as default + if(openLayerPanel) + westPanel.expand(); + else + westPanel.collapse();//I'm closing the panel } }); @@ -142,6 +151,18 @@ public class GisViewerLayout extends LayoutContainer { southPanel.setBodyStyle(Constants.panelsBodyStyle); southPanel.setScrollMode(Scroll.AUTO); + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + if(openDataPanel) + southPanel.expand(); + else + southPanel.collapse();//I'm closing the panel + + } + }); + centerPanel = new ContentPanel(){ protected void onResize(int width, int height) { super.onResize(width, height); diff --git a/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerPanel.java b/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerPanel.java index 2b966d2..afff150 100644 --- a/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerPanel.java +++ b/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerPanel.java @@ -158,11 +158,15 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle INSTANCE = this; // create an empty layers panel layersPanel = new LayersPanel(this); - createOpenLayersMap(); + + //TEMPORARY SOLUTION. MUST BECOME INIT PARAMETERS + LonLat centerMapTo = null; //new LonLat(12.45, 42.98); + Integer initZoomTo = null; + createOpenLayersMap(centerMapTo, initZoomTo); // initialize the layout this.setLayout(new FitLayout()); - mainPanel = new GisViewerLayout(parameters.isOpenDataPanelAtStart(), this) { + mainPanel = new GisViewerLayout(parameters.isOpenDataPanelAtStart(), parameters.isOpenLayerPanelAtStart(), this) { /* (non-Javadoc) * @see com.extjs.gxt.ui.client.widget.LayoutContainer#onRender(com.google.gwt.user.client.Element, int) */ @@ -353,10 +357,7 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle /** * Creates the open layers map. */ - private void createOpenLayersMap() { // TODO update for pluggable layers - - final LonLat centerMapTo = null; - final Integer initZoomTo = null; + private void createOpenLayersMap(final LonLat centerMapTo, final Integer initZoomTo) { // TODO update for pluggable layers GisViewer.service.getBaseLayersToGisViewer(new AsyncCallback>() { diff --git a/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerParameters.java b/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerParameters.java index f46968f..084c219 100644 --- a/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerParameters.java +++ b/src/main/java/org/gcube/portlets/user/gisviewer/client/GisViewerParameters.java @@ -1,6 +1,8 @@ package org.gcube.portlets.user.gisviewer.client; +import org.gwtopenmaps.openlayers.client.LonLat; +// TODO: Auto-generated Javadoc /** * The Class GisViewerParameters. * @@ -13,6 +15,9 @@ public class GisViewerParameters { private GisViewerSaveHandler gisViewerSaveHandler = null; private DataPanelOpenListener dataPanelOpenHandler = null; private boolean openDataPanelAtStart = Constants.geoWindowDataPanelOpenedAtStart; + private boolean openLayerPanelAtStart = Constants.geoWindowLayerPanelOpenedAtStart; + private LonLat centerMapTo = null; //new LonLat(12.45, 42.98); + private Integer initZoomTo = null; /** * Instantiates a new gis viewer parameters. @@ -30,6 +35,50 @@ public class GisViewerParameters { this.projection = projection; this.gisViewerSaveHandler = gisViewerSaveHandler; } + + + + /** + * Instantiates a new gis viewer parameters. + * + * @param projection the projection + * @param gisViewerSaveHandler the gis viewer save handler + * @param dataPanelOpenHandler the data panel open handler + * @param openDataPanelAtStart the open data panel at start + * @param openLayerPanelAtStart the open layer panel at start + * @param centerMapTo the center map to + * @param initZoomTo the init zoom to + */ + public GisViewerParameters(String projection, GisViewerSaveHandler gisViewerSaveHandler, + DataPanelOpenListener dataPanelOpenHandler, boolean openDataPanelAtStart, boolean openLayerPanelAtStart, + LonLat centerMapTo, Integer initZoomTo) { + super(); + this.projection = projection; + this.gisViewerSaveHandler = gisViewerSaveHandler; + this.dataPanelOpenHandler = dataPanelOpenHandler; + this.openDataPanelAtStart = openDataPanelAtStart; + this.openLayerPanelAtStart = openLayerPanelAtStart; + this.centerMapTo = centerMapTo; + this.initZoomTo = initZoomTo; + } + + /** + * Checks if is open layer panel at start. + * + * @return true, if is open layer panel at start + */ + public boolean isOpenLayerPanelAtStart() { + return openLayerPanelAtStart; + } + + /** + * Sets the open layer panel at start. + * + * @param openLayerPanelAtStart the new open layer panel at start + */ + public void setOpenLayerPanelAtStart(boolean openLayerPanelAtStart) { + this.openLayerPanelAtStart = openLayerPanelAtStart; + } /** * Sets the projection. @@ -102,4 +151,51 @@ public class GisViewerParameters { public DataPanelOpenListener getDataPanelOpenHandler() { return dataPanelOpenHandler; } + + /** + * Gets the center map to. + * + * @return the center map to + */ + public LonLat getCenterMapTo() { + return centerMapTo; + } + + /** + * Sets the center map to. + * + * @param centerMapTo the new center map to + */ + public void setCenterMapTo(LonLat centerMapTo) { + this.centerMapTo = centerMapTo; + } + + /** + * Gets the inits the zoom to. + * + * @return the inits the zoom to + */ + public Integer getInitZoomTo() { + return initZoomTo; + } + + /** + * Sets the inits the zoom to. + * + * @param initZoomTo the new inits the zoom to + */ + public void setInitZoomTo(Integer initZoomTo) { + this.initZoomTo = initZoomTo; + } + + /** + * Sets the data panel open handler. + * + * @param dataPanelOpenHandler the new data panel open handler + */ + public void setDataPanelOpenHandler(DataPanelOpenListener dataPanelOpenHandler) { + this.dataPanelOpenHandler = dataPanelOpenHandler; + } + + } diff --git a/src/main/java/org/gcube/portlets/user/gisviewer/client/openlayers/OpenLayersMap.java b/src/main/java/org/gcube/portlets/user/gisviewer/client/openlayers/OpenLayersMap.java index 7b282bb..ceae98d 100644 --- a/src/main/java/org/gcube/portlets/user/gisviewer/client/openlayers/OpenLayersMap.java +++ b/src/main/java/org/gcube/portlets/user/gisviewer/client/openlayers/OpenLayersMap.java @@ -52,6 +52,7 @@ import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.DockPanel; import com.google.gwt.user.client.ui.Widget; +// TODO: Auto-generated Javadoc /** * The Class OpenLayersMap. * @@ -259,7 +260,7 @@ public class OpenLayersMap { @Override public void execute() { - GWT.log("Centering on Italy"); + GWT.log("Centering on: "+centerMapTo); //map.setCenter(new LonLat(12.45, 42.98), 6); if(initZoomTo!=null) map.setCenter(centerMapTo,initZoomTo); @@ -268,8 +269,6 @@ public class OpenLayersMap { } }); } - - } /** @@ -1142,5 +1141,31 @@ public class OpenLayersMap { public Map getMap() { return map; } + + + /** + * Sets the zoom level. + * + * @param zoomLevel the new zoom level + */ + public void setZoomLevel(int zoomLevel) { + GWT.log("setting zoom at: "+zoomLevel); + if(zoomLevel>0 && zoomLevel