From 84fcc7dbb37b5d72222aa52254759acafd31938a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 14 Nov 2022 14:12:50 +0100 Subject: [PATCH] Added Application Notifier. Improved Modal Expand --- .../client/GeoportalDataViewer.java | 6 ++-- .../client/ui/cms/project/ProjectUtil.java | 19 ++++++++++ .../client/ui/cms/project/ProjectViewer.java | 4 ++- .../relation/TimelineManagerStatus.java | 35 +++++++++++++++++-- src/main/webapp/GeoportalDataViewer.css | 6 ++++ src/main/webapp/GeoportalDataViewer.html | 1 + .../GeoPortalDataViewerAppPortlet_view.jsp | 2 +- 7 files changed, 66 insertions(+), 7 deletions(-) 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 f307efe..c8f3d3e 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 @@ -85,6 +85,8 @@ import ol.layer.Image; public class GeoportalDataViewer implements EntryPoint { public static final String DIV_TIMELINE_DATA = "timeline-data"; + + public static final String APP_NOTIFIER = "app-notifier"; /** The Constant APP_DIV. */ public final static String APP_DIV = "geoportal-data-viewer"; @@ -395,7 +397,7 @@ public class GeoportalDataViewer implements EntryPoint { if (showDetailsEvent.isLoadTimelineRelationships() && relationships != null && relationships.size() > 0) { GWT.log("LoadTimelineRelationships is true and the project has Relationships"); - timelineMS.showTimelineProjectRelations(result.getTheProjectDV()); + timelineMS.showTimelineProjectRelations(result.getTheProjectDV(), false); } } }); @@ -533,7 +535,7 @@ public class GeoportalDataViewer implements EntryPoint { switch (timelineProjectRelationsEvent.getEventType()) { case SHOW: { - timelineMS.showTimelineProjectRelations(timelineProjectRelationsEvent.getTheProjectDV()); + timelineMS.showTimelineProjectRelations(timelineProjectRelationsEvent.getTheProjectDV(), true); break; } case HIDE: diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectUtil.java index 6453f5b..ba7d1c7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectUtil.java @@ -24,6 +24,25 @@ public class ProjectUtil { return htmlCode; } + public static String toHMLCode(boolean showkey, T document, String projectID) { + String htmlCode = ""; + + if (document == null) + return htmlCode; + + Entry firstEntrySet = document.getFirstEntryOfMap(); + if (firstEntrySet != null) { + htmlCode += showkey ? firstEntrySet.getKey() + ": " + firstEntrySet.getValue() + "" + : firstEntrySet.getValue(); + } + + if (projectID != null) { + htmlCode += " (id: " + projectID + ")"; + } + + return htmlCode; + } + public static String toHMLCode(T document) { String htmlCode = ""; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.java index 7a507af..4cb723f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.java @@ -149,7 +149,9 @@ public class ProjectViewer extends Composite { cv.setAddLayersToMapVisible(false); int width = Window.getClientWidth() * 75 / 100; int height = Window.getClientHeight() * 70 / 100; - ModalWindow mw = new ModalWindow(theTitle, width, height); + + String modalTitle = ProjectUtil.toHMLCode(false, theProjectView.getTheProjectDV().getTheDocument(), theProjectView.getTheProjectDV().getId()); + ModalWindow mw = new ModalWindow(modalTitle, width, height); mw.add(cv); mw.setCaller(ProjectViewer.this); // mw.setWidth(900); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/relation/TimelineManagerStatus.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/relation/TimelineManagerStatus.java index c311dc7..ec631c1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/relation/TimelineManagerStatus.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/relation/TimelineManagerStatus.java @@ -3,9 +3,13 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relati import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer; +import com.github.gwtbootstrap.client.ui.Popover; +import com.github.gwtbootstrap.client.ui.constants.Placement; import com.google.gwt.core.client.GWT; import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.Widget; public class TimelineManagerStatus { @@ -43,23 +47,48 @@ public class TimelineManagerStatus { } - public void showTimelineProjectRelations(ProjectDV theProject) { + public void showTimelineProjectRelations(ProjectDV theProject, boolean showNotify) { GWT.log("Showing project relations for: " + theProject); TimelineStatus timelineStatus = getTimelineOf(theProject); if (timelineStatus.isStatusChanged()) { RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).clear(); RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).add(timelineStatus.getTimelineRP()); + + } else if (showNotify) { + setupPopover(RootPanel.get(GeoportalDataViewer.APP_NOTIFIER), + "Timeline from the selected project is already displayed", "Timeline displayed"); } - + RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(true); timelineStatus.getTimelineRP().setTimelineContainerVisible(true); } + protected void setupPopover(final Widget w, String message, String heading) { + + final Popover popover = new Popover(); + popover.setWidget(w); + popover.setText(message); + if (heading != null) + popover.setHeading(heading); + popover.setPlacement(Placement.BOTTOM); + popover.reconfigure(); + popover.show(); + Timer timer = new Timer() { + + @Override + public void run() { + popover.hide(); + } + }; + + timer.schedule(3000); + } + public void hideTimelineProjectRelations() { GWT.log("hideTimelineProjectRelations"); RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(false); - //RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).clear(); + // RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).clear(); } public class TimelineStatus { diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index bd896cf..a1c2d9b 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -619,6 +619,12 @@ body { max-height: 400px; } +.app-notifier { + top: 0; + width: 100%; + text-align: center; +} + /***** RESPONSIVE diff --git a/src/main/webapp/GeoportalDataViewer.html b/src/main/webapp/GeoportalDataViewer.html index cdc31da..0b2010b 100644 --- a/src/main/webapp/GeoportalDataViewer.html +++ b/src/main/webapp/GeoportalDataViewer.html @@ -137,6 +137,7 @@ Your web browser must have JavaScript enabled in order for this application to display correctly. +
diff --git a/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp b/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp index 481e08b..e442d80 100644 --- a/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp @@ -110,7 +110,7 @@ }; - +