70 lines
2.3 KiB
Java
70 lines
2.3 KiB
Java
|
package org.gcube.portlets.user.questions.client;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
|
||
|
import org.gcube.portal.databook.shared.UserInfo;
|
||
|
import org.gcube.portlets.user.questions.client.resources.Images;
|
||
|
import org.gcube.portlets.user.questions.client.ui.DisplayBadge;
|
||
|
|
||
|
import com.google.gwt.core.client.GWT;
|
||
|
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.HasAlignment;
|
||
|
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
||
|
import com.google.gwt.user.client.ui.Image;
|
||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||
|
|
||
|
public class VREManagersPanel extends Composite {
|
||
|
|
||
|
private final QuestionsServiceAsync service = GWT.create(QuestionsService.class);
|
||
|
|
||
|
|
||
|
private Image loadingImage;
|
||
|
|
||
|
private VerticalPanel mainPanel = new VerticalPanel();
|
||
|
public VREManagersPanel() {
|
||
|
super();
|
||
|
Images images = GWT.create(Images.class);
|
||
|
loadingImage = new Image(images.membersLoader().getSafeUri());
|
||
|
mainPanel.add(loadingImage);
|
||
|
showLoader();
|
||
|
service.getManagers(new AsyncCallback<ArrayList<UserInfo>>() {
|
||
|
|
||
|
@Override
|
||
|
public void onSuccess(ArrayList<UserInfo> users) {
|
||
|
mainPanel.clear();
|
||
|
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||
|
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
||
|
if (users == null || users.isEmpty()) {
|
||
|
mainPanel.add(new HTML("<div class=\"frame\" style=\"font-size: 16px;\">Ops, something went wrong. Please <a href=\"javascript: location.reload();\">reload<a/> this page.</div>"));
|
||
|
} else {
|
||
|
for (int i = 0; i < users.size(); i++) {
|
||
|
mainPanel.add(new DisplayBadge(users.get(i)));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onFailure(Throwable caught) {
|
||
|
mainPanel.add(new HTML("<div class=\"nofeed-message\">" +
|
||
|
"Sorry, looks like something is broken with the server connection<br> " +
|
||
|
"Please check your connection and try refresh this page.</div>"));
|
||
|
|
||
|
}
|
||
|
});
|
||
|
initWidget(mainPanel);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
private void showLoader() {
|
||
|
mainPanel.clear();
|
||
|
mainPanel.setWidth("100%");
|
||
|
mainPanel.setHeight("300px");
|
||
|
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
|
||
|
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
|
||
|
mainPanel.add(loadingImage);
|
||
|
}
|
||
|
}
|