use of cz.metacentrum.perun.webgui.json.usersManager.GetVosWhereUserIsMember in project perun by CESNET.
the class SelfVosTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": VO settings");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
final TabMenu menu = new TabMenu();
final ScrollPanel sp = new ScrollPanel();
sp.setSize("100%", "100%");
sp.setStyleName("perun-tableScrollPanel");
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
final ListBoxWithObjects<VirtualOrganization> vosListbox = new ListBoxWithObjects<VirtualOrganization>();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addWidget(new HTML("<strong>Selected VO:</strong>"));
menu.addWidget(vosListbox);
vp.add(menu);
vp.setCellHeight(menu, "50px");
vp.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE);
vp.add(new HTML("<hr size=\"1\" color=\"#ccc\">"));
vp.add(sp);
vp.setCellHeight(sp, "100%");
final GetVosWhereUserIsMember whereMember = new GetVosWhereUserIsMember(userId, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
vosListbox.clear();
if (vos != null && !vos.isEmpty()) {
for (VirtualOrganization vo : vos) {
vosListbox.addItem(vo);
if (vo.getId() == selectedVoId) {
vosListbox.setSelected(vo, true);
}
}
vosListbox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
selectedVoId = vosListbox.getSelectedObject().getId();
sp.setWidget(displayVoSubtab(vosListbox.getSelectedObject()));
}
});
sp.setWidget(displayVoSubtab(vosListbox.getSelectedObject()));
} else {
vosListbox.addItem("No VO available");
sp.setWidget(new HTML(new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>You are not member of any VO.</h2>"));
}
}
@Override
public void onLoadingStart() {
vosListbox.clear();
vosListbox.addItem("Loading...");
}
@Override
public void onError(PerunError error) {
vosListbox.clear();
vosListbox.addItem("Error while loading");
sp.clear();
}
});
whereMember.retrieveData();
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.usersManager.GetVosWhereUserIsMember 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