Added support to automatically increment/decrement the number of posts written by the user

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@122500 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-01-25 17:49:31 +00:00
parent 4145a09afd
commit 886b8fc239
6 changed files with 39 additions and 20 deletions

View File

@ -2,6 +2,7 @@
<Changeset component="org.gcube.portlets-user.news-feed.1-13-0" <Changeset component="org.gcube.portlets-user.news-feed.1-13-0"
date="2016-01-22"> date="2016-01-22">
<Change>Multi-attachment supported</Change> <Change>Multi-attachment supported</Change>
<Change>Image preview available</Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.portlets-user.newsfeed.1-12-0" <Changeset component="org.gcube.portlets-user.newsfeed.1-12-0"
date="2015-11-12"> date="2015-11-12">

View File

@ -23,10 +23,10 @@ import com.google.gwt.user.client.ui.RootPanel;
public class NewsFeed implements EntryPoint { public class NewsFeed implements EntryPoint {
private final String UNIQUE_DIV = "newsfeedDIV"; private final String UNIQUE_DIV = "newsfeedDIV";
final PageBusAdapter pageBusAdapter = new PageBusAdapter(); final public static PageBusAdapter pageBusAdapter = new PageBusAdapter();
NewsFeedPanel mainPanel; NewsFeedPanel mainPanel;
public void onModuleLoad() { public void onModuleLoad() {
ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() { ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() {
@Override @Override
@ -38,14 +38,14 @@ public class NewsFeed implements EntryPoint {
} }
}); });
} }
public void init() { public void init() {
mainPanel = new NewsFeedPanel(); mainPanel = new NewsFeedPanel();
mainPanel.setWidth("620px"); mainPanel.setWidth("620px");
RootPanel.get(UNIQUE_DIV).add(mainPanel); RootPanel.get(UNIQUE_DIV).add(mainPanel);
ClientFeed notification = new ClientFeed(); ClientFeed notification = new ClientFeed();
//Subscribe to message and associate subsequent receptions with custom subscriber data //Subscribe to message and associate subsequent receptions with custom subscriber data
try { try {
@ -62,6 +62,9 @@ public class NewsFeed implements EntryPoint {
ClientFeed feed = (ClientFeed)event.getMessage((Jsonizer)GWT.create(ClientFeedJsonizer.class)); ClientFeed feed = (ClientFeed)event.getMessage((Jsonizer)GWT.create(ClientFeedJsonizer.class));
mainPanel.addJustAddedFeed(feed); mainPanel.addJustAddedFeed(feed);
// alert the User statistics widget to increment the number of user's posts (no need to pass info)
pageBusAdapter.PageBusPublish("org.gcube.portal.incrementPostCount", null, null);
} catch (PageBusAdapterException e) { } catch (PageBusAdapterException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -71,5 +74,4 @@ public class NewsFeed implements EntryPoint {
} }
}); });
} }
} }

View File

