diff --git a/.classpath b/.classpath
index 3e21853..f0a1c26 100644
--- a/.classpath
+++ b/.classpath
@@ -1,6 +1,6 @@
-
+
@@ -29,10 +29,10 @@
-
+
-
+
diff --git a/pom.xml b/pom.xml
index 4ae4530..fbb489d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
org.gcube.portlets.user
user-statistics
war
- 1.0.0-SNAPSHOT
+ 1.0.1-SNAPSHOT
User statistics portlet
User statistics portlet shows main user's statistics.
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 79719e7..ea1db88 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
@@ -99,9 +99,24 @@ public class StatisticsPanel extends Composite {
private Label numberOfFeedsLabel;
/**
- * Number of written posts in the actual VRE
+ * Since the number of likes/comments got can be manipulated, we need a class reference
*/
- private long numberOfWrittenPostsVRE;
+ private CommentsAndLikesWidget content;
+
+ /**
+ * Number of written posts
+ */
+ private long numberOfWrittenFeeds;
+
+ /**
+ * Number of likes got
+ */
+ private long numberOfLikesGot;
+
+ /**
+ * Number of likes got
+ */
+ private long numberOfCommentsGot;
/**
* Pagebus to listen for events (coming from the news feed portlet)
@@ -115,7 +130,7 @@ public class StatisticsPanel extends Composite {
initWidget(mainPanel);
// bind pagebus events
- //bind();
+ bind();
// set style of the main panel
mainPanel.setStyleName("user-stats-frame");
@@ -369,13 +384,13 @@ public class StatisticsPanel extends Composite {
else
numberOfFeedsLabel.setTitle("Your posts during the last year in this VRE (" + postsBean.getFeedsNumber() + ").");
- numberOfWrittenPostsVRE = postsBean.getFeedsNumber();
+ numberOfWrittenFeeds = postsBean.getFeedsNumber();
numberOfFeedsLabel.setStyleName("statistic-value");
feeds.appendToPanel(numberOfFeedsLabel);
// updates comments and likes
likesAndComments.clearPanelValues();
- CommentsAndLikesWidget content = new CommentsAndLikesWidget();
+ content = new CommentsAndLikesWidget();
String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png";
if(isRoot)
@@ -391,6 +406,8 @@ public class StatisticsPanel extends Composite {
"Likes you got during the last year in this VRE",
"Likes you got during the last year in this VRE (" + postsBean.getLikesReceived() + ").");
+ numberOfLikesGot = postsBean.getLikesReceived();
+
String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png";
if(isRoot)
content.setComments(
@@ -405,6 +422,7 @@ public class StatisticsPanel extends Composite {
"Post replies you got during the last year in this VRE.",
"Post replies you got during the last year in this VRE (" + postsBean.getCommentsReceived() + ").");
+ numberOfCommentsGot = postsBean.getCommentsReceived();
likesAndComments.appendToPanel(content);
}
@@ -421,7 +439,7 @@ public class StatisticsPanel extends Composite {
private void bind() {
try {
- // increment
+ // increment post number
pageBusAdapter.PageBusSubscribe("org.gcube.portal.incrementPostCount", null, null, null, null);
pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener(){
@@ -434,18 +452,22 @@ public class StatisticsPanel extends Composite {
@Override
public void onPageBusSubscriptionCallback(PageBusEvent event) {
- printJS("Increment number of post message received");
-
- Window.alert("TEST");
+ if(event.getSubject().equals(this.getName())){
- numberOfWrittenPostsVRE ++;
- numberOfFeedsLabel.setText(formattedNumbers(numberOfWrittenPostsVRE));
- numberOfFeedsLabel.setTitle("Your posts during the last year in this VRE (" + numberOfWrittenPostsVRE + ").");
+ GWT.log("Increment number of post message received");
+ numberOfWrittenFeeds ++;
+ numberOfFeedsLabel.setText(formattedNumbers(numberOfWrittenFeeds));
+ if(isRoot)
+ numberOfFeedsLabel.setTitle("Your posts during the last year (" + numberOfWrittenFeeds + ").");
+ else
+ numberOfFeedsLabel.setTitle("Your posts during the last year in this VRE (" + numberOfWrittenFeeds + ").");
+ GWT.log("Number of written posts changed to " + numberOfWrittenFeeds);
+ }
}
});
- // decrement
+ // decrement post number
pageBusAdapter.PageBusSubscribe("org.gcube.portal.decrementPostCount", null, null, null, null);
pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener(){
@@ -458,24 +480,183 @@ public class StatisticsPanel extends Composite {
@Override
public void onPageBusSubscriptionCallback(PageBusEvent event) {
- printJS("Decrement number of post message received");
-
- numberOfWrittenPostsVRE --;
- numberOfFeedsLabel.setText(formattedNumbers(numberOfWrittenPostsVRE));
- numberOfFeedsLabel.setTitle("Your posts during the last year in this VRE (" + numberOfWrittenPostsVRE + ").");
+ if(event.getSubject().equals(this.getName())){
+ GWT.log("Decrement number of post message received");
+ numberOfWrittenFeeds --;
+ numberOfFeedsLabel.setText(formattedNumbers(numberOfWrittenFeeds));
+ if(isRoot)
+ numberOfFeedsLabel.setTitle("Your posts during the last year (" + numberOfWrittenFeeds + ").");
+ else
+ numberOfFeedsLabel.setTitle("Your posts during the last year in this VRE (" + numberOfWrittenFeeds + ").");
+ GWT.log("Number of written posts changed to " + numberOfWrittenFeeds);
+ }
}});
+ // increment likes got number
+ pageBusAdapter.PageBusSubscribe("org.gcube.portal.incrementLikesGot", null, null, null, null);
+
+ pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener(){
+
+ @Override
+ public String getName() {
+ return "org.gcube.portal.incrementLikesGot";
+ }
+
+ @Override
+ public void onPageBusSubscriptionCallback(PageBusEvent event) {
+
+ if(event.getSubject().equals(this.getName())){
+
+ GWT.log("Increment number of likes received");
+
+ numberOfLikesGot ++;
+ String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png";
+
+ if(isRoot)
+ content.setLikes(
+ urlLikesIcon,
+ formattedNumbers(numberOfLikesGot),
+ "Likes you got during the last year.",
+ "Likes you got during the last year (" + numberOfLikesGot + ").");
+ else
+ content.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 + ").");
+
+
+
+ GWT.log("Number of likes got changed to " + numberOfLikesGot);
+ }
+ }
+ });
+
+ // decrement likes got
+ pageBusAdapter.PageBusSubscribe("org.gcube.portal.decrementLikesGot", null, null, null, null);
+
+ pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener(){
+
+ @Override
+ public String getName() {
+ return "org.gcube.portal.decrementLikesGot";
+ }
+
+ @Override
+ public void onPageBusSubscriptionCallback(PageBusEvent event) {
+
+ if(event.getSubject().equals(this.getName())){
+
+ GWT.log("Decrement number of likes received");
+
+ numberOfLikesGot --;
+
+ String urlLikesIcon = GWT.getModuleBaseURL() + "../images/star_blue.png";
+
+ if(isRoot)
+ content.setLikes(
+ urlLikesIcon,
+ formattedNumbers(numberOfLikesGot),
+ "Likes you got during the last year.",
+ "Likes you got during the last year (" + numberOfLikesGot + ").");
+ else
+ content.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 + ").");
+
+ GWT.log("Number of likes got changed to " + numberOfLikesGot);
+ }
+ }
+ });
+
+ // increment comments got number
+ pageBusAdapter.PageBusSubscribe("org.gcube.portal.incrementCommentsGot", null, null, null, null);
+
+ pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener(){
+
+ @Override
+ public String getName() {
+ return "org.gcube.portal.incrementCommentsGot";
+ }
+
+ @Override
+ public void onPageBusSubscriptionCallback(PageBusEvent event) {
+
+ if(event.getSubject().equals(this.getName())){
+
+ GWT.log("Increment number of comments received");
+
+ numberOfCommentsGot ++;
+
+ String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png";
+
+ if(isRoot)
+ content.setComments(
+ urlCommentsIcon,
+ formattedNumbers(numberOfCommentsGot),
+ "Post replies you got during the last year.",
+ "Post replies you got during the last year (" + numberOfCommentsGot + ").");
+ else
+ content.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 + ").");
+
+ GWT.log("Number of comments got changed to " + numberOfCommentsGot);
+ }
+ }
+ });
+
+ // decrement comments got
+ pageBusAdapter.PageBusSubscribe("org.gcube.portal.decrementCommentsGot", null, null, null, null);
+
+ pageBusAdapter.addPageBusSubscriptionCallbackListener(new PageBusListener(){
+
+ @Override
+ public String getName() {
+ return "org.gcube.portal.decrementCommentsGot";
+ }
+
+ @Override
+ public void onPageBusSubscriptionCallback(PageBusEvent event) {
+
+ if(event.getSubject().equals(this.getName())){
+
+ GWT.log("Decrement number of comments received");
+
+ numberOfCommentsGot --;
+
+ String urlCommentsIcon = GWT.getModuleBaseURL() + "../images/comment_edit.png";
+ if(isRoot)
+ content.setComments(
+ urlCommentsIcon,
+ formattedNumbers(numberOfCommentsGot),
+ "Post replies you got during the last year.",
+ "Post replies you got during the last year (" + numberOfCommentsGot + ").");
+ else
+ content.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 + ").");
+
+ GWT.log("Number of comments got changed to " + numberOfCommentsGot);
+ }
+ }
+ });
+
+ GWT.log("Subscriptions ok");
+
} catch (PageBusAdapterException e) {
- printJS(e.toString());
+ GWT.log(e.toString());
}
}
- public static native void printJS(String msg)/*-{
- console.log(msg);
-}-*/;
-
/**
* Show loading image
*/