refactored for pickitem widget

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@100556 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-10-08 21:15:42 +00:00
parent 46654dd1b5
commit 820076b008
11 changed files with 58 additions and 66 deletions

View File

@ -4,12 +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="workspace-light-tree-2.13.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/workspace-light-tree/workspace-light-tree">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="wsmail-widget-1.7.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/wsmail-widget/wsmail-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="news-feed"/>
</wb-module>

View File

@ -75,8 +75,8 @@
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>pickuser-widget</artifactId>
<version>[0.4.0-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
<artifactId>pickitem-widget</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>

View File

@ -7,7 +7,7 @@ import org.gcube.portal.databook.shared.Like;
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
import org.gcube.portlets.user.newsfeed.shared.MoreFeedsBean;
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
import org.gcube.portlets.widgets.pickuser.shared.PickingUser;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -49,5 +49,5 @@ public interface NewsService extends RemoteService {
EnhancedFeed getSingleFeed(String feedKey);
ArrayList<PickingUser> getOrganizationUsers(String currentScope);
ArrayList<ItemBean> getOrganizationUsers(String currentScope);
}

View File

@ -7,7 +7,7 @@ import org.gcube.portal.databook.shared.Like;
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
import org.gcube.portlets.user.newsfeed.shared.MoreFeedsBean;
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
import org.gcube.portlets.widgets.pickuser.shared.PickingUser;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -57,7 +57,7 @@ public interface NewsServiceAsync {
AsyncCallback<Boolean> callback);
void getOrganizationUsers(String currentScope,
AsyncCallback<ArrayList<PickingUser>> callback);
AsyncCallback<ArrayList<ItemBean>> callback);
void getFeedsByHashtag(String hashtag,
AsyncCallback<ArrayList<EnhancedFeed>> callback);

View File

