2022-10-11 15:00:39 +02:00
|
|
|
package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project;
|
|
|
|
|
2022-10-18 17:32:12 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
|
2022-10-11 15:00:39 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
2022-10-17 16:52:22 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow;
|
2022-10-11 15:00:39 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
|
|
|
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
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.Window;
|
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
import com.google.gwt.user.client.ui.Composite;
|
2022-10-24 12:23:52 +02:00
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
2022-10-11 15:00:39 +02:00
|
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
|
|
|
import ol.Coordinate;
|
|
|
|
|
|
|
|
public class ProjectViewer extends Composite {
|
|
|
|
|
|
|
|
private static ProjectViewerUiBinder uiBinder = GWT.create(ProjectViewerUiBinder.class);
|
|
|
|
|
|
|
|
interface ProjectViewerUiBinder extends UiBinder<Widget, ProjectViewer> {
|
|
|
|
}
|
|
|
|
|
|
|
|
@UiField
|
2022-10-24 12:23:52 +02:00
|
|
|
HTMLPanel headerPanel;
|
2022-10-11 15:00:39 +02:00
|
|
|
|
|
|
|
@UiField
|
|
|
|
HTMLPanel pageViewDetails;
|
|
|
|
|
2022-10-17 16:52:22 +02:00
|
|
|
@UiField
|
|
|
|
HTMLPanel centroidPanel;
|
|
|
|
|
2022-10-11 15:00:39 +02:00
|
|
|
@UiField
|
|
|
|
Button shareButton;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
Button expandButton;
|
2022-10-18 17:32:12 +02:00
|
|
|
|
|
|
|
@UiField
|
|
|
|
Button relationshipsButton;
|
2022-10-11 15:00:39 +02:00
|
|
|
|
2022-10-17 16:52:22 +02:00
|
|
|
private ProjectView theProjectView;
|
2022-10-11 15:00:39 +02:00
|
|
|
|
|
|
|
private CustomFlexTable customTable = new CustomFlexTable();
|
|
|
|
|
2022-10-18 17:32:12 +02:00
|
|
|
private GeoportalItemReferences geoportalItemReferences;
|
2022-10-11 15:00:39 +02:00
|
|
|
|
|
|
|
private String myLogin;
|
|
|
|
|
|
|
|
private boolean viewImageButtonVisible = true;
|
|
|
|
|
|
|
|
private boolean openImageButtonVisible = true;
|
|
|
|
|
|
|
|
private ProjectViewer() {
|
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
pageViewDetails.getElement().setId("page-view-details");
|
|
|
|
}
|
|
|
|
|
2022-10-18 17:32:12 +02:00
|
|
|
public ProjectViewer(GeoportalItemReferences geoportalItemRefs, ProjectView projectView) {
|
|
|
|
this(geoportalItemRefs, projectView, true, true);
|
2022-10-11 15:00:39 +02:00
|
|
|
}
|
|
|
|
|
2022-10-18 17:32:12 +02:00
|
|
|
public ProjectViewer(GeoportalItemReferences geoportalItemRefs, final ProjectView projectView, boolean viewImageButtonVisible,
|
2022-10-11 15:00:39 +02:00
|
|
|
boolean openImageButtonVisible) {
|
|
|
|
this();
|
|
|
|
GWT.log("Rendering " + projectView.getTheProjectDV().getId());
|
2022-10-17 16:52:22 +02:00
|
|
|
this.theProjectView = projectView;
|
2022-10-18 17:32:12 +02:00
|
|
|
this.geoportalItemReferences = geoportalItemRefs;
|
2022-10-11 15:00:39 +02:00
|
|
|
this.viewImageButtonVisible = viewImageButtonVisible;
|
|
|
|
this.openImageButtonVisible = openImageButtonVisible;
|
|
|
|
|
2022-10-17 16:52:22 +02:00
|
|
|
final String theTitle = projectView.getTheProjectDV().getProfileName() != null
|
|
|
|
? projectView.getTheProjectDV().getProfileName()
|
|
|
|
: projectView.getTheProjectDV().getId();
|
|
|
|
|
2022-10-24 12:23:52 +02:00
|
|
|
headerPanel.add(new HTML("Project: " + theTitle));
|
2022-10-17 16:52:22 +02:00
|
|
|
|
2022-10-11 15:00:39 +02:00
|
|
|
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) {
|
2022-10-18 17:32:12 +02:00
|
|
|
DialogShareableLink dg = new DialogShareableLink(geoportalItemReferences, null);
|
2022-10-11 15:00:39 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
expandButton.setType(ButtonType.LINK);
|
|
|
|
expandButton.setIcon(IconType.EXPAND);
|
|
|
|
expandButton.setTitle("Show this view in new Window");
|
|
|
|
|
|
|
|
expandButton.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
2022-10-17 16:52:22 +02:00
|
|
|
|
2022-10-18 17:32:12 +02:00
|
|
|
ProjectViewer cv = new ProjectViewer(geoportalItemReferences, theProjectView, false, openImageButtonVisible);
|
2022-10-11 15:00:39 +02:00
|
|
|
cv.setExpandViewButtonVisible(false);
|
|
|
|
int width = Window.getClientWidth() * 75 / 100;
|
|
|
|
int height = Window.getClientHeight() * 70 / 100;
|
2022-10-17 16:52:22 +02:00
|
|
|
ModalWindow mw = new ModalWindow(theTitle, width, height);
|
2022-10-11 15:00:39 +02:00
|
|
|
mw.add(cv);
|
|
|
|
mw.setCaller(ProjectViewer.this);
|
|
|
|
// mw.setWidth(900);
|
|
|
|
mw.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2022-10-18 17:32:12 +02:00
|
|
|
|
|
|
|
relationshipsButton.setType(ButtonType.LINK);
|
|
|
|
relationshipsButton.setIcon(IconType.LINK);
|
|
|
|
relationshipsButton.setTitle("Show Relationships of this Project");
|
|
|
|
|
|
|
|
List<RelationshipDV> relationships = projectView.getTheProjectDV().getRelationships();
|
|
|
|
if(relationships!=null && relationships.size()>0) {
|
|
|
|
relationshipsButton.setVisible(true);
|
|
|
|
}else
|
|
|
|
relationshipsButton.setVisible(false);
|
|
|
|
|
2022-10-11 15:00:39 +02:00
|
|
|
|
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(String result) {
|
|
|
|
myLogin = result;
|
|
|
|
addCentroidMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
}
|
|
|
|
});
|
2022-10-17 16:52:22 +02:00
|
|
|
|
2022-10-11 15:00:39 +02:00
|
|
|
for (SectionView sectionView : projectView.getListSections()) {
|
2022-10-17 16:52:22 +02:00
|
|
|
|
|
|
|
if (!sectionView.isEmpty()) {
|
2022-10-14 15:31:32 +02:00
|
|
|
SectionViewer sectionViewer = new SectionViewer(sectionView);
|
|
|
|
pageViewDetails.add(sectionViewer);
|
|
|
|
}
|
2022-10-11 15:00:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addCentroidMap() {
|
|
|
|
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
|
|
|
|
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
|
|
|
|
MapView mapView = new MapView(transformedCenterCoordinate,
|
|
|
|
GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px");
|
|
|
|
|
2022-10-17 16:52:22 +02:00
|
|
|
if (theProjectView != null && theProjectView.getCentroidLat() != null
|
|
|
|
&& theProjectView.getCentroidLong() != null) {
|
|
|
|
Coordinate coord = new Coordinate(theProjectView.getCentroidLong(), theProjectView.getCentroidLat());
|
|
|
|
Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
// Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord);
|
|
|
|
boolean authenticatedUser = myLogin != null ? true : false;
|
|
|
|
mapView.addMarker(transfCoord, authenticatedUser);
|
|
|
|
centroidPanel.add(mapView);
|
|
|
|
} else if (theProjectView != null) {
|
|
|
|
GeoportalDataViewerConstants
|
|
|
|
.printJs("I cannot add centroid as maker one or both coordinates are null. Lat: "
|
|
|
|
+ theProjectView.getCentroidLong() + ", Long:" + theProjectView.getCentroidLat());
|
|
|
|
}
|
2022-10-11 15:00:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ProjectView getProjectView() {
|
2022-10-17 16:52:22 +02:00
|
|
|
return theProjectView;
|
2022-10-11 15:00:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void setExpandViewButtonVisible(boolean bool) {
|
|
|
|
expandButton.setVisible(bool);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|