use of com.google.gwt.event.logical.shared.OpenEvent in project perun by CESNET.
the class SelfResourcesSettingsTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Resources settings");
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
final TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
final ScrollPanel scroll = new ScrollPanel();
scroll.setWidget(vp);
scroll.setStyleName("perun-tableScrollPanel");
session.getUiElements().resizeSmallTabPanel(scroll, 350, this);
scroll.setWidth("100%");
final AjaxLoaderImage loader = new AjaxLoaderImage();
// RETRIEVES ALL VOS WHERE USER IS A MEMBER
GetVosWhereUserIsMember vosRequest = new GetVosWhereUserIsMember(userId, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
vp.getWidget(1).removeFromParent();
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
// if vos length = 1, load immediately all resources
final boolean loadImmediately = (vos.size() == 1);
// FOR EACH VO, FIND THE MEMBER
for (final VirtualOrganization innerVo : vos) {
final FlexTable header = new FlexTable();
header.setWidth("100%");
header.setWidget(0, 0, new Image(LargeIcons.INSTANCE.buildingIcon()));
header.getFlexCellFormatter().setWidth(0, 0, "40px");
Anchor a = new Anchor("<p class=\"now-managing disclosurePanelHeader\">" + innerVo.getName() + "</p>", true);
header.setWidget(0, 1, a);
header.setTitle("Click to show resources for " + innerVo.getName());
// disclosure panel
final DisclosurePanel settings = new DisclosurePanel();
settings.setWidth("100%");
settings.setHeader(header);
// load content on open
settings.addOpenHandler(new OpenHandler<DisclosurePanel>() {
public void onOpen(OpenEvent<DisclosurePanel> event) {
if (settings.getContent() == null) {
GetMemberByUser memberRequest = new GetMemberByUser(innerVo.getId(), userId, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
Member member = jso.cast();
// set content
settings.setContent(userSettingsForVo(innerVo, member));
}
});
memberRequest.retrieveData();
}
}
});
vp.add(settings);
settings.setOpen((vos.size() == 1) || (vo != null && vo.getId() == innerVo.getId()));
}
}
@Override
public void onLoadingStart() {
vp.add(loader);
}
@Override
public void onError(PerunError error) {
loader.loadingError(error);
}
});
vosRequest.retrieveData();
this.contentWidget.setWidget(scroll);
return getWidget();
}
Aggregations