Bug #16225 mentions and replies http links not working in some email notifications

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@178462 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2019-03-04 16:37:21 +00:00
parent 45c305c16c
commit 83c3b07fc2
2 changed files with 35 additions and 16 deletions

View File

@ -12,12 +12,14 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiFactory;
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.Window.ClosingHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
@ -41,6 +43,8 @@ public class AddCommentTemplate extends Composite {
private boolean isEditing = false;
private HTMLPanel commentPanel;
private Comment toEdit;
private ClosingHandler closingHandler;
private HandlerRegistration handlerRegistration;
@UiField HTMLPanel mainPanel;
@UiField Image avatarImage;
@ -66,16 +70,6 @@ public class AddCommentTemplate extends Composite {
cancelButton.setVisible(false);
commentTextArea.setHeight("30px");
commentTextArea.setContext(owner.getVREContext());
// add onWindowClosing handler to alert the user who didn't share post if really wants to leave
Window.addWindowClosingHandler(new Window.ClosingHandler() {
public void onWindowClosing(Window.ClosingEvent closingEvent) {
String currentText = commentTextArea.getText();
if(!currentText.isEmpty()){
closingEvent.setMessage("Do you really want to leave the page?");
}
}
});
}
/**
* called on edit comment
@ -103,17 +97,19 @@ public class AddCommentTemplate extends Composite {
mainPanel.setStyleName("single-comment");
commentTextArea.addStyleName("comment-dark-color");
submitButton.setText("Edit");
// add onWindowClosing handler to alert the user who didn't share post if really wants to leave
Window.addWindowClosingHandler(new Window.ClosingHandler() {
closingHandler = new Window.ClosingHandler() {
public void onWindowClosing(Window.ClosingEvent closingEvent) {
String currentText = commentTextArea.getText();
if(!currentText.isEmpty()){
closingEvent.setMessage("Do you really want to leave the page?");
}
}
});
};
handlerRegistration = Window.addWindowClosingHandler(closingHandler);
}
/** Used by AddCommentTemplate to instantiate SuperPosedTextArea */
@UiFactory SuperPosedTextArea build() {
@ -123,11 +119,21 @@ public class AddCommentTemplate extends Composite {
public void setFocus() {
commentTextArea.setFocus(true);
submitButton.setVisible(true);
cancelButton.setVisible(true);
//it needs a timer otherwise it won't work
Timer t = new Timer() {
@Override
public void run() {
setCaretPositionToBegin(commentTextArea.getAreaId());
closingHandler = new Window.ClosingHandler() {
public void onWindowClosing(Window.ClosingEvent closingEvent) {
String currentText = commentTextArea.getText();
if(!currentText.isEmpty()){
closingEvent.setMessage("Do you really want to leave the page?");
}
}
};
handlerRegistration = Window.addWindowClosingHandler(closingHandler);
}
};
t.schedule(200);
@ -156,6 +162,8 @@ public class AddCommentTemplate extends Composite {
}
this.getWidget().setVisible(false);
owner.setCommentingDisabled(false);
handlerRegistration.removeHandler();
GWT.log(" handlerRegistration.removeHandler();");
}
/**
@ -185,6 +193,7 @@ public class AddCommentTemplate extends Composite {
SingleComment sc = new SingleComment(toEdit, owner, true);
commentPanel.add(sc);
}
handlerRegistration.removeHandler();
}
@ -196,6 +205,16 @@ public class AddCommentTemplate extends Composite {
commentTextArea.removeStyleName("nwfeed-error");
}
submitButton.setVisible(true);
cancelButton.setVisible(true);
closingHandler = new Window.ClosingHandler() {
public void onWindowClosing(Window.ClosingEvent closingEvent) {
String currentText = commentTextArea.getText();
if(!currentText.isEmpty()){
closingEvent.setMessage("Do you really want to leave the page?");
}
}
};
handlerRegistration = Window.addWindowClosingHandler(closingHandler);
}
@UiHandler("commentTextArea")

View File

@ -671,7 +671,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
//if there are users who liked this post they get notified, asynchronously with this thread
ArrayList<Like> favorites = getAllLikesByPost(feedid);
Thread likesThread = new Thread(new LikeNotificationsThread(commentText, nm, favorites, feedOwnerId, comment.getKey()));
Thread likesThread = new Thread(new LikeNotificationsThread(escapedCommentText, nm, favorites, feedOwnerId, comment.getKey()));
likesThread.start();
//notify the other users who commented this post (excluding the ones above)
@ -724,7 +724,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
toPass.add(new GenericItemBean(userBean.getId(), userBean.getName(), userBean.getAlternativeName(), userBean.getThumbnailURL()));
}
Thread thread = new Thread(new MentionNotificationsThread(comment.getFeedid(), commentText, nm, null, toPass));
Thread thread = new Thread(new MentionNotificationsThread(comment.getFeedid(), escapedCommentText, nm, null, toPass));
thread.start();
}
}