Details for selected product are shown in the right panel

This commit is contained in:
Francesco Mangiacrapa 2020-11-18 12:19:29 +01:00
parent eb8ea01bfb
commit 294bc2aa66
11 changed files with 314 additions and 155 deletions

36
pom.xml
View File

@ -109,30 +109,30 @@
<artifactId>geo-utility</artifactId>
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.common</groupId> -->
<!-- <artifactId>authorization-client</artifactId> -->
<!-- <version>[2.0.0, 3.0.0-SNAPSHOT)</version> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.resources.discovery</groupId> -->
<!-- <artifactId>ic-client</artifactId> -->
<!-- <version>[1.0.0, 2.0.0-SNAPSHOT)</version> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<version>[1.1.0, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-url-shortener</artifactId>
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.portlets.user</groupId> -->
<!-- <artifactId>gcube-url-shortener</artifactId> -->
<!-- <version>[1.0.0,2.0.0-SNAPSHOT)</version> -->
<!-- <scope>compile</scope> -->
<!-- </dependency> -->
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>

View File

@ -10,8 +10,6 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
@ -19,7 +17,6 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
/**
@ -183,29 +180,31 @@ public class GeoportalDataViewer implements EntryPoint {
String tabName = showDetailsEvent.getItemName()==null?"Dettagli Prodotto":showDetailsEvent.getItemName();
boolean found = mainPanel.selectTabForProductId(id);
// boolean found = mainPanel.selectTabForProductId(id);
boolean found = false;
GWT.log("Product with id: "+id+" found? "+found);
if(!found) {
if(showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
final Tab theTab = mainPanel.addAsTab(tabName, true, null);
//final Tab theTab = mainPanel.addAsTab(tabName, true, null);
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(id, new AsyncCallback<ConcessioneDV>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
theTab.clear();
theTab.setIcon(IconType.WARNING_SIGN);
theTab.add(new HTML(caught.getMessage()));
// theTab.clear();
// theTab.setIcon(IconType.WARNING_SIGN);
// theTab.add(new HTML(caught.getMessage()));
}
@Override
public void onSuccess(ConcessioneDV result) {
GWT.log("Showing: "+result);
mainPanel.renderProductIntoTab(theTab, result, showDetailsEvent.getGeonaItemRef());
public void onSuccess(ConcessioneDV concessioneDV) {
GWT.log("Showing: "+concessioneDV);
//mainPanel.renderProductIntoTab(theTab, concessioneDV, showDetailsEvent.getGeonaItemRef());
mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef());
}
});
}

View File

@ -0,0 +1,65 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni.ConcessioneView;
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.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.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class DetailsPanel extends Composite {
private static DetailsPanelUiBinder uiBinder = GWT.create(DetailsPanelUiBinder.class);
@UiField
Button closeButton;
@UiField
HTMLPanel datailsContainerPanel;
@UiField
HTMLPanel detailsHTMLPanel;
interface DetailsPanelUiBinder extends UiBinder<Widget, DetailsPanel> {
}
public DetailsPanel() {
initWidget(uiBinder.createAndBindUi(this));
closeButton.setType(ButtonType.LINK);
closeButton.setIcon(IconType.REMOVE_SIGN);
closeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
showPanelDetails(false);
}
});
}
public void showDetailsFor(ConcessioneDV cdv, GeoNaItemRef geonaItemRef) {
datailsContainerPanel.clear();
if(detailsHTMLPanel.getParent()!=null)
detailsHTMLPanel.getParent().getElement().setScrollTop(0);
datailsContainerPanel.add(new ConcessioneView(geonaItemRef, cdv));
showPanelDetails(true);
}
private void showPanelDetails(boolean visible) {
detailsHTMLPanel.setVisible(visible);
}
}

View File

@ -0,0 +1,19 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.to-align-right{
position: absolute;
top: 10px;
right: 10px;
}
</ui:style>
<g:HTMLPanel ui:field="detailsHTMLPanel" visible="false">
<b:Button ui:field="closeButton" addStyleNames="{style.to-align-right}"></b:Button>
<g:HTMLPanel ui:field="datailsContainerPanel"></g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -6,25 +6,21 @@ import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni.ConcessioneView;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
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.TabPanel;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
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 {
@ -34,8 +30,11 @@ public class GeonaDataViewMainPanel extends Composite {
interface GeonaDataViewMainPanelUiBinder extends UiBinder<Widget, GeonaDataViewMainPanel> {
}
// @UiField
// Tab mapTabPanel;
@UiField
Tab mapTabPanel;
HTMLPanel mainTabPanel;
@UiField
NavLink dataPointSelection;
@ -46,8 +45,11 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
Button removeQuery;
// @UiField
// TabPanel mainTabPanel;
@UiField
TabPanel mainTabPanel;
DetailsPanel detailsPanel;
private List<Tab> listTabs = new ArrayList<Tab>();
@ -63,7 +65,8 @@ public class GeonaDataViewMainPanel extends Composite {
initWidget(uiBinder.createAndBindUi(this));
this.eventBus = eventBus;
mapPanel = new MapPanel(mapHeight+"px");
mapTabPanel.add(mapPanel);
detailsPanel.setHeight(mapHeight+"px");
mainTabPanel.add(mapPanel);
bindHandlers();
dataPointSelection.setIcon(IconType.SCREENSHOT);
dataBoxSelection.setIcon(IconType.BOOKMARK);
@ -126,90 +129,95 @@ public class GeonaDataViewMainPanel extends Composite {
}
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 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;
}
// 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);
}
// /**
// * 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++;
}
// 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);
}
}

View File

@ -1,26 +1,32 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:c="urn:import:org.gcube.portlets.user.geoportaldataviewer.client.ui">
<ui:style>
.margin-right-10 {
margin-right: 10px;
}
</ui:style>
<g:HTMLPanel ui:field="mainHTMLPanel">
<b:TabPanel ui:field="mainTabPanel" tabPosition="top">
<b:Tab ui:field="mapTabPanel" active="true" heading="Map">
<b:DropdownButton type="LINK" text="Query">
<!-- <b:ButtonGroup toggle="checkbox" ui:field="buttonGroup"> -->
<b:NavLink ui:field="dataPointSelection"
addStyleNames="{style.margin-right-10}">Data Point
Selection</b:NavLink>
<b:NavLink ui:field="dataBoxSelection" visible="false">Data Box
Selection</b:NavLink>
<!-- </b:ButtonGroup> -->
</b:DropdownButton>
<b:Button type="LINK" ui:field="removeQuery" text="Remove Query" visible="false"></b:Button>
</b:Tab>
</b:TabPanel>
<!-- <b:TabPanel ui:field="mainTabPanel" tabPosition="top"> -->
<!-- <b:Tab ui:field="mapTabPanel" active="true" heading="Map"> -->
<g:HTMLPanel ui:field="mainTabPanel">
<b:DropdownButton type="LINK" text="Query">
<!-- <b:ButtonGroup toggle="checkbox" ui:field="buttonGroup"> -->
<b:NavLink ui:field="dataPointSelection"
addStyleNames="{style.margin-right-10}">Data Point
Selection</b:NavLink>
<b:NavLink ui:field="dataBoxSelection" visible="false">Data Box
Selection</b:NavLink>
<!-- </b:ButtonGroup> -->
</b:DropdownButton>
<b:Button type="LINK" ui:field="removeQuery"
text="Remove Query" visible="false"></b:Button>
</g:HTMLPanel>
<!-- </b:Tab> -->
<!-- </b:TabPanel> -->
<c:DetailsPanel ui:field="detailsPanel"
addStyleNames="details-panel"></c:DetailsPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -16,6 +16,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.Relazio
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.PageHeader;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.Thumbnails;
@ -69,10 +70,14 @@ public class ConcessioneView extends Composite {
@UiField
HTMLPanel piantaFineScavoPanel;
@UiField
HTMLPanel sharePanel;
// @UiField
// HTMLPanel sharePanel;
@UiField
Button shareButton;
@UiField
Button openButton;
private ConcessioneDV concessioneDV;
@ -159,7 +164,6 @@ public class ConcessioneView extends Composite {
customTable.addNextKeyValue("Titolare Copyright", concessioneDV.getTitolareCopyright());
}
shareButton = new Button("Share");
shareButton.setType(ButtonType.LINK);
shareButton.setIcon(IconType.SHARE);
@ -172,7 +176,19 @@ public class ConcessioneView extends Composite {
}
});
sharePanel.add(shareButton);
openButton.setType(ButtonType.LINK);
openButton.setIcon(IconType.EXPAND);
openButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
}
});
// sharePanel.add(shareButton);
concessioniPanel.add(customTable);

View File

@ -18,10 +18,14 @@
}
</ui:style>
<g:HTMLPanel ui:field="pageViewDetails">
<g:HTMLPanel ui:field="sharePanel"
addStyleNames="{style.align-to-right}">
</g:HTMLPanel>
<!-- <g:HTMLPanel ui:field="sharePanel" -->
<!-- addStyleNames="{style.align-to-right}"> -->
<!-- </g:HTMLPanel> -->
<b:PageHeader ui:field="titolo"></b:PageHeader>
<g:HorizontalPanel>
<b:Button ui:field="shareButton">Share</b:Button>
<b:Button ui:field="openButton">Open</b:Button>
</g:HorizontalPanel>
<b:Paragraph ui:field="introduzione"></b:Paragraph>
<g:HorizontalPanel>
<g:HTMLPanel ui:field="concessioniPanel">

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataviewer.server;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@ -13,7 +14,6 @@ import org.gcube.application.geoportal.managers.ManagerFactory;
import org.gcube.application.geoportal.model.Record;
import org.gcube.application.geoportal.model.concessioni.Concessione;
import org.gcube.application.geoportal.model.content.UploadedImage;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
@ -441,7 +441,22 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (shortener != null && shortener.isAvailable()) {
String toShort = longUrl;
return shortener.shorten(toShort);
String[] splitted = toShort.split("\\?");
LOG.debug("Splitted long URL is: "+Arrays.asList(splitted));
String link = toShort;
if (splitted.length > 1) {
LOG.debug("Query string detected, encoding it...");
String encodedQuery = splitted[1];
try {
encodedQuery = URLEncoder.encode(splitted[1], "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
LOG.debug("encodedQuery is: "+encodedQuery);
link = String.format("%s?%s", splitted[0], encodedQuery);
}
return shortener.shorten(link);
}
return longUrl;

View File

@ -1,5 +1,10 @@
/** Add css rules here for your application. */
/** Most GWT widgets already have a style name defined */
body {
padding-top: 0px !important;
}
.gwt-DialogBox {
width: 400px;
}
@ -43,6 +48,7 @@
width: 0;
position: absolute;
pointer-events: none;
overflow: hidden;
}
.ol-popup:after {
@ -155,4 +161,21 @@
font-size: 14px !important;
padding-top: 4px !important;
margin-bottom: 5px;
}
.details-panel {
position: absolute;
top: 0;
right: 0px;
background: #FFF;
width: 725px;
margin-top: 30px;
padding-left: 5px;
overflow-y: auto;
transition: width 0.2s;
}
.overlay {
z-index: 1000;
opacity: 0.9;
}

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.urlshortener.UrlShortener;
@ -10,22 +11,25 @@ public class TestShortener {
public static void main(String[] args) {
try {
String toShort = "https://next.d4science.org/group/nextnext/geona-data-viewer?gid=20&git=concessione";
String toShort = "https://next.d4science.org/group/nextnext/geona-data-viewer";
String[] splitted = toShort.split("\\?");
System.out.println("Splitted is: "+Arrays.asList(splitted));
String link = toShort;
// if (splitted.length > 1) {
// String encodedQuery = splitted[1];
// try {
// encodedQuery = URLEncoder.encode(splitted[1], "UTF-8");
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
//
// }
// link = String.format("%s?%s", splitted[0], encodedQuery);
// }
// ScopeProvider.instance.set("/gcube/devNext/NextNext");
// UrlShortener shortener = new UrlShortener();
// System.out.println(shortener.shorten(link));
if (splitted.length > 1) {
String encodedQuery = splitted[1];
try {
encodedQuery = URLEncoder.encode(splitted[1], "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
System.out.println("encodedQuery is: "+encodedQuery);
link = String.format("%s?%s", splitted[0], encodedQuery);
}
ScopeProvider.instance.set("/gcube/devNext/NextNext");
UrlShortener shortener = new UrlShortener();
System.out.println(shortener.shorten(link));
} catch (Exception e) {
e.printStackTrace();
}