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"
date="2016-01-22">
<Change>Multi-attachment supported</Change>
<Change>Image preview available</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.newsfeed.1-12-0"
date="2015-11-12">

View File

@ -23,10 +23,10 @@ import com.google.gwt.user.client.ui.RootPanel;
public class NewsFeed implements EntryPoint {
private final String UNIQUE_DIV = "newsfeedDIV";
final PageBusAdapter pageBusAdapter = new PageBusAdapter();
final public static PageBusAdapter pageBusAdapter = new PageBusAdapter();
NewsFeedPanel mainPanel;
public void onModuleLoad() {
ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() {
@Override
@ -38,14 +38,14 @@ public class NewsFeed implements EntryPoint {
}
});
}
public void init() {
mainPanel = new NewsFeedPanel();
mainPanel.setWidth("620px");
RootPanel.get(UNIQUE_DIV).add(mainPanel);
ClientFeed notification = new ClientFeed();
//Subscribe to message and associate subsequent receptions with custom subscriber data
try {
@ -62,6 +62,9 @@ public class NewsFeed implements EntryPoint {
ClientFeed feed = (ClientFeed)event.getMessage((Jsonizer)GWT.create(ClientFeedJsonizer.class));
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) {
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
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.UiHandler;
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.HTML;
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.List;
import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapterException;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder;
import org.gcube.portal.databook.shared.Attachment;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
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.DeleteFeedEvent;
import org.gcube.portlets.user.newsfeed.client.event.OpenFeedEvent;
@ -163,7 +166,7 @@ public class TweetTemplate extends Composite {
EnhancedImage enhancedImage = new EnhancedImage(
new com.github.gwtbootstrap.client.ui.Image(
feed.getUriThumbnail()),
feed.getUri()),
feed.getLinkTitle(),
feed.getLinkTitle(),
feed.getUri()
@ -175,12 +178,12 @@ public class TweetTemplate extends Composite {
// set handler on the linkpreviewer image to show this carousel
linkPreviewer.onImageClickOpenCarousel(carousel);
// remove next and prev buttons of the carousel since we have only an image
carousel.hideArrows();
}
// add link preview to the preview panel
previewPanel.add(linkPreviewer);
}
@ -208,13 +211,13 @@ public class TweetTemplate extends Composite {
// create first attachment previewer and pass it the carousel
AttachmentPreviewer firstAttachmentPreviewer = new AttachmentPreviewer(firstAttachment);
// check if it is an image
if(firstAttachment.getMimeType().contains("image/")){
EnhancedImage enhancedImage = new EnhancedImage(
new com.github.gwtbootstrap.client.ui.Image(
feed.getUriThumbnail()),
feed.getUri()),
feed.getLinkTitle(),
feed.getLinkTitle(),
feed.getUri()
@ -224,7 +227,7 @@ public class TweetTemplate extends Composite {
firstAttachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage);
}
// add the first attachment to the panel
attachmentPreviewPanel.add(firstAttachmentPreviewer);
@ -237,14 +240,14 @@ public class TweetTemplate extends Composite {
EnhancedImage enhancedImage = new EnhancedImage(
new com.github.gwtbootstrap.client.ui.Image(
otherAttachment.getThumbnailURL()),
otherAttachment.getUri()),
otherAttachment.getName(),
otherAttachment.getName(),
otherAttachment.getUri()
);
listOfEnhancedImages.add(enhancedImage);
// pass the carousel
attachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage);
@ -254,7 +257,7 @@ public class TweetTemplate extends Composite {
attachmentPreviewPanel.add(attachmentPreviewer);
}
// update the carousel's images
carousel.updateImages(listOfEnhancedImages);
@ -402,8 +405,21 @@ public class TweetTemplate extends Composite {
@UiHandler("closeImage")
void onDeleteFeedClick(ClickEvent e) {
if (isUsers || myUserInfo.isAdmin())
if (isUsers || myUserInfo.isAdmin()){
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 {
GWT.log("not belong to user");
}

View File

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