From 5daa568c44c6d66784bf2cac4f470a0c645cdc54 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 7 Dec 2021 17:13:20 +0100 Subject: [PATCH 01/12] In progress #22518 --- .classpath | 6 +- .../com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 35 +- CHANGELOG.md | 7 + pom.xml | 2 +- .../client/GeoportalDataViewer.java | 57 ++- .../client/GeoportalDataViewerConstants.java | 4 + .../client/GeoportalDataViewerService.java | 23 ++ .../GeoportalDataViewerServiceAsync.java | 8 + .../client/OLMapManager.java | 13 +- .../client/OverlayLayerManager.java | 1 - .../client/events/GetListOfRecordsEvent.java | 83 ++++ .../events/GetListOfRecordsEventHandler.java | 22 ++ .../client/ui/GeonaDataViewMainPanel.java | 27 +- .../client/ui/GeonaDataViewMainPanel.ui.xml | 10 +- .../client/ui/SearchFacilityUI.java | 369 ++++++++++++++++++ .../client/ui/SearchFacilityUI.ui.xml | 60 +++ .../GeoportalDataViewerServiceImpl.java | 70 ++++ .../server/util/SessionUtil.java | 50 +++ src/main/webapp/GeoportalDataViewer.css | 48 +++ 20 files changed, 866 insertions(+), 31 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/GetListOfRecordsEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/GetListOfRecordsEventHandler.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.ui.xml diff --git a/.classpath b/.classpath index 3f84059..2d08333 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -35,5 +35,5 @@ - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index 4c65c64..5367c1d 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.1.0-SNAPSHOT +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.2.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index af45588..db1d6e9 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,41 +1,54 @@ - + - - + + + + - + + - + + - + + - + + - + + uses + + + - + + - + + - + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 95a8e22..87fc667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,17 @@ 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). +## [v2.2.0-SNAPSHOT] - 2021-12-07 + +#### Enhancements + +- [#22518] Added the search for fields facility + ## [v2.1.0-SNAPSHOT] - 2021-11-10 #### Enhancements +- [#22518] Added the search for name facility - [#22027] Integrated with MapBox Satellite - Added link "Open Project" in the pop-up of WFS details - Moved to gwt-ol3 v8.1.0-gwt2_9 diff --git a/pom.xml b/pom.xml index eccb30a..a7fea41 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-viewer-app war - 2.1.0-SNAPSHOT + 2.2.0-SNAPSHOT GeoPortal Data Viewer App The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products 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 9dd16d9..2e1af10 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 @@ -1,11 +1,16 @@ package org.gcube.portlets.user.geoportaldataviewer.client; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.LayerItem; +import org.gcube.application.geoportalcommon.shared.SearchingFilter; +import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; @@ -100,6 +105,10 @@ public class GeoportalDataViewer implements EntryPoint { private HTML attributionDiv = new HTML(); private static List listBaseMapLayers = null; + + private List displayFields = new ArrayList(); + private List sortByFields = new ArrayList(); + private List searchByFields = new ArrayList(); /** * This is the entry point method. @@ -120,8 +129,49 @@ public class GeoportalDataViewer implements EntryPoint { RootPanel.get(APP_DIV).add(loaderApp); - mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight()); - RootPanel.get(APP_DIV).add(mainPanel); + GeoportalDataViewerServiceAsync.Util.getInstance().listOfFieldsForSearching(new AsyncCallback>() { + + @Override + public void onFailure(Throwable caught) { + Window.alert(caught.getMessage()); + + } + + @Override + public void onSuccess(List result) { + + for (ItemField itemField : result) { + if(itemField.isDisplayIntoTable()) { + displayFields.add(itemField); + } + + if(itemField.isSearchable()) { + searchByFields.add(itemField); + } + + if(itemField.isSortable()) { + sortByFields.add(itemField); + } + } + + + GWT.log("List display fields: "+result); + SearchingFilter initialSortFilter = new SearchingFilter(); + initialSortFilter.setOrder(ORDER.ASC); + initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true))); + + mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight(),searchByFields,sortByFields,initialSortFilter); + RootPanel.get(APP_DIV).add(mainPanel); + + initApplication(); + } + + + }); + + } + + private void initApplication() { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @@ -176,11 +226,10 @@ public class GeoportalDataViewer implements EntryPoint { } }); - - bindEvents(); RootPanel.get(APP_DIV).add(attributionDiv); + } public static List getListBaseMapLayers() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index e1117c0..5f7b211 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -67,6 +67,10 @@ public class GeoportalDataViewerConstants { } } + + public enum RECORD_TYPE { + CONCESSIONE + } public static final double ITALY_CENTER_LONG = 12.45; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index b48828a..c1479a1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -4,6 +4,9 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.ItemField; +import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; +import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; @@ -127,5 +130,25 @@ public interface GeoportalDataViewerService extends RemoteService { List getListBaseLayers(); + /** + * List of fields for searching. + * + * @return the list + */ + List listOfFieldsForSearching(); + + /** + * Gets the list concessioni. + * + * @param start the start + * @param limit the limit + * @param filter the filter + * @param reloadFromService the reload from service + * @return the list concessioni + * @throws Exception the exception + */ + ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter, + boolean reloadFromService) throws Exception; + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index 462a52e..ec88a44 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -4,6 +4,9 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.ItemField; +import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; +import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; @@ -61,4 +64,9 @@ public interface GeoportalDataViewerServiceAsync { void getListBaseLayers(AsyncCallback> callback); + void listOfFieldsForSearching(AsyncCallback> callback); + + void getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService, + AsyncCallback callback); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index 294aab6..24fa9b6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -46,7 +46,7 @@ public class OLMapManager { * * @param targetId the target id * @param layerManagerBus the layer manager bus - * @param baseMapLayer the base map layer + * @param baseMapLayer the base map layer */ public OLMapManager(String targetId, HandlerManager layerManagerBus, BaseMapLayer baseMapLayer) { this.targetId = targetId; @@ -75,7 +75,8 @@ public class OLMapManager { // // } - ExtentWrapped toExt = new ExtentWrapped(coordinate.getX(), coordinate.getY(), coordinate.getX(), coordinate.getY()); + ExtentWrapped toExt = new ExtentWrapped(coordinate.getX(), coordinate.getY(), coordinate.getX(), + coordinate.getY()); GeoQuery select = toDataPointQuery(coordinate, true); layerManagerBus.fireEvent(new QueryDataEvent(select, toExt, null, true, MapEventType.MOUSE_CLICK)); @@ -140,7 +141,7 @@ public class OLMapManager { /** * To data point query. * - * @param coordinate the coordinate + * @param coordinate the coordinate * @param manualClick the manual click * @return the geo query */ @@ -157,12 +158,12 @@ public class OLMapManager { // ratio - mapPixelWeight : bboxWeight = 20px : geoRectangleWidth // where 10px is the pixel diameter dimension of the clicked point double bboxWidth = Math.abs(olMap.getExtent().getLowerLeftX() - olMap.getExtent().getUpperRightX()); - + double geoWidth = 0; // adding a tolerance in case of manual click if (manualClick) { // adding a tolerance for clicking - //geoWidth = (bboxWidth / w) * (14 / 2); + // geoWidth = (bboxWidth / w) * (14 / 2); geoWidth = (bboxWidth / w) * (16 / 2); } else { // data point selection for coordinate loaded from concessione @@ -211,7 +212,7 @@ public class OLMapManager { GWT.log("the distance is: " + dist); if (dist > 5000 || startExt.containsExtent(endExt)) { GeoQuery select = toDataBoxQuery(dragEndExtent); - //TODO THE AUTOMATICALLY SHOWING POP-UP ACCORDING TO ZOOM IS BUGGY + // TODO THE AUTOMATICALLY SHOWING POP-UP ACCORDING TO ZOOM IS BUGGY layerManagerBus.fireEvent(new QueryDataEvent(select, endExt, null, false, mapEventType)); } } else if (zoomStart != null && zoomEnd != null) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OverlayLayerManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OverlayLayerManager.java index 05affaa..436423b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OverlayLayerManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OverlayLayerManager.java @@ -16,7 +16,6 @@ public class OverlayLayerManager { public OverlayLayerManager(HandlerManager applicationBus) { this.applicationBus = applicationBus; - //fp.addStyleName("layers-panel"); } void addLayerItem(LayerObject lo) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/GetListOfRecordsEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/GetListOfRecordsEvent.java new file mode 100644 index 0000000..a4f2cc7 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/GetListOfRecordsEvent.java @@ -0,0 +1,83 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import org.gcube.application.geoportalcommon.shared.SearchingFilter; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.RECORD_TYPE; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class GetListOfRecordsEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Dec 7, 2021 + */ +public class GetListOfRecordsEvent extends GwtEvent { + + /** The type. */ + public static Type TYPE = new Type(); + private RECORD_TYPE recordType; + private SearchingFilter sortFilter; + + /** + * Instantiates a new cancel upload event. + * + * @param recordType the record type + * @param sortFilter the sort filter + */ + public GetListOfRecordsEvent(RECORD_TYPE recordType, SearchingFilter sortFilter) { + this.recordType = recordType; + this.sortFilter = sortFilter; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + /* + * (non-Javadoc) + * + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared. + * EventHandler) + */ + @Override + protected void dispatch(GetListOfRecordsEventHandler handler) { + handler.onGetList(this); + } + + /** + * Gets the record type. + * + * @return the record type + */ + public RECORD_TYPE getRecordType() { + return recordType; + } + + /** + * Gets the sort filter. + * + * @return the sort filter + */ + public SearchingFilter getSortFilter() { + return sortFilter; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/GetListOfRecordsEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/GetListOfRecordsEventHandler.java new file mode 100644 index 0000000..4d00089 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/GetListOfRecordsEventHandler.java @@ -0,0 +1,22 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import com.google.gwt.event.shared.EventHandler; + + +/** + * The Interface GetListOfRecordsEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 4, 2021 + */ +public interface GetListOfRecordsEventHandler extends EventHandler { + + + /** + * On get list. + * + * @param getListOfRecordsEvent the get list of records event + */ + void onGetList(GetListOfRecordsEvent getListOfRecordsEvent); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index 3a7e45f..6fb57e8 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -3,6 +3,8 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.ItemField; +import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; @@ -87,9 +89,15 @@ public class GeonaDataViewMainPanel extends Composite { @UiField Button linkLayers; + + @UiField + DropdownButton searchFacilityButton; @UiField ScrollPanel overlayLayersPanel; + + @UiField + ScrollPanel searchFacilityPanel; @UiField HTMLPanel panelAttribution; @@ -109,6 +117,8 @@ public class GeonaDataViewMainPanel extends Composite { private HandlerManager applicationBus; + private SearchFacilityUI searchFacility; + /** * Instantiates a new geona data view main panel. @@ -116,7 +126,8 @@ public class GeonaDataViewMainPanel extends Composite { * @param applicationBus the application bus * @param mapHeight the map height */ - public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight) { + public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight, List sortByFields, + List searchForFields, SearchingFilter initialSortFilter) { initWidget(uiBinder.createAndBindUi(this)); this.applicationBus = applicationBus; mapPanel = new MapPanel(mapHeight + "px"); @@ -142,6 +153,8 @@ public class GeonaDataViewMainPanel extends Composite { linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get()); linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get()); + searchFacility = new SearchFacilityUI(applicationBus, sortByFields, searchForFields, initialSortFilter); + searchFacilityPanel.add(searchFacility); // layersDDB.setToggle(true); bindEvents(); @@ -163,7 +176,17 @@ public class GeonaDataViewMainPanel extends Composite { } } }); - + + searchFacilityButton.addDomHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + //event.preventDefault(); + event.stopPropagation(); + + } + }, ClickEvent.getType()); + } /** diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index c996e06..d0397c4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -35,12 +35,14 @@ - + + title="Center Map to Location" text="Preset Location" + ui:field="linkPresetLocation"> @@ -50,6 +52,10 @@ text="World" title="Center to World"> + + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java new file mode 100644 index 0000000..811853f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java @@ -0,0 +1,369 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.ui; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.gcube.application.geoportalcommon.shared.ItemField; +import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; +import org.gcube.application.geoportalcommon.shared.SearchingFilter; +import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.RECORD_TYPE; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; +import org.gcube.portlets.user.geoportaldataviewer.client.events.GetListOfRecordsEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; + +import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.ListBox; +import com.github.gwtbootstrap.client.ui.NavLink; +import com.github.gwtbootstrap.client.ui.TextBox; +import com.github.gwtbootstrap.client.ui.constants.ButtonType; +import com.google.gwt.core.client.GWT; +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.KeyPressEvent; +import com.google.gwt.event.dom.client.KeyPressHandler; +import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.FlexTable; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HTMLPanel; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Widget; + +public class SearchFacilityUI extends Composite { + + private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class); + + protected static final int MIN_LENGHT_SERCHING_STRING = 3; + + @UiField + ListBox listBoxSortBy; + + @UiField + ListBox listBoxSearchFor; + + @UiField + TextBox searchField; + + @UiField + NavLink sortByToogle; + + @UiField + Button resetSearch; + + @UiField + HTMLPanel panelResults; + + @UiField + HorizontalPanel toogleSortBy; + + private List searchForFields; + + private List sortByFields; + + private SearchingFilter currentSortFilter; + + private HandlerManager appManagerBus; + + private static final String LABEL_FILTER_SEPARATOR = " - "; + + interface SearchFacilityPanelUiBinder extends UiBinder { + } + + public SearchFacilityUI(HandlerManager appManagerBus, List sortByFields, List searchForFields, + SearchingFilter initialSortFilter) { + initWidget(uiBinder.createAndBindUi(this)); + this.searchForFields = searchForFields; + this.currentSortFilter = initialSortFilter; + this.sortByFields = sortByFields; + this.appManagerBus = appManagerBus; + + resetSearch.setType(ButtonType.LINK); + + listBoxSortBy.setWidth("130px"); + listBoxSearchFor.setWidth("130px"); + + bindEvents(); + } + + private String toLabelFilter(ItemField itemField, ORDER direction) { + String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name(); + return labelFilter; + } + + /** + * Bind events. + */ + private void bindEvents() { + + for (ItemField record_FIELD : sortByFields) { + String labelASC = toLabelFilter(record_FIELD, ORDER.ASC); + String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC); + listBoxSortBy.addItem(labelASC); + listBoxSortBy.addItem(labelDESC); + } + + listBoxSortBy.addChangeHandler(new ChangeHandler() { + + @Override + public void onChange(ChangeEvent event) { + appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); + + } + }); + + for (ItemField record_FIELD : searchForFields) { + listBoxSearchFor.addItem(record_FIELD.getDisplayName()); + } + + listBoxSearchFor.addChangeHandler(new ChangeHandler() { + + @Override + public void onChange(ChangeEvent event) { + + // alertSearchFor.setText(listBoxSearchFor.getSelectedValue()); + + if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) { + doSearchEvent(); + } + + } + }); + + sortByToogle.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + if (toogleSortBy.isVisible()) + toogleSortBy.setVisible(false); + else + toogleSortBy.setVisible(true); + + } + }); + +// navShowOnMap.addClickHandler(new ClickHandler() { +// +// @Override +// public void onClick(ClickEvent event) { +// List listConcessioni = null; +// if (grpw != null && grpw.getSelectItems() != null) { +// listConcessioni = grpw.getSelectItems(); +// } +// appManagerBus +// .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.VIEW_ON_MAP)); +// +// } +// }); + + searchField.addKeyPressHandler(new KeyPressHandler() { + + @Override + public void onKeyPress(KeyPressEvent event) { + if (com.google.gwt.event.dom.client.KeyCodes.KEY_ENTER == event.getCharCode()) { + GWT.log(searchField.getText()); + doSearchEvent(); + } + + } + }); + + resetSearch.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + searchField.setText(""); + appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); + resetSearch.setVisible(false); + } + }); + + } + + private void searchConcessioni() { + + SearchingFilter filter = getCurrentSortFilter(); + + GeoportalDataViewerServiceAsync.Util.getInstance().getListConcessioni(0, 30, filter, false, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { +// showLoading(false); +// Window.alert(caught.getMessage()); + + } + + @Override + public void onSuccess(ResultSetPaginatedData result) { + + panelResults.clear(); + panelResults.add(new HTML("
")); + + if (result.getData().size() == 0) { + panelResults.add(new HTML("No result found")); + return; + } + + FlexTable ft = new FlexTable(); + ft.getElement().setClassName("table-results"); + int i = 0; + ft.setWidget(0, i, new HTML("Name")); + + String selValue = listBoxSearchFor.getSelectedValue().toLowerCase(); + + boolean addIntroduction = false; + if(selValue.startsWith("name")) { + ft.setWidget(0, ++i, new HTML("Introduction")); + addIntroduction = true; + } + + boolean addStaff = false; + if(selValue.startsWith("staff")) { + ft.setWidget(0, ++i, new HTML("Staff")); + addStaff = true; + } + boolean addParole = false; + if(selValue.startsWith("parola")) { + ft.setWidget(0, ++i, new HTML("Parole Libere")); + ft.setWidget(0, ++i, new HTML("Parole Cronologia")); + addParole = true; + } + + i = 1; + for (ConcessioneDV concessione : result.getData()) { + int j = -1; + ft.setWidget(i, ++j, new HTML(concessione.getNome())); + if(addIntroduction) + ft.setWidget(i, ++j, new HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 100))); + + if(addStaff) { + ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getAuthors()))); + } + + if(addParole) { + ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveLibere()))); + ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveICCD()))); + } + + +// List listImg = concessione.getImmaginiRappresentative(); +// GWT.log(listImg.toString()); +// boolean imagePreviewFound = false; +// if (listImg != null && listImg.size() > 0) { +// +// UploadedImageDV uImg = listImg.get(0); +// +// if (uImg != null && uImg.getListWsContent() != null +// && uImg.getListWsContent().size() > 0) { +// WorkspaceContentDV wsc = uImg.getListWsContent().get(0); +// String image = "" + wsc.getName() + ""; +// ft.setWidget(i, 2, new HTML(image)); +// imagePreviewFound = true; +// } +// } +// +// if (!imagePreviewFound) { +// ft.setWidget(i, 2, new Image(GNAImages.ICONS.italyIcon())); +// } + + i++; + } + + panelResults.add(ft); + + } + }); + } + + /** + * To display authors. + * + * @param authors the authors + * @return the string + */ + private String toDisplayList(List listValues) { + String toDisplay = ""; + if (listValues == null) + return toDisplay; + + for (String author : listValues) { + toDisplay += author + "; "; + } + return toDisplay; + } + + private void doSearchEvent() { + String searchText = searchField.getText(); + if (searchText.length() < MIN_LENGHT_SERCHING_STRING) { + Window.alert("Please enter at least " + MIN_LENGHT_SERCHING_STRING + " characters"); + return; + } + + resetSearch.setVisible(true); + // appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, + // getCurrentSortFilter())); + + searchConcessioni(); + } + + public SearchingFilter toSortFilter(String labelFilter) { + GWT.log("toSortFilter for label " + labelFilter); + String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR); + + SearchingFilter sortFilter = null; + try { + ItemField recordField = null; + for (ItemField value : sortByFields) { + if (array[0].equalsIgnoreCase(value.getDisplayName())) { + recordField = value; + break; + } + } + ORDER orderField = ORDER.valueOf(array[1]); + sortFilter = new SearchingFilter(Arrays.asList(recordField), orderField); + } catch (Exception e) { + + } + GWT.log("toSortFilter Got " + sortFilter); + return sortFilter; + + } + + private SearchingFilter builtSearchingFilter() { + SearchingFilter searchingFilter = toSortFilter(listBoxSortBy.getSelectedValue()); + String searchText = searchField.getText(); + if (searchText != null && !searchText.isEmpty()) { + Map searchInto = new HashMap(); + + String searchForField = ""; + + for (ItemField recordField : searchForFields) { + if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) { + searchForField = recordField.getJsonFields().get(0); + continue; + } + } + searchInto.put(searchForField, searchText); + searchingFilter.setSearchInto(searchInto); + } + return searchingFilter; + } + + public SearchingFilter getCurrentSortFilter() { + currentSortFilter = builtSearchingFilter(); + GWT.log("currentSortFilter: " + currentSortFilter); + return currentSortFilter; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.ui.xml new file mode 100644 index 0000000..c69f3ab --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.ui.xml @@ -0,0 +1,60 @@ + + + + .important { + font-weight: bold; + } + + .container-panel { + padding: 10px; + } + + .add-margin-right { + margin-right: 5px; + } + + .add-margin-right-23 { + margin-right: 23px; + } + + .margin-top-5 { + margin-top: 5px; + } + .font-size-12 { + font-size: 12px; + } + + + + + + + Search for: + + + + Reset + + + + Sort Results + + Sort by: + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index fcad66e..0065e9f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -16,9 +16,13 @@ import org.gcube.application.geoportal.common.model.legacy.UploadedImage; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader; import org.gcube.application.geoportalcommon.GeoportalCommon; +import org.gcube.application.geoportalcommon.MongoServiceCommon; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.LayerItem; +import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; +import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; @@ -667,6 +671,11 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } + /** + * Gets the list base layers. + * + * @return the list base layers + */ @Override public List getListBaseLayers() { LOG.info("getListBaseLayers called"); @@ -678,5 +687,66 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme return listBL; } + + // TODO THIS PART REQUIRES THE JSON MAPPING based on keys read from gCube Meta + + /** + * List of fields for searching. + * + * @return the list + */ + @Override + public List listOfFieldsForSearching() { + //GeoportalCommon gc = new GeoportalCommon(); + //return gc.getGNADataConfig().getListItemFields(); + + List listItemFields = new ArrayList(); + listItemFields.add(new ItemField("Name", Arrays.asList("nome"), true, true, true)); + listItemFields.add(new ItemField("Staff", Arrays.asList("authors"), true, true, true)); + listItemFields.add(new ItemField("Parola chiave", Arrays.asList("paroleChiaveLibere","paroleChiaveICCD"), true, true, true)); + return listItemFields; + } + + + /** + * Gets the list concessioni. + * + * @param start the start + * @param limit the limit + * @param filter the filter + * @param reloadFromService the reload from service + * @return the list concessioni + * @throws Exception the exception + */ + @Override + public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter, + boolean reloadFromService) throws Exception { + LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit + ", filter: " + filter); + + try { + + SessionUtil.getCurrentContext(getThreadLocalRequest(), true); + + MongoServiceCommon serviceCommon = new MongoServiceCommon(); +// MongoServiceUtil serviceUtil = new MongoServiceUtil(); +// MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + + // TODO MUST BE REPLACED BY COUNT + + List listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(), + reloadFromService); + int listConcessioniSize = listOfConcessioni.size(); + + ResultSetPaginatedData searchedData = serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter, + "concessione"); + return searchedData; + + } catch (Exception e) { + LOG.error("Error on loading paginated and filtered list of concessioni: ", e); + throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage()); + } + + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java index 301178d..424fc66 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java @@ -3,11 +3,16 @@ */ package org.gcube.portlets.user.geoportaldataviewer.server.util; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.application.geoportal.common.rest.MongoConcessioni; +import org.gcube.application.geoportalcommon.MongoServiceCommon; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; @@ -40,6 +45,8 @@ public class SessionUtil { private static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; private static final String LIST_BASE_MAPS_LAYERS = "LIST_BASE_MAPS_LAYERS"; + private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI_DATA_VIEWER"; + /** * Checks if is into portal. * @@ -197,4 +204,47 @@ public class SessionUtil { } return lstBML; } + + + /** + * Gets the list of concessioni. + * + * @param httpServletRequest the http servlet request + * @param reloadFromService the reload from service + * @return the list of concessioni + * @throws Exception the exception + */ + public static List getListOfConcessioni(HttpServletRequest httpServletRequest, + boolean reloadFromService) throws Exception { + HttpSession session = httpServletRequest.getSession(); + List listOfConcessioni = (List) session.getAttribute(LIST_OF_CONCESSIONI); + + // setting null to force reloading from service + if (reloadFromService) + listOfConcessioni = null; + + if (listOfConcessioni == null) { + listOfConcessioni = new ArrayList(); + LOG.info("Loading list of concessione from client mongo"); + SessionUtil.getCurrentContext(httpServletRequest, true); + MongoServiceCommon serviceUtil = new MongoServiceCommon(); + MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); + + Iterator concessioni = clientMongo.getList(); + if (concessioni != null) { + while (concessioni.hasNext()) { + Concessione concessione = (Concessione) concessioni.next(); + listOfConcessioni.add(concessione); + + } + } + // LOG.debug("Got list of concessioni from client mongo: " + listOfConcessioni); + session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni); + LOG.info("Saved in session list of concessioni from client mongo with size: " + listOfConcessioni.size()); + } else + LOG.info("list of concessioni presents in session, using it"); + + LOG.info("read list of concessioni with size: " + listOfConcessioni.size()); + return listOfConcessioni; + } } diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index ae17cf6..26624c2 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -450,4 +450,52 @@ body { top: 50%; left: 50%; } + + +/*******************************************/ + +.search-facility { + width: 600px; + max-height: 700px; +} + +.search-textbox { + padding: 4px 14px !important; + margin-bottom: 0 !important; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important; + font-size: 13px !important; + font-weight: normal !important; + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + border-radius: 15px !important; + width: 250px !important; +} + +.table-results { + table-layout: fixed; + width: 600px; +} + +.table-results td { + padding: 5px; + /* For Firefox */ + white-space: pre-wrap; + word-break: break-all; + /* For Chrome and IE */ + word-wrap: break-word; +} + +.table-results tr:nth-child(1) { + font-weight: bolder; + color: #333; + font-style: italic +} + +.table-results tr { + border-bottom: 1px solid #ccc; +} + +.table-results td:nth-child(1) { + width: 200px; +} \ No newline at end of file -- 2.17.1 From 0e97a234cec4e5b742cff63ffad578897df77812 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 10 Dec 2021 16:19:33 +0100 Subject: [PATCH 02/12] #22518 Added the search facility --- .../client/GeoportalDataViewer.java | 22 +++- .../events/ShowPopupOnCentroiEvent.java | 61 ++++++++++ .../ShowPopupOnCentroiEventHandler.java | 21 ++++ .../client/ui/GeonaDataViewMainPanel.java | 15 ++- .../client/ui/GeonaDataViewMainPanel.ui.xml | 9 +- .../client/ui/SearchFacilityUI.java | 105 ++++++++++++++---- .../GeoportalDataViewerServiceImpl.java | 15 ++- src/main/webapp/GeoportalDataViewer.css | 6 +- 8 files changed, 213 insertions(+), 41 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEventHandler.java 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 2e1af10..2a133b8 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 @@ -31,6 +31,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEven import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler; +import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEventHandler; 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.gis.ExtentWrapped; @@ -139,6 +141,7 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void onSuccess(List result) { + GWT.log("Loaded item fields: "+result); for (ItemField itemField : result) { if(itemField.isDisplayIntoTable()) { @@ -160,7 +163,7 @@ public class GeoportalDataViewer implements EntryPoint { initialSortFilter.setOrder(ORDER.ASC); initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true))); - mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight(),searchByFields,sortByFields,initialSortFilter); + mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight(),sortByFields,searchByFields,initialSortFilter); RootPanel.get(APP_DIV).add(mainPanel); initApplication(); @@ -256,7 +259,7 @@ public class GeoportalDataViewer implements EntryPoint { geonaDataViewerProfile = profile; GWT.log("Profile: " + geonaDataViewerProfile); Iterator it; - String theItemType = paramGeonaItemType; + String theItemType = paramGeonaItemType.toLowerCase(); if (theItemType == null) { it = geonaDataViewerProfile.getMapLayers().keySet().iterator(); it.hasNext(); @@ -381,7 +384,7 @@ public class GeoportalDataViewer implements EntryPoint { public void run() { attempt++; GWT.log("waiting get record: " + attempt); - RecordDV record = mainPanel.getDisplyedRecord(); + RecordDV record = mainPanel.getDisplayedRecord(); if (record != null) { this.cancel(); GWT.log("cancelled timer"); @@ -427,7 +430,7 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) { - if (mainPanel.getDisplyedRecord() == null && !olMapMng.isQueryPointActive()) { + if (mainPanel.getDisplayedRecord() == null && !olMapMng.isQueryPointActive()) { olMapMng.hidePopInfo(); layerManager.removeAllDetailLayers(); @@ -518,6 +521,17 @@ public class GeoportalDataViewer implements EntryPoint { } }); + + applicationBus.addHandler(ShowPopupOnCentroiEvent.TYPE, new ShowPopupOnCentroiEventHandler() { + + @Override + public void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent) { + + if(showPopupOnCentroiEvent.getRecord()!=null) + performWFSQueryOnCentroid(showPopupOnCentroiEvent.getRecord()); + + } + }); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEvent.java new file mode 100644 index 0000000..07c07af --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEvent.java @@ -0,0 +1,61 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; + +import com.google.gwt.event.shared.GwtEvent; + + +/** + * The Class ShowDetailsEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jul 30, 2021 + */ +public class ShowPopupOnCentroiEvent extends GwtEvent { + public static Type TYPE = new Type(); + private RecordDV record; + + + /** + * Instantiates a new show details event. + * + * @param geonaItemType the geona item type + * @param geonaMongoID the geona mongo ID + * @param itemName the item name + * @param featureRow the feature row + */ + public ShowPopupOnCentroiEvent(RecordDV record) { + this.record = record; + + } + + + /** + * Gets the associated type. + * + * @return the associated type + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + @Override + protected void dispatch(ShowPopupOnCentroiEventHandler handler) { + handler.onShowPopup(this); + + } + + public RecordDV getRecord() { + return record; + } + + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEventHandler.java new file mode 100644 index 0000000..c668c23 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEventHandler.java @@ -0,0 +1,21 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import com.google.gwt.event.shared.EventHandler; + + +/** + * The Interface ShowPopupOnCentroiEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Dec 10, 2021 + */ +public interface ShowPopupOnCentroiEventHandler extends EventHandler { + + /** + * On show popup. + * + * @param showPopupOnCentroiEvent the show popup on centroi event + */ + void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent); +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index 6fb57e8..d02ae32 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -23,6 +23,8 @@ import com.github.gwtbootstrap.client.ui.NavLink; import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.constants.IconType; import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -154,7 +156,18 @@ public class GeonaDataViewMainPanel extends Composite { linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get()); searchFacility = new SearchFacilityUI(applicationBus, sortByFields, searchForFields, initialSortFilter); + searchFacilityButton.setIcon(IconType.SEARCH); searchFacilityPanel.add(searchFacility); + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + searchFacilityPanel.getElement().getParentElement().getStyle().setOpacity(0.9); + + } + + }); + // layersDDB.setToggle(true); bindEvents(); @@ -318,7 +331,7 @@ public class GeonaDataViewMainPanel extends Composite { * * @return the displyed record */ - public RecordDV getDisplyedRecord() { + public RecordDV getDisplayedRecord() { return detailsPanel.getDisplayedRecord(); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index d0397c4..22022a9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -35,6 +35,11 @@
+ + + @@ -52,10 +57,6 @@ text="World" title="Center to World"> - - - diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java index 811853f..d719152 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java @@ -1,25 +1,32 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.RECORD_TYPE; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; -import org.gcube.portlets.user.geoportaldataviewer.client.events.GetListOfRecordsEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; +import com.github.gwtbootstrap.client.ui.Alert; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.NavLink; import com.github.gwtbootstrap.client.ui.TextBox; +import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.ButtonType; +import com.github.gwtbootstrap.client.ui.constants.IconType; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; @@ -75,6 +82,8 @@ public class SearchFacilityUI extends Composite { private HandlerManager appManagerBus; private static final String LABEL_FILTER_SEPARATOR = " - "; + + private ResultSetPaginatedData latestResult; interface SearchFacilityPanelUiBinder extends UiBinder { } @@ -106,32 +115,35 @@ public class SearchFacilityUI extends Composite { private void bindEvents() { for (ItemField record_FIELD : sortByFields) { - String labelASC = toLabelFilter(record_FIELD, ORDER.ASC); - String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC); - listBoxSortBy.addItem(labelASC); - listBoxSortBy.addItem(labelDESC); + if(record_FIELD.isSortable()) { + String labelASC = toLabelFilter(record_FIELD, ORDER.ASC); + String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC); + listBoxSortBy.addItem(labelASC); + listBoxSortBy.addItem(labelDESC); + } } listBoxSortBy.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { - appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); - + if(latestResult!=null && latestResult.getData().size()>0) { + doSearchEvent(); + } } }); for (ItemField record_FIELD : searchForFields) { - listBoxSearchFor.addItem(record_FIELD.getDisplayName()); + GWT.log("search for: "+record_FIELD); + if(record_FIELD.isSearchable()) { + listBoxSearchFor.addItem(record_FIELD.getDisplayName()); + } } listBoxSearchFor.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { - - // alertSearchFor.setText(listBoxSearchFor.getSelectedValue()); - if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) { doSearchEvent(); } @@ -182,8 +194,10 @@ public class SearchFacilityUI extends Composite { @Override public void onClick(ClickEvent event) { searchField.setText(""); - appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); + //appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); resetSearch.setVisible(false); + panelResults.clear(); + latestResult = null; } }); @@ -192,19 +206,30 @@ public class SearchFacilityUI extends Composite { private void searchConcessioni() { SearchingFilter filter = getCurrentSortFilter(); - + panelResults.clear(); + panelResults.add(new HTML("
")); + panelResults.add(new LoaderIcon("Searching...")); GeoportalDataViewerServiceAsync.Util.getInstance().getListConcessioni(0, 30, filter, false, new AsyncCallback() { + + @Override public void onFailure(Throwable caught) { // showLoading(false); // Window.alert(caught.getMessage()); - + panelResults.clear(); + panelResults.add(new HTML("
")); + Alert alert = new Alert("Error on searching. Please, refresh or change it"); + alert.setType(AlertType.ERROR); + alert.setClose(false); + panelResults.add(alert); } @Override public void onSuccess(ResultSetPaginatedData result) { + + latestResult = result; panelResults.clear(); panelResults.add(new HTML("
")); @@ -216,20 +241,24 @@ public class SearchFacilityUI extends Composite { FlexTable ft = new FlexTable(); ft.getElement().setClassName("table-results"); - int i = 0; + int i = 1; ft.setWidget(0, i, new HTML("Name")); String selValue = listBoxSearchFor.getSelectedValue().toLowerCase(); boolean addIntroduction = false; - if(selValue.startsWith("name")) { + if(selValue.startsWith("name") || selValue.startsWith("any")) { ft.setWidget(0, ++i, new HTML("Introduction")); addIntroduction = true; } boolean addStaff = false; - if(selValue.startsWith("staff")) { - ft.setWidget(0, ++i, new HTML("Staff")); + if(selValue.startsWith("direttore")) { + ft.setWidget(0, ++i, new HTML("Authors")); + ft.setWidget(0, ++i, new HTML("Responsabile")); + ft.setWidget(0, ++i, new HTML("Editore")); + ft.setWidget(0, ++i, new HTML("Titolari")); + ft.setWidget(0, ++i, new HTML("Contributore")); addStaff = true; } boolean addParole = false; @@ -242,12 +271,35 @@ public class SearchFacilityUI extends Composite { i = 1; for (ConcessioneDV concessione : result.getData()) { int j = -1; + + NavLink locateOnMap = new NavLink("Show"); + locateOnMap.setTitle("Locate on the Map and show details"); + locateOnMap.setIcon(IconType.MAP_MARKER); + + locateOnMap.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + GeoNaItemRef gir = new GeoNaItemRef(concessione.getItemId(), GeoportalDataViewerConstants.RECORD_TYPE.CONCESSIONE.toString()); + appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null)); + appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(concessione)); + + } + }); + + ft.setWidget(i, ++j, locateOnMap); + + ft.setWidget(i, ++j, new HTML(concessione.getNome())); if(addIntroduction) ft.setWidget(i, ++j, new HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 100))); if(addStaff) { ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getAuthors()))); + ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getResponsabile())))); + ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getEditore())))); + ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getTitolari()))); + ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getContributore())))); } if(addParole) { @@ -276,7 +328,7 @@ public class SearchFacilityUI extends Composite { // if (!imagePreviewFound) { // ft.setWidget(i, 2, new Image(GNAImages.ICONS.italyIcon())); // } - + i++; } @@ -346,15 +398,22 @@ public class SearchFacilityUI extends Composite { if (searchText != null && !searchText.isEmpty()) { Map searchInto = new HashMap(); - String searchForField = ""; + List listOfSeachingFields = new ArrayList(); for (ItemField recordField : searchForFields) { if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) { - searchForField = recordField.getJsonFields().get(0); + listOfSeachingFields = recordField.getJsonFields(); continue; } } - searchInto.put(searchForField, searchText); + + if(listOfSeachingFields.size()==0) { + listOfSeachingFields.add("nome"); + } + for (String fieldname : listOfSeachingFields) { + searchInto.put(fieldname, searchText); + } + searchingFilter.setSearchInto(searchInto); } return searchingFilter; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index 0065e9f..63cdb9f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -697,16 +697,19 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme */ @Override public List listOfFieldsForSearching() { - //GeoportalCommon gc = new GeoportalCommon(); - //return gc.getGNADataConfig().getListItemFields(); - + // GeoportalCommon gc = new GeoportalCommon(); + // return gc.getGNADataConfig().getListItemFields(); + List listItemFields = new ArrayList(); + listItemFields.add(new ItemField("Any Field", + Arrays.asList("nome", "authors", "introduzione", "contributore", "titolari", "editore", "responsabile", "paroleChiaveLibere", "paroleChiaveICCD"), false, false, true)); listItemFields.add(new ItemField("Name", Arrays.asList("nome"), true, true, true)); - listItemFields.add(new ItemField("Staff", Arrays.asList("authors"), true, true, true)); - listItemFields.add(new ItemField("Parola chiave", Arrays.asList("paroleChiaveLibere","paroleChiaveICCD"), true, true, true)); + listItemFields.add(new ItemField("Direttore/Staff", + Arrays.asList("authors", "contributore", "titolari", "editore", "responsabile"), true, false, true)); + listItemFields.add(new ItemField("Parola chiave", Arrays.asList("paroleChiaveLibere", "paroleChiaveICCD"), true, + false, true)); return listItemFields; } - /** * Gets the list concessioni. diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index 26624c2..e5a7752 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -473,14 +473,14 @@ body { .table-results { table-layout: fixed; - width: 600px; + /*width: 600px;*/ } .table-results td { padding: 5px; /* For Firefox */ white-space: pre-wrap; - word-break: break-all; + /*word-break: break-all;*/ /* For Chrome and IE */ word-wrap: break-word; } @@ -496,6 +496,6 @@ body { } .table-results td:nth-child(1) { - width: 200px; + /*width: 200px;*/ } \ No newline at end of file -- 2.17.1 From 54e0d0de010cf41c516ba6df692f5c742cae3073 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 10 Dec 2021 16:59:31 +0100 Subject: [PATCH 03/12] removing toLowerCase --- .../user/geoportaldataviewer/client/GeoportalDataViewer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2a133b8..b0ec985 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 @@ -259,7 +259,7 @@ public class GeoportalDataViewer implements EntryPoint { geonaDataViewerProfile = profile; GWT.log("Profile: " + geonaDataViewerProfile); Iterator it; - String theItemType = paramGeonaItemType.toLowerCase(); + String theItemType = paramGeonaItemType; if (theItemType == null) { it = geonaDataViewerProfile.getMapLayers().keySet().iterator(); it.hasNext(); -- 2.17.1 From 479ee9f7a71a8a148a2597bb76a76ce95722cf4f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 13 Dec 2021 11:28:47 +0100 Subject: [PATCH 04/12] Changed display name for item fields --- .../server/GeoportalDataViewerServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index 63cdb9f..5a936a9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -704,9 +704,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme listItemFields.add(new ItemField("Any Field", Arrays.asList("nome", "authors", "introduzione", "contributore", "titolari", "editore", "responsabile", "paroleChiaveLibere", "paroleChiaveICCD"), false, false, true)); listItemFields.add(new ItemField("Name", Arrays.asList("nome"), true, true, true)); - listItemFields.add(new ItemField("Direttore/Staff", + listItemFields.add(new ItemField("Director/Staff", Arrays.asList("authors", "contributore", "titolari", "editore", "responsabile"), true, false, true)); - listItemFields.add(new ItemField("Parola chiave", Arrays.asList("paroleChiaveLibere", "paroleChiaveICCD"), true, + listItemFields.add(new ItemField("Keywords", Arrays.asList("paroleChiaveLibere", "paroleChiaveICCD"), true, false, true)); return listItemFields; } -- 2.17.1 From fb827a691334e396e0c64746cc77856462c916a1 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 13 Dec 2021 11:58:35 +0100 Subject: [PATCH 05/12] fixed labels --- .../client/ui/SearchFacilityUI.java | 14 +++++++------- .../server/GeoportalDataViewerServiceImpl.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java index d719152..2b514d5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java @@ -242,19 +242,19 @@ public class SearchFacilityUI extends Composite { FlexTable ft = new FlexTable(); ft.getElement().setClassName("table-results"); int i = 1; - ft.setWidget(0, i, new HTML("Name")); + ft.setWidget(0, i, new HTML("Nome Progetto")); String selValue = listBoxSearchFor.getSelectedValue().toLowerCase(); boolean addIntroduction = false; - if(selValue.startsWith("name") || selValue.startsWith("any")) { - ft.setWidget(0, ++i, new HTML("Introduction")); + if(selValue.startsWith("proj") || selValue.startsWith("any")) { + ft.setWidget(0, ++i, new HTML("Introduzione")); addIntroduction = true; } boolean addStaff = false; - if(selValue.startsWith("direttore")) { - ft.setWidget(0, ++i, new HTML("Authors")); + if(selValue.startsWith("director")) { + ft.setWidget(0, ++i, new HTML("Autori")); ft.setWidget(0, ++i, new HTML("Responsabile")); ft.setWidget(0, ++i, new HTML("Editore")); ft.setWidget(0, ++i, new HTML("Titolari")); @@ -262,7 +262,7 @@ public class SearchFacilityUI extends Composite { addStaff = true; } boolean addParole = false; - if(selValue.startsWith("parola")) { + if(selValue.startsWith("keyword")) { ft.setWidget(0, ++i, new HTML("Parole Libere")); ft.setWidget(0, ++i, new HTML("Parole Cronologia")); addParole = true; @@ -292,7 +292,7 @@ public class SearchFacilityUI extends Composite { ft.setWidget(i, ++j, new HTML(concessione.getNome())); if(addIntroduction) - ft.setWidget(i, ++j, new HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 100))); + ft.setWidget(i, ++j, new HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 200))); if(addStaff) { ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getAuthors()))); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index 5a936a9..09f6938 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -703,7 +703,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme List listItemFields = new ArrayList(); listItemFields.add(new ItemField("Any Field", Arrays.asList("nome", "authors", "introduzione", "contributore", "titolari", "editore", "responsabile", "paroleChiaveLibere", "paroleChiaveICCD"), false, false, true)); - listItemFields.add(new ItemField("Name", Arrays.asList("nome"), true, true, true)); + listItemFields.add(new ItemField("Project Name", Arrays.asList("nome"), true, true, true)); listItemFields.add(new ItemField("Director/Staff", Arrays.asList("authors", "contributore", "titolari", "editore", "responsabile"), true, false, true)); listItemFields.add(new ItemField("Keywords", Arrays.asList("paroleChiaveLibere", "paroleChiaveICCD"), true, -- 2.17.1 From 342d40fdf906d5929f610c873d46563f515df98a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 14 Dec 2021 15:26:09 +0100 Subject: [PATCH 06/12] Searching facility integrated with CQL filter --- .../client/GeoportalDataViewer.java | 39 ++++++++ .../client/events/SearchPerformedEvent.java | 71 ++++++++++++++ .../events/SearchPerformedEventHandler.java | 20 ++++ .../client/gis/OpenLayerMap.java | 31 ++++++ .../client/ui/GeonaDataViewMainPanel.java | 8 +- .../client/ui/SearchFacilityUI.java | 95 +++++++++++++++---- .../client/ui/map/MapView.java | 24 ++--- .../concessioni/LayerConcessioneView.java | 2 +- .../GeoportalDataViewerServiceImpl.java | 2 +- src/main/webapp/GeoportalDataViewer.css | 9 +- 10 files changed, 263 insertions(+), 38 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEventHandler.java 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 b0ec985..2b6d8ed 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 @@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; @@ -29,6 +30,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetai import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent; @@ -59,6 +62,7 @@ import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.RootPanel; import ol.Coordinate; +import ol.layer.Image; /** * Entry point classes define onModuleLoad(). @@ -532,6 +536,41 @@ public class GeoportalDataViewer implements EntryPoint { } }); + + applicationBus.addHandler(SearchPerformedEvent.TYPE, new SearchPerformedEventHandler() { + + @Override + public void onSearchDone(SearchPerformedEvent searchPerformedEvent) { + + if(searchPerformedEvent!=null) { + + + + LinkedHashMap wmsMap = olMapMng.getOLMap().getWmsLayerMap(); + String firstWMSKey = wmsMap.keySet().iterator().next(); + List result = searchPerformedEvent.getData(); + + if(result!=null && result.size()>0) { + String cqlFilter = "product_id IN("; + for (ConcessioneDV concessioneDV : result) { + cqlFilter+="'"+concessioneDV.getItemId()+"',"; + } + cqlFilter = cqlFilter.substring(0,cqlFilter.length()-1)+")"; + + olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, cqlFilter); + }else { + olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, null); + } + + if(searchPerformedEvent.isSearchReset()) { + olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, null); + } + + } + + + } + }); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEvent.java new file mode 100644 index 0000000..0074ce9 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEvent.java @@ -0,0 +1,71 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import java.util.List; + +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class SearchPerformedEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Dec 14, 2021 + */ +public class SearchPerformedEvent extends GwtEvent { + public static Type TYPE = new Type(); + private List data; + private boolean searchReset; + + /** + * Instantiates a new search performed event. + * + * @param data the data + * @param searchReset the search reset + */ + public SearchPerformedEvent(List data, boolean searchReset) { + this.data = data; + this.searchReset = searchReset; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + @Override + protected void dispatch(SearchPerformedEventHandler handler) { + handler.onSearchDone(this); + + } + + /** + * Gets the data. + * + * @return the data + */ + public List getData() { + return data; + } + + /** + * Checks if is search reset. + * + * @return true, if is search reset + */ + public boolean isSearchReset() { + return searchReset; + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEventHandler.java new file mode 100644 index 0000000..de6a195 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/SearchPerformedEventHandler.java @@ -0,0 +1,20 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import com.google.gwt.event.shared.EventHandler; + +/** + * The Interface SearchPerformedEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Dec 14, 2021 + */ +public interface SearchPerformedEventHandler extends EventHandler { + + /** + * On search done. + * + * @param searchPerformedEvent the search performed event + */ + void onSearchDone(SearchPerformedEvent searchPerformedEvent); +} 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 e487256..9f8e73e 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 @@ -395,9 +395,11 @@ public abstract class OpenLayerMap { if (layer == null) { ImageWmsParams imageWMSParams = OLFactory.createOptions(); imageWMSParams.setLayers(layerItem.getName()); + //imageWMSParams.set("CQL_FILTER", "product_id IN('6165b07202ad3d60e1d26f42','6166ff8002ad3d60e1d26fb7')"); ImageWmsOptions imageWMSOptions = OLFactory.createOptions(); imageWMSOptions.setUrl(layerItem.getMapServerHost()); + imageWMSOptions.setParams(imageWMSParams); // imageWMSOptions.setRatio(1.5f); @@ -405,6 +407,7 @@ public abstract class OpenLayerMap { LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(imageWMSSource); + // Settings MIN and MAX Resolution if (layerItem.getMinResolution() != null) { layerOptions.setMinResolution(layerItem.getMinResolution()); @@ -414,6 +417,7 @@ public abstract class OpenLayerMap { } Image wmsLayer = new Image(layerOptions); + int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_WMS)+wmsLayerMap.size()+1; wmsLayer.setZIndex(zIndex); // visibleLayerItems @@ -428,6 +432,33 @@ public abstract class OpenLayerMap { } } + + public void setCQLFilterToWMSLayer(String key, String cqlFilterExpression) { + + GWT.log("Getting key: "+key); + + GWT.log("Setting CQL FILTER: "+cqlFilterExpression); + Image wmsLayer = wmsLayerMap.get(key); + + GWT.log("WMS layer is: "+wmsLayer); + + //map.removeLayer(wmsLayer); + + ImageWms imageWMSSource = wmsLayer.getSource(); + ImageWmsParams imageWMSParams = imageWMSSource.getParams(); + + if (cqlFilterExpression == null) { + imageWMSParams.delete("CQL_FILTER"); + } else { + imageWMSParams.set("CQL_FILTER", cqlFilterExpression); + } + + imageWMSSource.updateParams(imageWMSParams); + wmsLayer.setSource(imageWMSSource); + + //map.addLayer(wmsLayer); + + } /** * Adds the WMS detail layer. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index d02ae32..57735b4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -11,7 +11,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap; -import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; @@ -151,11 +150,12 @@ public class GeonaDataViewMainPanel extends Composite { extentToEarth.getElement().appendChild(worldImg.getElement()); extentToEarth.setWidth("140px"); - linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get()); - linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get()); - linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get()); + //linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get()); + //linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get()); + //linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get()); searchFacility = new SearchFacilityUI(applicationBus, sortByFields, searchForFields, initialSortFilter); + searchFacility.setSearchButton(searchFacilityButton); searchFacilityButton.setIcon(IconType.SEARCH); searchFacilityPanel.add(searchFacility); Scheduler.get().scheduleDeferred(new ScheduledCommand() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java index 2b514d5..1900b13 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java @@ -14,6 +14,7 @@ import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; +import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent; import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; @@ -21,6 +22,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; import com.github.gwtbootstrap.client.ui.Alert; import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.DropdownButton; import com.github.gwtbootstrap.client.ui.ListBox; import com.github.gwtbootstrap.client.ui.NavLink; import com.github.gwtbootstrap.client.ui.TextBox; @@ -46,6 +48,14 @@ import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.Widget; + +/** + * The Class SearchFacilityUI. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Dec 14, 2021 + */ public class SearchFacilityUI extends Composite { private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class); @@ -85,9 +95,26 @@ public class SearchFacilityUI extends Composite { private ResultSetPaginatedData latestResult; + private DropdownButton searchFacilityButton; + + /** + * The Interface SearchFacilityPanelUiBinder. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Dec 14, 2021 + */ interface SearchFacilityPanelUiBinder extends UiBinder { } + /** + * Instantiates a new search facility UI. + * + * @param appManagerBus the app manager bus + * @param sortByFields the sort by fields + * @param searchForFields the search for fields + * @param initialSortFilter the initial sort filter + */ public SearchFacilityUI(HandlerManager appManagerBus, List sortByFields, List searchForFields, SearchingFilter initialSortFilter) { initWidget(uiBinder.createAndBindUi(this)); @@ -98,12 +125,19 @@ public class SearchFacilityUI extends Composite { resetSearch.setType(ButtonType.LINK); - listBoxSortBy.setWidth("130px"); - listBoxSearchFor.setWidth("130px"); + listBoxSortBy.setWidth("180px"); + listBoxSearchFor.setWidth("140px"); bindEvents(); } + /** + * To label filter. + * + * @param itemField the item field + * @param direction the direction + * @return the string + */ private String toLabelFilter(ItemField itemField, ORDER direction) { String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name(); return labelFilter; @@ -163,20 +197,6 @@ public class SearchFacilityUI extends Composite { } }); -// navShowOnMap.addClickHandler(new ClickHandler() { -// -// @Override -// public void onClick(ClickEvent event) { -// List listConcessioni = null; -// if (grpw != null && grpw.getSelectItems() != null) { -// listConcessioni = grpw.getSelectItems(); -// } -// appManagerBus -// .fireEvent(new ActionOnItemEvent(listConcessioni, ACTION_ON_ITEM.VIEW_ON_MAP)); -// -// } -// }); - searchField.addKeyPressHandler(new KeyPressHandler() { @Override @@ -194,15 +214,28 @@ public class SearchFacilityUI extends Composite { @Override public void onClick(ClickEvent event) { searchField.setText(""); - //appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE, getCurrentSortFilter())); resetSearch.setVisible(false); panelResults.clear(); latestResult = null; + appManagerBus.fireEvent(new SearchPerformedEvent(null,true)); + setSearchEnabled(false); } }); } + + private void setSearchEnabled(boolean bool) { + if(bool) { + searchFacilityButton.getElement().addClassName("highlight-button"); + } + else { + searchFacilityButton.getElement().removeClassName("highlight-button"); + } + } + /** + * Search concessioni. + */ private void searchConcessioni() { SearchingFilter filter = getCurrentSortFilter(); @@ -229,6 +262,8 @@ public class SearchFacilityUI extends Composite { @Override public void onSuccess(ResultSetPaginatedData result) { + appManagerBus.fireEvent(new SearchPerformedEvent(result.getData(),false)); + setSearchEnabled(true); latestResult = result; panelResults.clear(); @@ -341,7 +376,7 @@ public class SearchFacilityUI extends Composite { /** * To display authors. * - * @param authors the authors + * @param listValues the list values * @return the string */ private String toDisplayList(List listValues) { @@ -355,6 +390,9 @@ public class SearchFacilityUI extends Composite { return toDisplay; } + /** + * Do search event. + */ private void doSearchEvent() { String searchText = searchField.getText(); if (searchText.length() < MIN_LENGHT_SERCHING_STRING) { @@ -369,6 +407,12 @@ public class SearchFacilityUI extends Composite { searchConcessioni(); } + /** + * To sort filter. + * + * @param labelFilter the label filter + * @return the searching filter + */ public SearchingFilter toSortFilter(String labelFilter) { GWT.log("toSortFilter for label " + labelFilter); String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR); @@ -392,6 +436,11 @@ public class SearchFacilityUI extends Composite { } + /** + * Built searching filter. + * + * @return the searching filter + */ private SearchingFilter builtSearchingFilter() { SearchingFilter searchingFilter = toSortFilter(listBoxSortBy.getSelectedValue()); String searchText = searchField.getText(); @@ -419,10 +468,20 @@ public class SearchFacilityUI extends Composite { return searchingFilter; } + /** + * Gets the current sort filter. + * + * @return the current sort filter + */ public SearchingFilter getCurrentSortFilter() { currentSortFilter = builtSearchingFilter(); GWT.log("currentSortFilter: " + currentSortFilter); return currentSortFilter; } + public void setSearchButton(DropdownButton searchFacilityButton) { + this.searchFacilityButton = searchFacilityButton; + + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java index 5fde1df..26059cf 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java @@ -67,7 +67,7 @@ public class MapView extends Composite { @UiField HorizontalPanel coordinatePanel; - private LightOpenLayerMap lightOLSM; + private LightOpenLayerMap lightOLM; private HTML attributionDiv = null; @@ -92,14 +92,14 @@ public class MapView extends Composite { @Override public void execute() { - lightOLSM = new LightOpenLayerMap(theMapId); + lightOLM = new LightOpenLayerMap(theMapId); setBaseLayers(); // EPSG_3857 LOCATION TO ITALY Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); - lightOLSM.setCenter(transformedCenterCoordinate); - lightOLSM.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); + lightOLM.setCenter(transformedCenterCoordinate); + lightOLM.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); } }); } @@ -127,7 +127,7 @@ public class MapView extends Composite { @Override public void onValueChange(ValueChangeEvent event) { - lightOLSM.changeBaseMap(baseMapLayer); + lightOLM.changeBaseMap(baseMapLayer); setMapAttribution(baseMapLayer); } }); @@ -193,9 +193,9 @@ public class MapView extends Composite { @Override public void execute() { - if (lightOLSM != null) { - lightOLSM.addPoint(coordinate, showCoordinateText, true); - lightOLSM.getMap().getView().setCenter(coordinate); + if (lightOLM != null) { + lightOLM.addPoint(coordinate, showCoordinateText, true); + lightOLM.getMap().getView().setCenter(coordinate); } } }); @@ -232,11 +232,11 @@ public class MapView extends Composite { null); } - lightOLSM.addWMSLayer(mapServerHost, layerName, theBBOX); + lightOLM.addWMSLayer(mapServerHost, layerName, theBBOX); if (ew != null) { - lightOLSM.getMap().getView().fit(ew); + lightOLM.getMap().getView().fit(ew); } @@ -245,8 +245,8 @@ public class MapView extends Composite { } - public LightOpenLayerMap getLightOLSM() { - return lightOLSM; + public LightOpenLayerMap getLightOLM() { + return lightOLM; } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java index c1743c9..f60b3b0 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java @@ -110,7 +110,7 @@ public class LayerConcessioneView extends Composite { } // DOWNLOAD the OSM + layer by canvas - downloadMap(mapView.getLightOLSM().getMap(), mapView.getPanelMapElementId(), htmlLinkId, + downloadMap(mapView.getLightOLM().getMap(), mapView.getPanelMapElementId(), htmlLinkId, filename, mimeType); // mapExport(mapView.getLightOLSM().getMap(), mapView.getPanelMapElementId()); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index 09f6938..4dceee1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -92,7 +92,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme * @return the geo information for WMS request * @throws Exception the exception */ - public static GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) + public GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) throws Exception { try { WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName); diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index e5a7752..b207c37 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -495,7 +495,12 @@ body { border-bottom: 1px solid #ccc; } -.table-results td:nth-child(1) { - /*width: 200px;*/ +.table-results td:nth-child(1) { +} + +.highlight-button { + border: 2px solid #08c; + border-radius: 4px; + box-shadow: 2px 2px #08c; } \ No newline at end of file -- 2.17.1 From 99984fcd2c8319f32f1049fca8518214f6739e18 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 15 Dec 2021 15:44:31 +0100 Subject: [PATCH 07/12] integrated with WhereClause. Updated icons --- .../client/resources/layers.png | Bin 465 -> 810 bytes .../client/resources/layers2.png | Bin 0 -> 465 bytes .../client/resources/map.png | Bin 500 -> 693 bytes .../client/resources/map2.png | Bin 0 -> 500 bytes .../client/resources/map4.png | Bin 0 -> 744 bytes .../client/resources/preset_location.png | Bin 683 -> 599 bytes .../client/ui/GeonaDataViewMainPanel.java | 7 ++++--- .../client/ui/SearchFacilityUI.java | 13 ++++++++++++- .../user/geoportaldataviewer/IAMClient.java | 2 -- 9 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layers2.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map2.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map4.png diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layers.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layers.png index 41fc600fc69f83969e0755321c9fc3d4d15c2486..4a90fb33909bc4694a6ac0287e9bd7c0153378f7 100644 GIT binary patch delta 763 zcmV*#0n^U*7X@2Z%Z8I~WG{pQ9jEGVP z734(_)P**kS(g%BMCMkz@FD^u>_%%)7e?K6Bgi0EV3@Pb>6mk0nsc7B^RZtSfr!lK z@_nD@d3hfm1jnH3e&Xgjo1Vl7L%mcr6nt)*D#t@d2N&Ici8CpBJFv!Nni2lLE+GtD z(YR70>8>qIaKFkLbo;|}WL=qF(`0&!DjC%ltG0|{Wgif-m{sr3B&oj~rKqu!H_x>w zPS>mt@dpO&!?8OtCjBx??Xg;!mKuwOC(GlfA0NKdI${NleHkz)(;NR^)PFYKaR^McDKWfsjzWP@OP|)vl1&I)7N) z?ulL4q_*F0(mPg0A#oF5^Qk>!zkU#6=fGx5LYw)2xIt$f1Xh7XG=9?*D|=+JAc;tM z7pHTVC8Qt=Z`^1Q^;hO!G=u;E(8)(Xk~)P-*<@qS7oT~x%@e&Fr*ji&DzDKfluVRV zI8O?sLDKRT!7vho&*!el10RDsn?8o|n&9xi%q z{!0&1wEzHf*T7dB39%yz4swbHico86|6ZP((*Yc(u?;k0IIWe|pk#GP2002ovPDHLkV1iZxSziDE delta 415 zcmV;Q0bu^B2GIi{iBL{Q4GJ0x0000DNk~Le0000F0000F2nGNE06W%|N|7NN3k}o& z01eau?~%F{kwzzf0ZvIoK~yM_ozpRER8bJc@!vcpO=6*78iimZ7Ft-C!cMU81K4S0 zlS(kF8wCZQ5{TigyEb-KVwcv!La?#b516Ne;TKNsL`v!OQr4TCg{t@iqaXoW8kLg=cryG+fymY{Ii}88b z*vfNwg7agbcevqJyd4y3xXKgKVN3B|W@x)CRhYv%9_V_ejJ|fxV?!f8g({oELrmeh z-|o5{>#Ce)R=A+=jb?0F&EpCy!WC>w_s6B(6(0Giql{mk=8T>OmN31?_jS^qf8Zld z;?PiMXU_xu#|tZV%FTGK>ns+e?<3HrbVt{j0l1s?sP_4*{s8<$bFr9?OK<=H002ov JPDHLkV1lI2zeoT8 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layers2.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layers2.png new file mode 100644 index 0000000000000000000000000000000000000000..41fc600fc69f83969e0755321c9fc3d4d15c2486 GIT binary patch literal 465 zcmV;?0WSWDP)Ez6#xJL8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H10ZvIoK~yM_ozpRER8bJc@!vcpO=6*78iimZ7Ft-C!cMU81K4S0 zlS(kF8wCZQ5{TigyEb-KVwcv!La?#b51042!8vhoA#*o`K$f_{6urHn2t+u00000NkvXX Hu0mjfZC%U! literal 0 HcmV?d00001 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map.png index da4854a01dbab38de8bfcc75803ecc7c778a2e60..d2c357fc8dde564451b1c1c1fd091132012f7dd0 100644 GIT binary patch delta 645 zcmV;00($-Q1GNPqiBL{Q4GJ0x0000DNk~Le0000G0000G2nGNE03Y-JVUZyk3j?tL z00XfB^@Ht6kwzzf0y0TNK~y-6l~YS-6HydB?`6_VTAPpgG=sm9AT2RUBQ|b=n`(tt zbnD8ELiSY@s^Vw~sDW7As9m`hH(gk%T}Tu{(Y6B?yAT>;wWPKACrzeFX2wOEHVGA) zv$`D4x$kfvhoA|!pT8Jd*fczjR!pumbUIZfuxd(@QW@u=Vz ziWC6eRXf9xGG}wKIrQkV4dRn*9@o1P4g9x?-7=d#_89<(5PCK+n(LdAL2#2x;Qpl( zSc<10E@yCm+1rb5o=5EaClI3rvDG93krbwLR_KU~5!37iMyyyyYSHMRPi+;rAj&`cF zY}*ATs!9)Q3Z)vM?!#2C>7vCFJ)|it)(EA=1U!>}TcD@gQV*DIE2~lz(uD@mdOVJm zj28LyMneJ?Rh(&CyGH*lIj~{_Yy)YtJcsLkPFrj>mr> z;gvLkW4NjG#Dpu-f<*X?3up_UR5lgPOK+ssFi4X)ju+CJailNU5H4b}S6vzwE~$JK zMit%{byI-?(+X{qi3sPA{8K7^x~lE#XfUi4)eLZ^lfDjV_8Ge%AS8#U1}82Wep zCnV+mkZ72H_ETqfNLA+>RHZwqokm?Kgdfsd-A&w0DZR$JG$x(Jvl?1;Av>n9fi2;s zsB58;p5udX0xLG1R+y1a;vLq}H`?XAEUng=j|d-e7z-w>xgI}z-urpbwprZ4cym8i t@{o=>VFt@e58aLJJ=$b3&j_o(0D8}LtO+;OCIA2m002ovPDHLkV1heB#K`~v diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map2.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/map2.png new file mode 100644 index 0000000000000000000000000000000000000000..da4854a01dbab38de8bfcc75803ecc7c778a2e60 GIT binary patch literal 500 zcmV*lIlf?i%K6&nbLE2)Eph$A2K< zl{A85xT*BSge%g5MEHygXbYcIHWkiGZ=}{RNRv2@7t)$>q%YVIE@HA*T^bfHseBbi z72X$hQ-K203T>gpIZR`y?{}g;grk^}#)_I=^ko`Cr-lwH8}ZOHMos@4HPJB``gi>& zB<22)Xqfg>XLm?d=NnX|JE@&UT_}Vf(p%k4+)XLH#=0~noyD^nT6G~irm%r6;iaf+ zp^~2CgKz>XHl0?Okxt?r*3mcG<-9Dd)|rn8A8{B9Cak$0KYQN$dC<05+`)KrKUVUP qjyYil%SsR3jqN?!WHHYOtG@tx&vmQ`H`OKp0000P)WAWB>pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H10%b`=K~y-6y^~EyR8bVifA_s{92*L&@!Lj5Nf`~5(VQYHbhM2L znnjc=g;`1w1hy!mMPMzmRplngiduwVw2_F482SJ$F)}h^5Tlurz!8*{^Sfh!kKGOV>~9}q_V+Zy zFA53thVl6i10YnP&uG2SwD|kGC*#DT8gnxd0=;3~M3eecCtKf4#@1SkSBS;r-;qfv zkuq^Twiq{CjOo?XjmU%|)-=;hWah%lX2u7qb^W#xAQQco!bmm*sv=BzB2le^V$vvL zMZQ6XPG(7t9~H3%q#^{0C2>O&<~EHpkd&+fQ03c>HDxnao50($GhRS|YBDoZvUF&r z@r$kYN{(K*h|5!jJyjRhw0|bY9bocP8$t!eB8=;I4QJ^QbDMfXoxg|bR=+_B6CbAt zeZ9%T!X&xwOYA6d5S^1)k_7WJ8md)bvkQI&qXdWh2!A=noBq(!jABHlB;N*y_%U{l zz{3F({S9i{+Q=!sjH@D(lr0Lu4A}`tmIR00000@?km1=j>2iBL{Q4GJ0x0000DNk~Le0000E0000H2nGNE0PV<~pOGON3kBc+ z00rOy_N)_zkwzzf0n|xEK~yM_ebLX0%yAsY@yBO;rs6fTr(wV{ z)|n@B)w5n~#$rsvN5VtKE{dI>{)~nRDAu}2w@}A@(gz`b6eWwW6`3%$OW%fvlVIg( zw^SG)-J`8nT=Vs>B(XXhR|q=^-D2rc5MQ)Ye}`w5f9cWFGpeOh5c8XaO^UykX4Lnf zNOA83bnfviBgHOc()50D^>;#|x*r?WvvL93F(|J6G9GJzpT#$l8 zOoHJqX@{5(66&NSg4ncp6^09>2iPXQn$fsW8W0@7GSW&R9M-q~&UpWs=s|x*c8$>k z{J4N#(6|0FE>HcEa0+d*aJ3+Iycd+QSFFaV!{e%Lk{)3v3mNi&{N_3A`S`4QW_%MCS4LckNzKQz~^xU oqlB|!=|t;@t>H6be)3=TZ(6*es3ZIr$N&HU07*qoM6N<$f(EPp!~g&Q delta 635 zcmV->0)+k71gixhiBL{Q4GJ0x0000DNk~Le0000H0000H2nGNE06T3*`jH_T3j~G$ z00f2syc1Gmkwzzf0w_sDK~y-6ozqQ-)>RY+@ZY)b%!ou2Iv`2(W*}J@?jn!^cQ%e; zi+F=J4&+$02+L_maTf{UJ4p-)E(|0|7~I$@XbQBCRf~cI^CQg26xujSW5fLar^UQY z^Um1D1DAWxea`c6&&Lf*?O+b*^NO@hv0HJ=oL8|0r&K zdk%wm8I{U^`l2#|wb+1nh40+9)r^C}F|@4n%Y5>YY8UVn2Czo4vnaZX1Zr3CwDhRj zVXdeZu(7y|=W)GL)g49JbQh6d(G(_)#r0+QX#9zj9q-9y_`O(Y=N0sK-LBL$;}SkM z8pC&Gw(}@<<3_>nSk<*=G;tLzhjRIIC$oW}j`u@<4^CtAlCVec69yDVwDW+bZ(X$t zFZj(Jwe5;2;dGB#$Mo5UJJP54O6?mn&UnCsYWHinsTGxW-Y3jru(NM9=feEN9?mEH z?V4UYq#=aj%}$pZIIDPF?IgZdObS1G$Stj?{{Qb3kEwhpY{M`%;_XE#zhN{c=DX8f z@m&}~N56Db!-U!iwL!%>tj4sk-`@D>Us|^a9LhC{5ot&G;wC{0I9b Vxu)mV-9!KY002ovPDHLkV1jHfGzS0x diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index 57735b4..37803a9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -11,6 +11,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap; +import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; @@ -150,9 +151,9 @@ public class GeonaDataViewMainPanel extends Composite { extentToEarth.getElement().appendChild(worldImg.getElement()); extentToEarth.setWidth("140px"); - //linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get()); - //linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get()); - //linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get()); + linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get()); + linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get()); + linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get()); searchFacility = new SearchFacilityUI(applicationBus, sortByFields, searchForFields, initialSortFilter); searchFacility.setSearchButton(searchFacilityButton); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java index 1900b13..9646e21 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java @@ -10,7 +10,9 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; +import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP; import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; +import org.gcube.application.geoportalcommon.shared.WhereClause; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; @@ -463,7 +465,16 @@ public class SearchFacilityUI extends Composite { searchInto.put(fieldname, searchText); } - searchingFilter.setSearchInto(searchInto); + WhereClause where = new WhereClause(); + where.setSearchInto(searchInto); + where.setOperator(LOGICAL_OP.OR); + + //THIS CLAUSE IS ADDED IN ORDER TO SEARCH ONLY PUBLISHED PRODUCT (WITH SUCCESS) + Map searchInto2 = new HashMap(); + searchInto2.put("report.status", "PASSED"); + WhereClause where2 = new WhereClause(LOGICAL_OP.AND, searchInto2); + + searchingFilter.setConditions(Arrays.asList(where, where2)); } return searchingFilter; } diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java index 0aa3b91..b45ae06 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java @@ -1,7 +1,5 @@ package org.gcube.portlets.user.geoportaldataviewer; -import java.util.List; - import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.IAMClientCredentialsReader; -- 2.17.1 From d739fbee4d840df42a22f1b73b2c5128ad087951 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 17 Dec 2021 10:50:13 +0100 Subject: [PATCH 08/12] improved css --- src/main/webapp/GeoportalDataViewer.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index b207c37..6bb8759 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -462,6 +462,8 @@ body { .search-textbox { padding: 4px 14px !important; margin-bottom: 0 !important; + margin-left: 2px !important; + margin-right: 2px !important; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important; font-size: 13px !important; font-weight: normal !important; -- 2.17.1 From 98349ac121bd091bf36c19cd93909d61ee63523f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 17 Dec 2021 10:51:22 +0100 Subject: [PATCH 09/12] improved error message --- .../user/geoportaldataviewer/client/ui/SearchFacilityUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java index 9646e21..d89d048 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java @@ -255,7 +255,7 @@ public class SearchFacilityUI extends Composite { // Window.alert(caught.getMessage()); panelResults.clear(); panelResults.add(new HTML("
")); - Alert alert = new Alert("Error on searching. Please, refresh or change it"); + Alert alert = new Alert("Error on searching. Please, refresh or change the search"); alert.setType(AlertType.ERROR); alert.setClose(false); panelResults.add(alert); -- 2.17.1 From 5d59c9dcbcdf271499a3240dd7a5811c6069ac7c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 21 Dec 2021 16:52:35 +0100 Subject: [PATCH 10/12] ported to GNADataViewerConfigProfile --- .../client/GeoportalDataViewer.java | 10 +-- .../client/GeoportalDataViewerService.java | 7 +- .../GeoportalDataViewerServiceAsync.java | 4 +- .../GeoportalDataViewerServiceImpl.java | 90 ++++++++++--------- .../server/util/SessionUtil.java | 31 ++++++- 5 files changed, 87 insertions(+), 55 deletions(-) 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 2b6d8ed..664bfdd 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 @@ -6,7 +6,7 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; -import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; +import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.LayerItem; @@ -100,7 +100,7 @@ public class GeoportalDataViewer implements EntryPoint { private String paramGeonaItemID; - private GeoNaDataViewerProfile geonaDataViewerProfile; + private GNADataViewerConfigProfile geonaDataViewerProfile; private OLMapManager olMapMng = null; @@ -148,7 +148,7 @@ public class GeoportalDataViewer implements EntryPoint { GWT.log("Loaded item fields: "+result); for (ItemField itemField : result) { - if(itemField.isDisplayIntoTable()) { + if(itemField.isDisplayAsResult()) { displayFields.add(itemField); } @@ -250,7 +250,7 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void execute() { GeoportalDataViewerServiceAsync.Util.getInstance() - .getGeoNaDataViewProfile(new AsyncCallback() { + .getGeoNaDataViewProfile(new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -259,7 +259,7 @@ public class GeoportalDataViewer implements EntryPoint { } @Override - public void onSuccess(GeoNaDataViewerProfile profile) { + public void onSuccess(GNADataViewerConfigProfile profile) { geonaDataViewerProfile = profile; GWT.log("Profile: " + geonaDataViewerProfile); Iterator it; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index c1479a1..131611f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -2,7 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client; import java.util.List; -import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; +import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; @@ -83,7 +83,7 @@ public interface GeoportalDataViewerService extends RemoteService { * @return the geo na data view profile * @throws Exception the exception */ - GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception; + GNADataViewerConfigProfile getGeoNaDataViewProfile() throws Exception; /** * Gets the uploaded images for id. @@ -134,8 +134,9 @@ public interface GeoportalDataViewerService extends RemoteService { * List of fields for searching. * * @return the list + * @throws Exception */ - List listOfFieldsForSearching(); + List listOfFieldsForSearching() throws Exception; /** * Gets the list concessioni. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index ec88a44..3468f11 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -2,7 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client; import java.util.List; -import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; +import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; @@ -49,7 +49,7 @@ public interface GeoportalDataViewerServiceAsync { void getLayerForType(String layerType, AsyncCallback callback); - void getGeoNaDataViewProfile(AsyncCallback callback); + void getGeoNaDataViewProfile(AsyncCallback callback); void getUploadedImagesForId(String itemType, String itemId, Integer maxImages, AsyncCallback> callback); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index 4dceee1..3afcfa3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -14,10 +14,9 @@ import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; import org.gcube.application.geoportal.common.model.legacy.UploadedImage; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; -import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader; import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.MongoServiceCommon; -import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; +import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ItemField; import org.gcube.application.geoportalcommon.shared.LayerItem; @@ -71,6 +70,27 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE"; + /** + * Gets the GNA data viewe config profile. + * + * @return the GNA data viewe config profile + * @throws Exception the exception + */ + private GNADataViewerConfigProfile getGNADataVieweConfigProfile() throws Exception { + + GNADataViewerConfigProfile profile = SessionUtil.getGNADataViewerConfigProfile(getThreadLocalRequest()); + if (profile == null) { + LOG.info(GNADataViewerConfigProfile.class.getSimpleName() + " is null, loading configurations from IS"); + //to be sure + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + GeoportalCommon geoportalComm = new GeoportalCommon(); + profile = geoportalComm.readGNADataViewerConfig(null); + } else { + LOG.info(GNADataViewerConfigProfile.class.getSimpleName() + " read from session"); + } + return profile; + } + /** * Parses the wms request. * @@ -92,8 +112,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme * @return the geo information for WMS request * @throws Exception the exception */ - public GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) - throws Exception { + public GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) throws Exception { try { WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName); String wmsServiceHost = validator.getWmsServiceHost(); @@ -326,7 +345,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (layerPosizionamento != null) { if (!GeoNACheckAccessPolicy.isAccessible(layerPosizionamento.getPolicy(), userName)) { concessionDV.setPosizionamentoScavo(null); - LOG.info("Posizionamento di Scavo is not accessible by current user: "+userName); + LOG.info("Posizionamento di Scavo is not accessible by current user: " + userName); } } @@ -336,8 +355,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme for (LayerConcessioneDV layerDV : listLayersDV) { if (GeoNACheckAccessPolicy.isAccessible(layerDV.getPolicy(), userName)) { accessibleListLayersDV.add(layerDV); - }else { - LOG.info("(Pianta) Layer "+layerDV.getLayerName()+" is not accessible by current user: "+userName); + } else { + LOG.info("(Pianta) Layer " + layerDV.getLayerName() + + " is not accessible by current user: " + userName); } } concessionDV.setPianteFineScavo(accessibleListLayersDV); @@ -347,7 +367,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (abstractRS != null) { if (!GeoNACheckAccessPolicy.isAccessible(abstractRS.getPolicy(), userName)) { concessionDV.setAbstractRelazioneScavo(null); - LOG.info("Abstract relazione is not accessible by current user: "+userName); + LOG.info("Abstract relazione is not accessible by current user: " + userName); } } @@ -355,7 +375,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (relazioneScavo != null) { if (!GeoNACheckAccessPolicy.isAccessible(relazioneScavo.getPolicy(), userName)) { concessionDV.setRelazioneScavo(null); - LOG.info("Relazione scavo is not accessible by current user: "+userName); + LOG.info("Relazione scavo is not accessible by current user: " + userName); } } @@ -368,8 +388,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (GeoNACheckAccessPolicy.isAccessible(uploadedImageDV.getPolicy(), userName)) { accessibleListImages.add(uploadedImageDV); - }else { - LOG.info("Immagine "+uploadedImageDV.getTitolo()+" is not accessible by current user: "+userName); + } else { + LOG.info("Immagine " + uploadedImageDV.getTitolo() + + " is not accessible by current user: " + userName); } } @@ -455,8 +476,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme throw new Exception("The input parameter layerType is null or empty"); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app"); - GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure(); + + GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile(); LOG.info("Read profile: " + profile); String lowerLayerType = layerType.toLowerCase(); @@ -481,12 +502,11 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme * @throws Exception the exception */ @Override - public GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception { + public GNADataViewerConfigProfile getGeoNaDataViewProfile() throws Exception { LOG.info("getGeoNaDataViewProfile called"); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - GeoportalCommon gc = new GeoportalCommon(); - org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile profile = gc.getGeoNaDataViewProfile(null); + GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile(); LOG.info("Returning profile: " + profile); return profile; } @@ -670,7 +690,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } } - + /** * Gets the list base layers. * @@ -680,43 +700,36 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme public List getListBaseLayers() { LOG.info("getListBaseLayers called"); List listBL = new ArrayList(); - //Setting scope in the cuurent thread + // Setting scope in the cuurent thread SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); listBL = SessionUtil.getGNABaseMaps(this.getThreadLocalRequest()); - LOG.info("getListBaseLayers returning "+listBL.size() +" base maps"); + LOG.info("getListBaseLayers returning " + listBL.size() + " base maps"); return listBL; } - + // TODO THIS PART REQUIRES THE JSON MAPPING based on keys read from gCube Meta /** * List of fields for searching. * * @return the list + * @throws Exception the exception */ @Override - public List listOfFieldsForSearching() { - // GeoportalCommon gc = new GeoportalCommon(); - // return gc.getGNADataConfig().getListItemFields(); - - List listItemFields = new ArrayList(); - listItemFields.add(new ItemField("Any Field", - Arrays.asList("nome", "authors", "introduzione", "contributore", "titolari", "editore", "responsabile", "paroleChiaveLibere", "paroleChiaveICCD"), false, false, true)); - listItemFields.add(new ItemField("Project Name", Arrays.asList("nome"), true, true, true)); - listItemFields.add(new ItemField("Director/Staff", - Arrays.asList("authors", "contributore", "titolari", "editore", "responsabile"), true, false, true)); - listItemFields.add(new ItemField("Keywords", Arrays.asList("paroleChiaveLibere", "paroleChiaveICCD"), true, - false, true)); - return listItemFields; + public List listOfFieldsForSearching() throws Exception { + LOG.info("listOfFieldsForSearching called"); + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile(); + return profile.getListItemFields(); } /** * Gets the list concessioni. * - * @param start the start - * @param limit the limit - * @param filter the filter + * @param start the start + * @param limit the limit + * @param filter the filter * @param reloadFromService the reload from service * @return the list concessioni * @throws Exception the exception @@ -729,13 +742,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme try { SessionUtil.getCurrentContext(getThreadLocalRequest(), true); - MongoServiceCommon serviceCommon = new MongoServiceCommon(); -// MongoServiceUtil serviceUtil = new MongoServiceUtil(); -// MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); // TODO MUST BE REPLACED BY COUNT - List listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(), reloadFromService); int listConcessioniSize = listOfConcessioni.size(); @@ -751,5 +760,4 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } - } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java index 424fc66..118cf7a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java @@ -13,6 +13,7 @@ import javax.servlet.http.HttpSession; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.rest.MongoConcessioni; import org.gcube.application.geoportalcommon.MongoServiceCommon; +import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; @@ -44,8 +45,8 @@ public class SessionUtil { private static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; private static final String LIST_BASE_MAPS_LAYERS = "LIST_BASE_MAPS_LAYERS"; - private static final String LIST_OF_CONCESSIONI = "LIST_OF_CONCESSIONI_DATA_VIEWER"; + private static final String GNA_DATAVIEWER_CONFIG_PROFILE = "GNA_DATAVIEWER_CONFIG_PROFILE"; /** * Checks if is into portal. @@ -204,8 +205,7 @@ public class SessionUtil { } return lstBML; } - - + /** * Gets the list of concessioni. * @@ -229,7 +229,7 @@ public class SessionUtil { SessionUtil.getCurrentContext(httpServletRequest, true); MongoServiceCommon serviceUtil = new MongoServiceCommon(); MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni(); - + Iterator concessioni = clientMongo.getList(); if (concessioni != null) { while (concessioni.hasNext()) { @@ -247,4 +247,27 @@ public class SessionUtil { LOG.info("read list of concessioni with size: " + listOfConcessioni.size()); return listOfConcessioni; } + + /** + * Gets the GNA data viewer config profile. + * + * @param httpServletRequest the http servlet request + * @return the GNA data viewer config profile + */ + public static GNADataViewerConfigProfile getGNADataViewerConfigProfile(HttpServletRequest httpServletRequest) { + HttpSession session = httpServletRequest.getSession(); + return (GNADataViewerConfigProfile) session.getAttribute(GNA_DATAVIEWER_CONFIG_PROFILE); + } + + /** + * Sets the list item fields config. + * + * @param httpServletRequest the http servlet request + * @param gNADVConfigProfile the g NADV config profile + */ + public static void setListItemFieldsConfig(HttpServletRequest httpServletRequest, + GNADataViewerConfigProfile gNADVConfigProfile) { + HttpSession session = httpServletRequest.getSession(); + session.setAttribute(GNA_DATAVIEWER_CONFIG_PROFILE, gNADVConfigProfile); + } } -- 2.17.1 From 736264ddf1a1926acc70fb8e66f8ffe30574f165 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 22 Dec 2021 12:24:03 +0100 Subject: [PATCH 11/12] removed comments --- .../client/GeoportalDataViewerService.java | 13 ++++++------- .../client/GeoportalDataViewerServiceAsync.java | 7 +++---- .../server/GeoportalDataViewerServiceImpl.java | 1 - 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index 131611f..bba187a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -88,11 +88,11 @@ public interface GeoportalDataViewerService extends RemoteService { /** * Gets the uploaded images for id. * - * @param itemType the item type - * @param itemId the item id + * @param itemType the item type + * @param itemId the item id * @param maxImages the max images * @return the uploaded images for id - * @throws Exception + * @throws Exception */ List getUploadedImagesForId(String itemType, String itemId, Integer maxImages) throws Exception; @@ -108,8 +108,8 @@ public interface GeoportalDataViewerService extends RemoteService { /** * Gets the layers for id. * - * @param itemType the item type - * @param itemId the item id + * @param itemType the item type + * @param itemId the item id * @return the layers for id * @throws Exception the exception */ @@ -134,7 +134,7 @@ public interface GeoportalDataViewerService extends RemoteService { * List of fields for searching. * * @return the list - * @throws Exception + * @throws Exception */ List listOfFieldsForSearching() throws Exception; @@ -151,5 +151,4 @@ public interface GeoportalDataViewerService extends RemoteService { ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService) throws Exception; - } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index 3468f11..143455e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -40,8 +40,8 @@ public interface GeoportalDataViewerServiceAsync { void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback callback); - void getDataResult(List layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel, - AsyncCallback> callback); + void getDataResult(List layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, + double zoomLevel, AsyncCallback> callback); void getConcessioneForId(String mongoId, AsyncCallback callback); @@ -56,8 +56,7 @@ public interface GeoportalDataViewerServiceAsync { void getPublicLinksFor(GeoNaItemRef item, AsyncCallback asyncCallback); - void getLayersForId(String itemType, String itemId, - AsyncCallback> asyncCallback); + void getLayersForId(String itemType, String itemId, AsyncCallback> asyncCallback); void getWFSFeatures(List layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel, AsyncCallback> callback); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index 3afcfa3..953db43 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -743,7 +743,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme SessionUtil.getCurrentContext(getThreadLocalRequest(), true); MongoServiceCommon serviceCommon = new MongoServiceCommon(); - // TODO MUST BE REPLACED BY COUNT List listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(), reloadFromService); -- 2.17.1 From e819f342674f92f04f25732870b42dd75b7907a2 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 22 Dec 2021 15:40:45 +0100 Subject: [PATCH 12/12] New icons added for layer (in)visible --- .../client/resources/GNAImages.java | 33 ++++++--- .../client/resources/baseIcons.css | 2 +- .../client/resources/layer_invisible.png | Bin 0 -> 1099 bytes .../client/resources/layer_visible.png | Bin 0 -> 650 bytes .../client/ui/dandd/DragDropLayer.java | 69 ++++++++++++------ src/main/webapp/GeoportalDataViewer.css | 5 ++ 6 files changed, 72 insertions(+), 37 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layer_invisible.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layer_visible.png diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java index e327a65..ae46827 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/GNAImages.java @@ -6,23 +6,26 @@ import com.google.gwt.resources.client.CssResource; import com.google.gwt.resources.client.ImageResource; public interface GNAImages extends ClientBundle { - + /** Get access to the css resource during gwt compilation */ @Source("baseIcons.css") CssResource css(); public static final GNAImages ICONS = GWT.create(GNAImages.class); - - /** Our sample image icon. Makes the image resource for the gwt-compiler's css composer accessible */ - @Source("map.png") - ImageResource map(); - - @Source("preset_location.png") - ImageResource preset_location(); - - @Source("layers.png") - ImageResource layers(); - + + /** + * Our sample image icon. Makes the image resource for the gwt-compiler's css + * composer accessible + */ + @Source("map.png") + ImageResource map(); + + @Source("preset_location.png") + ImageResource preset_location(); + + @Source("layers.png") + ImageResource layers(); + @Source("loading.gif") ImageResource loading(); @@ -38,4 +41,10 @@ public interface GNAImages extends ClientBundle { @Source("world.png") ImageResource worldIcon(); + @Source("layer_visible.png") + ImageResource layerVisible(); + + @Source("layer_invisible.png") + ImageResource layerInvisible(); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css index d209eca..a4e6cf6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/baseIcons.css @@ -22,4 +22,4 @@ vertical-align: middle; width: 17px !important; height: 17px !important; -} \ No newline at end of file +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layer_invisible.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/layer_invisible.png new file mode 100644 index 0000000000000000000000000000000000000000..68cb9997292afcd33c31558c24ee0f43c1e4dc72 GIT binary patch literal 1099 zcmV-R1ho5!P)jW^+}@zL21(uDTL3v_ealK2Rcr!cdED1k>C(vzn;o&O7IQ zy4X>-ZFa^2pUdYw&;R%Q-}8RJC5$+6^9x0{<=SQ1G4We)si2W{3)HhkgcGN`&&~u6 z{V#CA>MZfueW+e9B3B{)N)H}2rvyDB$brhi+*USA7F+j_dbR+6c;n}!_Oe40^;&{E zS87*2tUrhF6uy2d00N4F3Ic$R6|1gbvt&Ki&GVj5fRmZ=bC27OpPOk*vt-u_?aX!5 zUle!==xnW4hHZX-WSN>;IX$t(OiV=9JrH!bp9E|RsDd5_ zjsR=Ya=5Nw-GdG2pGN)MVVmDyNU}|McOXt&Z%fBf(XB)n0CJO=6Oni8k}Ds#^4s`f z@q7-P71ga-lLo8VX_PTWR>!B$X(#GTD84}7*JPHIaU(EIUx zCNPR>Z>1dWi~8$tjDwDGguy6r1OEWW{dKEj|FcybteRjj=%{a1v|1_U--)fex8c-z zqrGW4|3jSAUqg9e5{=b`#1#P~w)Mx=>&Hy8(awcHS>S6g%u8Ph`+98cZtrCW;MHhv z)#mp`N$nYs584<|MHU5keYG95QGPVb!UNT{va8$H?($x?1L}>=AF=tpg;hFJa8tCc z5CS@AypcZ6AI273VYIqdelOVCoo39b7^4eDZ2tSG-wkTMexo9@+jCKnK2x>9R#j}9 z5noSB`40=Wc87TR0?3Ks;bEKqE=t@0$~_}TgKvSw7lBQxrC^%@sFuSL!rDowZ&gac z%Tcj*yYccR5Mo$ZvEiP$SbJWP>GjcIQ9Pqw1g>kz6gH&gaG+u4LPUw{0|q#M%w$tq z$}NkF?lu+K1x&%PFty<~=X$!VUL9!GkLt56n3*W6D&=s)1wRuaPF$~|?{rk=h|E&_G^2;bwkJdxUP`^5A$T3CpXA}EJJu&@y!rD7w9U@8R>0tP%VcETw^MY*U*KqWZ~@4!YWqKyamAM!87I!2R26tWXM-?uEZuw2%O1%_hWbUGy$ONw~X@}MH8Y(9; z%z`NQRG6->cL9e0)BK9w3?@1Axg-m#!0SeJqgekypugF5L9419mXLf<7ltsX!A^yc z_J}Y6($f?T6%Fpdr%UqwCwRlC_NF#{BuH;Yrm2`XK(t#Gy$*ELlKVr9U#s)4SQ;b?csq&8-rUDRrOqr|TwYWM5VKj)8$f40K5vkdQDYU6X^IwC zBUGfFKxb7sVr?=T2}2T5liI1&rJIb%U7$NF(^c)%P{9EbQSJjzSaR469OO?2$a4Mj kk@<`M$0xB;f8$&H0XTL3sHU8q%>V!Z07*qoM6N<$g3c!o%K!iX literal 0 HcmV?d00001 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/DragDropLayer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/DragDropLayer.java index cc6deb7..6c53001 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/DragDropLayer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/DragDropLayer.java @@ -4,18 +4,20 @@ import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer; +import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages; import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import com.github.gwtbootstrap.client.ui.Button; -import com.github.gwtbootstrap.client.ui.CheckBox; import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.DragLeaveEvent; import com.google.gwt.event.dom.client.DragLeaveHandler; import com.google.gwt.event.dom.client.DragOverEvent; @@ -24,11 +26,11 @@ import com.google.gwt.event.dom.client.DragStartEvent; import com.google.gwt.event.dom.client.DragStartHandler; import com.google.gwt.event.dom.client.DropEvent; import com.google.gwt.event.dom.client.DropHandler; -import com.google.gwt.event.logical.shared.ValueChangeEvent; -import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; @@ -38,25 +40,28 @@ public class DragDropLayer extends FlowPanel { private static DragDropLayer draggingTarget = null; final boolean droppable; private Label labelLayerName; - private CheckBox checkBoxVisibility = new CheckBox(); + private Image imgLayerVisible = new Image(GNAImages.ICONS.layerVisible()); + private Image imgLayerInvisible = new Image(GNAImages.ICONS.layerInvisible()); private Button draggableButton = new Button(); private HandlerManager applicationBus; private LayerObject layerObject; private LayerItem layerItem; + private boolean layerVisibility = true; + private HTML buttonLayerVisibility = new HTML(); public DragDropLayer(HandlerManager applicationBus, LayerObject layerObject, boolean draggable, boolean droppable) { this.applicationBus = applicationBus; this.layerObject = layerObject; this.layerItem = layerObject.getLayerItem(); - + String layerName = StringUtil.fullNameToLayerName(layerItem.getName(), ":"); - + this.labelLayerName = new Label(layerName); this.labelLayerName.setTitle(layerItem.getName()); this.labelLayerName.setType(LabelType.INFO); - + BaseConcessioneDV refConcessione = layerObject.getSourceConcessione(); - String nameConcessione = StringUtil.ellipsize(refConcessione.getNome(),40); + String nameConcessione = StringUtil.ellipsize(refConcessione.getNome(), 40); com.google.gwt.user.client.ui.Label labelConcessione = new com.google.gwt.user.client.ui.Label(nameConcessione); labelConcessione.setTitle(refConcessione.getNome()); @@ -79,33 +84,47 @@ public class DragDropLayer extends FlowPanel { } RangeSlider rs = new RangeSlider(applicationBus, layerItem); - rs.getElement().addClassName("range-slider "); + rs.getElement().addClassName("range-slider"); FlexTable ft = new FlexTable(); ft.setWidget(0, 0, draggableButton); draggableButton.setTitle("Drag and Drop me up or down to change my position on the Map"); - checkBoxVisibility.getElement().getStyle().setMarginLeft(10, Unit.PX); - checkBoxVisibility.setValue(true); - //labelLayerName.getElement().getStyle().setMarginLeft(10, Unit.PX); - ft.setWidget(0, 1, checkBoxVisibility); + imgLayerVisible.getElement().addClassName("layer-visibility-st"); + imgLayerInvisible.getElement().addClassName("layer-visibility-st"); + setLayerVisibilityButtonImage(); + + // labelLayerName.getElement().getStyle().setMarginLeft(10, Unit.PX); + ft.setWidget(0, 1, buttonLayerVisibility); ft.setWidget(0, 2, labelConcessione); ft.setWidget(1, 2, labelLayerName); ft.setWidget(2, 2, new SimplePanel(rs)); add(ft); draggableButton.setIcon(IconType.MOVE); - checkBoxVisibility.addValueChangeHandler(new ValueChangeHandler() { + buttonLayerVisibility.addClickHandler(new ClickHandler() { @Override - public void onValueChange(ValueChangeEvent event) { - DoActionOnDetailLayersEvent dae = new DoActionOnDetailLayersEvent(DO_LAYER_ACTION.VISIBILITY, layerItem); - dae.setVisibility(checkBoxVisibility.getValue()); + public void onClick(ClickEvent event) { + layerVisibility = !layerVisibility; + setLayerVisibilityButtonImage(); + DoActionOnDetailLayersEvent dae = new DoActionOnDetailLayersEvent(DO_LAYER_ACTION.VISIBILITY, + layerItem); + dae.setVisibility(layerVisibility); applicationBus.fireEvent(dae); - } }); } + private void setLayerVisibilityButtonImage() { + buttonLayerVisibility.getElement().removeAllChildren(); + if (layerVisibility) { + buttonLayerVisibility.getElement().appendChild(imgLayerVisible.getElement()); + } else { + buttonLayerVisibility.getElement().appendChild(imgLayerInvisible.getElement()); + } + + } + private void initDrag() { draggableButton.getElement().setDraggable(Element.DRAGGABLE_TRUE); @@ -156,9 +175,9 @@ public class DragDropLayer extends FlowPanel { source = dragging; int sourceIndex = tree.getWidgetIndex(source); int targetIndex = tree.getWidgetIndex(draggingTarget); - - GWT.log("sourceIndex: " + sourceIndex+", sourceItem: "+dragging.getLayerItem().getName()); - GWT.log("targetIndex: " + targetIndex+", targetItem: "+draggingTarget.getLayerItem().getName()); + + GWT.log("sourceIndex: " + sourceIndex + ", sourceItem: " + dragging.getLayerItem().getName()); + GWT.log("targetIndex: " + targetIndex + ", targetItem: " + draggingTarget.getLayerItem().getName()); if (sourceIndex != targetIndex && targetIndex >= 0) { tree.remove(source); target = tree; @@ -168,8 +187,10 @@ public class DragDropLayer extends FlowPanel { // target.setState(true); DoActionOnDetailLayersEvent actionSwapLayers = new DoActionOnDetailLayersEvent( DO_LAYER_ACTION.SWAP, layerItem); - SwapLayer swapLS = new DoActionOnDetailLayersEvent.SwapLayer(dragging.getLayerItem(), sourceIndex); - SwapLayer swapLT = new DoActionOnDetailLayersEvent.SwapLayer(draggingTarget.getLayerItem(), targetIndex); + SwapLayer swapLS = new DoActionOnDetailLayersEvent.SwapLayer(dragging.getLayerItem(), + sourceIndex); + SwapLayer swapLT = new DoActionOnDetailLayersEvent.SwapLayer(draggingTarget.getLayerItem(), + targetIndex); actionSwapLayers.setSwapLayers(swapLS, swapLT); applicationBus.fireEvent(actionSwapLayers); } @@ -179,7 +200,7 @@ public class DragDropLayer extends FlowPanel { } }, DropEvent.getType()); } - + public LayerItem getLayerItem() { return layerItem; } diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index 6bb8759..f7ce891 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -505,4 +505,9 @@ body { border-radius: 4px; box-shadow: 2px 2px #08c; } +.layer-visibility-st { + padding-left: 7px; + padding-right: 5px; + cursor: pointer; +} \ No newline at end of file -- 2.17.1