diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 753eaa6..e356dfa 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -86,7 +87,8 @@ - + + @@ -173,7 +175,8 @@ - + + @@ -260,7 +263,8 @@ - + + @@ -347,7 +351,8 @@ - + + @@ -434,7 +439,8 @@ - + + @@ -521,7 +527,11 @@ - + + uses + + + @@ -608,7 +618,8 @@ - + + @@ -695,7 +706,8 @@ - + + @@ -782,7 +794,8 @@ - + + diff --git a/CHANGELOG.md b/CHANGELOG.md index c6df39c..f555c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v3.5.0] +## [v3.5.0-SNAPSHOT] - Supported the cross-filtering [#25074] - Supported the grouped custom layers [#25110] +- Managed the (WMS) Layer Style facility [#25066] ## [v3.4.0] - 2023-05-11 diff --git a/pom.xml b/pom.xml index b9b09bc..523aedd 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-viewer-app war - 3.5.0 + 3.5.0-SNAPSHOT GeoPortal Data Viewer App The GeoPortal Data Viewer App is an application to access, discovery and navigate the Geoportal projects/documents by a Web-Map Interface diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index d72cfac..7b7a230 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -52,6 +52,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCent import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEvent.EVENT_TYPE; import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEventHandler; +import org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.CloseCollectionEvent; @@ -947,6 +949,30 @@ public class GeoportalDataViewer implements EntryPoint { } }); + applicationBus.addHandler(UpdateLayerToMapEvent.TYPE, new UpdateLayerToMapEventHandler() { + + @Override + public void onUpdateLayer(UpdateLayerToMapEvent updateLayerToMapEvent) { + + if (updateLayerToMapEvent != null && updateLayerToMapEvent.getOperation() != null) { + + if (updateLayerToMapEvent.getLayerType().equals( + org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEvent.LAYER_TYPE.INDEX)) { + + switch (updateLayerToMapEvent.getOperation()) { + case STYLE: + olMapMng.getOLMap().setLayerStyleForIndex(updateLayerToMapEvent.getLayerName(), + updateLayerToMapEvent.getValue()); + break; + + default: + break; + } + + } + } + } + }); } /** diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/UpdateLayerToMapEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/UpdateLayerToMapEvent.java new file mode 100644 index 0000000..d07f8cb --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/UpdateLayerToMapEvent.java @@ -0,0 +1,134 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class UpdateLayerToMapEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 15, 2023 + */ +public class UpdateLayerToMapEvent extends GwtEvent { + public static Type TYPE = new Type(); + private GCubeCollection collection; + private String layerName; + private REQUEST_PARAMETER operation; + private String value; + private LAYER_TYPE layerType; + + /** + * The Enum REQUEST_PARAMETER. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 15, 2023 + */ + public static enum REQUEST_PARAMETER { + STYLE + } + + /** + * The Enum LAYER_TYPE. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 15, 2023 + */ + public static enum LAYER_TYPE { + INDEX, DETAILS + } + + /** + * Instantiates a new adds the layer to map event. + * + * @param collection the collection + * @param layerName the layer name + * @param type the type + */ + public UpdateLayerToMapEvent(GCubeCollection collection, String layerName, LAYER_TYPE type) { + this.collection = collection; + this.layerName = layerName; + this.layerType = type; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Sets the operation. + * + * @param operation the operation + * @param value the value + */ + public void setOperation(REQUEST_PARAMETER operation, String value) { + this.operation = operation; + this.value = value; + } + + /** + * Gets the value. + * + * @return the value + */ + public String getValue() { + return value; + } + + /** + * Gets the layer type. + * + * @return the layer type + */ + public LAYER_TYPE getLayerType() { + return layerType; + } + + /** + * Gets the operation. + * + * @return the operation + */ + public REQUEST_PARAMETER getOperation() { + return operation; + } + + /** + * Gets the layer name. + * + * @return the layer name + */ + public String getLayerName() { + return layerName; + } + + /** + * Gets the collection. + * + * @return the collection + */ + public GCubeCollection getCollection() { + return collection; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + @Override + protected void dispatch(UpdateLayerToMapEventHandler handler) { + handler.onUpdateLayer(this); + + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/UpdateLayerToMapEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/UpdateLayerToMapEventHandler.java new file mode 100644 index 0000000..1ffc5a8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/UpdateLayerToMapEventHandler.java @@ -0,0 +1,20 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import com.google.gwt.event.shared.EventHandler; + +/** + * The Interface UpdateLayerToMapEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jun 15, 2023 + */ +public interface UpdateLayerToMapEventHandler extends EventHandler { + + /** + * On update layer. + * + * @param updateLayerToMapEvent the update layer to map event + */ + void onUpdateLayer(UpdateLayerToMapEvent updateLayerToMapEvent); +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java index be37cc3..985ae26 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java @@ -523,11 +523,10 @@ public abstract class OpenLayerMap { return setCQLFilter; } - /** * Adds the WMS detail layer. * - * @param layerItem the layer item + * @param layerItem the layer item * @param initialOpacity the initial opacity */ public void addWMSDetailLayer(LayerItem layerItem, double initialOpacity) { @@ -1131,6 +1130,23 @@ public abstract class OpenLayerMap { layer.setVisible(visible); } + public void setLayerStyleForIndex(String layerName, String value) { + GWT.log("Setting style " + value + " for " + layerName); + + Image indexWmsLayer = wmsLayerMap.get(layerName); + GWT.log("WMS layer is: " + indexWmsLayer); + + if (indexWmsLayer != null) { + ImageWms imageWMSSource = indexWmsLayer.getSource(); + ImageWmsParams imageWMSParams = imageWMSSource.getParams(); + imageWMSParams.set("STYLES", value); + + imageWMSSource.updateParams(imageWMSParams); + indexWmsLayer.setSource(imageWMSSource); + indexWmsLayer.changed(); + } + } + /** * Sets the WMS detail layer opacity. * @@ -1202,7 +1218,7 @@ public abstract class OpenLayerMap { public void fitToExtent(ol.Extent extent) { ViewFitOptions opt = new ViewFitOptions(); opt.setMaxZoom(16); - opt.setDuration(SET_CENTER_ANIMATED_DURATION*5); + opt.setDuration(SET_CENTER_ANIMATED_DURATION * 5); map.getView().fit(extent, opt); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/layercollection/LayerCollectionPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/layercollection/LayerCollectionPanel.java index b8a74ce..033f0d8 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/layercollection/LayerCollectionPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/layercollection/LayerCollectionPanel.java @@ -5,6 +5,9 @@ import java.util.HashMap; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; +import org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEvent.LAYER_TYPE; +import org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEvent.REQUEST_PARAMETER; import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.CloseCollectionEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.OpenCollectionEvent; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; @@ -18,6 +21,8 @@ import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.FontWeight; +import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ErrorEvent; @@ -42,13 +47,12 @@ import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.Widget; - /** * The Class LayerCollectionPanel. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * May 15, 2023 + * May 15, 2023 */ public class LayerCollectionPanel extends Composite { @@ -77,6 +81,12 @@ public class LayerCollectionPanel extends Composite { private ListBox listBoxStyles = new ListBox(); + private String layerName; + + private GCubeCollection gcubeCollection; + + private HandlerManager applicationBus; + /** * The Interface LayerCollectionPanelUiBinder. * @@ -93,8 +103,9 @@ public class LayerCollectionPanel extends Composite { * @param coll the coll * @param applicationBus the application bus */ - public LayerCollectionPanel(GCubeCollection coll, HandlerManager applicationBus) { + public LayerCollectionPanel(final GCubeCollection coll, HandlerManager applicationBus) { initWidget(uiBinder.createAndBindUi(this)); + this.applicationBus = applicationBus; buttonLegend.setType(ButtonType.LINK); legendPanel.setVisible(false); @@ -112,18 +123,16 @@ public class LayerCollectionPanel extends Composite { @Override public void onValueChange(ValueChangeEvent event) { GWT.log("Collection selector flag changed to value : " + event.toDebugString()); - -// String collectionID = ((CheckBox) event.getSource()).getId().replace("gcubeCollectionSelector_", -// ""); - GWT.log("Collection ID is : " + collectionID + ", event value: " + event.getValue()); if (event.getValue()) { // OPEN COLLECTION applicationBus.fireEvent(new OpenCollectionEvent(collectionID)); + enableLayerStyle(true); } else { // CLOSE COLLECTION - legendPanel.clear(); - legendPanel.setVisible(false); + hideStyleLegend(); + resetLayerStyle(); + enableLayerStyle(false); applicationBus.fireEvent(new CloseCollectionEvent(collectionID)); } } @@ -132,7 +141,7 @@ public class LayerCollectionPanel extends Composite { basePanel.add(checkbox); ViewerConfiguration theConfig = GeoportalDataViewer.getStatus().getViewerConfig(); - GCubeCollection toOpen = theConfig.getAvailableCollections().get(collectionID); + final GCubeCollection toOpen = theConfig.getAvailableCollections().get(collectionID); // Check if indexes is empty if (toOpen.getIndexes() == null || toOpen.getIndexes().isEmpty()) { @@ -140,6 +149,7 @@ public class LayerCollectionPanel extends Composite { Window.alert("Cannot open collection index layer for " + toOpen.getUcd().getName() + "."); return; } + this.gcubeCollection = toOpen; // TODO Get Default Index Layer // For now we just take the first - only 1 is expected IndexLayerDV layer = toOpen.getIndexes().get(0); @@ -147,7 +157,7 @@ public class LayerCollectionPanel extends Composite { HashMap ogcLinks = layer.getLayer().getOgcLinks(); final String wmsLink = ogcLinks.get("wms"); - final String layerName = URLUtil.getValueOfParameter("layers", wmsLink); + this.layerName = URLUtil.getValueOfParameter("layers", wmsLink); GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, new AsyncCallback() { @@ -182,9 +192,7 @@ public class LayerCollectionPanel extends Composite { GWT.log("is isToggle: " + buttonLegend.isToggle()); GWT.log("is isToggled: " + buttonLegend.isToggled()); if (legendPanel.isVisible()) { - legendPanel.clear(); - legendPanel.setVisible(false); - + hideStyleLegend(); } else { legendPanel.setVisible(true); loadLegend(wmsLink); @@ -193,11 +201,45 @@ public class LayerCollectionPanel extends Composite { } }); + listBoxStyles.addChangeHandler(new ChangeHandler() { + + @Override + public void onChange(ChangeEvent event) { + setLayerStyle(); + + } + }); } }); } + private void setLayerStyle() { + UpdateLayerToMapEvent updateLayer = new UpdateLayerToMapEvent(this.gcubeCollection, this.layerName, + LAYER_TYPE.INDEX); + updateLayer.setOperation(REQUEST_PARAMETER.STYLE, listBoxStyles.getSelectedValue()); + applicationBus.fireEvent(updateLayer); + if (legendPanel.isVisible()) { + legendPanel.clear(); + legendPanel.setVisible(false); + + } + } + + private void resetLayerStyle() { + listBoxStyles.setSelectedIndex(0); + listBoxStyles.setSelectedValue(listBoxStyles.getSelectedValue()); + } + + private void enableLayerStyle(boolean enabled) { + listBoxStyles.setEnabled(enabled); + } + + private void hideStyleLegend() { + legendPanel.clear(); + legendPanel.setVisible(false); + } + /** * Gets the checkbox. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/WFSMakerUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/WFSMakerUtil.java index 5307159..5b09174 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/WFSMakerUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/WFSMakerUtil.java @@ -8,6 +8,7 @@ public class WFSMakerUtil { public static final String CQL_FILTER_PARAMETER = "CQL_FILTER"; + public static String buildWFSRequest(String webserviceURL, String layerName, int maxFeatures, String propertyName, String cqlFilter) throws Exception {