75 lines
2.6 KiB
Java
75 lines
2.6 KiB
Java
package org.gcube.portlets.user.socialprofile.client.ui;
|
|
|
|
import org.gcube.portal.databook.shared.UserInfo;
|
|
import org.gcube.portlets.user.socialprofile.client.SocialService;
|
|
import org.gcube.portlets.user.socialprofile.client.SocialServiceAsync;
|
|
import org.gcube.portlets.user.socialprofile.shared.UserContext;
|
|
|
|
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.Window;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
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 DisplayProfile extends Composite {
|
|
|
|
private static DisplayProfileUiBinder uiBinder = GWT
|
|
.create(DisplayProfileUiBinder.class);
|
|
|
|
interface DisplayProfileUiBinder extends UiBinder<Widget, DisplayProfile> {
|
|
}
|
|
public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png";
|
|
public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif";
|
|
public static final String GET_OID_PARAMETER = "oid";
|
|
private final SocialServiceAsync socialService = GWT.create(SocialService.class);
|
|
|
|
@UiField HTMLPanel mainPanel;
|
|
@UiField Image avatarImage;
|
|
@UiField HTML userFullName;
|
|
@UiField HTML headline;
|
|
@UiField HTML institution;
|
|
|
|
private UserInfo myUserInfo;
|
|
|
|
public DisplayProfile() {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
avatarImage.setUrl(loading);
|
|
mainPanel.addStyleName("framed");
|
|
|
|
if (getUserToShowId() == null) { //its him seeing himself
|
|
socialService.getUserContext(null, new AsyncCallback<UserContext>() {
|
|
@Override
|
|
public void onSuccess(UserContext result) {
|
|
myUserInfo = result.getUserInfo();
|
|
avatarImage.getElement().getParentElement().setAttribute("href", myUserInfo.getAccountURL());
|
|
avatarImage.setSize("100px", "100px");
|
|
avatarImage.setUrl(myUserInfo.getAvatarId());
|
|
userFullName.setText(myUserInfo.getFullName());
|
|
headline.setText(result.getHeadline());
|
|
institution.setText(result.getInstitution());
|
|
}
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
Window.alert("Failure: " + caught.getMessage());
|
|
avatarImage.setSize("100px", "100px");
|
|
avatarImage.setUrl(avatar_default);
|
|
}
|
|
});
|
|
} else {
|
|
|
|
}
|
|
}
|
|
/**
|
|
* check if it has to show just one feed
|
|
* @return
|
|
*/
|
|
private String getUserToShowId() {
|
|
return Window.Location.getParameter(GET_OID_PARAMETER);
|
|
}
|
|
}
|