2013-01-04 19:22:23 +01:00
|
|
|
package org.gcube.portlets.user.notifications.client.view.templates;
|
|
|
|
|
|
|
|
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
|
|
|
import org.gcube.portal.databook.shared.Notification;
|
2013-01-05 18:56:12 +01:00
|
|
|
import org.gcube.portal.databook.shared.NotificationType;
|
|
|
|
import org.gcube.portlets.user.notifications.client.view.templates.images.NotificationImages;
|
2013-01-04 19:22:23 +01:00
|
|
|
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
2013-01-05 18:56:12 +01:00
|
|
|
import com.google.gwt.resources.client.ImageResource;
|
2013-01-04 19:22:23 +01:00
|
|
|
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.HTMLPanel;
|
|
|
|
import com.google.gwt.user.client.ui.Image;
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
|
|
|
public class SingleNotificationView extends Composite {
|
|
|
|
|
|
|
|
private static NotificationsDayUiBinder uiBinder = GWT
|
|
|
|
.create(NotificationsDayUiBinder.class);
|
|
|
|
|
|
|
|
interface NotificationsDayUiBinder extends
|
2013-01-05 18:56:12 +01:00
|
|
|
UiBinder<Widget, SingleNotificationView> {
|
2013-01-04 19:22:23 +01:00
|
|
|
}
|
2013-01-05 18:56:12 +01:00
|
|
|
|
|
|
|
NotificationImages images = GWT.create(NotificationImages.class);
|
|
|
|
|
2013-01-04 19:22:23 +01:00
|
|
|
private Notification myNotification;
|
2013-01-05 18:56:12 +01:00
|
|
|
|
2013-01-04 19:22:23 +01:00
|
|
|
@UiField
|
|
|
|
Image notificationImage;
|
|
|
|
@UiField HTMLPanel mainPanel;
|
2013-01-10 12:20:33 +01:00
|
|
|
@UiField Span notificationText;
|
|
|
|
@UiField Span timeArea;
|
2013-01-04 19:22:23 +01:00
|
|
|
|
|
|
|
public SingleNotificationView(Notification toShow) {
|
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
myNotification = toShow;
|
|
|
|
String notificationToShow = toShow.getDescription();
|
2013-01-05 18:56:12 +01:00
|
|
|
|
2013-01-04 19:22:23 +01:00
|
|
|
notificationText.setHTML(
|
|
|
|
"<a class=\"link\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"\">"+
|
|
|
|
toShow.getSenderFullName()+"</a> " + notificationToShow);
|
|
|
|
|
|
|
|
|
2013-01-05 18:56:12 +01:00
|
|
|
timeArea.setHTML(DateTimeFormat.getFormat("h:mm a").format(toShow.getTime()));
|
|
|
|
|
|
|
|
notificationImage.setResource(getImageType(toShow.getType()));
|
2013-01-04 19:22:23 +01:00
|
|
|
}
|
|
|
|
|
2013-01-05 18:56:12 +01:00
|
|
|
private ImageResource getImageType(NotificationType type) {
|
|
|
|
switch (type) {
|
|
|
|
case LIKE:
|
|
|
|
return images.like();
|
|
|
|
case COMMENT:
|
|
|
|
return images.comment();
|
|
|
|
case MESSAGE:
|
|
|
|
return images.message();
|
|
|
|
case WP_FOLDER_ADDEDUSER:
|
|
|
|
return images.share();
|
|
|
|
case WP_FOLDER_REMOVEDUSER:
|
|
|
|
return images.share();
|
|
|
|
case WP_FOLDER_SHARE:
|
|
|
|
return images.share();
|
|
|
|
case WP_ITEM_NEW:
|
|
|
|
return images.share();
|
|
|
|
case WP_ITEM_DELETE:
|
|
|
|
return images.share();
|
|
|
|
case WP_ITEM_UPDATED:
|
|
|
|
return images.share();
|
|
|
|
case OWN_COMMENT:
|
|
|
|
return images.comment();
|
|
|
|
case REQUEST_CONNECTION:
|
|
|
|
return images.connectionRequest();
|
|
|
|
case JOB_COMPLETED_NOK:
|
|
|
|
return images.jobNOK();
|
|
|
|
case JOB_COMPLETED_OK:
|
|
|
|
return images.jobOK();
|
|
|
|
default:
|
|
|
|
return images.generic();
|
|
|
|
}
|
|
|
|
}
|
2013-01-04 19:22:23 +01:00
|
|
|
}
|