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.gis.OpenLayerOSM; 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.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.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 { } @UiField HTMLPanel mainContainerPanel; @UiField HTMLPanel mainToolBar; @UiField NavLink dataPointSelection; @UiField NavLink dataBoxSelection; @UiField Button removeQuery; @UiField DetailsPanel detailsPanel; 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); } /** * 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); } }); } /** * 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(); } }