2013-04-04 15:41:17 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-04-11 13:02:15 +02:00
|
|
|
package org.gcube.portlets.user.newsfeed.client.ui;
|
2013-04-04 15:41:17 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2016-08-03 16:29:59 +02:00
|
|
|
import java.util.Date;
|
2015-12-11 14:16:21 +01:00
|
|
|
import java.util.Iterator;
|
2013-04-04 15:41:17 +02:00
|
|
|
|
2016-04-06 16:35:20 +02:00
|
|
|
import org.gcube.common.portal.GCubePortalConstants;
|
2013-04-04 15:41:17 +02:00
|
|
|
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
2013-07-18 19:01:36 +02:00
|
|
|
import org.gcube.portal.databook.client.util.Encoder;
|
2016-01-19 10:25:30 +01:00
|
|
|
import org.gcube.portal.databook.shared.Attachment;
|
2013-04-04 15:41:17 +02:00
|
|
|
import org.gcube.portal.databook.shared.Comment;
|
2016-02-04 18:04:25 +01:00
|
|
|
import org.gcube.portal.databook.shared.EnhancedFeed;
|
2013-04-04 15:41:17 +02:00
|
|
|
import org.gcube.portal.databook.shared.Feed;
|
|
|
|
import org.gcube.portal.databook.shared.UserInfo;
|
|
|
|
import org.gcube.portlets.user.newsfeed.client.event.AddLikeEvent;
|
2018-06-25 17:53:00 +02:00
|
|
|
import org.gcube.portlets.user.newsfeed.client.event.DeletePostEvent;
|
|
|
|
import org.gcube.portlets.user.newsfeed.client.event.OpenPostEvent;
|
2013-04-04 15:41:17 +02:00
|
|
|
import org.gcube.portlets.user.newsfeed.client.event.SeeCommentsEvent;
|
|
|
|
import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEvent;
|
2014-04-08 23:40:13 +02:00
|
|
|
import org.gcube.portlets.user.newsfeed.client.event.UnLikeEvent;
|
2013-04-04 15:41:17 +02:00
|
|
|
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
|
2016-01-22 18:54:30 +01:00
|
|
|
import org.gcube.portlets.widgets.imagepreviewerwidget.client.EnhancedImage;
|
|
|
|
import org.gcube.portlets.widgets.imagepreviewerwidget.client.ui.Carousel;
|
2013-04-04 15:41:17 +02:00
|
|
|
|
2016-09-26 17:07:44 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
2013-04-04 15:41:17 +02:00
|
|
|
import com.google.gwt.core.client.GWT;
|
2016-09-26 17:07:44 +02:00
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
2013-04-04 15:41:17 +02:00
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
|
import com.google.gwt.event.dom.client.MouseOutEvent;
|
|
|
|
import com.google.gwt.event.dom.client.MouseOverEvent;
|
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
|
|
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
|
|
|
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;
|
2016-04-06 16:35:20 +02:00
|
|
|
import com.google.gwt.user.client.Window.Location;
|
2013-04-04 15:41:17 +02:00
|
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
|
|
import com.google.gwt.user.client.ui.Image;
|
2019-04-08 18:30:59 +02:00
|
|
|
import com.google.gwt.user.client.ui.InlineLabel;
|
2013-04-04 15:41:17 +02:00
|
|
|
import com.google.gwt.user.client.ui.Label;
|
|
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
|
|
|
/**
|
2016-01-19 18:43:15 +01:00
|
|
|
* @author Massimiliano Assante at ISTI-CNR
|
|
|
|
* @author Costantino Perciante at ISTI-CNR
|
2013-04-04 15:41:17 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class TweetTemplate extends Composite {
|
|
|
|
|
|
|
|
private static TweetTemplateUiBinder uiBinder = GWT
|
|
|
|
.create(TweetTemplateUiBinder.class);
|
|
|
|
|
|
|
|
interface TweetTemplateUiBinder extends UiBinder<Widget, TweetTemplate> {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static final String loading = GWT.getModuleBaseURL() + "../images/loading-comments.gif";
|
2016-09-26 17:07:44 +02:00
|
|
|
|
2019-05-22 16:12:23 +02:00
|
|
|
private static final int MAX_SHOWTEXT_LENGTH = 612;
|
2013-04-04 15:41:17 +02:00
|
|
|
|
2019-04-08 18:30:59 +02:00
|
|
|
private EnhancedFeed myPost;
|
2013-04-04 15:41:17 +02:00
|
|
|
private UserInfo myUserInfo;
|
|
|
|
|
|
|
|
private HandlerManager eventBus;
|
|
|
|
private ArrayList<SingleComment> myComments;
|
|
|
|
private boolean commentingDisabled = false;
|
|
|
|
private boolean commentsFetched = false;
|
|
|
|
private int totalComments = 0;
|
|
|
|
private HTML showAllComments = new HTML();
|
2019-04-08 18:30:59 +02:00
|
|
|
private boolean isAppPost = false;
|
2017-11-13 15:12:07 +01:00
|
|
|
private HTML submitCommentPreloader = new HTML("<div class=\"more-comment\"><img style=\"padding-right:15px;\"src=\""+ loading +"\" /></div>");
|
2016-01-19 10:25:30 +01:00
|
|
|
private TweetTemplate myInstance;
|
2013-04-08 17:25:37 +02:00
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
// Carousel from the image-previewer widget
|
|
|
|
private Carousel carousel;
|
|
|
|
|
2013-04-04 15:41:17 +02:00
|
|
|
/**
|
|
|
|
* tell if this tweet is belonging to the current user
|
|
|
|
*/
|
|
|
|
private boolean isUsers = false;
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
HTML contentArea;
|
|
|
|
@UiField
|
2019-04-08 18:30:59 +02:00
|
|
|
HTML postOwnerArea;
|
|
|
|
@UiField
|
2013-04-04 15:41:17 +02:00
|
|
|
HTML seeMore;
|
|
|
|
@UiField
|
2019-04-08 18:30:59 +02:00
|
|
|
InlineLabel timeArea;
|
|
|
|
@UiField
|
|
|
|
InlineLabel separator;
|
|
|
|
@UiField
|
|
|
|
InlineLabel vreSourceInMetadata;
|
2013-04-04 15:41:17 +02:00
|
|
|
@UiField
|
|
|
|
HTML likeArea;
|
|
|
|
@UiField
|
|
|
|
HTML commentArea;
|
|
|
|
@UiField
|
|
|
|
Image avatarImage;
|
|
|
|
@UiField
|
2014-04-12 19:13:17 +02:00
|
|
|
AvatarReplacement avatarReplacement;
|
|
|
|
@UiField
|
2013-04-04 15:41:17 +02:00
|
|
|
HTMLPanel mainHTML;
|
|
|
|
@UiField
|
2016-09-26 17:07:44 +02:00
|
|
|
Button likesNo;
|
2013-04-04 15:41:17 +02:00
|
|
|
@UiField
|
2016-09-26 17:07:44 +02:00
|
|
|
Button commentsNo;
|
2013-04-04 15:41:17 +02:00
|
|
|
@UiField
|
|
|
|
VerticalPanel commentsPanel;
|
|
|
|
@UiField
|
|
|
|
HTML closeImage;
|
|
|
|
@UiField
|
2013-07-11 12:19:36 +02:00
|
|
|
HTML openImage;
|
|
|
|
@UiField
|
2013-04-04 15:41:17 +02:00
|
|
|
VerticalPanel previewPanel;
|
2016-01-19 18:43:15 +01:00
|
|
|
@UiField
|
2016-01-20 18:49:31 +01:00
|
|
|
Placeholder attachmentPreviewPanel;
|
2013-04-04 15:41:17 +02:00
|
|
|
@UiField
|
|
|
|
Label messageSeparator;
|
|
|
|
/**
|
|
|
|
* used when fetching tweets from server
|
|
|
|
* @param myUserInfo
|
2019-04-08 18:30:59 +02:00
|
|
|
* @param myPost
|
2013-04-04 15:41:17 +02:00
|
|
|
* @param isUsers
|
2013-04-19 14:24:54 +02:00
|
|
|
* @param displaySingle tells if you're displaying a single fedd or not
|
2013-04-04 15:41:17 +02:00
|
|
|
* @param eventBus
|
|
|
|
*/
|
2019-04-08 18:30:59 +02:00
|
|
|
public TweetTemplate(boolean displaySingle, boolean showTimelineSource, UserInfo myUserInfo, EnhancedFeed myPost, HandlerManager eventBus) {
|
2013-04-04 15:41:17 +02:00
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
2016-09-26 17:07:44 +02:00
|
|
|
commentsNo.getElement().getStyle().setPaddingTop(0, Unit.PX);
|
|
|
|
likesNo.getElement().getStyle().setPaddingTop(0, Unit.PX);
|
2016-09-27 16:24:00 +02:00
|
|
|
likesNo.getElement().getStyle().setPaddingRight(2, Unit.PX);
|
|
|
|
commentsNo.getElement().getStyle().setPaddingRight(2, Unit.PX);
|
|
|
|
likesNo.getElement().getStyle().setPaddingLeft(2, Unit.PX);
|
|
|
|
commentsNo.getElement().getStyle().setPaddingLeft(2, Unit.PX);
|
|
|
|
|
2016-01-19 10:25:30 +01:00
|
|
|
myInstance = this;
|
2013-04-04 15:41:17 +02:00
|
|
|
this.myUserInfo = myUserInfo;
|
2019-04-08 18:30:59 +02:00
|
|
|
this.vreSourceInMetadata.setVisible(false);
|
|
|
|
this.separator.setVisible(false);
|
|
|
|
this.myPost = myPost;
|
|
|
|
isAppPost = myPost.getFeed().isApplicationFeed();
|
2019-05-22 16:12:23 +02:00
|
|
|
Feed post = myPost.getFeed();
|
2013-04-04 15:41:17 +02:00
|
|
|
this.eventBus = eventBus;
|
2019-04-08 18:30:59 +02:00
|
|
|
this.isUsers = myPost.isUsers();
|
2016-01-22 18:54:30 +01:00
|
|
|
this.carousel = new Carousel();
|
2013-04-04 15:41:17 +02:00
|
|
|
myComments = new ArrayList<SingleComment>();
|
2014-03-10 16:47:02 +01:00
|
|
|
|
2014-02-14 15:11:09 +01:00
|
|
|
if (isUsers || myUserInfo.isAdmin()) {
|
2013-04-04 15:41:17 +02:00
|
|
|
closeImage.setStyleName("closeImage");
|
2014-02-14 15:11:09 +01:00
|
|
|
closeImage.setTitle(myUserInfo.isAdmin() ? "Delete (Administrator Mode)" : "delete");
|
|
|
|
} else {
|
|
|
|
closeImage.removeFromParent();
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
2016-01-19 18:43:15 +01:00
|
|
|
|
2016-01-25 15:40:03 +01:00
|
|
|
// if there is one attachment or a link preview, maintain backward compatibility
|
2019-05-22 16:12:23 +02:00
|
|
|
if (post.getUri() != null && post.getUri().compareTo("") != 0 && post.getLinkTitle() != null && post.getLinkTitle().compareTo("") != 0 && !post.isMultiFileUpload()) {
|
2016-01-21 14:29:46 +01:00
|
|
|
|
|
|
|
// hide the attachments panel
|
|
|
|
attachmentPreviewPanel.setVisible(false);
|
2016-01-22 18:54:30 +01:00
|
|
|
|
2019-05-22 16:12:23 +02:00
|
|
|
LinkPreviewer linkPreviewer = new LinkPreviewer(post.getLinkTitle(), post.getLinkDescription(), post.getLinkHost(), post.getUriThumbnail(), post.getUri());
|
2016-01-22 18:54:30 +01:00
|
|
|
|
|
|
|
// enable the image previewer if it is an image (mime)
|
2019-05-22 16:12:23 +02:00
|
|
|
if(post.getLinkHost().contains("image/")){
|
2016-01-22 18:54:30 +01:00
|
|
|
|
|
|
|
ArrayList<EnhancedImage> listOfEnhancedImages;
|
|
|
|
|
|
|
|
EnhancedImage enhancedImage = new EnhancedImage(
|
2019-05-22 16:12:23 +02:00
|
|
|
post.getUri(),
|
|
|
|
post.getLinkTitle() +
|
|
|
|
" (" + post.getLinkDescription() + ", type:" + post.getLinkHost() +")",
|
|
|
|
post.getLinkTitle(),
|
|
|
|
post.getUri()
|
2016-01-22 18:54:30 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
listOfEnhancedImages = new ArrayList<EnhancedImage>();
|
|
|
|
listOfEnhancedImages.add(enhancedImage);
|
|
|
|
carousel.updateImages(listOfEnhancedImages);
|
|
|
|
|
2016-01-26 18:28:08 +01:00
|
|
|
// set handler on the linkpreviewer image to show this carousel and on the image title too
|
2016-01-22 18:54:30 +01:00
|
|
|
linkPreviewer.onImageClickOpenCarousel(carousel);
|
2016-01-26 18:28:08 +01:00
|
|
|
linkPreviewer.onFileNameClickOpenCarousel(carousel);
|
2016-01-25 18:49:31 +01:00
|
|
|
|
2016-01-25 15:40:03 +01:00
|
|
|
// remove next and prev buttons of the carousel since we have only an image
|
|
|
|
carousel.hideArrows();
|
2016-01-22 18:54:30 +01:00
|
|
|
|
|
|
|
}
|
2016-01-25 18:49:31 +01:00
|
|
|
|
2016-01-25 15:40:03 +01:00
|
|
|
// add link preview to the preview panel
|
2016-01-22 18:54:30 +01:00
|
|
|
previewPanel.add(linkPreviewer);
|
2016-01-21 14:29:46 +01:00
|
|
|
}
|
|
|
|
|
2016-01-19 18:43:15 +01:00
|
|
|
// in case there are attachments, we have to fill attachmentPreviewPanel instead of the previewPanel
|
2019-05-22 16:12:23 +02:00
|
|
|
if(post.isMultiFileUpload()){
|
2016-01-20 18:49:31 +01:00
|
|
|
|
2016-01-21 14:29:46 +01:00
|
|
|
// set style to the attachment container
|
|
|
|
attachmentPreviewPanel.setStyleName("attachment-preview-container");
|
|
|
|
|
|
|
|
// hide link preview panel
|
|
|
|
previewPanel.setVisible(false);
|
2016-01-19 18:43:15 +01:00
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
// prepare the carousel
|
|
|
|
ArrayList<EnhancedImage> listOfEnhancedImages = new ArrayList<EnhancedImage>();
|
|
|
|
|
2016-01-19 18:43:15 +01:00
|
|
|
// remember that one attachment is stored in the fields: uri, uriThumbnail, linkTitle, linkDescription, linkHost
|
|
|
|
Attachment firstAttachment = new Attachment(
|
2019-05-22 16:12:23 +02:00
|
|
|
post.getKey(), // it is meaningless but it's needed
|
|
|
|
post.getUri(),
|
|
|
|
post.getLinkTitle(),
|
|
|
|
post.getLinkDescription(),
|
|
|
|
post.getUriThumbnail(),
|
|
|
|
post.getLinkHost());
|
2016-01-19 18:43:15 +01:00
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
// create first attachment previewer and pass it the carousel
|
|
|
|
AttachmentPreviewer firstAttachmentPreviewer = new AttachmentPreviewer(firstAttachment);
|
2016-01-25 18:49:31 +01:00
|
|
|
|
2016-01-28 11:57:31 +01:00
|
|
|
// determine if the left/right arrows must be removed
|
|
|
|
int imagesAvailableInCarousel = 0;
|
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
// check if it is an image
|
|
|
|
if(firstAttachment.getMimeType().contains("image/")){
|
|
|
|
|
|
|
|
EnhancedImage enhancedImage = new EnhancedImage(
|
2019-05-22 16:12:23 +02:00
|
|
|
post.getUri(),
|
|
|
|
post.getLinkTitle() +
|
|
|
|
" (" + post.getLinkDescription() + ", type:" + post.getLinkHost() +")",
|
|
|
|
post.getLinkTitle(),
|
|
|
|
post.getUri()
|
2016-01-22 18:54:30 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
listOfEnhancedImages.add(enhancedImage);
|
2016-01-25 15:40:03 +01:00
|
|
|
firstAttachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage);
|
2016-01-22 18:54:30 +01:00
|
|
|
|
2016-01-28 11:57:31 +01:00
|
|
|
// increment the images
|
|
|
|
imagesAvailableInCarousel ++;
|
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
}
|
2016-01-25 18:49:31 +01:00
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
// add the first attachment to the panel
|
|
|
|
attachmentPreviewPanel.add(firstAttachmentPreviewer);
|
2016-01-19 18:43:15 +01:00
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
// check the others
|
2019-04-08 18:30:59 +02:00
|
|
|
for (Attachment otherAttachment : myPost.getAttachments()) {
|
2016-01-20 18:49:31 +01:00
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
AttachmentPreviewer attachmentPreviewer = new AttachmentPreviewer(otherAttachment);
|
|
|
|
|
|
|
|
if(otherAttachment.getMimeType().contains("image/")){
|
|
|
|
|
|
|
|
EnhancedImage enhancedImage = new EnhancedImage(
|
2016-11-21 12:30:12 +01:00
|
|
|
otherAttachment.getUri(),
|
2016-01-29 11:44:11 +01:00
|
|
|
otherAttachment.getName() +
|
2019-05-22 16:12:23 +02:00
|
|
|
" (" + otherAttachment.getDescription() + ", type:" + post.getLinkHost() +")",
|
2016-01-22 18:54:30 +01:00
|
|
|
otherAttachment.getName(),
|
|
|
|
otherAttachment.getUri()
|
|
|
|
);
|
|
|
|
|
|
|
|
listOfEnhancedImages.add(enhancedImage);
|
2016-01-25 18:49:31 +01:00
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
// pass the carousel
|
2016-01-25 15:40:03 +01:00
|
|
|
attachmentPreviewer.onImageClickOpenCarousel(carousel, enhancedImage);
|
2016-01-22 18:54:30 +01:00
|
|
|
|
2016-01-28 11:57:31 +01:00
|
|
|
// increment the images
|
|
|
|
imagesAvailableInCarousel ++;
|
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
}
|
|
|
|
|
2016-01-20 18:49:31 +01:00
|
|
|
// try to build the attachment viewer
|
2016-01-22 18:54:30 +01:00
|
|
|
attachmentPreviewPanel.add(attachmentPreviewer);
|
2016-01-19 18:43:15 +01:00
|
|
|
|
2016-01-28 12:04:42 +01:00
|
|
|
// hide arrows if there is no more than 1 image
|
2016-01-28 11:57:31 +01:00
|
|
|
if(imagesAvailableInCarousel <= 1)
|
|
|
|
carousel.hideArrows();
|
|
|
|
|
2016-01-19 10:25:30 +01:00
|
|
|
}
|
2016-01-25 18:49:31 +01:00
|
|
|
|
2016-01-22 18:54:30 +01:00
|
|
|
// update the carousel's images
|
|
|
|
carousel.updateImages(listOfEnhancedImages);
|
2016-01-21 14:29:46 +01:00
|
|
|
|
2016-01-20 18:49:31 +01:00
|
|
|
// invoke append label
|
|
|
|
attachmentPreviewPanel.appendShowMoreLabel();
|
2016-01-19 10:25:30 +01:00
|
|
|
}
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2013-07-11 12:19:36 +02:00
|
|
|
openImage.setStyleName("openImage");
|
|
|
|
openImage.setTitle("Open this feed separately");
|
2014-04-08 23:40:13 +02:00
|
|
|
//show if the user has already liked this or not
|
2019-04-08 18:30:59 +02:00
|
|
|
setFavoritedUI(myPost.isLiked());
|
2014-04-12 19:13:17 +02:00
|
|
|
|
2013-04-04 15:41:17 +02:00
|
|
|
commentArea.setHTML("<a>" + NewsFeedPanel.COMMENT_LABEL + "</a>");
|
|
|
|
|
2019-05-22 16:12:23 +02:00
|
|
|
String postText = post.getDescription();
|
|
|
|
String descWithoutHTML = new HTML(postText).getText();
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2019-05-22 16:12:23 +02:00
|
|
|
if ( (! postText.startsWith("<span")) && descWithoutHTML.length() > MAX_SHOWTEXT_LENGTH && !displaySingle) {
|
|
|
|
final int TEXT_TO_SHOW_LENGHT = (descWithoutHTML.length() < 600) ? (postText.length() - (postText.length() / 3)) : 600;
|
|
|
|
postText = postText.substring(0, TEXT_TO_SHOW_LENGHT) + "...";
|
2013-04-04 15:41:17 +02:00
|
|
|
seeMore.setHTML("<a class=\"seemore\"> See More </a>");
|
|
|
|
}
|
2014-04-12 19:13:17 +02:00
|
|
|
|
2019-05-22 16:12:23 +02:00
|
|
|
avatarImage.setUrl(post.getThumbnailURL());
|
2019-04-08 18:30:59 +02:00
|
|
|
avatarImage.setPixelSize(40, 40);
|
2014-04-12 19:13:17 +02:00
|
|
|
|
2014-04-10 17:45:50 +02:00
|
|
|
//replace the < & and >
|
2019-05-22 16:12:23 +02:00
|
|
|
postText = postText.replaceAll("<","<").replaceAll(">",">");
|
|
|
|
postText = postText.replaceAll("&","&");
|
2016-08-03 16:29:59 +02:00
|
|
|
|
2017-03-01 12:09:16 +01:00
|
|
|
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + NewsFeedPanel.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
|
2018-02-09 12:07:09 +01:00
|
|
|
|
2019-04-08 18:30:59 +02:00
|
|
|
|
|
|
|
|
2019-05-22 16:12:23 +02:00
|
|
|
if (showTimelineSource && post.getVreid() != null && post.getVreid().compareTo("") != 0) {
|
2019-04-08 18:30:59 +02:00
|
|
|
this.vreSourceInMetadata.setVisible(true);
|
|
|
|
this.separator.setVisible(true);
|
2019-05-22 16:12:23 +02:00
|
|
|
String vreName = post.getVreid().substring(post.getVreid().lastIndexOf("/")+1);
|
2019-04-08 18:30:59 +02:00
|
|
|
vreSourceInMetadata.setText(vreName);
|
|
|
|
vreSourceInMetadata.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
Location.assign("/group/"+vreName.toLowerCase());
|
|
|
|
}
|
|
|
|
});
|
2018-02-09 12:07:09 +01:00
|
|
|
}
|
2019-04-08 18:30:59 +02:00
|
|
|
|
|
|
|
if (! isAppPost) {
|
2016-08-03 16:29:59 +02:00
|
|
|
// sharePostArea.setHTML("<a>" + NewsFeedPanel.SHARE_FWD_LABEL + "</a>");
|
2019-04-08 18:30:59 +02:00
|
|
|
postOwnerArea.setHTML("<a class=\"linkProfile\" href=\""+profilePageURL
|
2013-07-18 19:01:36 +02:00
|
|
|
+"?"+
|
|
|
|
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
|
2019-05-22 16:12:23 +02:00
|
|
|
Encoder.encode(post.getEntityId())+"\">"+post.getFullName()+"</a>");
|
|
|
|
contentArea.setHTML(postText);
|
2014-04-12 19:13:17 +02:00
|
|
|
|
|
|
|
//check if the user has his own avatar
|
2019-05-22 16:12:23 +02:00
|
|
|
if (post.getThumbnailURL().contains("img_id=0") || !post.getThumbnailURL().contains("?")) { //it means no avatar is set
|
2014-04-12 19:13:17 +02:00
|
|
|
avatarImage.setVisible(false);
|
|
|
|
String f = "A";
|
|
|
|
String s = "Z";
|
2019-05-22 16:12:23 +02:00
|
|
|
if (post.getFullName() != null) {
|
|
|
|
String[] parts = post.getFullName().split("\\s");
|
2014-04-12 19:13:17 +02:00
|
|
|
if (parts.length > 0) {
|
|
|
|
f = parts[0].toUpperCase();
|
|
|
|
s = parts[parts.length-1].toUpperCase();
|
|
|
|
} else {
|
2019-05-22 16:12:23 +02:00
|
|
|
f = post.getFullName().substring(0,1);
|
|
|
|
s = post.getFullName().substring(1,2);
|
2014-04-12 19:13:17 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-22 16:12:23 +02:00
|
|
|
avatarReplacement.setInitials(post.getEntityId(), f, s);
|
2014-04-12 19:13:17 +02:00
|
|
|
avatarReplacement.setVisible(true);
|
|
|
|
}
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// messageSeparator.setVisible(false);
|
2019-05-22 16:12:23 +02:00
|
|
|
postOwnerArea.setHTML("<a class=\"linkProfile\" href=\""+post.getUri()+"\">"+post.getFullName()+"</a>");
|
|
|
|
contentArea.setHTML(postText);
|
2019-04-08 18:30:59 +02:00
|
|
|
|
|
|
|
if (isAppPost) {
|
2014-02-14 15:11:09 +01:00
|
|
|
if (myUserInfo.isAdmin())
|
|
|
|
closeImage.setTitle("Delete this Application feed (Administrator Only)");
|
|
|
|
else
|
|
|
|
closeImage.removeFromParent();
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-12 19:13:17 +02:00
|
|
|
|
2013-04-04 15:41:17 +02:00
|
|
|
try {
|
2016-08-03 16:29:59 +02:00
|
|
|
Date now = new Date();
|
|
|
|
String formattedTime;
|
|
|
|
// TODO java.util.Calendar is not yet available in GWT
|
2019-05-22 16:12:23 +02:00
|
|
|
if(now.getYear() != post.getTime().getYear())
|
|
|
|
formattedTime = DateTimeFormat.getFormat("MMMM dd yyyy, h:mm a").format(post.getTime());
|
2016-08-03 16:29:59 +02:00
|
|
|
else
|
2019-05-22 16:12:23 +02:00
|
|
|
formattedTime = DateTimeFormat.getFormat("MMMM dd, h:mm a").format(post.getTime());
|
2016-08-03 16:29:59 +02:00
|
|
|
|
2019-04-08 18:30:59 +02:00
|
|
|
timeArea.setText(formattedTime);
|
2019-05-22 16:12:23 +02:00
|
|
|
String formattedTimeWithYear = DateTimeFormat.getFormat("dd MMMM yyyy h:mm a ").format(post.getTime());
|
2015-10-23 17:33:28 +02:00
|
|
|
timeArea.setTitle(formattedTimeWithYear);
|
2019-05-22 16:12:23 +02:00
|
|
|
if (! post.getCommentsNo().equals("0")) {
|
2016-09-26 17:07:44 +02:00
|
|
|
commentsNo.setVisible(true);
|
2019-05-22 16:12:23 +02:00
|
|
|
commentsNo.setText(post.getCommentsNo());
|
|
|
|
commentsNo.setTitle(post.getCommentsNo() + " people commented this.");
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
2019-05-22 16:12:23 +02:00
|
|
|
if (! post.getLikesNo().equals("0")) {
|
2016-09-26 17:07:44 +02:00
|
|
|
likesNo.setVisible(true);
|
2019-05-22 16:12:23 +02:00
|
|
|
likesNo.setText(post.getLikesNo());
|
2013-04-04 15:41:17 +02:00
|
|
|
likesNo.setTitle("Show People who have " + NewsFeedPanel.LIKED_LABEL + " this.");
|
|
|
|
}
|
2019-05-22 16:12:23 +02:00
|
|
|
totalComments = Integer.parseInt(post.getCommentsNo());
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
catch (NumberFormatException e) {
|
|
|
|
totalComments = 0;
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
2019-04-08 18:30:59 +02:00
|
|
|
timeArea.setText("just now");
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
commentsPanel.setStyleName("commentsPanel");
|
2019-04-08 18:30:59 +02:00
|
|
|
if (myPost.getComments() != null && myPost.getComments().size() > 0) {
|
2013-04-19 14:24:54 +02:00
|
|
|
if (totalComments > 2 && !displaySingle) {
|
2013-04-04 15:41:17 +02:00
|
|
|
showAllComments = getShowAllCommentsLink(totalComments);
|
|
|
|
commentsPanel.add(showAllComments);
|
2016-09-26 17:07:44 +02:00
|
|
|
commentsNo.setVisible(true);
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
2019-04-08 18:30:59 +02:00
|
|
|
for (Comment comment : myPost.getComments()) {
|
2015-12-11 14:16:21 +01:00
|
|
|
addComment(new SingleComment(comment, this, (comment.getUserid().equals(myUserInfo.getUsername()))));
|
2014-04-11 00:49:53 +02:00
|
|
|
}
|
2014-04-11 12:50:23 +02:00
|
|
|
showAddCommentForm(false);
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* used when getting tweets from the client
|
|
|
|
* @param myUserInfo
|
|
|
|
* @param feed
|
|
|
|
* @param eventBus
|
|
|
|
* @param hidden
|
|
|
|
*/
|
|
|
|
public TweetTemplate(UserInfo myUserInfo, EnhancedFeed feed, HandlerManager eventBus, boolean hidden) {
|
2014-03-10 16:47:02 +01:00
|
|
|
this(false, false, myUserInfo, feed, eventBus);
|
2013-04-04 15:41:17 +02:00
|
|
|
contentArea.getElement().getParentElement().getParentElement().setClassName("div-table-col content hidden");
|
|
|
|
}
|
|
|
|
|
|
|
|
@UiHandler("contentArea")
|
|
|
|
public void onHover(MouseOutEvent event) {
|
|
|
|
if (isUsers)
|
|
|
|
closeImage.removeStyleName("uiCloseButton");
|
2013-07-11 12:19:36 +02:00
|
|
|
openImage.removeStyleName("uiOpenButton");
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@UiHandler("contentArea")
|
|
|
|
public void onHover(MouseOverEvent event) {
|
2014-02-14 15:11:09 +01:00
|
|
|
if (isUsers) {
|
2013-04-04 15:41:17 +02:00
|
|
|
closeImage.addStyleName("uiCloseButton");
|
2014-02-14 15:11:09 +01:00
|
|
|
GWT.log("this belong to user");
|
|
|
|
}
|
2013-07-11 12:19:36 +02:00
|
|
|
openImage.addStyleName("uiOpenButton");
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@UiHandler("closeImage")
|
|
|
|
void onDeleteFeedClick(ClickEvent e) {
|
2016-01-25 18:49:31 +01:00
|
|
|
if (isUsers || myUserInfo.isAdmin()){
|
2018-06-25 17:53:00 +02:00
|
|
|
eventBus.fireEvent(new DeletePostEvent(this));
|
2016-01-25 18:49:31 +01:00
|
|
|
}
|
2014-02-14 15:11:09 +01:00
|
|
|
else {
|
|
|
|
GWT.log("not belong to user");
|
|
|
|
}
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
2014-03-10 16:47:02 +01:00
|
|
|
|
2013-07-11 12:19:36 +02:00
|
|
|
@UiHandler("openImage")
|
|
|
|
void onOpenFeedClick(ClickEvent e) {
|
2018-06-25 17:53:00 +02:00
|
|
|
eventBus.fireEvent(new OpenPostEvent(this));
|
2013-07-11 12:19:36 +02:00
|
|
|
}
|
2014-03-10 16:47:02 +01:00
|
|
|
|
|
|
|
|
2013-04-04 15:41:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
@UiHandler("seeMore")
|
|
|
|
void onSeeMoreClick(ClickEvent e) {
|
2019-05-22 16:12:23 +02:00
|
|
|
String postText = myPost.getFeed().getDescription();
|
2014-11-18 18:23:58 +01:00
|
|
|
//replace the < & and >
|
2019-05-22 16:12:23 +02:00
|
|
|
postText = postText.replaceAll("<","<").replaceAll(">",">");
|
|
|
|
postText = postText.replaceAll("&","&");
|
2014-03-10 16:47:02 +01:00
|
|
|
|
2019-05-22 16:12:23 +02:00
|
|
|
contentArea.setHTML(postText);
|
2013-04-04 15:41:17 +02:00
|
|
|
seeMore.setHTML("");
|
|
|
|
}
|
|
|
|
|
2014-04-08 23:40:13 +02:00
|
|
|
private void setFavoritedUI(boolean favorited) {
|
|
|
|
if (favorited) {
|
|
|
|
likeArea.setHTML("<a style=\"color:#6E8CCC;\">" + NewsFeedPanel.LIKED_LABEL + "</a>");
|
2016-09-01 14:35:31 +02:00
|
|
|
likeArea.setTitle("Unlike this");
|
2014-04-08 23:40:13 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
likeArea.setHTML("<a>" + NewsFeedPanel.LIKE_LABEL + "</a>");
|
|
|
|
}
|
|
|
|
}
|
2014-04-12 19:13:17 +02:00
|
|
|
|
|
|
|
|
2013-04-04 15:41:17 +02:00
|
|
|
|
|
|
|
@UiHandler("likeArea")
|
|
|
|
void onLikeClick(ClickEvent e) {
|
2014-04-08 23:40:13 +02:00
|
|
|
//if is not liked
|
2013-04-04 15:41:17 +02:00
|
|
|
if (!likeArea.getText().equals(NewsFeedPanel.LIKED_LABEL)) {
|
|
|
|
try {
|
2019-04-08 18:30:59 +02:00
|
|
|
int cur = Integer.parseInt(myPost.getFeed().getLikesNo());
|
2013-04-04 15:41:17 +02:00
|
|
|
cur++;
|
|
|
|
if (cur == 1) {
|
2019-04-08 18:30:59 +02:00
|
|
|
myPost.getFeed().setLikesNo("1");
|
2016-09-26 17:07:44 +02:00
|
|
|
likesNo.setText("1");
|
2013-04-04 15:41:17 +02:00
|
|
|
likesNo.setTitle("People who have " + NewsFeedPanel.LIKED_LABEL + " this");
|
2016-09-26 17:07:44 +02:00
|
|
|
likesNo.setVisible(true);
|
2013-04-04 15:41:17 +02:00
|
|
|
} else {
|
2019-04-08 18:30:59 +02:00
|
|
|
myPost.getFeed().setLikesNo(""+cur);
|
2016-09-26 17:07:44 +02:00
|
|
|
likesNo.setText(""+cur);
|
|
|
|
likesNo.setVisible(true);
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
2019-04-08 18:30:59 +02:00
|
|
|
eventBus.fireEvent(new AddLikeEvent(this, myPost.getFeed().getKey()));
|
2014-04-08 23:40:13 +02:00
|
|
|
setFavoritedUI(true);
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
catch (NumberFormatException ex) {
|
|
|
|
likeArea.setHTML("Error on the server");
|
|
|
|
}
|
2014-04-08 23:40:13 +02:00
|
|
|
} else {
|
|
|
|
//it is liked
|
2019-04-08 18:30:59 +02:00
|
|
|
int cur = Integer.parseInt(myPost.getFeed().getLikesNo());
|
2014-04-08 23:40:13 +02:00
|
|
|
cur--;
|
|
|
|
if (cur == 0) {
|
2019-04-08 18:30:59 +02:00
|
|
|
myPost.getFeed().setLikesNo("0");
|
2016-09-26 17:07:44 +02:00
|
|
|
likesNo.setText("");
|
|
|
|
likesNo.setVisible(false);
|
2014-04-08 23:40:13 +02:00
|
|
|
likesNo.setTitle("");
|
|
|
|
} else {
|
2019-04-08 18:30:59 +02:00
|
|
|
myPost.getFeed().setLikesNo(""+cur);
|
2016-09-26 17:07:44 +02:00
|
|
|
likesNo.setText(""+cur);
|
|
|
|
likesNo.setVisible(true);
|
2014-04-08 23:40:13 +02:00
|
|
|
}
|
2019-04-08 18:30:59 +02:00
|
|
|
eventBus.fireEvent(new UnLikeEvent(this, myPost.getFeed().getKey()));
|
2014-04-08 23:40:13 +02:00
|
|
|
setFavoritedUI(false);
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@UiHandler("commentArea")
|
|
|
|
void onAddCommentClick(ClickEvent e) {
|
|
|
|
if (! commentingDisabled) {
|
|
|
|
if (! commentsFetched && totalComments > 2) { //if so, need to load all comments before adding a comment
|
|
|
|
fireSeeComments(true);
|
|
|
|
}
|
2014-04-11 00:49:53 +02:00
|
|
|
else {
|
2014-04-11 12:50:23 +02:00
|
|
|
showAddCommentForm(true);
|
2014-04-11 00:49:53 +02:00
|
|
|
}
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
GWT.log("Commenting disabled");
|
|
|
|
}
|
|
|
|
|
2014-04-11 12:50:23 +02:00
|
|
|
public void showAddCommentForm(boolean focus) {
|
2013-04-04 15:41:17 +02:00
|
|
|
final AddCommentTemplate toAdd = new AddCommentTemplate(this, myUserInfo, eventBus);
|
|
|
|
commentsPanel.add(toAdd);
|
|
|
|
commentingDisabled = true;
|
|
|
|
final Timer t = new Timer() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2014-04-11 12:50:23 +02:00
|
|
|
toAdd.setStyleName("comment-show");
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
};
|
2014-04-11 12:50:23 +02:00
|
|
|
if (focus)
|
|
|
|
toAdd.setFocus();
|
2013-04-04 15:41:17 +02:00
|
|
|
t.schedule(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
private HTML getShowAllCommentsLink(int commentsNo) {
|
|
|
|
final HTML toReturn = new HTML("<div class=\"more-comment\"><a class=\"link\" style=\"font-size:11px;\">Show all " + commentsNo + " comments<a/></div>");
|
|
|
|
toReturn.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
fireSeeComments(false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return toReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void fireSeeComments(boolean commentForm2Add) {
|
|
|
|
eventBus.fireEvent(new SeeCommentsEvent(this, commentForm2Add));
|
|
|
|
}
|
|
|
|
|
|
|
|
@UiHandler("likesNo")
|
|
|
|
void onSeeLikes(ClickEvent e) {
|
2019-04-08 18:30:59 +02:00
|
|
|
eventBus.fireEvent(new SeeLikesEvent(myPost.getFeed().getKey()));
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
2016-09-26 17:07:44 +02:00
|
|
|
|
2013-04-04 15:41:17 +02:00
|
|
|
@UiHandler("commentsNo")
|
|
|
|
void onSeeComments(ClickEvent e) {
|
|
|
|
fireSeeComments(false);
|
2016-09-26 17:07:44 +02:00
|
|
|
}
|
2013-04-04 15:41:17 +02:00
|
|
|
|
|
|
|
public void setcontentAreaStyle(String cssclass) {
|
|
|
|
contentArea.getElement().getParentElement().getParentElement().setClassName("div-table-col content visible");
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isCommenting() {
|
|
|
|
return commentingDisabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCommentingDisabled(boolean commenting) {
|
|
|
|
this.commentingDisabled = commenting;
|
|
|
|
}
|
|
|
|
public String getFeedKey() {
|
2019-04-08 18:30:59 +02:00
|
|
|
return myPost.getFeed().getKey();
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void remove(Widget w) {
|
|
|
|
mainHTML.remove(w);
|
|
|
|
}
|
|
|
|
|
2015-12-11 14:16:21 +01:00
|
|
|
public void addComment(SingleComment comment) {
|
|
|
|
commentsPanel.add(comment);
|
2013-04-04 15:41:17 +02:00
|
|
|
myComments.add(comment);
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2017-11-13 15:12:07 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param show true to show a preloader, false to hide it.
|
|
|
|
* display a preloader userful when the user is wating for the comment operation to be confirmed by the server
|
|
|
|
*/
|
|
|
|
public void showCommentingPreloader(boolean show) {
|
|
|
|
if (show)
|
|
|
|
commentsPanel.add(submitCommentPreloader);
|
|
|
|
else
|
|
|
|
commentsPanel.remove(submitCommentPreloader);
|
|
|
|
|
2015-12-11 14:16:21 +01:00
|
|
|
}
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2015-12-11 14:16:21 +01:00
|
|
|
public void updateSingleComment(Comment edited, HTMLPanel commentPanel){
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2015-12-11 14:16:21 +01:00
|
|
|
commentPanel.clear();
|
|
|
|
SingleComment sc = new SingleComment(edited, this, true);
|
|
|
|
commentPanel.add(sc);
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2015-12-11 14:16:21 +01:00
|
|
|
// replace the new SingleComment in the list
|
|
|
|
int index = 0;
|
|
|
|
Iterator<SingleComment> iterator = this.myComments.iterator();
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2015-12-11 14:16:21 +01:00
|
|
|
for (;iterator.hasNext();) {
|
|
|
|
SingleComment singleComment = (SingleComment) iterator.next();
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2015-12-11 14:16:21 +01:00
|
|
|
if(singleComment.getCommentKey().equals(edited.getKey())){
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2015-12-11 14:16:21 +01:00
|
|
|
iterator.remove();
|
|
|
|
this.myComments.add(index, sc);
|
|
|
|
break;
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2015-12-11 14:16:21 +01:00
|
|
|
}
|
|
|
|
index ++;
|
|
|
|
}
|
2016-01-19 14:35:27 +01:00
|
|
|
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void clearComments() {
|
|
|
|
myComments.clear();
|
|
|
|
commentsPanel.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void showLoadingComments() {
|
|
|
|
showAllComments.setHTML("<div class=\"more-comment\"><img style=\"padding-right:15px;\"src=\""+ loading +"\" /></div>");
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isCommentsFetched() {
|
|
|
|
return commentsFetched;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCommentsFetched(boolean commentsFetched) {
|
|
|
|
this.commentsFetched = commentsFetched;
|
|
|
|
}
|
|
|
|
public HandlerManager getEventBus() {
|
|
|
|
return eventBus;
|
|
|
|
}
|
|
|
|
public void updateCommentsNumberCount() {
|
|
|
|
if (myComments.size() == 1) {
|
2016-09-26 17:07:44 +02:00
|
|
|
//commentsNo.setStyleName("show-comments-number");
|
2013-04-04 15:41:17 +02:00
|
|
|
commentsNo.setTitle("Persons who have commented this.");
|
|
|
|
}
|
2016-09-26 17:07:44 +02:00
|
|
|
//commentsNo.setHTML(commentIcon.getElement().toString()+"<span> </span>"+myComments.size());
|
|
|
|
commentsNo.setText(""+myComments.size());
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
|
|
|
public UserInfo getMyUserInfo() {
|
|
|
|
return myUserInfo;
|
|
|
|
}
|
2014-03-10 16:47:02 +01:00
|
|
|
|
2013-04-04 15:41:17 +02:00
|
|
|
public String getMyFeedUserId() {
|
2019-04-08 18:30:59 +02:00
|
|
|
return myPost.getFeed().getEntityId();
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
2014-03-10 16:47:02 +01:00
|
|
|
|
2013-04-04 15:41:17 +02:00
|
|
|
public String getMyFeedText() {
|
2019-04-08 18:30:59 +02:00
|
|
|
return myPost.getFeed().getDescription();
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|
2014-03-10 16:47:02 +01:00
|
|
|
|
2013-04-08 17:25:37 +02:00
|
|
|
public boolean isAppFeed() {
|
2019-04-08 18:30:59 +02:00
|
|
|
return isAppPost;
|
2013-04-08 17:25:37 +02:00
|
|
|
}
|
2016-01-26 18:28:08 +01:00
|
|
|
|
|
|
|
public boolean isUser() {
|
|
|
|
return isUsers;
|
|
|
|
}
|
2016-01-28 15:28:06 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of comments this post has
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public int numberOfComments(){
|
|
|
|
return myComments.size();
|
|
|
|
}
|
2018-06-11 19:00:23 +02:00
|
|
|
/**
|
|
|
|
* Returns the context of the Post
|
|
|
|
* @return the context (scope) of the Post
|
|
|
|
*/
|
|
|
|
public String getVREContext() {
|
2019-04-08 18:30:59 +02:00
|
|
|
return this.myPost.getFeed().getVreid();
|
2018-06-11 19:00:23 +02:00
|
|
|
}
|
|
|
|
|
2016-01-28 15:28:06 +01:00
|
|
|
/**
|
|
|
|
* Returns the number of likes this post has
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public int numberOfLikes(){
|
|
|
|
|
|
|
|
// not so easy
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
try{
|
2016-01-29 17:23:35 +01:00
|
|
|
|
2016-09-26 17:07:44 +02:00
|
|
|
ret = Integer.parseInt(likesNo.getText());
|
2016-01-28 15:28:06 +01:00
|
|
|
|
|
|
|
}catch(NumberFormatException e){
|
|
|
|
|
|
|
|
GWT.log(e.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-04-04 15:41:17 +02:00
|
|
|
}
|