95 lines
2.6 KiB
Java
95 lines
2.6 KiB
Java
package org.gcube.portlet.user.userstatisticsportlet.client.ui;
|
|
|
|
import org.gcube.portal.databook.shared.ShowUserStatisticAction;
|
|
import org.gcube.portlet.user.userstatisticsportlet.client.events.ShowFeedsRelatedToUserStatisticsEvent;
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
import com.google.gwt.dom.client.Style.Cursor;
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
import com.google.gwt.event.shared.HandlerManager;
|
|
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.Image;
|
|
import com.google.gwt.user.client.ui.Label;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
public class CommentsAndLikesWidget extends Composite {
|
|
|
|
private static CommentsAndLikesWidgetUiBinder uiBinder = GWT
|
|
.create(CommentsAndLikesWidgetUiBinder.class);
|
|
|
|
interface CommentsAndLikesWidgetUiBinder extends
|
|
UiBinder<Widget, CommentsAndLikesWidget> {
|
|
}
|
|
|
|
@UiField
|
|
Image likesImage;
|
|
|
|
@UiField
|
|
Image commentsImage;
|
|
|
|
@UiField
|
|
Label likesValue;
|
|
|
|
@UiField
|
|
Label commentsValue;
|
|
|
|
private HandlerManager busEvents;
|
|
|
|
public CommentsAndLikesWidget() {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
}
|
|
|
|
public void setComments(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick){
|
|
|
|
this.commentsImage.setUrl(url);
|
|
this.commentsImage.setTitle(tipIcon);
|
|
this.commentsValue.setText(value);
|
|
this.commentsValue.setTitle(tipValue);
|
|
|
|
if(busEvents != null && actionToTakeOnClick != null){
|
|
|
|
commentsValue.getElement().getStyle().setCursor(Cursor.POINTER);
|
|
commentsValue.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
|
|
busEvents.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(actionToTakeOnClick));
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|
|
|
|
public void setLikes(String url, String value, String tipIcon, String tipValue, final ShowUserStatisticAction actionToTakeOnClick){
|
|
|
|
this.likesImage.setUrl(url);
|
|
this.likesImage.setTitle(tipIcon);
|
|
this.likesValue.setText(value);
|
|
this.likesValue.setTitle(tipValue);
|
|
|
|
if(busEvents != null && actionToTakeOnClick != null){
|
|
|
|
likesValue.getElement().getStyle().setCursor(Cursor.POINTER);
|
|
likesValue.addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
|
|
busEvents.fireEvent(new ShowFeedsRelatedToUserStatisticsEvent(actionToTakeOnClick));
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|
|
|
|
public void setEventBus(HandlerManager busEvents){
|
|
this.busEvents = busEvents;
|
|
}
|
|
}
|