@ -616,6 +616,7 @@ public class NewsFeedPanel extends Composite {
//insert it also in the model so that the user who created it do not get notified about this new update //insert it also in the model so that the user who created it do not get notified about this new update
allUpdates.add(0, toAdd); allUpdates.add(0, toAdd);
} }
/** /**

View File

@ -10,7 +10,6 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HTMLPanel;

View File

@ -7,12 +7,15 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapterException;
import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder; import org.gcube.portal.databook.client.util.Encoder;
import org.gcube.portal.databook.shared.Attachment; import org.gcube.portal.databook.shared.Attachment;
import org.gcube.portal.databook.shared.Comment; import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed; import org.gcube.portal.databook.shared.Feed;
import org.gcube.portal.databook.shared.UserInfo; import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.newsfeed.client.NewsFeed;
import org.gcube.portlets.user.newsfeed.client.event.AddLikeEvent; import org.gcube.portlets.user.newsfeed.client.event.AddLikeEvent;
import org.gcube.portlets.user.newsfeed.client.event.DeleteFeedEvent; import org.gcube.portlets.user.newsfeed.client.event.DeleteFeedEvent;
import org.gcube.portlets.user.newsfeed.client.event.OpenFeedEvent; import org.gcube.portlets.user.newsfeed.client.event.OpenFeedEvent;
@ -163,7 +166,7 @@ public class TweetTemplate extends Composite {
EnhancedImage enhancedImage = new EnhancedImage( EnhancedImage enhancedImage = new EnhancedImage(
new com.github.gwtbootstrap.client.ui.Image( new com.github.gwtbootstrap.client.ui.Image(
feed.getUriThumbnail()), feed.getUri()),
feed.getLinkTitle(), feed.getLinkTitle(),
feed.getLinkTitle(), feed.getLinkTitle(),
feed.getUri() feed.getUri()
@ -175,12 +178,12 @@ public class TweetTemplate extends Composite {
// set handler on the linkpreviewer image to show this carousel // set handler on the linkpreviewer image to show this carousel
linkPreviewer.onImageClickOpenCarousel(carousel); linkPreviewer.onImageClickOpenCarousel(carousel);
// remove next and prev buttons of the carousel since we have only an image // remove next and prev buttons of the carousel since we have only an image
carousel.hideArrows(); carousel.hideArrows();
} }
// add link preview to the preview panel // add link preview to the preview panel
previewPanel.add(linkPreviewer); previewPanel.add(linkPreviewer);
} }
@ -208,13 +211,13 @@ public class TweetTemplate extends Composite {
// create first attachment previewer and pass it the carousel // create first attachment previewer and pass it the carousel
AttachmentPreviewer firstAttachmentPreviewer = new AttachmentPreviewer(firstAttachment); AttachmentPreviewer firstAttachmentPreviewer = new AttachmentPreviewer(firstAttachment);
// check if it is an image // check if it is an image
if(firstAttachment.getMimeType().contains("image/")){ if(firstAttachment.getMimeType().contains("image/")){
EnhancedImage enhancedImage = new EnhancedImage( EnhancedImage enhancedImage = new EnhancedImage(
new com.github.gwtbootstrap.client.ui.Image( new com.github.gwtbootstrap.client.ui.Image(
feed.getUriThumbnail()), feed.getUri()),
feed.getLinkTitle(), feed.getLinkTitle(),
feed.getLinkTitle(), feed.getLinkTitle(),
feed.getUri() feed.getUri()
@ -224,7 +227,7 @@ public class TweetTemplate extends Composite {
firstAttachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage); firstAttachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage);
} }
// add the first attachment to the panel // add the first attachment to the panel
attachmentPreviewPanel.add(firstAttachmentPreviewer); attachmentPreviewPanel.add(firstAttachmentPreviewer);
@ -237,14 +240,14 @@ public class TweetTemplate extends Composite {
EnhancedImage enhancedImage = new EnhancedImage( EnhancedImage enhancedImage = new EnhancedImage(
new com.github.gwtbootstrap.client.ui.Image( new com.github.gwtbootstrap.client.ui.Image(
otherAttachment.getThumbnailURL()), otherAttachment.getUri()),
otherAttachment.getName(), otherAttachment.getName(),
otherAttachment.getName(), otherAttachment.getName(),
otherAttachment.getUri() otherAttachment.getUri()
); );
listOfEnhancedImages.add(enhancedImage); listOfEnhancedImages.add(enhancedImage);
// pass the carousel // pass the carousel
attachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage); attachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage);
@ -254,7 +257,7 @@ public class TweetTemplate extends Composite {
attachmentPreviewPanel.add(attachmentPreviewer); attachmentPreviewPanel.add(attachmentPreviewer);
} }
// update the carousel's images // update the carousel's images
carousel.updateImages(listOfEnhancedImages); carousel.updateImages(listOfEnhancedImages);
@ -402,8 +405,21 @@ public class TweetTemplate extends Composite {
@UiHandler("closeImage") @UiHandler("closeImage")
void onDeleteFeedClick(ClickEvent e) { void onDeleteFeedClick(ClickEvent e) {
if (isUsers || myUserInfo.isAdmin()) if (isUsers || myUserInfo.isAdmin()){
eventBus.fireEvent(new DeleteFeedEvent(this)); eventBus.fireEvent(new DeleteFeedEvent(this));
if(isUsers){
try {
// alert the User statistics widget to decrement the number of user's posts (no need to pass info)
NewsFeed.pageBusAdapter.PageBusPublish("org.gcube.portal.decrementPostCount", null, null);
} catch (PageBusAdapterException e1) {
GWT.log("Unable to send this notification " + e1.toString());
}
}
}
else { else {
GWT.log("not belong to user"); GWT.log("not belong to user");
} }

View File

@ -124,7 +124,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
*/ */
public String getDevelopmentUser() { public String getDevelopmentUser() {
String user = NewsConstants.TEST_USER; String user = NewsConstants.TEST_USER;
// user = "costantino.perciante"; // user = "costantino.perciante";
return user; return user;
} }
/** /**