@ -56,9 +56,6 @@ import org.gcube.portlets.widgets.userselection.shared.ItemSelectableBean;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import java.util.HashMap;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.shared.HandlerManager;
@ -376,6 +373,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.add(new HTML("<div class=\"nofeed-message\"><div style=\"padding-top: 90px;\">" +
"We're sorry, "+ usrLink +" removed the post in the meantime!</div></div>"));
} else{
newsPanel.add(new ResultsFor("selected post", ""));
newsPanel.setHeight("");
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
@ -484,7 +482,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.clear();
if (feeds != null) {
if (feeds.size() == 0) {
newsPanel.add(new ResultsFor(hashtag));
newsPanel.add(new ResultsFor("results for", hashtag));
newsPanel.add(new HTML("<div class=\"nofeed-message\" style=\"height: 200px;\">" +
"Sorry, looks like we found no updates with topic: " + hashtag +"</div>"));
isFirstTweet = true;
@ -493,7 +491,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.setHeight("");
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
newsPanel.add(new ResultsFor(hashtag));
newsPanel.add(new ResultsFor("results for", hashtag));
for (EnhancedFeed feed : feeds) {
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus)); //in the view
}

View File

@ -21,11 +21,11 @@ public class ResultsFor extends Composite {
@UiField HTML allUpdatesLink;
@UiField HTML resultForDiv;
public ResultsFor(String hashtag) {
public ResultsFor(String prefix, String hashtag) {
initWidget(uiBinder.createAndBindUi(this));
allUpdatesLink.setHTML("<a>All Updates</a>");
allUpdatesLink.getElement().getStyle().setCursor(Cursor.POINTER);
resultForDiv.setHTML("results for <a>" + hashtag+"</a>");
resultForDiv.setHTML(prefix + " <a>" + hashtag+"</a>");
resultForDiv.setStyleName("filter-selected");
}

View File

@ -9,10 +9,10 @@ import org.gcube.portlets.user.gcubewidgets.client.elements.Div;
import org.gcube.portlets.user.newsfeed.client.NewsService;
import org.gcube.portlets.user.newsfeed.client.NewsServiceAsync;
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
import org.gcube.portlets.widgets.pickuser.client.dialog.PickUsersDialog;
import org.gcube.portlets.widgets.pickuser.client.events.PickedUserEvent;
import org.gcube.portlets.widgets.pickuser.client.events.PickedUserEventHandler;
import org.gcube.portlets.widgets.pickuser.shared.PickingUser;
import org.gcube.portlets.widgets.pickitem.client.dialog.PickItemsDialog;
import org.gcube.portlets.widgets.pickitem.client.events.PickedItemEvent;
import org.gcube.portlets.widgets.pickitem.client.events.PickedItemEventHandler;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
@ -35,7 +35,7 @@ public class SuperPosedTextArea extends TextArea {
private final HandlerManager eventBus = new HandlerManager(null);
private PickUsersDialog pickUserDlg;
private PickItemsDialog pickUserDlg;
private Div highlighterDIV;
public final static int ARROW_UP = 38;
public final static int ARROW_DOWN = 40;
@ -57,11 +57,11 @@ public class SuperPosedTextArea extends TextArea {
//needed to give unique identifiers to the Area (for the jQuery plugin)
areaId = "postTextArea"+Random.nextInt();
newsService.getOrganizationUsers(NewsFeedPanel.getCurrentScope(), new AsyncCallback<ArrayList<PickingUser>>() {
newsService.getOrganizationUsers(NewsFeedPanel.getCurrentScope(), new AsyncCallback<ArrayList<ItemBean>>() {
@Override
public void onSuccess(ArrayList<PickingUser> users) {
pickUserDlg = new PickUsersDialog(users, eventBus, 460);
public void onSuccess(ArrayList<ItemBean> users) {
pickUserDlg = new PickItemsDialog('@', users, eventBus, 460);
}
@Override
@ -164,11 +164,11 @@ public class SuperPosedTextArea extends TextArea {
* events binder
*/
private void bind() {
eventBus.addHandler(PickedUserEvent.TYPE, new PickedUserEventHandler() {
eventBus.addHandler(PickedItemEvent.TYPE, new PickedItemEventHandler() {
@Override
public void onSelectedUser(PickedUserEvent event) {
public void onSelectedItem(PickedItemEvent event) {
String toAdd = event.getSelectedUser().getFullName();
String toAdd = event.getSelectedItem().getAlternativeName();
mentionedUsers.add(toAdd);
String[] toSplit = getText().split("@"); //get the preceeding part

View File

@ -3,7 +3,7 @@ package org.gcube.portlets.user.newsfeed.server;
import java.util.ArrayList;
import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.portlets.widgets.pickuser.shared.PickingUser;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -18,10 +18,10 @@ public class MentionNotificationsThread implements Runnable {
private String postText;
private String postId;
private NotificationsManager nm;
private ArrayList<PickingUser> users;
private ArrayList<ItemBean> users;
public MentionNotificationsThread(String postId, String postText, NotificationsManager nm, ArrayList<PickingUser> users) {
public MentionNotificationsThread(String postId, String postText, NotificationsManager nm, ArrayList<ItemBean> users) {
super();
this.postId = postId;
this.postText = postText;
@ -31,9 +31,9 @@ public class MentionNotificationsThread implements Runnable {
@Override
public void run() {
for (PickingUser userToNotify : users) {
boolean result = nm.notifyUserTag(userToNotify.getUsername(), postId, postText);
_log.trace("Sending Notification for post mention to: " + userToNotify.getUsername() + " result?"+ result);
for (ItemBean userToNotify : users) {
boolean result = nm.notifyUserTag(userToNotify.getName(), postId, postText);
_log.trace("Sending Notification for post mention to: " + userToNotify.getName() + " result?"+ result);
}
}
}

View File

@ -40,7 +40,7 @@ import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
import org.gcube.portlets.user.newsfeed.shared.MoreFeedsBean;
import org.gcube.portlets.user.newsfeed.shared.NewsConstants;
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
import org.gcube.portlets.widgets.pickuser.shared.PickingUser;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
import org.slf4j.Logger;
@ -605,7 +605,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
String escapedCommentText = Utils.escapeHtmlAndTransformUrl(commentText);
ArrayList<PickingUser> mentionedUsers = null;
ArrayList<ItemBean> mentionedUsers = null;
if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) {
mentionedUsers = getSelectedUserIds(mentionedUserFullNames);
escapedCommentText = Utils.convertMentionPeopleAnchorHTML(escapedCommentText, mentionedUsers);
@ -816,8 +816,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
}
}
@Override
public ArrayList<PickingUser> getOrganizationUsers(String currentScope) {
ArrayList<PickingUser> toReturn = Utils.getOrganizationUsers(currentScope, getASLSession().getUsername(), isWithinPortal());
public ArrayList<ItemBean> getOrganizationUsers(String currentScope) {
ArrayList<ItemBean> toReturn = Utils.getOrganizationUsers(currentScope, getASLSession().getUsername(), isWithinPortal());
_log.trace("Returning " + toReturn.size() + " users for scope " + currentScope);
return toReturn;
}
@ -878,15 +878,15 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
*
* @return the screennames of the addressee (user logins e.g. pino.pini)
*/
public ArrayList<PickingUser> getSelectedUserIds(ArrayList<String> fullNames) {
public ArrayList<ItemBean> getSelectedUserIds(ArrayList<String> fullNames) {
if (fullNames == null)
return new ArrayList<PickingUser>();
return new ArrayList<ItemBean>();
else {
ArrayList<PickingUser> allUsers = Utils.getOrganizationUsers("/"+OrganizationsUtil.getRootOrganizationName(), getASLSession().getUsername(), isWithinPortal());
ArrayList<PickingUser> toReturn = new ArrayList<PickingUser>();
ArrayList<ItemBean> allUsers = Utils.getOrganizationUsers("/"+OrganizationsUtil.getRootOrganizationName(), getASLSession().getUsername(), isWithinPortal());
ArrayList<ItemBean> toReturn = new ArrayList<ItemBean>();
for (String fullName : fullNames)
for (PickingUser puser : allUsers) {
if (puser.getFullName().compareTo(fullName) == 0) {
for (ItemBean puser : allUsers) {
if (puser.getAlternativeName().compareTo(fullName) == 0) {
toReturn.add(puser);
break;
}

View File

@ -12,7 +12,7 @@ import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portlets.widgets.pickuser.shared.PickingUser;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
@ -31,8 +31,8 @@ public class Utils {
* @param withinPortal true when is on Liferay portal
* @return the users belonging to the current organization (scope)
*/
public static ArrayList<PickingUser> getOrganizationUsers(String scope, String currUser, boolean withinPortal) {
ArrayList<PickingUser> portalUsers = new ArrayList<PickingUser>();
public static ArrayList<ItemBean> getOrganizationUsers(String scope, String currUser, boolean withinPortal) {
ArrayList<ItemBean> portalUsers = new ArrayList<ItemBean>();
try {
if (withinPortal) {
UserManager um = new LiferayUserManager();
@ -57,21 +57,21 @@ public class Utils {
String thumbnailURL = "";
com.liferay.portal.model.UserModel lifeUser = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), user.getScreenName());
thumbnailURL = "/image/user_male_portrait?img_id="+lifeUser.getPortraitId();
portalUsers.add(new PickingUser(user.getUserId(), user.getScreenName(), user.getFullname(), thumbnailURL));
portalUsers.add(new ItemBean(user.getUserId(), user.getScreenName(), user.getFullname(), thumbnailURL));
}
}
}
else { //test users
portalUsers.add(new PickingUser("12111", "massimiliano.assante", "Test User #1", ""));
portalUsers.add(new PickingUser("14111", "massimiliano.assante", "Test Second User #2", ""));
portalUsers.add(new PickingUser("11511", "massimiliano.assante", "Test Third User", ""));
portalUsers.add(new PickingUser("11611", "massimiliano.assante", "Test Fourth User", ""));
portalUsers.add(new PickingUser("11711", "massimiliano.assante", "Test Fifth User", ""));
portalUsers.add(new PickingUser("11811", "massimiliano.assante", "Test Sixth User", ""));
portalUsers.add(new PickingUser("15811", "massimiliano.assante", "Ninth Testing User", ""));
portalUsers.add(new PickingUser("15811", "massimiliano.assante", "Eighth Testing User", ""));
portalUsers.add(new PickingUser("11211", "giogio.giorgi", "Seventh Test User", ""));
portalUsers.add(new PickingUser("2222", "pino.pinetti", "Tenth Testing User", ""));
portalUsers.add(new ItemBean("12111", "massimiliano.assante", "Test User #1", ""));
portalUsers.add(new ItemBean("14111", "massimiliano.assante", "Test Second User #2", ""));
portalUsers.add(new ItemBean("11511", "massimiliano.assante", "Test Third User", ""));
portalUsers.add(new ItemBean("11611", "massimiliano.assante", "Test Fourth User", ""));
portalUsers.add(new ItemBean("11711", "massimiliano.assante", "Test Fifth User", ""));
portalUsers.add(new ItemBean("11811", "massimiliano.assante", "Test Sixth User", ""));
portalUsers.add(new ItemBean("15811", "massimiliano.assante", "Ninth Testing User", ""));
portalUsers.add(new ItemBean("15811", "massimiliano.assante", "Eighth Testing User", ""));
portalUsers.add(new ItemBean("11211", "giogio.giorgi", "Seventh Test User", ""));
portalUsers.add(new ItemBean("2222", "pino.pinetti", "Tenth Testing User", ""));
}
} catch (Exception e) {
_log.error("Error in server get all contacts ", e);
@ -152,13 +152,13 @@ public class Utils {
* @param taggedPeople
* @return
*/
protected static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList<PickingUser> taggedPeople) {
for (PickingUser tagged : taggedPeople) {
protected static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList<ItemBean> taggedPeople) {
for (ItemBean tagged : taggedPeople) {
String taggedHTML = "<a class=\"link\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK
+"?"+
new String(Base64.encodeBase64(GCubeSocialNetworking.USER_PROFILE_OID.getBytes()))+"="+
new String(Base64.encodeBase64(tagged.getUsername().getBytes()))+"\">"+tagged.getFullName()+"</a> ";
escapedFeedText = escapedFeedText.replace(tagged.getFullName(), taggedHTML);
new String(Base64.encodeBase64(tagged.getName().getBytes()))+"\">"+tagged.getAlternativeName()+"</a> ";
escapedFeedText = escapedFeedText.replace(tagged.getAlternativeName(), taggedHTML);
}
return escapedFeedText;
}

View File

@ -4,7 +4,7 @@
<inherits name='com.google.gwt.user.User' />
<!-- To Comment out -->
<set-property name="user.agent" value="safari,gecko1_8" />
<!-- <set-property name="user.agent" value="safari,gecko1_8" /> -->
<!-- Other module inherits -->
<inherits name="net.eliasbalasis.tibcopagebus4gwt.tibcopagebus4gwt" />
@ -16,7 +16,7 @@
<inherits name='org.gcube.portlets.widgets.wsmail.WsMail_Widget' />
<inherits name='org.gcube.portlets.widgets.userselection.UserSelection' />
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
<inherits name='org.gcube.portlets.widgets.pickuser.PickUser' />
<inherits name='org.gcube.portlets.widgets.pickitem.PickItem' />
<inherits
name='org.gcube.portlets.widgets.lighttree.WorkspacePortletLightTree' />
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />