431 lines
11 KiB
Java
431 lines
11 KiB
Java
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;
|
|
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;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
import com.github.gwtbootstrap.client.ui.DropdownButton;
|
|
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;
|
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
|
import com.google.gwt.event.shared.GwtEvent;
|
|
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.ui.Composite;
|
|
import com.google.gwt.user.client.ui.FlowPanel;
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
import com.google.gwt.user.client.ui.Image;
|
|
import com.google.gwt.user.client.ui.Label;
|
|
import com.google.gwt.user.client.ui.RadioButton;
|
|
import com.google.gwt.user.client.ui.ScrollPanel;
|
|
import com.google.gwt.user.client.ui.SimplePanel;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
/**
|
|
* The Class GeonaDataViewMainPanel.
|
|
*
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
*
|
|
* Nov 19, 2020
|
|
*/
|
|
public class GeonaDataViewMainPanel extends Composite {
|
|
|
|
private static GeonaDataViewMainPanelUiBinder uiBinder = GWT.create(GeonaDataViewMainPanelUiBinder.class);
|
|
|
|
/**
|
|
* The Interface GeonaDataViewMainPanelUiBinder.
|
|
*
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
*
|
|
* Nov 19, 2020
|
|
*/
|
|
interface GeonaDataViewMainPanelUiBinder extends UiBinder<Widget, GeonaDataViewMainPanel> {
|
|
}
|
|
|
|
@UiField
|
|
HTMLPanel mainContainerPanel;
|
|
|
|
@UiField
|
|
HTMLPanel mainToolBar;
|
|
|
|
@UiField
|
|
NavLink dataPointSelection;
|
|
|
|
@UiField
|
|
NavLink dataBoxSelection;
|
|
|
|
@UiField
|
|
Button removeQuery;
|
|
|
|
@UiField
|
|
DetailsPanel detailsPanel;
|
|
|
|
@UiField
|
|
Button extentToItaly;
|
|
|
|
@UiField
|
|
Button extentToEarth;
|
|
|
|
@UiField
|
|
Button linkLayers;
|
|
|
|
@UiField
|
|
DropdownButton searchFacilityButton;
|
|
|
|
@UiField
|
|
ScrollPanel overlayLayersPanel;
|
|
|
|
@UiField
|
|
ScrollPanel searchFacilityPanel;
|
|
|
|
@UiField
|
|
HTMLPanel panelAttribution;
|
|
|
|
@UiField
|
|
HTMLPanel panelBaseLayers;
|
|
|
|
@UiField
|
|
DropdownButton linkMap;
|
|
|
|
@UiField
|
|
DropdownButton linkPresetLocation;
|
|
|
|
private MapPanel mapPanel;
|
|
|
|
private OpenLayerMap map;
|
|
|
|
private HandlerManager applicationBus;
|
|
|
|
private SearchFacilityUI searchFacility;
|
|
|
|
|
|
/**
|
|
* Instantiates a new geona data view main panel.
|
|
*
|
|
* @param applicationBus the application bus
|
|
* @param mapHeight the map height
|
|
*/
|
|
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight, List<ItemField> sortByFields,
|
|
List<ItemField> searchForFields, SearchingFilter initialSortFilter) {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
this.applicationBus = applicationBus;
|
|
mapPanel = new MapPanel(mapHeight + "px");
|
|
detailsPanel.setHeight(mapHeight + "px");
|
|
detailsPanel.setApplicationBus(applicationBus);
|
|
mainContainerPanel.add(mapPanel);
|
|
bindHandlers();
|
|
dataPointSelection.setIcon(IconType.SCREENSHOT);
|
|
dataBoxSelection.setIcon(IconType.BOOKMARK);
|
|
removeQuery.setIcon(IconType.REMOVE);
|
|
|
|
Image italyImg = new Image(GNAImages.ICONS.italyIcon());
|
|
italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
|
|
extentToItaly.getElement().appendChild(italyImg.getElement());
|
|
extentToItaly.setWidth("140px");
|
|
|
|
Image worldImg = new Image(GNAImages.ICONS.worldIcon());
|
|
worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
|
|
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());
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
private void bindEvents() {
|
|
|
|
linkLayers.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
|
|
GWT.log("layersDDB clicked");
|
|
|
|
if (overlayLayersPanel.isVisible()) {
|
|
overlayLayersPanel.setVisible(false);
|
|
} else {
|
|
overlayLayersPanel.setVisible(true);
|
|
}
|
|
}
|
|
});
|
|
|
|
searchFacilityButton.addDomHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
//event.preventDefault();
|
|
event.stopPropagation();
|
|
|
|
}
|
|
}, ClickEvent.getType());
|
|
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
|
|
setOverlayPanelMaxHeight();
|
|
|
|
}
|
|
|
|
private void setOverlayPanelMaxHeight() {
|
|
|
|
String overlMH = mapPanel.getOffsetHeight() - 130 + "px";
|
|
GWT.log("overlayLayersPanel maxHeight: " + overlMH);
|
|
overlayLayersPanel.getElement().getStyle().setProperty("maxHeight", overlMH);
|
|
}
|
|
|
|
/**
|
|
* Gets the map panel.
|
|
*
|
|
* @return the map panel
|
|
*/
|
|
public MapPanel getMapPanel() {
|
|
return mapPanel;
|
|
}
|
|
|
|
/**
|
|
* Sets the map.
|
|
*
|
|
* @param map the new map
|
|
*/
|
|
public void setMap(OpenLayerMap map) {
|
|
this.map = map;
|
|
}
|
|
|
|
/**
|
|
* Bind handlers.
|
|
*/
|
|
public void bindHandlers() {
|
|
|
|
dataPointSelection.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
map.removeQueryInteractions();
|
|
GWT.log("dataPointSelection.isActive() " + dataPointSelection.isActive());
|
|
if (!dataPointSelection.isActive()) {
|
|
map.addPointVectorSource();
|
|
}
|
|
removeQuery.setVisible(true);
|
|
}
|
|
});
|
|
|
|
dataBoxSelection.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
map.removeQueryInteractions();
|
|
GWT.log("dataBoxSelection.isActive() " + dataBoxSelection.isActive());
|
|
if (!dataBoxSelection.isActive()) {
|
|
map.addExtentInteraction();
|
|
}
|
|
removeQuery.setVisible(true);
|
|
}
|
|
});
|
|
|
|
removeQuery.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
map.removeQueryInteractions();
|
|
removeQuery.setVisible(false);
|
|
}
|
|
});
|
|
|
|
extentToItaly.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
Location italyLocation = ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.ITALY);
|
|
applicationBus.fireEvent(new MapExtentToEvent(italyLocation));
|
|
map.setCenter(italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857));
|
|
map.setZoom(italyLocation.getZoomLevel());
|
|
|
|
}
|
|
});
|
|
|
|
extentToEarth.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
Location earthLocation = ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.WORLD);
|
|
applicationBus.fireEvent(new MapExtentToEvent(earthLocation));
|
|
map.setCenter(earthLocation.getCoordinate(MAP_PROJECTION.EPSG_3857));
|
|
map.setZoom(earthLocation.getZoomLevel());
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
* Show as details.
|
|
*
|
|
* @param concessioneDV the concessione DV
|
|
* @param geonaItemRef the geona item ref
|
|
*/
|
|
public void showAsDetails(ConcessioneDV concessioneDV, GeoNaItemRef geonaItemRef) {
|
|
detailsPanel.showDetailsFor(concessioneDV, geonaItemRef);
|
|
|
|
}
|
|
|
|
/**
|
|
* Hide panel details.
|
|
*/
|
|
public void hidePanelDetails() {
|
|
detailsPanel.hidePanelDetails();
|
|
|
|
}
|
|
|
|
/**
|
|
* Gets the displyed record.
|
|
*
|
|
* @return the displyed record
|
|
*/
|
|
public RecordDV getDisplayedRecord() {
|
|
return detailsPanel.getDisplayedRecord();
|
|
}
|
|
|
|
/**
|
|
* Gets the layers DDB.
|
|
*
|
|
* @return the layers DDB
|
|
*/
|
|
public Button getLayersDDB() {
|
|
return linkLayers;
|
|
}
|
|
|
|
/**
|
|
* Show overlay layers.
|
|
*
|
|
* @param panel the panel
|
|
*/
|
|
public void showOverlayLayers(FlowPanel panel) {
|
|
GWT.log("showOverlayLayers");
|
|
// layersDDB.setVisible(true);
|
|
overlayLayersPanel.setVisible(true);
|
|
overlayLayersPanel.clear();
|
|
|
|
setOverlayPanelMaxHeight();
|
|
overlayLayersPanel.add(panel);
|
|
// layersDDBClickEvent();
|
|
}
|
|
|
|
private void layersDDBClickEvent() {
|
|
linkLayers.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);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Hide overlay layers.
|
|
*/
|
|
public void hideOverlayLayers() {
|
|
GWT.log("hideOverlayLayers");
|
|
overlayLayersPanel.clear();
|
|
// layersDDB.setVisible(false);
|
|
overlayLayersPanel.setVisible(false);
|
|
// 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);
|
|
}
|
|
|
|
public void setBaseLayers(List<BaseMapLayer> listBaseLayers) {
|
|
|
|
if(listBaseLayers==null)
|
|
return;
|
|
|
|
int i = 0;
|
|
|
|
for (BaseMapLayer baseMapLayer : listBaseLayers) {
|
|
|
|
RadioButton radio = new RadioButton("base-layer");
|
|
radio.setText(baseMapLayer.getName());
|
|
if(i==0) {
|
|
radio.setValue(true, false);
|
|
}
|
|
|
|
radio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
|
|
|
@Override
|
|
public void onValueChange(ValueChangeEvent<Boolean> event) {
|
|
applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer));
|
|
|
|
}
|
|
});
|
|
|
|
SimplePanel sp = new SimplePanel(radio);
|
|
sp.getElement().addClassName("form-inline");
|
|
sp.getElement().addClassName("map-layers-radio");
|
|
panelBaseLayers.add(sp);
|
|
i++;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|