2020-10-23 18:18:06 +02:00
|
|
|
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
|
|
|
|
|
2020-12-02 14:39:52 +01:00
|
|
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
2021-08-02 15:20:01 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
2021-09-01 16:26:07 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
2021-09-01 12:51:06 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent;
|
2020-10-27 16:04:34 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
|
2021-09-01 16:26:07 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
|
2021-09-01 12:51:06 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
|
2021-09-01 16:26:07 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
|
2020-10-26 17:40:38 +01:00
|
|
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
2020-11-02 17:04:31 +01:00
|
|
|
import com.github.gwtbootstrap.client.ui.NavLink;
|
2021-11-11 16:32:49 +01:00
|
|
|
import com.github.gwtbootstrap.client.ui.Paragraph;
|
2020-10-28 11:19:12 +01:00
|
|
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
2020-10-23 18:18:06 +02:00
|
|
|
import com.google.gwt.core.client.GWT;
|
2021-09-01 16:26:07 +02:00
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
2020-10-26 17:40:38 +01:00
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
2021-10-14 11:34:04 +02:00
|
|
|
import com.google.gwt.event.shared.GwtEvent;
|
2020-11-03 13:09:08 +01:00
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
2020-10-23 18:18:06 +02:00
|
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
|
|
import com.google.gwt.user.client.ui.Composite;
|
2021-10-14 11:34:04 +02:00
|
|
|
import com.google.gwt.user.client.ui.FlowPanel;
|
2020-11-19 15:19:27 +01:00
|
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
2021-09-01 16:26:07 +02:00
|
|
|
import com.google.gwt.user.client.ui.Image;
|
2021-11-11 16:32:49 +01:00
|
|
|
import com.google.gwt.user.client.ui.Label;
|
2021-10-15 17:51:09 +02:00
|
|
|
import com.google.gwt.user.client.ui.ScrollPanel;
|
2020-10-23 18:18:06 +02:00
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* The Class GeonaDataViewMainPanel.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
*
|
2021-09-01 12:51:06 +02:00
|
|
|
* Nov 19, 2020
|
2020-11-19 15:19:27 +01:00
|
|
|
*/
|
2020-10-23 18:18:06 +02:00
|
|
|
public class GeonaDataViewMainPanel extends Composite {
|
|
|
|
|
|
|
|
private static GeonaDataViewMainPanelUiBinder uiBinder = GWT.create(GeonaDataViewMainPanelUiBinder.class);
|
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* The Interface GeonaDataViewMainPanelUiBinder.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
*
|
2021-09-01 12:51:06 +02:00
|
|
|
* Nov 19, 2020
|
2020-11-19 15:19:27 +01:00
|
|
|
*/
|
2020-10-23 18:18:06 +02:00
|
|
|
interface GeonaDataViewMainPanelUiBinder extends UiBinder<Widget, GeonaDataViewMainPanel> {
|
|
|
|
}
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
@UiField
|
|
|
|
HTMLPanel mainContainerPanel;
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2020-10-23 18:18:06 +02:00
|
|
|
@UiField
|
2020-11-19 15:19:27 +01:00
|
|
|
HTMLPanel mainToolBar;
|
|
|
|
|
2020-10-26 17:40:38 +01:00
|
|
|
@UiField
|
2020-11-02 17:04:31 +01:00
|
|
|
NavLink dataPointSelection;
|
2020-10-28 11:19:12 +01:00
|
|
|
|
2020-10-26 17:40:38 +01:00
|
|
|
@UiField
|
2020-11-02 17:04:31 +01:00
|
|
|
NavLink dataBoxSelection;
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2020-10-28 11:19:12 +01:00
|
|
|
@UiField
|
2020-11-02 17:04:31 +01:00
|
|
|
Button removeQuery;
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2020-11-03 13:09:08 +01:00
|
|
|
@UiField
|
2020-11-19 15:19:27 +01:00
|
|
|
DetailsPanel detailsPanel;
|
2020-10-28 11:19:12 +01:00
|
|
|
|
2021-09-01 12:51:06 +02:00
|
|
|
@UiField
|
|
|
|
Button extentToItaly;
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-09-01 16:26:07 +02:00
|
|
|
@UiField
|
|
|
|
Button extentToEarth;
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
@UiField
|
|
|
|
Button layersDDB;
|
|
|
|
|
|
|
|
@UiField
|
2021-10-15 17:51:09 +02:00
|
|
|
ScrollPanel overlayLayersPanel;
|
2021-10-14 11:34:04 +02:00
|
|
|
|
2021-11-11 16:32:49 +01:00
|
|
|
@UiField
|
|
|
|
HTMLPanel panelAttribution;
|
|
|
|
|
2020-10-27 10:19:32 +01:00
|
|
|
private MapPanel mapPanel;
|
2020-10-26 17:40:38 +01:00
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
private OpenLayerOSM map;
|
2020-10-28 11:19:12 +01:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
private HandlerManager applicationBus;
|
2020-11-03 13:09:08 +01:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new geona data view main panel.
|
|
|
|
*
|
|
|
|
* @param applicationBus the application bus
|
2021-09-01 12:51:06 +02:00
|
|
|
* @param mapHeight the map height
|
2020-11-19 15:19:27 +01:00
|
|
|
*/
|
|
|
|
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight) {
|
2020-10-23 18:18:06 +02:00
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
2020-11-19 15:19:27 +01:00
|
|
|
this.applicationBus = applicationBus;
|
2021-09-01 12:51:06 +02:00
|
|
|
mapPanel = new MapPanel(mapHeight + "px");
|
|
|
|
detailsPanel.setHeight(mapHeight + "px");
|
2020-11-19 15:19:27 +01:00
|
|
|
detailsPanel.setApplicationBus(applicationBus);
|
|
|
|
mainContainerPanel.add(mapPanel);
|
2020-10-26 17:40:38 +01:00
|
|
|
bindHandlers();
|
2020-10-28 11:19:12 +01:00
|
|
|
dataPointSelection.setIcon(IconType.SCREENSHOT);
|
|
|
|
dataBoxSelection.setIcon(IconType.BOOKMARK);
|
2020-11-02 17:04:31 +01:00
|
|
|
removeQuery.setIcon(IconType.REMOVE);
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-09-01 16:26:07 +02:00
|
|
|
Image italyImg = new Image(Images.ICONS.italyIcon());
|
|
|
|
italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
|
|
|
|
extentToItaly.getElement().appendChild(italyImg.getElement());
|
|
|
|
extentToItaly.setWidth("140px");
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-09-01 16:26:07 +02:00
|
|
|
Image worldImg = new Image(Images.ICONS.worldIcon());
|
|
|
|
worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
|
|
|
|
extentToEarth.getElement().appendChild(worldImg.getElement());
|
|
|
|
extentToEarth.setWidth("140px");
|
2021-11-11 16:32:49 +01:00
|
|
|
|
|
|
|
// layersDDB.setToggle(true);
|
2021-10-14 11:34:04 +02:00
|
|
|
bindEvents();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void bindEvents() {
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
layersDDB.addClickHandler(new ClickHandler() {
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
GWT.log("layersDDB clicked");
|
2021-11-11 16:32:49 +01:00
|
|
|
|
|
|
|
if (overlayLayersPanel.isVisible()) {
|
2021-10-14 11:34:04 +02:00
|
|
|
overlayLayersPanel.setVisible(false);
|
2021-11-11 16:32:49 +01:00
|
|
|
} else {
|
2021-10-14 11:34:04 +02:00
|
|
|
overlayLayersPanel.setVisible(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2020-10-23 18:18:06 +02:00
|
|
|
}
|
2020-10-28 11:19:12 +01:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Sets the panels height.
|
|
|
|
*
|
|
|
|
* @param height the new panels height
|
|
|
|
*/
|
|
|
|
public void setPanelsHeight(int height) {
|
|
|
|
String toH = height + "px";
|
|
|
|
mapPanel.setMapHeight(height);
|
|
|
|
detailsPanel.setHeight(toH);
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-10-18 17:35:00 +02:00
|
|
|
setOverlayPanelMaxHeight();
|
|
|
|
|
|
|
|
}
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-10-18 17:35:00 +02:00
|
|
|
private void setOverlayPanelMaxHeight() {
|
2021-11-11 16:32:49 +01:00
|
|
|
|
|
|
|
String overlMH = mapPanel.getOffsetHeight() - 130 + "px";
|
|
|
|
GWT.log("overlayLayersPanel maxHeight: " + overlMH);
|
2021-10-18 17:35:00 +02:00
|
|
|
overlayLayersPanel.getElement().getStyle().setProperty("maxHeight", overlMH);
|
2020-10-26 11:01:07 +01:00
|
|
|
}
|
2020-10-23 18:18:06 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Gets the map panel.
|
|
|
|
*
|
|
|
|
* @return the map panel
|
|
|
|
*/
|
2020-10-27 10:19:32 +01:00
|
|
|
public MapPanel getMapPanel() {
|
|
|
|
return mapPanel;
|
2020-10-23 18:18:06 +02:00
|
|
|
}
|
2020-10-28 11:19:12 +01:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Sets the map.
|
|
|
|
*
|
|
|
|
* @param map the new map
|
|
|
|
*/
|
2020-10-27 16:04:34 +01:00
|
|
|
public void setMap(OpenLayerOSM map) {
|
2020-10-26 17:40:38 +01:00
|
|
|
this.map = map;
|
|
|
|
}
|
2020-10-28 11:19:12 +01:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Bind handlers.
|
|
|
|
*/
|
2020-10-28 11:19:12 +01:00
|
|
|
public void bindHandlers() {
|
|
|
|
|
2020-10-26 17:40:38 +01:00
|
|
|
dataPointSelection.addClickHandler(new ClickHandler() {
|
2020-10-28 11:19:12 +01:00
|
|
|
|
2020-10-26 17:40:38 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
2020-10-28 11:19:12 +01:00
|
|
|
map.removeQueryInteractions();
|
|
|
|
GWT.log("dataPointSelection.isActive() " + dataPointSelection.isActive());
|
|
|
|
if (!dataPointSelection.isActive()) {
|
|
|
|
map.addPointVectorSource();
|
|
|
|
}
|
2020-11-02 17:04:31 +01:00
|
|
|
removeQuery.setVisible(true);
|
2020-10-26 17:40:38 +01:00
|
|
|
}
|
|
|
|
});
|
2020-10-28 11:19:12 +01:00
|
|
|
|
2020-10-26 17:40:38 +01:00
|
|
|
dataBoxSelection.addClickHandler(new ClickHandler() {
|
2020-10-28 11:19:12 +01:00
|
|
|
|
2020-10-26 17:40:38 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
2020-10-28 11:19:12 +01:00
|
|
|
map.removeQueryInteractions();
|
2020-10-30 17:32:05 +01:00
|
|
|
GWT.log("dataBoxSelection.isActive() " + dataBoxSelection.isActive());
|
2020-10-28 11:19:12 +01:00
|
|
|
if (!dataBoxSelection.isActive()) {
|
|
|
|
map.addExtentInteraction();
|
|
|
|
}
|
2020-11-02 17:04:31 +01:00
|
|
|
removeQuery.setVisible(true);
|
2020-10-26 17:40:38 +01:00
|
|
|
}
|
|
|
|
});
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2020-11-02 17:04:31 +01:00
|
|
|
removeQuery.addClickHandler(new ClickHandler() {
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2020-11-02 17:04:31 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
map.removeQueryInteractions();
|
|
|
|
removeQuery.setVisible(false);
|
|
|
|
}
|
|
|
|
});
|
2020-10-28 11:19:12 +01:00
|
|
|
|
2021-09-01 12:51:06 +02:00
|
|
|
extentToItaly.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
2021-09-01 16:26:07 +02:00
|
|
|
Location italyLocation = ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.ITALY);
|
|
|
|
applicationBus.fireEvent(new MapExtentToEvent(italyLocation));
|
|
|
|
map.setCenter(italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857));
|
|
|
|
map.setZoom(italyLocation.getZoomLevel());
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-09-01 16:26:07 +02:00
|
|
|
extentToEarth.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
2021-09-06 17:15:38 +02:00
|
|
|
Location earthLocation = ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.WORLD);
|
2021-09-01 16:26:07 +02:00
|
|
|
applicationBus.fireEvent(new MapExtentToEvent(earthLocation));
|
|
|
|
map.setCenter(earthLocation.getCoordinate(MAP_PROJECTION.EPSG_3857));
|
|
|
|
map.setZoom(earthLocation.getZoomLevel());
|
2021-09-01 12:51:06 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-10-26 17:40:38 +01:00
|
|
|
}
|
2020-11-19 15:19:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show as details.
|
|
|
|
*
|
|
|
|
* @param concessioneDV the concessione DV
|
2021-09-01 12:51:06 +02:00
|
|
|
* @param geonaItemRef the geona item ref
|
2020-11-19 15:19:27 +01:00
|
|
|
*/
|
|
|
|
public void showAsDetails(ConcessioneDV concessioneDV, GeoNaItemRef geonaItemRef) {
|
|
|
|
detailsPanel.showDetailsFor(concessioneDV, geonaItemRef);
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2020-11-05 14:05:14 +01:00
|
|
|
}
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2020-11-05 14:05:14 +01:00
|
|
|
/**
|
2020-11-19 15:19:27 +01:00
|
|
|
* Hide panel details.
|
2020-11-05 14:05:14 +01:00
|
|
|
*/
|
2020-11-19 15:19:27 +01:00
|
|
|
public void hidePanelDetails() {
|
|
|
|
detailsPanel.hidePanelDetails();
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2020-11-05 14:05:14 +01:00
|
|
|
}
|
2021-09-01 12:51:06 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Gets the displyed record.
|
|
|
|
*
|
|
|
|
* @return the displyed record
|
|
|
|
*/
|
|
|
|
public RecordDV getDisplyedRecord() {
|
|
|
|
return detailsPanel.getDisplayedRecord();
|
2020-11-03 13:09:08 +01:00
|
|
|
}
|
2020-10-23 18:18:06 +02:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
/**
|
|
|
|
* Gets the layers DDB.
|
|
|
|
*
|
|
|
|
* @return the layers DDB
|
|
|
|
*/
|
|
|
|
public Button getLayersDDB() {
|
|
|
|
return layersDDB;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show overlay layers.
|
|
|
|
*
|
|
|
|
* @param panel the panel
|
|
|
|
*/
|
|
|
|
public void showOverlayLayers(FlowPanel panel) {
|
|
|
|
GWT.log("showOverlayLayers");
|
2021-11-11 16:32:49 +01:00
|
|
|
// layersDDB.setVisible(true);
|
2021-10-14 11:34:04 +02:00
|
|
|
overlayLayersPanel.setVisible(true);
|
|
|
|
overlayLayersPanel.clear();
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-10-18 17:35:00 +02:00
|
|
|
setOverlayPanelMaxHeight();
|
2021-10-14 11:34:04 +02:00
|
|
|
overlayLayersPanel.add(panel);
|
2021-11-11 16:32:49 +01:00
|
|
|
// layersDDBClickEvent();
|
2021-10-14 11:34:04 +02:00
|
|
|
}
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
private void layersDDBClickEvent() {
|
2021-11-11 16:32:49 +01:00
|
|
|
layersDDB.fireEvent(new GwtEvent<ClickHandler>() {
|
|
|
|
@Override
|
|
|
|
public com.google.gwt.event.shared.GwtEvent.Type<ClickHandler> getAssociatedType() {
|
|
|
|
return ClickEvent.getType();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void dispatch(ClickHandler handler) {
|
|
|
|
handler.onClick(null);
|
|
|
|
}
|
|
|
|
});
|
2021-10-14 11:34:04 +02:00
|
|
|
}
|
2021-11-11 16:32:49 +01:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
/**
|
|
|
|
* Hide overlay layers.
|
|
|
|
*/
|
|
|
|
public void hideOverlayLayers() {
|
|
|
|
GWT.log("hideOverlayLayers");
|
|
|
|
overlayLayersPanel.clear();
|
2021-11-11 16:32:49 +01:00
|
|
|
// layersDDB.setVisible(false);
|
2021-10-14 11:34:04 +02:00
|
|
|
overlayLayersPanel.setVisible(false);
|
2021-11-11 16:32:49 +01:00
|
|
|
// layersDDBClickEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMapAttribution(String attribution) {
|
|
|
|
panelAttribution.clear();
|
|
|
|
Label label = new Label("Base Map Credits");
|
|
|
|
Paragraph p = new Paragraph(attribution);
|
|
|
|
panelAttribution.add(label);
|
|
|
|
panelAttribution.add(p);
|
2021-10-14 11:34:04 +02:00
|
|
|
}
|
|
|
|
|
2020-10-23 18:18:06 +02:00
|
|
|
}
|