|
|
|
@ -1,10 +1,5 @@
|
|
|
|
|
package org.gcube.portlet.user.userstatisticsportlet.client;
|
|
|
|
|
|
|
|
|
|
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapter;
|
|
|
|
|
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapterException;
|
|
|
|
|
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusEvent;
|
|
|
|
|
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusListener;
|
|
|
|
|
|
|
|
|
|
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
|
|
|
|
import org.gcube.portal.databook.client.util.Encoder;
|
|
|
|
|
import org.gcube.portal.databook.shared.ShowUserStatisticAction;
|
|
|
|
@ -37,6 +32,11 @@ 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.Image;
|
|
|
|
|
|
|
|
|
|
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapter;
|
|
|
|
|
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapterException;
|
|
|
|
|
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusEvent;
|
|
|
|
|
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusListener;
|
|
|
|
|
/**
|
|
|
|
|
* Panel to show received user's statistics
|
|
|
|
|
*
|
|
|
|
@ -95,11 +95,6 @@ public class StatisticsPanel extends Composite {
|
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
@ -159,11 +154,6 @@ public class StatisticsPanel extends Composite {
|
|
|
|
|
*/
|
|
|
|
|
private long numberOfLikesGot;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Number of likes got
|
|
|
|
|
*/
|
|
|
|
|
private long numberOfCommentsGot;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pagebus to listen for events (coming from the news feed portlet)
|
|
|
|
|
*/
|
|
|
|
@ -535,20 +525,7 @@ public class StatisticsPanel extends Composite {
|
|
|
|
|
TOOLTIP_LIKES_DONE_VRE + " (" + postsBean.getLikesMade() + ")",
|
|
|
|
|
ShowUserStatisticAction.LIKES_MADE_BY_USER,
|
|
|
|
|
information.getCurrentPageLanding());
|
|
|
|
|
|
|
|
|
|
if(isRoot || isProfilePage)
|
|
|
|
|
activityDone.setComments(
|
|
|
|
|
formattedNumbers(postsBean.getCommentsMade()),
|
|
|
|
|
TOOLTIP_REPLIES_DONE + " (" + postsBean.getCommentsMade() + ")",
|
|
|
|
|
ShowUserStatisticAction.COMMENTS_MADE_BY_USER,
|
|
|
|
|
information.getCurrentPageLanding());
|
|
|
|
|
else
|
|
|
|
|
activityDone.setComments(
|
|
|
|
|
formattedNumbers(postsBean.getCommentsMade()),
|
|
|
|
|
TOOLTIP_REPLIES_DONE_VRE +" (" + postsBean.getCommentsMade() + ")",
|
|
|
|
|
ShowUserStatisticAction.COMMENTS_MADE_BY_USER,
|
|
|
|
|
information.getCurrentPageLanding());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
activityDoneWidgetContainer.appendToPanel(activityDone);
|
|
|
|
|
|
|
|
|
|
// updates comments and likes got
|
|
|
|
@ -572,21 +549,6 @@ public class StatisticsPanel extends Composite {
|
|
|
|
|
information.getCurrentPageLanding());
|
|
|
|
|
|
|
|
|
|
numberOfLikesGot = postsBean.getLikesReceived();
|
|
|
|
|
|
|
|
|
|
if(isRoot || isProfilePage)
|
|
|
|
|
activityGot.setComments(
|
|
|
|
|
formattedNumbers(postsBean.getCommentsReceived()),
|
|
|
|
|
TOOLTIP_REPLIES_GOT + " (" + postsBean.getCommentsReceived() + ")",
|
|
|
|
|
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
|
|
|
|
|
information.getCurrentPageLanding());
|
|
|
|
|
else
|
|
|
|
|
activityGot.setComments(
|
|
|
|
|
formattedNumbers(postsBean.getCommentsReceived()),
|
|
|
|
|
TOOLTIP_REPLIES_GOT_VRE + " (" + postsBean.getCommentsReceived() + ")",
|
|
|
|
|
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
|
|
|
|
|
information.getCurrentPageLanding());
|
|
|
|
|
|
|
|
|
|
numberOfCommentsGot = postsBean.getCommentsReceived();
|
|
|
|
|
activityGotWidgetContainer.appendToPanel(activityGot);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -811,83 +773,7 @@ public class StatisticsPanel extends Composite {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// increment comments got number
|
|
|
|
|
pageBusAdapter.PageBusSubscribe(PageBusEvents.commentsIncrement, null, null, null, null);
|
|
|
|
|
|
|
|
|
|
pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener(){
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getName() {
|
|
|
|
|
return PageBusEvents.commentsIncrement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPageBusSubscriptionCallback(PageBusEvent event) {
|
|
|
|
|
|
|
|
|
|
if(event.getSubject().equals(this.getName())){
|
|
|
|
|
|
|
|
|
|
GWT.log("Increment number of comments received");
|
|
|
|
|
|
|
|
|
|
numberOfCommentsGot ++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isRoot)
|
|
|
|
|
activityGot.setComments(
|
|
|
|
|
formattedNumbers(numberOfCommentsGot),
|
|
|
|
|
TOOLTIP_REPLIES_GOT + " (" + numberOfCommentsGot + ")",
|
|
|
|
|
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
|
|
|
|
|
informationBeanRetrieved.getCurrentPageLanding());
|
|
|
|
|
else
|
|
|
|
|
activityGot.setComments(
|
|
|
|
|
formattedNumbers(numberOfCommentsGot),
|
|
|
|
|
TOOLTIP_REPLIES_GOT_VRE + " (" + numberOfCommentsGot + ")",
|
|
|
|
|
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
|
|
|
|
|
informationBeanRetrieved.getCurrentPageLanding());
|
|
|
|
|
|
|
|
|
|
GWT.log("Number of comments got changed to " + numberOfCommentsGot);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// decrement comments got
|
|
|
|
|
pageBusAdapter.PageBusSubscribe(PageBusEvents.commentsDecrement, null, null, null, null);
|
|
|
|
|
|
|
|
|
|
pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener(){
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getName() {
|
|
|
|
|
return PageBusEvents.commentsDecrement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPageBusSubscriptionCallback(PageBusEvent event) {
|
|
|
|
|
|
|
|
|
|
if(event.getSubject().equals(this.getName())){
|
|
|
|
|
|
|
|
|
|
GWT.log("Decrement number of comments received");
|
|
|
|
|
|
|
|
|
|
// they can't be less than zero...
|
|
|
|
|
numberOfCommentsGot --;
|
|
|
|
|
numberOfCommentsGot = numberOfCommentsGot < 0 ? 0: numberOfCommentsGot;
|
|
|
|
|
if(isRoot)
|
|
|
|
|
activityGot.setComments(
|
|
|
|
|
formattedNumbers(numberOfCommentsGot),
|
|
|
|
|
TOOLTIP_REPLIES_GOT + " (" + numberOfCommentsGot + ")",
|
|
|
|
|
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
|
|
|
|
|
informationBeanRetrieved.getCurrentPageLanding());
|
|
|
|
|
else
|
|
|
|
|
activityGot.setComments(
|
|
|
|
|
formattedNumbers(numberOfCommentsGot),
|
|
|
|
|
TOOLTIP_REPLIES_GOT_VRE + " (" + numberOfCommentsGot + ")",
|
|
|
|
|
ShowUserStatisticAction.COMMENTS_GOT_BY_USER,
|
|
|
|
|
informationBeanRetrieved.getCurrentPageLanding());
|
|
|
|
|
|
|
|
|
|
GWT.log("Number of comments got changed to " + numberOfCommentsGot);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
GWT.log("Subscriptions ok");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (PageBusAdapterException e) {
|
|
|
|
|
GWT.log(e.toString());
|
|
|
|
|