Statistics panel refactored: there is now an activity part for the done posts, likes and replies

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/user-statistics@131057 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-08-31 08:45:58 +00:00
parent c6c9ddaa3d
commit b46c4cf006
6 changed files with 259 additions and 177 deletions

View File

@ -12,7 +12,7 @@ import org.gcube.portlet.user.userstatisticsportlet.client.events.PageBusEvents;
import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEvent;
import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEventHandler;
import org.gcube.portlet.user.userstatisticsportlet.client.resources.Images;
import org.gcube.portlet.user.userstatisticsportlet.client.ui.CommentsAndLikesWidget;
import org.gcube.portlet.user.userstatisticsportlet.client.ui.ActivityWidget;
import org.gcube.portlet.user.userstatisticsportlet.client.ui.StatisticWidget;
import org.gcube.portlet.user.userstatisticsportlet.shared.PostsStatsBean;
import org.gcube.portlet.user.userstatisticsportlet.shared.UserInformation;
@ -23,7 +23,6 @@ import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
@ -72,9 +71,8 @@ public class StatisticsPanel extends Composite {
/**
* Labels
*/
private final static String POSTS_LABEL = "Posts";
private final static String LIKES_COMMENTS_MADE_LABEL = "Yours";
private final static String LIKES_COMMENTS_GOT_LABEL = "Others";
private final static String ACTIVITY_LABEL = "Activity";
private final static String LIKES_COMMENTS_GOT_LABEL = "Got";
private final static String STORAGE_LABEL = "Space Used";
private final static String PROFILE_STRENGTH_LABEL = "Profile Strength";
private final static String SHOW_STATISTICS_OPTION_LABEL = "Show my statistics to VRE Members";
@ -82,10 +80,8 @@ public class StatisticsPanel extends Composite {
/**
* Some tooltips
*/
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_ACTIVITY_ROOT_PROFILE = "Posts, likes, replies done during the last year";
private final static String TOOLTIP_ACTIVITY_VRE = "Posts, likes, replies done in 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";
@ -93,8 +89,10 @@ public class StatisticsPanel extends Composite {
private final static String SHOW_STATISTICS_OPTION_TOOLTIP = "Show Statistics to members viewing your profile";
/**
* Specific tooltips
* Specific tooltips (for the values)
*/
private final static String TOOLTIP_POSTS_DONE = "Posts done during the last year";
private final static String TOOLTIP_POSTS_DONE_VRE = "Posts done during the last year in this VRE";
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";
@ -143,15 +141,15 @@ public class StatisticsPanel extends Composite {
*/
private FlowPanel mainPanel = new FlowPanel();
/**
* Since the number of feeds(posts) can be manipulated when the user posts, we need a class reference
*/
private Label numberOfFeedsLabel;
/**
* Since the number of likes/comments got can be manipulated, we need a class reference
*/
private CommentsAndLikesWidget contentLikesAndCommentsGot;
private ActivityWidget activityGot;
/**
* Posts, comments, likes done
*/
private ActivityWidget activityDone;
/**
* Number of written posts
@ -227,7 +225,7 @@ 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/her statistics to private"));
mainPanel.add(new HTML("Sorry but the user set statistics to private"));
return;
}
@ -282,57 +280,40 @@ public class StatisticsPanel extends Composite {
// add image to mainPanel
mainPanel.add(userImage);
// feeds
final StatisticWidget feeds = new StatisticWidget(isRoot);
feeds.setHeader(POSTS_LABEL);
// feeds, posts, likes
final StatisticWidget activityDoneWidgetContainer = new StatisticWidget(isRoot);
activityDoneWidgetContainer.setHeader(ACTIVITY_LABEL);
if(isRoot || isProfilePage)
feeds.setToolTip(TOOLTIP_POSTS_ROOT_PROFILE);
activityDoneWidgetContainer.setToolTip(TOOLTIP_ACTIVITY_ROOT_PROFILE);
else
feeds.setToolTip(TOOLTIP_POSTS_VRE);
activityDoneWidgetContainer.setToolTip(TOOLTIP_ACTIVITY_VRE);
// add loading image that will be replaced by the incoming values
Image postsLoader = new Image(imagePath);
postsLoader.setStyleName("loading-image-center-small");
feeds.appendToPanel(postsLoader);
activityDoneWidgetContainer.appendToPanel(postsLoader);
// append widget
mainPanel.add(feeds);
// likes & comments made
final StatisticWidget likesAndCommentsMade = new StatisticWidget(isRoot);
likesAndCommentsMade.setHeader(LIKES_COMMENTS_MADE_LABEL);
if(isRoot || isProfilePage)
likesAndCommentsMade.setToolTip(TOOLTIP_FAVORITES_REPLIES_ROOT_PROFILE);
else
likesAndCommentsMade.setToolTip(TOOLTIP_FAVORITES_REPLIES_POSTS_VRE);
// add loading image that will be replaced by the incoming values
Image commentsLikesMadeLoader = new Image(imagePath);
commentsLikesMadeLoader.setStyleName("loading-image-center-small");
likesAndCommentsMade.appendToPanel(commentsLikesMadeLoader);
// append widget
mainPanel.add(likesAndCommentsMade);
mainPanel.add(activityDoneWidgetContainer);
// likes & comments got
final StatisticWidget likesAndCommentsGot = new StatisticWidget(isRoot);
likesAndCommentsGot.setHeader(LIKES_COMMENTS_GOT_LABEL);
final StatisticWidget activityGotWidgetContainer = new StatisticWidget(isRoot);
activityGotWidgetContainer.setHeader(LIKES_COMMENTS_GOT_LABEL);
if(isRoot || isProfilePage)
likesAndCommentsGot.setToolTip(TOOLTIP_GOT_ROOT_PROFILE);
activityGotWidgetContainer.setToolTip(TOOLTIP_GOT_ROOT_PROFILE);
else
likesAndCommentsGot.setToolTip(TOOLTIP_GOT_VRE);
activityGotWidgetContainer.setToolTip(TOOLTIP_GOT_VRE);
// add loading image that will be replaced by the incoming values
Image commentsLikesLoader = new Image(imagePath);
commentsLikesLoader.setStyleName("loading-image-center-small");
likesAndCommentsGot.appendToPanel(commentsLikesLoader);
activityGotWidgetContainer.appendToPanel(commentsLikesLoader);
// append widget
mainPanel.add(likesAndCommentsGot);
mainPanel.add(activityGotWidgetContainer);
// the storage and the profile strength(only in root)
final StatisticWidget storage = new StatisticWidget(isRoot);
@ -376,14 +357,12 @@ public class StatisticsPanel extends Composite {
if(spaceInUse == null){
appendAlertIcon(storage);
return;
}else{
storage.clearPanelValues();
Label storageValue = new Label(spaceInUse);
storageValue.setStyleName("statistic-value");
storage.appendToPanel(storageValue);
}
storage.clearPanelValues();
Label storageValue = new Label(spaceInUse);
storageValue.setStyleName("statistic-value");
storage.appendToPanel(storageValue);
}
});
@ -402,62 +381,61 @@ public class StatisticsPanel extends Composite {
if(profileStrengthInt < 0){
appendAlertIcon(profileStrength);
return;
}else{
// clear panel
profileStrength.clearPanelValues();
final Label profileStrengthLabel = new Label(profileStrengthInt + "%");
profileStrengthLabel.setStyleName("statistic-value");
profileStrength.appendToPanel(profileStrengthLabel);
// in case too low information within the user profile
if(profileStrengthInt < profileImproveThreshold && information.isOwner()){
// Show an alert block in which underline how he can improve the profile
final AlertBlock improveProfileHint = new AlertBlock();
improveProfileHint.setType(AlertType.INFO);
improveProfileHint.addStyleName("improve-profile-hint-message");
final Button improveProfileButton = new Button(IMPROVE_BUTTON_LABEL);
improveProfileButton.setType(ButtonType.INFO);
improveProfileButton.setTitle("Improve your profile");
improveProfileButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
// set text according current url
if(isProfilePage)
improveProfileHint.setHTML(IMPROVE_PROFILE_HINT_MESSAGE_PROFILE);
else
improveProfileHint.setHTML(IMPROVE_PROFILE_HINT_MESSAGE_ROOT);
mainPanel.add(improveProfileHint);
}
});
profileStrengthLabel.setStyleName("statistic-value-inline");
improveProfileButton.addStyleName("button-improve-profile");
profileStrength.appendToPanel(improveProfileButton);
}
}
// clear panel
profileStrength.clearPanelValues();
final Label profileStrengthLabel = new Label(profileStrengthInt + "%");
profileStrengthLabel.setStyleName("statistic-value");
profileStrength.appendToPanel(profileStrengthLabel);
// in case too low information within the user profile
if(profileStrengthInt < profileImproveThreshold && information.isOwner()){
// Show an alert block in which underline how he can improve the profile
final AlertBlock improveProfileHint = new AlertBlock();
improveProfileHint.setType(AlertType.INFO);
improveProfileHint.addStyleName("improve-profile-hint-message");
final Button improveProfileButton = new Button(IMPROVE_BUTTON_LABEL);
improveProfileButton.setType(ButtonType.INFO);
improveProfileButton.setTitle("Improve your profile");
improveProfileButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
// set text according current url
if(isProfilePage)
improveProfileHint.setHTML(IMPROVE_PROFILE_HINT_MESSAGE_PROFILE);
else
improveProfileHint.setHTML(IMPROVE_PROFILE_HINT_MESSAGE_ROOT);
mainPanel.add(improveProfileHint);
}
});
profileStrengthLabel.setStyleName("statistic-value-inline");
improveProfileButton.addStyleName("button-improve-profile");
profileStrength.appendToPanel(improveProfileButton);
}
}
});
}
// retrieve othe information about number of feeds and post replies/likes
// retrieve other information about number of feeds and post replies/likes done and got
statisticsService.getPostsStats(userid, new AsyncCallback<PostsStatsBean>(){
public void onFailure(Throwable arg0) {
appendAlertIcon(feeds);
appendAlertIcon(likesAndCommentsGot);
appendAlertIcon(activityDoneWidgetContainer);
appendAlertIcon(activityGotWidgetContainer);
}
@ -466,50 +444,45 @@ public class StatisticsPanel extends Composite {
// if there are no statistics
if(postsBean == null){
appendAlertIcon(feeds);
appendAlertIcon(likesAndCommentsGot);
appendAlertIcon(activityDoneWidgetContainer);
appendAlertIcon(activityGotWidgetContainer);
return;
}
// update feeds number
feeds.clearPanelValues();
numberOfFeedsLabel = new Label(formattedNumbers(postsBean.getFeedsNumber()));
numberOfFeedsLabel.setStyleName("statistic-value");
// update feeds number, comments and likes done
activityDoneWidgetContainer.clearPanelValues();
activityDone = new ActivityWidget();
// set the event handler if needed
if(!isProfilePage || information.isOwner())
activityDone.setEventBus(eventBus);
String urlPostsIcon = GWT.getModuleBaseURL() + "../images/share-blue.png";
if(isRoot || isProfilePage)
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_ROOT_PROFILE + " (" + postsBean.getFeedsNumber() + ")");
activityDone.setPosts(
urlPostsIcon,
formattedNumbers(postsBean.getFeedsNumber()),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE + " (" + postsBean.getFeedsNumber() + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
information.getCurrentPageLanding());
else
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_VRE + " (" + postsBean.getFeedsNumber() + ")");
// add handler for user that clicks on the numberOfFeedsLabel
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, information.getCurrentPageLanding()));
}
});
}
activityDone.setPosts(
urlPostsIcon,
formattedNumbers(postsBean.getFeedsNumber()),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE_VRE + " (" + postsBean.getFeedsNumber() + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
information.getCurrentPageLanding());
numberOfWrittenFeeds = postsBean.getFeedsNumber();
feeds.appendToPanel(numberOfFeedsLabel);
// updates comments and likes made
likesAndCommentsMade.clearPanelValues();
CommentsAndLikesWidget contentLikesAndCommentsMade = new CommentsAndLikesWidget();
if(!isProfilePage || information.isOwner())
contentLikesAndCommentsMade.setEventBus(eventBus);
activityDoneWidgetContainer.appendToPanel(activityDone);
String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png";
if(isRoot || isProfilePage)
contentLikesAndCommentsMade.setLikes(
activityDone.setLikes(
urlLikesIcon,
formattedNumbers(postsBean.getLikesMade()),
TOOLTIP_LIKES_DONE,
@ -517,7 +490,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.LIKES_MADE_BY_USER,
information.getCurrentPageLanding());
else
contentLikesAndCommentsMade.setLikes(
activityDone.setLikes(
urlLikesIcon,
formattedNumbers(postsBean.getLikesMade()),
TOOLTIP_LIKES_DONE_VRE,
@ -527,7 +500,7 @@ public class StatisticsPanel extends Composite {
String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png";
if(isRoot || isProfilePage)
contentLikesAndCommentsMade.setComments(
activityDone.setComments(
urlCommentsIcon,
formattedNumbers(postsBean.getCommentsMade()),
TOOLTIP_REPLIES_DONE,
@ -535,7 +508,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.COMMENTS_MADE_BY_USER,
information.getCurrentPageLanding());
else
contentLikesAndCommentsMade.setComments(
activityDone.setComments(
urlCommentsIcon,
formattedNumbers(postsBean.getCommentsMade()),
TOOLTIP_REPLIES_DONE_VRE,
@ -543,17 +516,17 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.COMMENTS_MADE_BY_USER,
information.getCurrentPageLanding());
likesAndCommentsMade.appendToPanel(contentLikesAndCommentsMade);
activityDoneWidgetContainer.appendToPanel(activityDone);
// updates comments and likes got
likesAndCommentsGot.clearPanelValues();
contentLikesAndCommentsGot = new CommentsAndLikesWidget();
activityGotWidgetContainer.clearPanelValues();
activityGot = new ActivityWidget();
if(!isProfilePage || information.isOwner())
contentLikesAndCommentsGot.setEventBus(eventBus);
activityGot.setEventBus(eventBus);
if(isRoot || isProfilePage)
contentLikesAndCommentsGot.setLikes(
activityGot.setLikes(
urlLikesIcon,
formattedNumbers(postsBean.getLikesReceived()),
TOOLTIP_LIKES_GOT,
@ -561,7 +534,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.LIKES_GOT_BY_USER,
information.getCurrentPageLanding());
else
contentLikesAndCommentsGot.setLikes(
activityGot.setLikes(
urlLikesIcon,
formattedNumbers(postsBean.getLikesReceived()),
TOOLTIP_LIKES_GOT_VRE,
@ -572,7 +545,7 @@ public class StatisticsPanel extends Composite {
numberOfLikesGot = postsBean.getLikesReceived();
if(isRoot || isProfilePage)
contentLikesAndCommentsGot.setComments(
activityGot.setComments(
urlCommentsIcon,
formattedNumbers(postsBean.getCommentsReceived()),
TOOLTIP_REPLIES_GOT,
@ -580,7 +553,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
information.getCurrentPageLanding());
else
contentLikesAndCommentsGot.setComments(
activityGot.setComments(
urlCommentsIcon,
formattedNumbers(postsBean.getCommentsReceived()),
TOOLTIP_REPLIES_GOT_VRE,
@ -589,7 +562,7 @@ public class StatisticsPanel extends Composite {
information.getCurrentPageLanding());
numberOfCommentsGot = postsBean.getCommentsReceived();
likesAndCommentsGot.appendToPanel(contentLikesAndCommentsGot);
activityGotWidgetContainer.appendToPanel(activityGot);
}
});
@ -680,11 +653,25 @@ public class StatisticsPanel extends Composite {
GWT.log("Increment number of post message received");
numberOfWrittenFeeds ++;
numberOfFeedsLabel.setText(formattedNumbers(numberOfWrittenFeeds));
String urlPostsIcon = GWT.getModuleBaseURL() + "../images/share-blue.png";
if(isRoot)
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_ROOT_PROFILE + " (" + numberOfWrittenFeeds + ")");
activityDone.setPosts(
urlPostsIcon,
formattedNumbers(numberOfWrittenFeeds),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE + " (" + numberOfWrittenFeeds + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
else
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_VRE + " (" + numberOfWrittenFeeds + ")");
activityDone.setPosts(
urlPostsIcon,
formattedNumbers(numberOfWrittenFeeds),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE_VRE + " (" + numberOfWrittenFeeds + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
GWT.log("Number of written posts changed to " + numberOfWrittenFeeds);
}
}
@ -709,11 +696,25 @@ public class StatisticsPanel extends Composite {
// they can't be less than zero...
numberOfWrittenFeeds --;
numberOfWrittenFeeds = numberOfWrittenFeeds < 0 ? 0: numberOfWrittenFeeds;
numberOfFeedsLabel.setText(formattedNumbers(numberOfWrittenFeeds));
String urlPostsIcon = GWT.getModuleBaseURL() + "../images/share-blue.png";
if(isRoot)
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_ROOT_PROFILE + " (" + numberOfWrittenFeeds + ")");
activityDone.setPosts(
urlPostsIcon,
formattedNumbers(numberOfWrittenFeeds),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE + " (" + numberOfWrittenFeeds + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
else
numberOfFeedsLabel.setTitle(TOOLTIP_POSTS_VRE + " (" + numberOfWrittenFeeds + ")");
activityDone.setPosts(
urlPostsIcon,
formattedNumbers(numberOfWrittenFeeds),
TOOLTIP_POSTS_DONE,
TOOLTIP_POSTS_DONE_VRE + " (" + numberOfWrittenFeeds + ")",
ShowUserStatisticAction.POSTS_MADE_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
GWT.log("Number of written posts changed to " + numberOfWrittenFeeds);
}
}});
@ -739,7 +740,7 @@ public class StatisticsPanel extends Composite {
String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png";
if(isRoot)
contentLikesAndCommentsGot.setLikes(
activityGot.setLikes(
urlLikesIcon,
formattedNumbers(numberOfLikesGot),
TOOLTIP_LIKES_GOT,
@ -747,7 +748,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.LIKES_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
else
contentLikesAndCommentsGot.setLikes(
activityGot.setLikes(
urlLikesIcon,
formattedNumbers(numberOfLikesGot),
TOOLTIP_LIKES_GOT_VRE,
@ -783,7 +784,7 @@ public class StatisticsPanel extends Composite {
String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png";
if(isRoot)
contentLikesAndCommentsGot.setLikes(
activityGot.setLikes(
urlLikesIcon,
formattedNumbers(numberOfLikesGot),
TOOLTIP_LIKES_GOT,
@ -791,7 +792,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.LIKES_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
else
contentLikesAndCommentsGot.setLikes(
activityGot.setLikes(
urlLikesIcon,
formattedNumbers(numberOfLikesGot),
TOOLTIP_LIKES_GOT_VRE,
@ -826,7 +827,7 @@ public class StatisticsPanel extends Composite {
String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png";
if(isRoot)
contentLikesAndCommentsGot.setComments(
activityGot.setComments(
urlCommentsIcon,
formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT,
@ -834,7 +835,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
else
contentLikesAndCommentsGot.setComments(
activityGot.setComments(
urlCommentsIcon,
formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT_VRE,
@ -869,7 +870,7 @@ public class StatisticsPanel extends Composite {
numberOfCommentsGot = numberOfCommentsGot < 0 ? 0: numberOfCommentsGot;
String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png";
if(isRoot)
contentLikesAndCommentsGot.setComments(
activityGot.setComments(
urlCommentsIcon,
formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT,
@ -877,7 +878,7 @@ public class StatisticsPanel extends Composite {
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
informationBeanRetrieved.getCurrentPageLanding());
else
contentLikesAndCommentsGot.setComments(
activityGot.setComments(
urlCommentsIcon,
formattedNumbers(numberOfCommentsGot),
TOOLTIP_REPLIES_GOT_VRE,

View File

@ -15,13 +15,13 @@ import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
public class CommentsAndLikesWidget extends Composite {
public class ActivityWidget extends Composite {
private static CommentsAndLikesWidgetUiBinder uiBinder = GWT
.create(CommentsAndLikesWidgetUiBinder.class);
interface CommentsAndLikesWidgetUiBinder extends
UiBinder<Widget, CommentsAndLikesWidget> {
UiBinder<Widget, ActivityWidget> {
}
@UiField
@ -30,24 +30,39 @@ public class CommentsAndLikesWidget extends Composite {
@UiField
Image commentsImage;
@UiField
Image postsImage;
@UiField
Label likesValue;
@UiField
Label commentsValue;
@UiField
Label postsValue;
private HandlerManager busEvents;
public CommentsAndLikesWidget() {
public ActivityWidget() {
initWidget(uiBinder.createAndBindUi(this));
}
/**
* Set comments information
* @param url
* @param value
* @param tipIcon
* @param tipValue
* @param actionToTakeOnClick
* @param landingPage
*/
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);
commentsImage.setUrl(url);
commentsImage.setTitle(tipIcon);
commentsValue.setText(value);
commentsValue.setTitle(tipValue);
if(busEvents != null && actionToTakeOnClick != null){
@ -64,14 +79,27 @@ public class CommentsAndLikesWidget extends Composite {
});
}
// set to visible
commentsValue.setVisible(true);
commentsImage.setVisible(true);
}
/**
* Set likes information
* @param url
* @param value
* @param tipIcon
* @param tipValue
* @param actionToTakeOnClick
* @param landingPage
*/
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);
likesImage.setUrl(url);
likesImage.setTitle(tipIcon);
likesValue.setText(value);
likesValue.setTitle(tipValue);
if(busEvents != null && actionToTakeOnClick != null){
@ -88,8 +116,53 @@ public class CommentsAndLikesWidget extends Composite {
});
}
// set to visible
likesValue.setVisible(true);
likesImage.setVisible(true);
}
/**
* Set posts information
* @param url
* @param value
* @param tipIcon
* @param tipValue
* @param actionToTakeOnClick
* @param landingPage
*/
public void setPosts(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick, final String landingPage){
postsImage.setUrl(url);
postsImage.setTitle(tipIcon);
postsValue.setText(value);
postsValue.setTitle(tipValue);
if(busEvents != null && actionToTakeOnClick != null){
postsValue.getElement().getStyle().setCursor(Cursor.POINTER);
postsValue.addStyleName("statistic-value-underline");
postsValue.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
busEvents.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(actionToTakeOnClick, landingPage));
}
});
}
// set to visible
postsValue.setVisible(true);
postsImage.setVisible(true);
}
/**
* Set the event bus to let this widget fire events
* @param busEvents
*/
public void setEventBus(HandlerManager busEvents){
this.busEvents = busEvents;
}

