From 294bc2aa66b156f28dd44c708e091620ffcb3b77 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 18 Nov 2020 12:19:29 +0100 Subject: [PATCH] Details for selected product are shown in the right panel --- pom.xml | 36 ++-- .../client/GeoportalDataViewer.java | 23 ++- .../client/ui/DetailsPanel.java | 65 +++++++ .../client/ui/DetailsPanel.ui.xml | 19 ++ .../client/ui/GeonaDataViewMainPanel.java | 182 +++++++++--------- .../client/ui/GeonaDataViewMainPanel.ui.xml | 36 ++-- .../products/concessioni/ConcessioneView.java | 24 ++- .../concessioni/ConcessioneView.ui.xml | 10 +- .../GeoportalDataViewerServiceImpl.java | 19 +- src/main/webapp/GeoportalDataViewer.css | 23 +++ .../geoportaldataviewer/TestShortener.java | 32 +-- 11 files changed, 314 insertions(+), 155 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.ui.xml diff --git a/pom.xml b/pom.xml index 79b5e0e..71917fc 100644 --- a/pom.xml +++ b/pom.xml @@ -109,30 +109,30 @@ geo-utility [1.0.0,2.0.0-SNAPSHOT) - - org.gcube.common - authorization-client - [2.0.0, 3.0.0-SNAPSHOT) - provided - - - org.gcube.resources.discovery - ic-client - [1.0.0, 2.0.0-SNAPSHOT) - provided - + + + + + + + + + + + + org.gcube.core common-scope-maps [1.1.0, 2.0.0-SNAPSHOT) compile - - org.gcube.portlets.user - gcube-url-shortener - [1.0.0,2.0.0-SNAPSHOT) - compile - + + + + + + org.gcube.common.portal portal-manager diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index fbea59c..c86f2a4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -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() { @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()); } }); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java new file mode 100644 index 0000000..6a95226 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java @@ -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 { + } + + + 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); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.ui.xml new file mode 100644 index 0000000..3bdc067 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.ui.xml @@ -0,0 +1,19 @@ + + + + .important { + font-weight: bold; + } + .to-align-right{ + position: absolute; + top: 10px; + right: 10px; + } + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index 7a03dd1..70f45c1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -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 { } +// @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 listTabs = new ArrayList(); @@ -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); + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index 209440c..184b7e1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -1,26 +1,32 @@ + xmlns:b="urn:import:com.github.gwtbootstrap.client.ui" + xmlns:c="urn:import:org.gcube.portlets.user.geoportaldataviewer.client.ui"> .margin-right-10 { margin-right: 10px; } - - - - - Data Point - Selection - Data Box - Selection - - - - - + + + + + + Data Point + Selection + Data Box + Selection + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index b117a0f..4693c3e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -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); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.ui.xml index f58e7f7..60164f0 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.ui.xml @@ -18,10 +18,14 @@ } - - + + + + + Share + Open + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index 71d8e79..f812f77 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -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; diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index ea01540..3ba1ae8 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -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; } \ No newline at end of file diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/TestShortener.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/TestShortener.java index 638e9a8..a13f365 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/TestShortener.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/TestShortener.java @@ -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(); }