package org.gcube.portlets.user.notifications.client.view.templates; import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.shared.Notification; import org.gcube.portal.databook.shared.NotificationType; import org.gcube.portlets.user.notifications.client.view.templates.images.NotificationImages; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.resources.client.ImageResource; 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 UiBinder { } NotificationImages images = GWT.create(NotificationImages.class); private Notification myNotification; @UiField Image notificationImage; @UiField HTMLPanel mainPanel; @UiField Span notificationText; @UiField Span timeArea; public SingleNotificationView(Notification toShow) { initWidget(uiBinder.createAndBindUi(this)); myNotification = toShow; String notificationToShow = toShow.getDescription(); notificationText.setHTML( ""+ toShow.getSenderFullName()+" " + notificationToShow); timeArea.setHTML(DateTimeFormat.getFormat("h:mm a").format(toShow.getTime())); notificationImage.setResource(getImageType(toShow.getType())); } 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(); } } }