View File

@ -5,8 +5,8 @@
.statistic-icon {
display: inline-block;
vertical-align: text-bottom;
width: auto;
height: 19px;
width: 22px;
height: 22px;
}
.statistic-value {
@ -17,9 +17,17 @@
}
</ui:style>
<g:HTMLPanel>
<g:Image styleName="{style.statistic-icon}" ui:field="likesImage"></g:Image>
<g:Label styleName="{style.statistic-value}" ui:field="likesValue"></g:Label>
<g:Image styleName="{style.statistic-icon}" ui:field="commentsImage"></g:Image>
<g:Label styleName="{style.statistic-value}" ui:field="commentsValue"></g:Label>
<g:Image styleName="{style.statistic-icon}" ui:field="postsImage"
visible="false"></g:Image>
<g:Label styleName="{style.statistic-value}" ui:field="postsValue"
visible="false"></g:Label>
<g:Image styleName="{style.statistic-icon}" ui:field="likesImage"
visible="false"></g:Image>
<g:Label styleName="{style.statistic-value}" ui:field="likesValue"
visible="false"></g:Label>
<g:Image styleName="{style.statistic-icon}" ui:field="commentsImage"
visible="false"></g:Image>
<g:Label styleName="{style.statistic-value}" ui:field="commentsValue"
visible="false"></g:Label>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -61,7 +61,7 @@ public class ServerUtils {
*/
public static String getDevelopmentUser() {
String user = UserStatisticsServiceImpl.defaultUserId;
// user = "costantino.perciante";
// user = "costantino.perciante";
return user;
}

View File

@ -53,7 +53,7 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
@Override
public void init() {
// get connection to Cassandra
logger.debug("Getting connection to Cassandra..");
store = new DBCassandraAstyanaxImpl();
@ -256,12 +256,12 @@ public class UserStatisticsServiceImpl extends RemoteServiceServlet implements U
// page landing
String pageLanding = PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest());
UserInformation bean = new UserInformation(isInfrastructure, thumbnailURL, userName, actualVre, isOwner, isProfileShowable);
bean.setCurrentPageLanding(pageLanding);
return bean;
}
else return new UserInformation(true, null, userName, vreID, true, true);
else
return new UserInformation(true, null, userName, vreID, true, true);
}
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B