220 lines
6.9 KiB
Java
220 lines
6.9 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.ui.images.ImageView;
|
||
|
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.products.ConcessioneDV;
|
||
|
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.Label;
|
||
|
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.LabelType;
|
||
|
import com.google.gwt.core.client.GWT;
|
||
|
import com.google.gwt.dom.client.Style.Unit;
|
||
|
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.FlowPanel;
|
||
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||
|
import com.google.gwt.user.client.ui.Widget;
|
||
|
|
||
|
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;
|
||
|
|
||
|
private ConcessioneDV concessioneDV;
|
||
|
|
||
|
private Thumbnails thumbNails = new Thumbnails();
|
||
|
|
||
|
private CustomFlexTable customTable = new CustomFlexTable();
|
||
|
|
||
|
public ConcessioneView() {
|
||
|
initWidget(uiBinder.createAndBindUi(this));
|
||
|
pageViewDetails.getElement().setId("page-view-details");
|
||
|
}
|
||
|
|
||
|
public ConcessioneView(ConcessioneDV concessioneDV) {
|
||
|
this();
|
||
|
this.concessioneDV = concessioneDV;
|
||
|
|
||
|
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());
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
concessioniPanel.add(customTable);
|
||
|
|
||
|
//concessioniPanel.add(new RecordView(concessioneDV));
|
||
|
addCentroidMap();
|
||
|
addRelazioneDiScavo();
|
||
|
addImages();
|
||
|
}
|
||
|
|
||
|
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
|
||
|
GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() {
|
||
|
|
||
|
@Override
|
||
|
public void onSuccess(String result) {
|
||
|
|
||
|
//Authenticated user
|
||
|
if(result!=null) {
|
||
|
relazioneScavoPanel.setVisible(true);
|
||
|
relazioneScavoPanel.add(new RelazioneScavoView(relazioneScavo));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onFailure(Throwable caught) {
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void addCentroidMap() {
|
||
|
MapView mapView = new MapView(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat(), true);
|
||
|
mapViewPanel.add(mapView);
|
||
|
}
|
||
|
|
||
|
private void addImages() {
|
||
|
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 ImageView(uploadedImageDV));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public void addLabel(FlowPanel w, String labelValue, LabelType type) {
|
||
|
Label label = new Label(labelValue);
|
||
|
label.setType(type);
|
||
|
label.getElement().getStyle().setMarginRight(5, Unit.PX);
|
||
|
w.add(label);
|
||
|
}
|
||
|
|
||
|
public void addLabel(FlowPanel w, String labelValue) {
|
||
|
com.google.gwt.user.client.ui.Label label = new com.google.gwt.user.client.ui.Label(labelValue);
|
||
|
label.getElement().getStyle().setMarginRight(5, Unit.PX);
|
||
|
w.add(label);
|
||
|
}
|
||
|
|
||
|
public ConcessioneDV getConcessioneDV() {
|
||
|
return concessioneDV;
|
||
|
}
|
||
|
|
||
|
}
|