works like a charm

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@73682 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-04-19 13:38:20 +00:00
parent b55f18790e
commit a7c3191953
3 changed files with 29 additions and 12 deletions

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.newsfeed.client.panels;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.shared.ClientFeed; import org.gcube.portal.databook.shared.ClientFeed;
import org.gcube.portal.databook.shared.Comment; import org.gcube.portal.databook.shared.Comment;
import org.gcube.portal.databook.shared.Feed; import org.gcube.portal.databook.shared.Feed;
@ -66,7 +67,8 @@ public class NewsFeedPanel extends Composite {
private final HandlerManager eventBus = new HandlerManager(null); private final HandlerManager eventBus = new HandlerManager(null);
private VerticalPanel mainPanel = new VerticalPanel(); private VerticalPanel mainPanel = new VerticalPanel();
private HorizontalPanel filterPanel = new HorizontalPanel(); private HorizontalPanel filterPanelWrapper = new HorizontalPanel();
private FilterPanel filterPanel;
private SimplePanel newUpdatesPanel = new SimplePanel(); private SimplePanel newUpdatesPanel = new SimplePanel();
private VerticalPanel newsPanel = new VerticalPanel(); private VerticalPanel newsPanel = new VerticalPanel();
@ -172,12 +174,12 @@ public class NewsFeedPanel extends Composite {
public NewsFeedPanel() { public NewsFeedPanel() {
bind(); bind();
mainPanel.setWidth("600px"); mainPanel.setWidth("600px");
mainPanel.add(filterPanel); mainPanel.add(filterPanelWrapper);
filterPanel.setVisible(false); filterPanelWrapper.setVisible(false);
mainPanel.add(newUpdatesPanel); mainPanel.add(newUpdatesPanel);
mainPanel.add(newsPanel); mainPanel.add(newsPanel);
filterPanel = new FilterPanel(this, newsService);
filterPanel.add(new FilterPanel(this, newsService)); filterPanelWrapper.add(filterPanel);
initWidget(mainPanel); initWidget(mainPanel);
newsPanel.clear(); newsPanel.clear();
newsPanel.setWidth("100%"); newsPanel.setWidth("100%");
@ -203,6 +205,7 @@ public class NewsFeedPanel extends Composite {
if (getFeedToShowId() != null) { if (getFeedToShowId() != null) {
String feedKey = getFeedToShowId(); String feedKey = getFeedToShowId();
showSingleFeed(feedKey); showSingleFeed(feedKey);
filterPanel.removeFilterSelected();
} else { } else {
showAllUpdatesFeeds(); showAllUpdatesFeeds();
} }
@ -210,7 +213,7 @@ public class NewsFeedPanel extends Composite {
} }
//adjustments in the UI Depending on the scope //adjustments in the UI Depending on the scope
if (result.isInfrastructure()) if (result.isInfrastructure())
filterPanel.setVisible(true); filterPanelWrapper.setVisible(true);
else else
mainPanel.addStyleName("framed"); mainPanel.addStyleName("framed");
@ -255,10 +258,16 @@ public class NewsFeedPanel extends Composite {
newsService.getSingleFeed(feedKey, new AsyncCallback<EnhancedFeed>() { newsService.getSingleFeed(feedKey, new AsyncCallback<EnhancedFeed>() {
@Override @Override
public void onSuccess(EnhancedFeed result) { public void onSuccess(EnhancedFeed result) {
newsPanel.setHeight(""); if (result.getFeed().getType() == FeedType.DISABLED) {
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); String usrLink = "<a class=\"link\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"?uid="+result.getFeed().getEntityId() + "\">"+result.getFeed().getFullName() +"</a> ";
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); newsPanel.add(new HTML("<div class=\"nofeed-message\"><div style=\"padding-top: 90px;\">" +
newsPanel.add(new TweetTemplate(true, myUserInfo, result, eventBus)); "We're sorry, "+ usrLink +" removed the post in the meantime!</div></div>"));
} else{
newsPanel.setHeight("");
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
newsPanel.add(new TweetTemplate(true, myUserInfo, result, eventBus));
}
newsPanel.add(new Image(spacer)); newsPanel.add(new Image(spacer));
} }
@Override @Override

View File

@ -1,6 +1,5 @@
package org.gcube.portlets.user.newsfeed.client.templates; package org.gcube.portlets.user.newsfeed.client.templates;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.newsfeed.client.FilterType; import org.gcube.portlets.user.newsfeed.client.FilterType;
import org.gcube.portlets.user.newsfeed.client.NewsServiceAsync; import org.gcube.portlets.user.newsfeed.client.NewsServiceAsync;
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel; import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
@ -81,6 +80,11 @@ public class FilterPanel extends Composite {
// }); // });
// } // }
// //
public void removeFilterSelected() {
allUpdatesLink.removeStyleName("filter-selected");
onlyme.removeStyleName("filter-selected");
favoritesLink.removeStyleName("filter-selected");
}
@UiHandler("favoritesLink") @UiHandler("favoritesLink")
void onFavoritesClick(ClickEvent e) { void onFavoritesClick(ClickEvent e) {

View File

@ -602,7 +602,11 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
} }
private UserSettings getUserSettingsFromSession() { private UserSettings getUserSettingsFromSession() {
return (UserSettings) getASLSession().getAttribute(USER_SETTINGS_ATTR); try {
return (UserSettings) getASLSession().getAttribute(USER_SETTINGS_ATTR);
} catch (ClassCastException e) { //handle the hot deploy
return null;
}
} }
private void setUserSettingsInSession(UserSettings user) { private void setUserSettingsInSession(UserSettings user) {