335 lines
11 KiB
Java
335 lines
11 KiB
Java
package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni;
|
|
|
|
import java.util.List;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.images.ThumbnailImageView;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RelazioneScavoDV;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
import com.github.gwtbootstrap.client.ui.PageHeader;
|
|
import com.github.gwtbootstrap.client.ui.Paragraph;
|
|
import com.github.gwtbootstrap.client.ui.Thumbnails;
|
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
|
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.uibinder.client.UiBinder;
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
import ol.Coordinate;
|
|
import ol.OLFactory;
|
|
|
|
public class ConcessioneView extends Composite {
|
|
|
|
|
|
|
|
private static ConcessioneViewUiBinder uiBinder = GWT.create(ConcessioneViewUiBinder.class);
|
|
|
|
interface ConcessioneViewUiBinder extends UiBinder<Widget, ConcessioneView> {
|
|
}
|
|
|
|
@UiField
|
|
PageHeader titolo;
|
|
|
|
@UiField
|
|
Paragraph introduzione;
|
|
|
|
@UiField
|
|
HTMLPanel concessioniPanel;
|
|
|
|
@UiField
|
|
HTMLPanel relazioneScavoPanel;
|
|
|
|
@UiField
|
|
HTMLPanel imagesPanel;
|
|
|
|
@UiField
|
|
HTMLPanel pageViewDetails;
|
|
|
|
@UiField
|
|
HTMLPanel mapViewPanel;
|
|
|
|
@UiField
|
|
HTMLPanel posizionamentoAreaIndaginePanel;
|
|
|
|
@UiField
|
|
HTMLPanel piantaFineScavoPanel;
|
|
|
|
// @UiField
|
|
// HTMLPanel sharePanel;
|
|
|
|
@UiField
|
|
Button shareButton;
|
|
|
|
@UiField
|
|
Button viewButton;
|
|
|
|
private ConcessioneDV concessioneDV;
|
|
|
|
private Thumbnails thumbNails = new Thumbnails();
|
|
|
|
private CustomFlexTable customTable = new CustomFlexTable();
|
|
|
|
private GeoNaItemRef geonaItemRef;
|
|
|
|
private String myLogin;
|
|
|
|
private boolean viewImageButtonVisible = true;
|
|
|
|
private boolean openImageButtonVisible = true;
|
|
|
|
private ConcessioneView() {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
pageViewDetails.getElement().setId("page-view-details");
|
|
}
|
|
|
|
public ConcessioneView(GeoNaItemRef item, ConcessioneDV concDV) {
|
|
this(item, concDV, true, true);
|
|
}
|
|
|
|
public ConcessioneView(GeoNaItemRef item, ConcessioneDV concDV, boolean viewImageButtonVisible, boolean openImageButtonVisible) {
|
|
this();
|
|
this.concessioneDV = concDV;
|
|
this.geonaItemRef = item;
|
|
this.viewImageButtonVisible = viewImageButtonVisible;
|
|
this.openImageButtonVisible = openImageButtonVisible;
|
|
|
|
titolo.setText(concessioneDV.getNome());
|
|
introduzione.setText(concessioneDV.getIntroduzione());
|
|
|
|
if (concessioneDV.getDataInizioProgetto() != null) {
|
|
customTable.addNextKeyValue("Data Inizio Progetto", concessioneDV.getDataFineProgetto());
|
|
}
|
|
|
|
if (concessioneDV.getDataFineProgetto() != null) {
|
|
customTable.addNextKeyValue("Data Fine Progetto", concessioneDV.getDataFineProgetto());
|
|
}
|
|
|
|
if (concessioneDV.getParoleChiaveLibere() != null) {
|
|
customTable.addNextKeyValues("Parole chiave Libere", concessioneDV.getParoleChiaveICCD(), GeoportalDataViewerConstants.NEW_LINE_BR);
|
|
}
|
|
|
|
if (concessioneDV.getParoleChiaveICCD() != null) {
|
|
customTable.addNextKeyValues("Parole chiave Cronologia", concessioneDV.getParoleChiaveICCD(), GeoportalDataViewerConstants.NEW_LINE_BR);
|
|
}
|
|
|
|
if (concessioneDV.getAuthors() != null) {
|
|
customTable.addNextKeyValues("Autori", concessioneDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR);
|
|
}
|
|
|
|
if (concessioneDV.getContributore() != null) {
|
|
customTable.addNextKeyValue("Contributore", concessioneDV.getContributore());
|
|
}
|
|
|
|
if (concessioneDV.getEditore() != null) {
|
|
customTable.addNextKeyValue("Editore", concessioneDV.getEditore());
|
|
}
|
|
|
|
if (concessioneDV.getResponsabile() != null) {
|
|
customTable.addNextKeyValue("Responsabile", concessioneDV.getResponsabile());
|
|
}
|
|
|
|
if (concessioneDV.getRisorseCorrelate() != null) {
|
|
customTable.addNextKeyValues("Risorse Correlate", concessioneDV.getRisorseCorrelate(), GeoportalDataViewerConstants.NEW_LINE_BR);
|
|
}
|
|
|
|
if (concessioneDV.getTitolari() != null) {
|
|
customTable.addNextKeyValues("Titolari dei dati", concessioneDV.getTitolari(), GeoportalDataViewerConstants.NEW_LINE_BR);
|
|
}
|
|
|
|
if (concessioneDV.getSoggetto() != null) {
|
|
customTable.addNextKeyValues("Soggetti", concessioneDV.getSoggetto(), GeoportalDataViewerConstants.NEW_LINE_BR);
|
|
}
|
|
|
|
if (concessioneDV.getEditore() != null) {
|
|
customTable.addNextKeyValue("Editore", concessioneDV.getEditore());
|
|
}
|
|
|
|
if (concessioneDV.getFontiFinanziamento() != null) {
|
|
customTable.addNextKeyValues("Fonti di Finanziamento", concessioneDV.getFontiFinanziamento(), GeoportalDataViewerConstants.NEW_LINE_BR);
|
|
}
|
|
|
|
if (concessioneDV.getLicenzaID() != null) {
|
|
customTable.addNextKeyValue("ID Licenza", concessioneDV.getLicenzaID());
|
|
}
|
|
|
|
if (concessioneDV.getTitolareLicenza() != null) {
|
|
customTable.addNextKeyValue("Titolare Licenza", concessioneDV.getTitolareLicenza());
|
|
}
|
|
|
|
if (concessioneDV.getTitolareCopyright() != null) {
|
|
customTable.addNextKeyValue("Titolare Copyright", concessioneDV.getTitolareCopyright());
|
|
}
|
|
|
|
shareButton.setType(ButtonType.LINK);
|
|
shareButton.setIcon(IconType.SHARE);
|
|
shareButton.setTitle("Get a link to share with...");
|
|
|
|
shareButton.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
DialogShareableLink dg = new DialogShareableLink(geonaItemRef, null);
|
|
|
|
}
|
|
});
|
|
|
|
viewButton.setType(ButtonType.LINK);
|
|
viewButton.setIcon(IconType.EXPAND);
|
|
viewButton.setTitle("View Details in New Dialog");
|
|
|
|
viewButton.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
|
|
ConcessioneView cv = new ConcessioneView(geonaItemRef, concessioneDV, false, openImageButtonVisible);
|
|
cv.setViewDetailsButtonVisible(false);
|
|
ModalWindow mw = new ModalWindow(concessioneDV.getNome());
|
|
mw.add(cv);
|
|
mw.setCaller(ConcessioneView.this);
|
|
//mw.setWidth(900);
|
|
mw.show();
|
|
|
|
}
|
|
});
|
|
|
|
concessioniPanel.add(customTable);
|
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() {
|
|
|
|
@Override
|
|
public void onSuccess(String result) {
|
|
myLogin = result;
|
|
addCentroidMap();
|
|
addRelazioneDiScavo();
|
|
addPosizionamentoAreaIndagine();
|
|
addPiantaFineScavo();
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
}
|
|
});
|
|
|
|
addUploadedImages();
|
|
|
|
}
|
|
|
|
private void addPosizionamentoAreaIndagine() {
|
|
|
|
LayerConcessioneDV layer = concessioneDV.getPosizionamentoScavo();
|
|
if(layer==null)
|
|
return;
|
|
|
|
if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) {
|
|
posizionamentoAreaIndaginePanel.setVisible(true);
|
|
posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer));
|
|
}else {
|
|
//I need to be authenticated to show the fields according to POLICY
|
|
if(myLogin!=null) {
|
|
posizionamentoAreaIndaginePanel.setVisible(true);
|
|
posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer));
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private void addPiantaFineScavo() {
|
|
|
|
List<LayerConcessioneDV> listLayersDV = concessioneDV.getPianteFineScavo();
|
|
|
|
if(listLayersDV==null)
|
|
return;
|
|
|
|
for (LayerConcessioneDV layer : listLayersDV) {
|
|
|
|
if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) {
|
|
piantaFineScavoPanel.setVisible(true);
|
|
piantaFineScavoPanel.add(new LayerConcessioneView(layer));
|
|
}else {
|
|
//I need to be authenticated to show the fields according to POLICY
|
|
if(myLogin!=null) {
|
|
piantaFineScavoPanel.setVisible(true);
|
|
piantaFineScavoPanel.add(new LayerConcessioneView(layer));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void addRelazioneDiScavo() {
|
|
|
|
RelazioneScavoDV relazioneScavo = concessioneDV.getRelazioneScavo();
|
|
|
|
if(relazioneScavo==null)
|
|
return;
|
|
|
|
if(relazioneScavo.getPolicy()==null || relazioneScavo.getPolicy().equalsIgnoreCase("OPEN")) {
|
|
relazioneScavoPanel.setVisible(true);
|
|
relazioneScavoPanel.add(new RelazioneScavoView(relazioneScavo));
|
|
}else {
|
|
//I need to be authenticated to show the fields according to POLICY
|
|
if(myLogin!=null) {
|
|
relazioneScavoPanel.setVisible(true);
|
|
relazioneScavoPanel.add(new RelazioneScavoView(relazioneScavo));
|
|
}
|
|
}
|
|
}
|
|
|
|
private void addCentroidMap() {
|
|
Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
|
|
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
|
MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON);
|
|
Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat());
|
|
Coordinate transfCoord = MapUtils.transformCoordiante(coord, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
|
//Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord);
|
|
boolean authenticatedUser = myLogin!=null?true:false;
|
|
mapView.addMarker(transfCoord, authenticatedUser);
|
|
mapViewPanel.add(mapView);
|
|
}
|
|
|
|
private void addUploadedImages() {
|
|
List<UploadedImageDV> immagini = concessioneDV.getImmaginiRappresentative();
|
|
if (immagini != null && immagini.size() > 0) {
|
|
imagesPanel.setVisible(true);
|
|
int i = 0;
|
|
for (UploadedImageDV uploadedImageDV : immagini) {
|
|
if (i == 0)
|
|
imagesPanel.add(thumbNails);
|
|
|
|
thumbNails.add(new ThumbnailImageView(uploadedImageDV, viewImageButtonVisible, openImageButtonVisible));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public ConcessioneDV getConcessioneDV() {
|
|
return concessioneDV;
|
|
}
|
|
|
|
protected void setViewDetailsButtonVisible(boolean bool) {
|
|
viewButton.setVisible(bool);
|
|
}
|
|
|
|
}
|