fixed paste on replies method

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@91611 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-02-14 14:11:09 +00:00
parent 379c6bcee3
commit 3f32513834
7 changed files with 49 additions and 21 deletions

View File

@ -28,7 +28,7 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/news-feed-1.5.0-SNAPSHOT/WEB-INF/classes"/>

View File

@ -4,9 +4,6 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<dependent-module archiveName="user-selection-dialog-1.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/user-selection-dialog/user-selection-dialog">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="wsmail-widget-1.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/wsmail-widget/wsmail-widget">
<dependency-type>uses</dependency-type>
</dependent-module>

View File

@ -87,6 +87,7 @@
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>user-selection-dialog</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>

View File

@ -12,6 +12,7 @@ import com.google.gwt.event.shared.HandlerManager;
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.Event;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
@ -34,7 +35,7 @@ public class AddCommentTemplate extends Composite{
private boolean isEditing = false;
private HTMLPanel commentPanel;
private Comment toEdit;
interface CommentTemplateUiBinder extends UiBinder<Widget, AddCommentTemplate> {
}
/**
@ -72,17 +73,32 @@ public class AddCommentTemplate extends Composite{
mainPanel.setStyleName("single-comment");
commentTextArea.addStyleName("dark-color");
}
@UiField HTMLPanel mainPanel;
@UiField Image avatarImage;
@UiField TextArea commentTextArea;
@UiField Button submitButton;
@UiField Button cancelButton;
public void setFocus() {
commentTextArea.setFocus(true);
}
/**
* paste event overridden
*/
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
switch (event.getTypeInt()) {
case Event.ONPASTE:
if (commentTextArea.getText().equals(COMMENT_TEXT) || commentTextArea.getText().equals(ERROR_UPDATE_TEXT) ) {
commentTextArea.setText("");
commentTextArea.addStyleName("dark-color");
commentTextArea.removeStyleName("error");
}
}
}
@UiHandler("submitButton")
void onSubmitClick(ClickEvent e) {
String userComment = commentTextArea.getText().trim();
@ -104,7 +120,7 @@ public class AddCommentTemplate extends Composite{
this.getWidget().setVisible(false);
owner.setCommentingDisabled(false);
}
/**
* called when pasting. it tries to avoid pasting long non spaced strings
* @param linkToCheck
@ -122,7 +138,7 @@ public class AddCommentTemplate extends Composite{
}
return true;
}
@UiHandler("cancelButton")
void onCancelClick(ClickEvent e) {
this.getWidget().setVisible(false);
@ -143,7 +159,7 @@ public class AddCommentTemplate extends Composite{
commentTextArea.removeStyleName("error");
}
}
@UiHandler("commentTextArea")
void onCommentKeyPress(KeyPressEvent e) {
if (commentTextArea.getText().equals(COMMENT_TEXT) || commentTextArea.getText().equals(ERROR_UPDATE_TEXT) ) {

View File

@ -14,6 +14,7 @@ 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.Event;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
@ -44,6 +45,7 @@ public class SingleComment extends Composite {
public SingleComment(Comment toShow, TweetTemplate owner, boolean isUsers) {
initWidget(uiBinder.createAndBindUi(this));
sinkEvents(Event.ONPASTE);
this.owner = owner;
this.isUsers = isUsers;
this.myComment = toShow;

View File

@ -116,6 +116,7 @@ public class TweetTemplate extends Composite {
public TweetTemplate(boolean displaySingle, UserInfo myUserInfo, EnhancedFeed myFeed, HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this));
this.myUserInfo = myUserInfo;
this.myFeed = myFeed;
isAppFeed = myFeed.getFeed().isApplicationFeed();
Feed feed = myFeed.getFeed();
@ -125,11 +126,14 @@ public class TweetTemplate extends Composite {
this.eventBus = eventBus;
this.isUsers = myFeed.isUsers();
myComments = new ArrayList<SingleComment>();
closeImage.setStyleName("closeImage");
if (isUsers) {
if (isUsers || myUserInfo.isAdmin()) {
closeImage.setStyleName("closeImage");
closeImage.setTitle("Delete");
closeImage.setTitle(myUserInfo.isAdmin() ? "Delete (Administrator Mode)" : "delete");
} else {
closeImage.removeFromParent();
}
openImage.setStyleName("openImage");
openImage.setTitle("Open this feed separately");
//show if the user has already liked this
@ -159,8 +163,11 @@ public class TweetTemplate extends Composite {
else {
// messageSeparator.setVisible(false);
contentArea.setHTML("<a class=\"link\" href=\""+feed.getUri()+"\">"+feed.getFullName()+"</a> " + feedText);
closeImage.setTitle("Delete this Application feed (Administrator Only)");
if (isAppFeed) {
if (myUserInfo.isAdmin())
closeImage.setTitle("Delete this Application feed (Administrator Only)");
else
closeImage.removeFromParent();
try{
String vreName = feed.getVreid().substring(feed.getVreid().lastIndexOf("/")+1);
messageArea.setHTML("<a class=\"link\" href=\""+feed.getUri()+"\"> go App [" +vreName + "]</a>");
@ -228,15 +235,20 @@ public class TweetTemplate extends Composite {
@UiHandler("contentArea")
public void onHover(MouseOverEvent event) {
if (isUsers)
if (isUsers) {
closeImage.addStyleName("uiCloseButton");
GWT.log("this belong to user");
}
openImage.addStyleName("uiOpenButton");
}
@UiHandler("closeImage")
void onDeleteFeedClick(ClickEvent e) {
if (isUsers)
if (isUsers || myUserInfo.isAdmin())
eventBus.fireEvent(new DeleteFeedEvent(this));
else {
GWT.log("not belong to user");
}
}
@UiHandler("openImage")

View File

@ -78,7 +78,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
private boolean withinPortal = false;
private final static int MAX_FEEDS_NO = 30;
private final static int MAX_FEEDS_NO = 45;
public void init() {
store = new DBCassandraAstyanaxImpl();
@ -98,8 +98,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
if (user == null) {
_log.warn("USER IS NULL setting testing user and Running OUTSIDE PORTAL");
user = "test.user";
user = "massimiliano.assante";
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube");
// user = "massimiliano.assante";
// SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube");
}
else {
withinPortal = true;
@ -128,7 +128,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
String accountURL = themeDisplay.getURLMyAccount().toString();
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, false, null);
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, isAdmin(), null);
UserSettings toReturn = new UserSettings(userInfo, getFeedsRefreshTimeInMillis(), session.getScopeName(), getVRELabel(), isInfrastructureScope());
setUserSettingsInSession(toReturn);
return toReturn;