From 2c55cfe4b214031206b795c8fc7861029a8b4b39 Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Mon, 29 Aug 2016 16:08:08 +0000 Subject: [PATCH] Some changes: added bootstrap popovers to show statistics' information, the handler to show statistics' related feeds works also on profile pages now (only the owner can view his feeds), underline effect added to hint to the user the view related feeds functionality. git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/user-statistics@131035 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/StatisticsPanel.java | 236 +++++++++++------- ...ShowFeedsRelatedToUserStatisticsEvent.java | 9 +- .../client/ui/CommentsAndLikesWidget.java | 38 +-- .../client/ui/StatisticWidget.java | 26 +- .../client/ui/StatisticWidget.ui.xml | 6 +- src/main/webapp/Statistics.css | 5 + 6 files changed, 206 insertions(+), 114 deletions(-) diff --git a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/StatisticsPanel.java b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/StatisticsPanel.java index dac7058..202bbb7 100644 --- a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/StatisticsPanel.java +++ b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/StatisticsPanel.java @@ -73,10 +73,30 @@ public class StatisticsPanel extends Composite { * Labels */ private final static String POSTS_LABEL = "Posts"; - private final static String LIKES_COMMENTS_MADE_LABEL = "Likes & Replies"; - private final static String LIKES_COMMENTS_GOT_LABEL = "Got"; + private final static String LIKES_COMMENTS_MADE_LABEL = "Yours"; + private final static String LIKES_COMMENTS_GOT_LABEL = "Others"; private final static String STORAGE_LABEL = "Space Used"; private final static String PROFILE_STRENGTH_LABEL = "Profile Strength"; + private final static String TOOLTIP_POSTS_ROOT_PROFILE = "Posts done during the last year"; + private final static String TOOLTIP_POSTS_VRE = "Posts done in the last year in this VRE"; + private final static String TOOLTIP_FAVORITES_REPLIES_ROOT_PROFILE = "Likes and post replies done during the last year"; + private final static String TOOLTIP_FAVORITES_REPLIES_POSTS_VRE = "Likes and post replies done during the last year in this VRE"; + private final static String TOOLTIP_GOT_ROOT_PROFILE = "Likes and post replies got during the last year"; + private final static String TOOLTIP_GOT_VRE = "Likes and post replies got during the last year in this VRE"; + private final static String TOOLTIP_INFRASTRUCTURE_SPACE = "Total amount of space used in the infrastructure"; + private final static String TOOLTIP_PROFILE_STRENGHT = "Your profile strength"; + + /** + * Specific tooltips + */ + private final static String TOOLTIP_LIKES_GOT = "Likes got during the last year"; + private final static String TOOLTIP_LIKES_GOT_VRE = "Likes got during the last year in this VRE"; + private final static String TOOLTIP_LIKES_DONE = "Likes done during the last year"; + private final static String TOOLTIP_LIKES_DONE_VRE = "Likes done during the last year in this VRE"; + private final static String TOOLTIP_REPLIES_DONE = "Post replies done during the last year"; + private final static String TOOLTIP_REPLIES_DONE_VRE = "Post replies done during the last year in this VRE"; + private final static String TOOLTIP_REPLIES_GOT = "Post replies got during the last year"; + private final static String TOOLTIP_REPLIES_GOT_VRE = "Post replies got during the last year in this VRE."; /** * improve profile hints @@ -125,7 +145,7 @@ public class StatisticsPanel extends Composite { /** * Since the number of likes/comments got can be manipulated, we need a class reference */ - private CommentsAndLikesWidget content; + private CommentsAndLikesWidget contentLikesAndCommentsGot; /** * Number of written posts @@ -152,6 +172,11 @@ public class StatisticsPanel extends Composite { */ private final HandlerManager eventBus = new HandlerManager(null); + /** + * Saved current user information bean + */ + UserInformation informationBeanRetrieved; + public StatisticsPanel() { //init this object @@ -196,11 +221,14 @@ public class StatisticsPanel extends Composite { // first of all check if the statistics can be shown to other people if(userid != null && !userid.equals(information.getAslSessionUsername()) && !information.isProfileShowable()){ - mainPanel.add(new HTML("Sorry but the user set his Statistics to private")); + mainPanel.add(new HTML("Sorry but the user set his/her statistics to private")); return; } + // save it + informationBeanRetrieved = information; + // is a user profile page? or a vre/home one (this portlet can be also deployed in a vre) final boolean isProfilePage = isProfilePage(); @@ -253,9 +281,9 @@ public class StatisticsPanel extends Composite { feeds.setHeader(POSTS_LABEL); if(isRoot || isProfilePage) - feeds.setToolTip("Posts during the last year"); + feeds.setToolTip(TOOLTIP_POSTS_ROOT_PROFILE); else - feeds.setToolTip("Posts during the last year in this VRE"); + feeds.setToolTip(TOOLTIP_POSTS_VRE); // add loading image that will be replaced by the incoming values @@ -271,9 +299,9 @@ public class StatisticsPanel extends Composite { likesAndCommentsMade.setHeader(LIKES_COMMENTS_MADE_LABEL); if(isRoot || isProfilePage) - likesAndCommentsMade.setToolTip("Likes and post replies made during the last year"); + likesAndCommentsMade.setToolTip(TOOLTIP_FAVORITES_REPLIES_ROOT_PROFILE); else - likesAndCommentsMade.setToolTip("Likes and post replies made during the last year in this VRE"); + likesAndCommentsMade.setToolTip(TOOLTIP_FAVORITES_REPLIES_POSTS_VRE); // add loading image that will be replaced by the incoming values Image commentsLikesMadeLoader = new Image(imagePath); @@ -288,9 +316,9 @@ public class StatisticsPanel extends Composite { likesAndCommentsGot.setHeader(LIKES_COMMENTS_GOT_LABEL); if(isRoot || isProfilePage) - likesAndCommentsGot.setToolTip("Likes and post replies got during the last year"); + likesAndCommentsGot.setToolTip(TOOLTIP_GOT_ROOT_PROFILE); else - likesAndCommentsGot.setToolTip("Likes and post replies got during the last year in this VRE"); + likesAndCommentsGot.setToolTip(TOOLTIP_GOT_VRE); // add loading image that will be replaced by the incoming values Image commentsLikesLoader = new Image(imagePath); @@ -307,7 +335,7 @@ public class StatisticsPanel extends Composite { if(isRoot || isProfilePage){ storage.setHeader(STORAGE_LABEL); - storage.setToolTip("Total amount of space used in the infrastructure"); + storage.setToolTip(TOOLTIP_INFRASTRUCTURE_SPACE); // add loading image that will be replaced by the incoming values Image totalSpaceLoader = new Image(imagePath); @@ -317,7 +345,7 @@ public class StatisticsPanel extends Composite { mainPanel.add(storage); profileStrength.setHeader(PROFILE_STRENGTH_LABEL); - profileStrength.setToolTip("Profile strength"); + profileStrength.setToolTip(TOOLTIP_PROFILE_STRENGHT); // add loading image that will be replaced by the incoming values Image profileStrengthLoader = new Image(imagePath); @@ -441,34 +469,36 @@ public class StatisticsPanel extends Composite { // update feeds number feeds.clearPanelValues(); numberOfFeedsLabel = new Label(formattedNumbers(postsBean.getFeedsNumber())); + numberOfFeedsLabel.setStyleName("statistic-value"); + if(isRoot || isProfilePage) - numberOfFeedsLabel.setTitle("Posts during the last year (" + postsBean.getFeedsNumber() + ")"); + numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_ROOT_PROFILE + " (" + postsBean.getFeedsNumber() + ")"); else - numberOfFeedsLabel.setTitle("Posts during the last year in this VRE (" + postsBean.getFeedsNumber() + ")"); + numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_VRE + " (" + postsBean.getFeedsNumber() + ")"); // add handler for user that clicks on the numberOfFeedsLabel - if(!isProfilePage){ + if(!isProfilePage || information.isOwner()){ numberOfFeedsLabel.getElement().getStyle().setCursor(Cursor.POINTER); + numberOfFeedsLabel.addStyleName("statistic-value-underline"); numberOfFeedsLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { - eventBus.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(ShowUserStatisticAction.POSTS_MADE_BY_USER)); + eventBus.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(ShowUserStatisticAction.POSTS_MADE_BY_USER, information.getCurrentPageLanding())); } }); } numberOfWrittenFeeds = postsBean.getFeedsNumber(); - numberOfFeedsLabel.setStyleName("statistic-value"); feeds.appendToPanel(numberOfFeedsLabel); // updates comments and likes made likesAndCommentsMade.clearPanelValues(); CommentsAndLikesWidget contentLikesAndCommentsMade = new CommentsAndLikesWidget(); - if(!isProfilePage) + if(!isProfilePage || information.isOwner()) contentLikesAndCommentsMade.setEventBus(eventBus); String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png"; @@ -476,76 +506,84 @@ public class StatisticsPanel extends Composite { contentLikesAndCommentsMade.setLikes( urlLikesIcon, formattedNumbers(postsBean.getLikesMade()), - "Likes made during the last year", - "Likes made during the last year (" + postsBean.getLikesMade() + ")", - ShowUserStatisticAction.LIKES_MADE_BY_USER); + TOOLTIP_LIKES_DONE, + TOOLTIP_LIKES_DONE + " (" + postsBean.getLikesMade() + ")", + ShowUserStatisticAction.LIKES_MADE_BY_USER, + information.getCurrentPageLanding()); else contentLikesAndCommentsMade.setLikes( urlLikesIcon, formattedNumbers(postsBean.getLikesMade()), - "Likes made during the last year in this VRE", - "Likes made during the last year in this VRE (" + postsBean.getLikesMade() + ")", - ShowUserStatisticAction.LIKES_MADE_BY_USER); + TOOLTIP_LIKES_DONE_VRE, + TOOLTIP_LIKES_DONE_VRE + " (" + postsBean.getLikesMade() + ")", + ShowUserStatisticAction.LIKES_MADE_BY_USER, + information.getCurrentPageLanding()); String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png"; if(isRoot || isProfilePage) contentLikesAndCommentsMade.setComments( urlCommentsIcon, formattedNumbers(postsBean.getCommentsMade()), - "Post replies made during the last year", - "Post replies made during the last year (" + postsBean.getCommentsMade() + ")", - ShowUserStatisticAction.COMMENTS_MADE_BY_USER); + TOOLTIP_REPLIES_DONE, + TOOLTIP_REPLIES_DONE + " (" + postsBean.getCommentsMade() + ")", + ShowUserStatisticAction.COMMENTS_MADE_BY_USER, + information.getCurrentPageLanding()); else contentLikesAndCommentsMade.setComments( urlCommentsIcon, formattedNumbers(postsBean.getCommentsMade()), - "Post replies made during the last year in this VRE", - "Post replies made during the last year in this VRE (" + postsBean.getCommentsMade() + ")", - ShowUserStatisticAction.COMMENTS_MADE_BY_USER); + TOOLTIP_REPLIES_DONE_VRE, + TOOLTIP_REPLIES_DONE_VRE +" (" + postsBean.getCommentsMade() + ")", + ShowUserStatisticAction.COMMENTS_MADE_BY_USER, + information.getCurrentPageLanding()); likesAndCommentsMade.appendToPanel(contentLikesAndCommentsMade); // updates comments and likes got likesAndCommentsGot.clearPanelValues(); - content = new CommentsAndLikesWidget(); + contentLikesAndCommentsGot = new CommentsAndLikesWidget(); - if(!isProfilePage) - content.setEventBus(eventBus); + if(!isProfilePage || information.isOwner()) + contentLikesAndCommentsGot.setEventBus(eventBus); if(isRoot || isProfilePage) - content.setLikes( + contentLikesAndCommentsGot.setLikes( urlLikesIcon, formattedNumbers(postsBean.getLikesReceived()), - "Likes got during the last year", - "Likes got during the last year (" + postsBean.getLikesReceived() + ")", - ShowUserStatisticAction.LIKES_GOT_BY_USER); + TOOLTIP_LIKES_GOT, + TOOLTIP_LIKES_GOT+ " (" + postsBean.getLikesReceived() + ")", + ShowUserStatisticAction.LIKES_GOT_BY_USER, + information.getCurrentPageLanding()); else - content.setLikes( + contentLikesAndCommentsGot.setLikes( urlLikesIcon, formattedNumbers(postsBean.getLikesReceived()), - "Likes got during the last year in this VRE", - "Likes got during the last year in this VRE (" + postsBean.getLikesReceived() + ")", - ShowUserStatisticAction.LIKES_GOT_BY_USER); + TOOLTIP_LIKES_GOT_VRE, + TOOLTIP_LIKES_GOT_VRE + " (" + postsBean.getLikesReceived() + ")", + ShowUserStatisticAction.LIKES_GOT_BY_USER, + information.getCurrentPageLanding()); numberOfLikesGot = postsBean.getLikesReceived(); if(isRoot || isProfilePage) - content.setComments( + contentLikesAndCommentsGot.setComments( urlCommentsIcon, formattedNumbers(postsBean.getCommentsReceived()), - "Post replies got during the last year", - "Post replies got during the last year (" + postsBean.getCommentsReceived() + ")", - ShowUserStatisticAction.COMMENTS_GOT_BY_USER); + TOOLTIP_REPLIES_GOT, + TOOLTIP_REPLIES_GOT + " (" + postsBean.getCommentsReceived() + ")", + ShowUserStatisticAction.COMMENTS_GOT_BY_USER, + information.getCurrentPageLanding()); else - content.setComments( + contentLikesAndCommentsGot.setComments( urlCommentsIcon, formattedNumbers(postsBean.getCommentsReceived()), - "Post replies got during the last year in this VRE.", - "Post replies got during the last year in this VRE (" + postsBean.getCommentsReceived() + ")", - ShowUserStatisticAction.COMMENTS_GOT_BY_USER); + TOOLTIP_REPLIES_GOT_VRE, + TOOLTIP_REPLIES_GOT_VRE + " (" + postsBean.getCommentsReceived() + ")", + ShowUserStatisticAction.COMMENTS_GOT_BY_USER, + information.getCurrentPageLanding()); numberOfCommentsGot = postsBean.getCommentsReceived(); - likesAndCommentsGot.appendToPanel(content); + likesAndCommentsGot.appendToPanel(contentLikesAndCommentsGot); } }); @@ -593,22 +631,28 @@ public class StatisticsPanel extends Composite { private void bind() { try { - + // on statistic value click handler eventBus.addHandler(ShowFeedsRelatedToUserStatisticsEvent.TYPE, new ShowFeedsRelatedToUserStatisticsEventHandler() { @Override public void onShowRelatedFeeds( ShowFeedsRelatedToUserStatisticsEvent event) { - + ShowUserStatisticAction actionToTake = event.getAction(); - + // get current url String currentUrl = Window.Location.getHref(); + + // if it is a profile page, we have to move the user to the sitelandingpage + if(isProfilePage()){ + currentUrl = event.getLandingPage(); + } + String[] splittedUrl = currentUrl.split("\\?"); - + Window.Location.assign(splittedUrl[0] + "?" + Encoder.encode(GCubeSocialNetworking.SHOW_STATISTICS_ACTION_OID) + "=" + Encoder.encode(actionToTake.toString())); - + } }); @@ -632,9 +676,9 @@ public class StatisticsPanel extends Composite { numberOfWrittenFeeds ++; numberOfFeedsLabel.setText(formattedNumbers(numberOfWrittenFeeds)); if(isRoot) - numberOfFeedsLabel.setTitle("Your posts during the last year (" + numberOfWrittenFeeds + ")"); + numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_ROOT_PROFILE + " (" + numberOfWrittenFeeds + ")"); else - numberOfFeedsLabel.setTitle("Your posts during the last year in this VRE (" + numberOfWrittenFeeds + ")"); + numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_VRE + " (" + numberOfWrittenFeeds + ")"); GWT.log("Number of written posts changed to " + numberOfWrittenFeeds); } } @@ -661,9 +705,9 @@ public class StatisticsPanel extends Composite { numberOfWrittenFeeds = numberOfWrittenFeeds < 0 ? 0: numberOfWrittenFeeds; numberOfFeedsLabel.setText(formattedNumbers(numberOfWrittenFeeds)); if(isRoot) - numberOfFeedsLabel.setTitle("Your posts during the last year (" + numberOfWrittenFeeds + ")"); + numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_ROOT_PROFILE + " (" + numberOfWrittenFeeds + ")"); else - numberOfFeedsLabel.setTitle("Your posts during the last year in this VRE (" + numberOfWrittenFeeds + ")"); + numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_VRE + " (" + numberOfWrittenFeeds + ")"); GWT.log("Number of written posts changed to " + numberOfWrittenFeeds); } }}); @@ -689,19 +733,21 @@ public class StatisticsPanel extends Composite { String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png"; if(isRoot) - content.setLikes( + contentLikesAndCommentsGot.setLikes( urlLikesIcon, formattedNumbers(numberOfLikesGot), - "Likes you got during the last year.", - "Likes you got during the last year (" + numberOfLikesGot + ")", - ShowUserStatisticAction.LIKES_GOT_BY_USER); + TOOLTIP_LIKES_GOT, + TOOLTIP_LIKES_GOT + " (" + numberOfLikesGot + ")", + ShowUserStatisticAction.LIKES_GOT_BY_USER, + informationBeanRetrieved.getCurrentPageLanding()); else - content.setLikes( + contentLikesAndCommentsGot.setLikes( urlLikesIcon, formattedNumbers(numberOfLikesGot), - "Likes you got during the last year in this VRE", - "Likes you got during the last year in this VRE (" + numberOfLikesGot + ")", - ShowUserStatisticAction.LIKES_GOT_BY_USER); + TOOLTIP_LIKES_GOT_VRE, + TOOLTIP_LIKES_GOT_VRE + " (" + numberOfLikesGot + ")", + ShowUserStatisticAction.LIKES_GOT_BY_USER, + informationBeanRetrieved.getCurrentPageLanding()); GWT.log("Number of likes got changed to " + numberOfLikesGot); } @@ -731,19 +777,21 @@ public class StatisticsPanel extends Composite { String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png"; if(isRoot) - content.setLikes( + contentLikesAndCommentsGot.setLikes( urlLikesIcon, formattedNumbers(numberOfLikesGot), - "Likes you got during the last year.", - "Likes you got during the last year (" + numberOfLikesGot + ")", - ShowUserStatisticAction.LIKES_GOT_BY_USER); + TOOLTIP_LIKES_GOT, + TOOLTIP_LIKES_GOT + " (" + numberOfLikesGot + ")", + ShowUserStatisticAction.LIKES_GOT_BY_USER, + informationBeanRetrieved.getCurrentPageLanding()); else - content.setLikes( + contentLikesAndCommentsGot.setLikes( urlLikesIcon, formattedNumbers(numberOfLikesGot), - "Likes you got during the last year in this VRE", - "Likes you got during the last year in this VRE (" + numberOfLikesGot + ")", - ShowUserStatisticAction.LIKES_GOT_BY_USER); + TOOLTIP_LIKES_GOT_VRE, + TOOLTIP_LIKES_GOT_VRE + " (" + numberOfLikesGot + ")", + ShowUserStatisticAction.LIKES_GOT_BY_USER, + informationBeanRetrieved.getCurrentPageLanding()); GWT.log("Number of likes got changed to " + numberOfLikesGot); } @@ -772,19 +820,21 @@ public class StatisticsPanel extends Composite { String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png"; if(isRoot) - content.setComments( + contentLikesAndCommentsGot.setComments( urlCommentsIcon, formattedNumbers(numberOfCommentsGot), - "Post replies you got during the last year.", - "Post replies you got during the last year (" + numberOfCommentsGot + ")", - ShowUserStatisticAction.COMMENTS_GOT_BY_USER); + TOOLTIP_REPLIES_GOT, + TOOLTIP_REPLIES_GOT + " (" + numberOfCommentsGot + ")", + ShowUserStatisticAction.COMMENTS_GOT_BY_USER, + informationBeanRetrieved.getCurrentPageLanding()); else - content.setComments( + contentLikesAndCommentsGot.setComments( urlCommentsIcon, formattedNumbers(numberOfCommentsGot), - "Post replies you got during the last year in this VRE.", - "Post replies you got during the last year in this VRE (" + numberOfCommentsGot + ")", - ShowUserStatisticAction.COMMENTS_GOT_BY_USER); + TOOLTIP_REPLIES_GOT_VRE, + TOOLTIP_REPLIES_GOT_VRE + " (" + numberOfCommentsGot + ")", + ShowUserStatisticAction.COMMENTS_GOT_BY_USER, + informationBeanRetrieved.getCurrentPageLanding()); GWT.log("Number of comments got changed to " + numberOfCommentsGot); } @@ -813,19 +863,21 @@ public class StatisticsPanel extends Composite { numberOfCommentsGot = numberOfCommentsGot < 0 ? 0: numberOfCommentsGot; String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png"; if(isRoot) - content.setComments( + contentLikesAndCommentsGot.setComments( urlCommentsIcon, formattedNumbers(numberOfCommentsGot), - "Post replies you got during the last year.", - "Post replies you got during the last year (" + numberOfCommentsGot + ")", - ShowUserStatisticAction.COMMENTS_GOT_BY_USER); + TOOLTIP_REPLIES_GOT, + TOOLTIP_REPLIES_GOT + " (" + numberOfCommentsGot + ")", + ShowUserStatisticAction.COMMENTS_GOT_BY_USER, + informationBeanRetrieved.getCurrentPageLanding()); else - content.setComments( + contentLikesAndCommentsGot.setComments( urlCommentsIcon, - formattedNumbers(numberOfCommentsGot), - "Post replies you got during the last year in this VRE.", - "Post replies you got during the last year in this VRE (" + numberOfCommentsGot + ")", - ShowUserStatisticAction.COMMENTS_GOT_BY_USER); + formattedNumbers(numberOfCommentsGot), + TOOLTIP_REPLIES_GOT_VRE, + TOOLTIP_REPLIES_GOT_VRE + " (" + numberOfCommentsGot + ")", + ShowUserStatisticAction.COMMENTS_GOT_BY_USER, + informationBeanRetrieved.getCurrentPageLanding()); GWT.log("Number of comments got changed to " + numberOfCommentsGot); } diff --git a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/events/ShowFeedsRelatedToUserStatisticsEvent.java b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/events/ShowFeedsRelatedToUserStatisticsEvent.java index 7b062da..382136b 100644 --- a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/events/ShowFeedsRelatedToUserStatisticsEvent.java +++ b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/events/ShowFeedsRelatedToUserStatisticsEvent.java @@ -12,13 +12,20 @@ public class ShowFeedsRelatedToUserStatisticsEvent extends GwtEvent TYPE = new Type(); private ShowUserStatisticAction action; - public ShowFeedsRelatedToUserStatisticsEvent(ShowUserStatisticAction actionToTake) { + private String currentSiteLandingPage; + + public ShowFeedsRelatedToUserStatisticsEvent(ShowUserStatisticAction actionToTake, String currentSiteLandingPage) { this.action = actionToTake; + this.currentSiteLandingPage = currentSiteLandingPage; } public ShowUserStatisticAction getAction() { return action; } + + public String getLandingPage() { + return currentSiteLandingPage; + } @Override public Type getAssociatedType() { diff --git a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/CommentsAndLikesWidget.java b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/CommentsAndLikesWidget.java index b224a29..54bca00 100644 --- a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/CommentsAndLikesWidget.java +++ b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/CommentsAndLikesWidget.java @@ -35,59 +35,61 @@ public class CommentsAndLikesWidget extends Composite { @UiField Label commentsValue; - + private HandlerManager busEvents; public CommentsAndLikesWidget() { initWidget(uiBinder.createAndBindUi(this)); } - public void setComments(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick){ + public void setComments(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick, final String landingPage){ this.commentsImage.setUrl(url); this.commentsImage.setTitle(tipIcon); this.commentsValue.setText(value); this.commentsValue.setTitle(tipValue); - + if(busEvents != null && actionToTakeOnClick != null){ - + commentsValue.getElement().getStyle().setCursor(Cursor.POINTER); + commentsValue.addStyleName("statistic-value-underline"); commentsValue.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { - - busEvents.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(actionToTakeOnClick)); - + + busEvents.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(actionToTakeOnClick, landingPage)); + } }); - + } } - public void setLikes(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick){ + public void setLikes(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick, final String landingPage){ this.likesImage.setUrl(url); this.likesImage.setTitle(tipIcon); this.likesValue.setText(value); this.likesValue.setTitle(tipValue); - + if(busEvents != null && actionToTakeOnClick != null){ - + likesValue.getElement().getStyle().setCursor(Cursor.POINTER); + likesValue.addStyleName("statistic-value-underline"); likesValue.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { - - busEvents.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(actionToTakeOnClick)); - + + busEvents.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(actionToTakeOnClick, landingPage)); + } }); - + } } - + public void setEventBus(HandlerManager busEvents){ this.busEvents = busEvents; } diff --git a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/StatisticWidget.java b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/StatisticWidget.java index b388d19..f166b57 100644 --- a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/StatisticWidget.java +++ b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/StatisticWidget.java @@ -1,10 +1,13 @@ package org.gcube.portlet.user.userstatisticsportlet.client.ui; +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.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.FlowPanel; +import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; @@ -30,6 +33,11 @@ public class StatisticWidget extends Composite{ @UiField FlowPanel containerValues; + + @UiField + Popover popover; + + private String headerTitle; public StatisticWidget(boolean isRoot) { initWidget(uiBinder.createAndBindUi(this)); @@ -37,6 +45,7 @@ public class StatisticWidget extends Composite{ public void setHeader(String header) { this.header.setText(header); + headerTitle = header; } public void appendToPanel(Widget w) { @@ -52,6 +61,21 @@ public class StatisticWidget extends Composite{ } public void setToolTip(String tooltip){ - this.setTitle(tooltip); + + HTML headerHtml = new HTML( + ""+headerTitle+"" + ); + + popover.setPlacement(Placement.TOP); + + // change popover text header + popover.setHeading(headerHtml.getHTML()); + + // change popover text content + popover.setText(tooltip); + + // set html + popover.setHtml(true); + } } diff --git a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/StatisticWidget.ui.xml b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/StatisticWidget.ui.xml index c609506..a081fae 100644 --- a/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/StatisticWidget.ui.xml +++ b/src/main/java/org/gcube/portlet/user/userstatisticsportlet/client/ui/StatisticWidget.ui.xml @@ -1,6 +1,6 @@ + xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"> .statistic-container { display: inline-block; @@ -26,7 +26,9 @@ - + + + diff --git a/src/main/webapp/Statistics.css b/src/main/webapp/Statistics.css index fa092bf..c9c0701 100644 --- a/src/main/webapp/Statistics.css +++ b/src/main/webapp/Statistics.css @@ -28,6 +28,11 @@ vertical-align: bottom; } +/* not for every "statistic-value" */ +.statistic-value-underline:hover { + text-decoration: underline; +} + .statistic-value-inline { color: #0084B4 !important; font-size: 14px;