224 lines
5.3 KiB
Java
224 lines
5.3 KiB
Java
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
import com.github.gwtbootstrap.client.ui.NavLink;
|
|
import com.github.gwtbootstrap.client.ui.Tab;
|
|
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;
|
|
|
|
public class GeonaDataViewMainPanel extends Composite {
|
|
|
|
private static GeonaDataViewMainPanelUiBinder uiBinder = GWT.create(GeonaDataViewMainPanelUiBinder.class);
|
|
|
|
interface GeonaDataViewMainPanelUiBinder extends UiBinder<Widget, GeonaDataViewMainPanel> {
|
|
}
|
|
|
|
// @UiField
|
|
// Tab mapTabPanel;
|
|
|
|
@UiField
|
|
HTMLPanel mainTabPanel;
|
|
|
|
@UiField
|
|
NavLink dataPointSelection;
|
|
|
|
@UiField
|
|
NavLink dataBoxSelection;
|
|
|
|
@UiField
|
|
Button removeQuery;
|
|
|
|
// @UiField
|
|
// TabPanel mainTabPanel;
|
|
|
|
@UiField
|
|
DetailsPanel detailsPanel;
|
|
|
|
private List<Tab> listTabs = new ArrayList<Tab>();
|
|
|
|
private MapPanel mapPanel;
|
|
|
|
private OpenLayerOSM map;
|
|
|
|
private HandlerManager eventBus;
|
|
|
|
private Map<Long, Tab> mapProducts = new HashMap<Long, Tab>();
|
|
|
|
public GeonaDataViewMainPanel(HandlerManager eventBus, int mapHeight) {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
this.eventBus = eventBus;
|
|
mapPanel = new MapPanel(mapHeight+"px");
|
|
detailsPanel.setHeight(mapHeight+"px");
|
|
mainTabPanel.add(mapPanel);
|
|
bindHandlers();
|
|
dataPointSelection.setIcon(IconType.SCREENSHOT);
|
|
dataBoxSelection.setIcon(IconType.BOOKMARK);
|
|
|
|
removeQuery.setIcon(IconType.REMOVE);
|
|
}
|
|
|
|
public void setMapHeight(int height) {
|
|
mapPanel.setHeight(height + "px");
|
|
}
|
|
|
|
public MapPanel getMapPanel() {
|
|
return mapPanel;
|
|
}
|
|
|
|
public void setMap(OpenLayerOSM map) {
|
|
this.map = map;
|
|
}
|
|
|
|
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.setActive(false);
|
|
//dataBoxSelection.getElement().removeClassName("active");
|
|
}
|
|
});
|
|
|
|
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);
|
|
//dataPointSelection.setActive(false);
|
|
//dataPointSelection.getElement().removeClassName("active");
|
|
}
|
|
});
|
|
|
|
removeQuery.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
map.removeQueryInteractions();
|
|
removeQuery.setVisible(false);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
// public void renderProductIntoTab(Tab tab, ConcessioneDV cdv, GeoNaItemRef geonaItemRef) {
|
|
// tab.clear();
|
|
// tab.setHeading(cdv.getNome());
|
|
// tab.add(new ConcessioneView(geonaItemRef, cdv));
|
|
// mapProducts.put(cdv.getId(), tab);
|
|
// selectTabForProductId(cdv.getId());
|
|
// }
|
|
|
|
// public boolean selectTabForProductId(long productId) {
|
|
//
|
|
// Tab product = mapProducts.get(productId);
|
|
// if(product!=null) {
|
|
// selectTab(product);
|
|
// //found
|
|
// return true;
|
|
// }
|
|
// //not found
|
|
// return false;
|
|
//
|
|
// }
|
|
|
|
// /**
|
|
// * Adds the as tab.
|
|
// *
|
|
// * @param tabTitle the tab title
|
|
// * @param tabDescr the tab descr
|
|
// * @param spinner the spinner
|
|
// * @param w the w
|
|
// * @return the tab
|
|
// */
|
|
// public Tab addAsTab(String tabTitle, boolean spinner, Widget w){
|
|
//
|
|
//// field_create_analytics_request.setActive(false);
|
|
//
|
|
// Tab tab = new Tab();
|
|
// mainTabPanel.add(tab);
|
|
//
|
|
// if(spinner) {
|
|
// LoaderIcon loader = new LoaderIcon("Loading...");
|
|
// tab.add(loader);
|
|
// }
|
|
//
|
|
// tab.addClickHandler(new ClickHandler() {
|
|
//
|
|
// @Override
|
|
// public void onClick(ClickEvent event) {
|
|
//
|
|
// }
|
|
// });
|
|
//
|
|
// //tab.setActive(true);
|
|
// tab.setHeading(tabTitle);
|
|
// listTabs.add(tab);
|
|
//
|
|
// if(w!=null)
|
|
// tab.add(w);
|
|
//
|
|
// Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
//
|
|
// @Override
|
|
// public void execute() {
|
|
// selectTab(tab);
|
|
//
|
|
// }
|
|
// });
|
|
//
|
|
// return tab;
|
|
//
|
|
//// tab.setActive(true);
|
|
// }
|
|
|
|
|
|
// private void selectTab(Tab theTab) {
|
|
// int i = 1;
|
|
// for (Tab tab : listTabs) {
|
|
// GWT.log("Selecting "+tab);
|
|
// tab.setActive(false);
|
|
// if(tab.equals(theTab)) {
|
|
// GWT.log("Tab selected "+tab);
|
|
// mainTabPanel.selectTab(i);
|
|
// }
|
|
// i++;
|
|
// }
|
|
//
|
|
// }
|
|
|
|
public void showAsDetails(ConcessioneDV concessioneDV, GeoNaItemRef geonaItemRef) {
|
|
detailsPanel.showDetailsFor(concessioneDV, geonaItemRef);
|
|
|
|
}
|
|
|
|
}
|