|
|
|
@ -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")
|
|
|
|
|