added user selection widget

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@82527 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-10-06 23:02:11 +00:00
parent 4f3c77d009
commit d545b6fd9d
8 changed files with 61 additions and 150 deletions

10
pom.xml
View File

@ -83,6 +83,11 @@
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>user-selection-dialog</artifactId>
<version>[0.1.0-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-light-tree</artifactId>
@ -104,6 +109,11 @@
<artifactId>custom-portal-handler</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Date;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder;
import org.gcube.portal.databook.shared.ClientFeed;
import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed;
@ -32,13 +33,17 @@ import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEvent;
import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEventHandler;
import org.gcube.portlets.user.newsfeed.client.event.ShowNewUpdatesEvent;
import org.gcube.portlets.user.newsfeed.client.event.ShowNewUpdatesEventHandler;
import org.gcube.portlets.user.newsfeed.client.panels.dialog.LikesDialog;
import org.gcube.portlets.user.newsfeed.client.templates.FilterPanel;
import org.gcube.portlets.user.newsfeed.client.templates.NewFeedsAvailable;
import org.gcube.portlets.user.newsfeed.client.templates.SingleComment;
import org.gcube.portlets.user.newsfeed.client.templates.TweetTemplate;
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
import org.gcube.portlets.widgets.userselection.client.UserSelectionDialog;
import org.gcube.portlets.widgets.userselection.client.events.SelectedUserEvent;
import org.gcube.portlets.widgets.userselection.client.events.SelectedUserEventHandler;
import org.gcube.portlets.widgets.userselection.client.events.UsersFetchedEvent;
import org.gcube.portlets.widgets.userselection.shared.SelectionUser;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
@ -46,6 +51,7 @@ import com.google.gwt.dom.client.Document;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
@ -139,6 +145,16 @@ public class NewsFeedPanel extends Composite {
});
eventBus.addHandler(SelectedUserEvent.TYPE, new SelectedUserEventHandler() {
@Override
public void onSelectedUser(SelectedUserEvent event) {
GWT.log("event...");
Location.assign(GCubeSocialNetworking.USER_PROFILE_LINK+"?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(event.getSelectedUser().getId()));
}
});
eventBus.addHandler(SeeLikesEvent.TYPE, new SeeLikesEventHandler() {
@Override
public void onSeeLikes(SeeLikesEvent event) {
@ -589,12 +605,13 @@ public class NewsFeedPanel extends Composite {
}
private void doShowLikes(final String feedId) {
GWT.runAsync(new RunAsyncCallback() {
GWT.runAsync(UserSelectionDialog.class, new RunAsyncCallback() {
@Override
public void onSuccess() {
final LikesDialog dlg = new LikesDialog();
final UserSelectionDialog dlg = new UserSelectionDialog("People who set this as Favorite", eventBus);
dlg.center();
dlg.show();
dlg.show();
newsService.getAllLikesByFeed(feedId, new AsyncCallback<ArrayList<Like>>() {
@Override
public void onFailure(Throwable caught) {
@ -603,7 +620,11 @@ public class NewsFeedPanel extends Composite {
@Override
public void onSuccess(ArrayList<Like> result) {
dlg.showLikes(result);
ArrayList<SelectionUser> toShow = new ArrayList<SelectionUser>();
for (Like like : result) {
toShow.add(new SelectionUser(like.getUserid(), like.getFullName(), like.getThumbnailURL()));
}
eventBus.fireEvent(new UsersFetchedEvent(toShow));
}
});
}

View File

@ -1,73 +0,0 @@
package org.gcube.portlets.user.newsfeed.client.panels.dialog;
import java.util.ArrayList;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
import org.gcube.portlets.user.newsfeed.client.templates.LikedTemplate;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CellPanel;
import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
public class LikesDialog extends GCubeDialog {
private static final int WIDTH = 420;
private CellPanel mainPanel = new VerticalPanel();
private VerticalPanel topPanel = new VerticalPanel();
private HorizontalPanel bottomPanel = new HorizontalPanel();
private Image loadingImage;
public LikesDialog() {
super(true);
setText("People who set this " + NewsFeedPanel.LIKE_LABEL);
loadingImage = new Image(NewsFeedPanel.loading);
setSize(""+WIDTH, "100");
topPanel.setPixelSize(WIDTH, 100);
bottomPanel.setPixelSize(WIDTH, 25);
topPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
topPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
topPanel.add(loadingImage);
ScrollPanel scroller = new ScrollPanel();
scroller.setPixelSize(WIDTH+40, 300);
scroller.add(topPanel);
mainPanel.add(scroller);
mainPanel.add(bottomPanel);
bottomPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
Button close = new Button("Close");
bottomPanel.add(close);
close.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
hide();
}
});
mainPanel.setCellHeight(bottomPanel, "25px");
setWidget(mainPanel);
}
/**
*
* @param likes
*/
public void showLikes(ArrayList<Like> likes) {
topPanel.remove(loadingImage);
bottomPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
for (Like like : likes) {
topPanel.add(new LikedTemplate(like));
}
}
}

View File

@ -1,35 +0,0 @@
package org.gcube.portlets.user.newsfeed.client.templates;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.shared.Like;
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
public class LikedTemplate extends Composite {
private static LikedTemplateUiBinder uiBinder = GWT
.create(LikedTemplateUiBinder.class);
interface LikedTemplateUiBinder extends UiBinder<Widget, LikedTemplate> {
}
public LikedTemplate(Like like) {
initWidget(uiBinder.createAndBindUi(this));
if (like.getThumbnailURL() != null)
avatarImage.setUrl(like.getThumbnailURL());
avatarImage.setPixelSize(30, 30);
contentArea.setHTML("<a class=\"person-link\" style=\"font-size:16px;\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"\">"+like.getFullName()+"</a> ");
}
@UiField
Image avatarImage;
@UiField
HTML contentArea;
}

View File

@ -1,25 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel ui:field="mainHTML">
<div class="div-table-400">
<div class="div-table-row">
<div class="div-table-col smallphoto">
<a href="">
<g:Image title="" styleName="member-photo" url=""
ui:field="avatarImage" width="30px" height="30px" />
</a>
</div>
<div class="div-table-col content">
<div class="liked-person">
<g:HTML styleName="" ui:field="contentArea" />
</div>
<div class="liked-aux">
</div>
</div>
</div>
</div>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -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/devsec/devVRE");
user = "massimiliano.assante";
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube");
}
else {
withinPortal = true;
@ -352,7 +352,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
for (Feed feed : toMerge) {
feed.setThumbnailURL("http://127.0.0.1:8888/images/Avatar_default.png");
}
//sort the feeds in reverse chronological order
Collections.sort(toMerge, Collections.reverseOrder());
return enhanceFeeds(toMerge, 2);
}
@ -668,16 +669,17 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
* @throws PortalException
*/
private boolean isAdmin() throws PortalException, SystemException {
User currUser = OrganizationsUtil.validateUser(getASLSession().getUsername());
List<Organization> organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
Organization rootOrganization = null;
for (Organization organization : organizations) {
if (organization.getName().equals(OrganizationsUtil.getRootOrganizationName() ) ) {
rootOrganization = organization;
break;
}
}
try {
User currUser = OrganizationsUtil.validateUser(getASLSession().getUsername());
List<Organization> organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount());
Organization rootOrganization = null;
for (Organization organization : organizations) {
if (organization.getName().equals(OrganizationsUtil.getRootOrganizationName() ) ) {
rootOrganization = organization;
break;
}
}
_log.trace("root: " + rootOrganization.getName() );
return (hasRole(ADMIN_ROLE, rootOrganization.getName(), currUser));
}

View File

@ -0,0 +1,10 @@
log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
# Print the date in ISO 8601 format
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
# Print only messages of level TRACE or above in the package org.gcube
log4j.logger.org.gcube=TRACE
log4j.logger.org.gcube.application.framework.core.session=INFO

View File

@ -14,6 +14,7 @@
<!-- inherits gCube Widgets Library -->
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<inherits name='org.gcube.portlets.user.wsmail.WsMail_Widget' />
<inherits name='org.gcube.portlets.widgets.userselection.UserSelection' />
<inherits
name='org.gcube.portlets.user.workspace.lighttree.WorkspacePortletLightTree' />