233 lines
6.2 KiB
Java
233 lines
6.2 KiB
Java
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
|
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.MapExtentToEvent;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
import com.github.gwtbootstrap.client.ui.NavLink;
|
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
|
import com.google.gwt.core.client.GWT;
|
|
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.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.HTMLPanel;
|
|
import com.google.gwt.user.client.ui.Image;
|
|
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;
|
|
|
|
private MapPanel mapPanel;
|
|
|
|
private OpenLayerOSM map;
|
|
|
|
private HandlerManager applicationBus;
|
|
|
|
/**
|
|
* Instantiates a new geona data view main panel.
|
|
*
|
|
* @param applicationBus the application bus
|
|
* @param mapHeight the map height
|
|
*/
|
|
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight) {
|
|
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(Images.ICONS.italyIcon());
|
|
italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
|
|
extentToItaly.getElement().appendChild(italyImg.getElement());
|
|
extentToItaly.setWidth("140px");
|
|
|
|
Image worldImg = new Image(Images.ICONS.worldIcon());
|
|
worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
|
|
extentToEarth.getElement().appendChild(worldImg.getElement());
|
|
extentToEarth.setWidth("140px");
|
|
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
|
|
/**
|
|
* Gets the map panel.
|
|
*
|
|
* @return the map panel
|
|
*/
|
|
public MapPanel getMapPanel() {
|
|
return mapPanel;
|
|
}
|
|
|
|
/**
|
|
* Sets the map.
|
|
*
|
|
* @param map the new map
|
|
*/
|
|
public void setMap(OpenLayerOSM 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.EARTH);
|
|
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 getDisplyedRecord() {
|
|
return detailsPanel.getDisplayedRecord();
|
|
}
|
|
|
|
}
|