use of cz.metacentrum.perun.webgui.json.resourcesManager.GetAllowedResources in project perun by CESNET.
the class SelfResourcesSettingsTabItem method userSettingsForVo.
/**
* User settings for the VO
* @param vo
* @param member
* @return
*/
protected Widget userSettingsForVo(final VirtualOrganization vo, Member member) {
final VerticalPanel vp = new VerticalPanel();
vp.setWidth("100%");
GetAllowedResources resourcesCallback = new GetAllowedResources(member.getId(), new JsonCallbackEvents() {
@Override
public void onLoadingStart() {
vp.clear();
vp.add(new AjaxLoaderImage());
}
@Override
public void onFinished(JavaScriptObject jso) {
vp.clear();
// convert & sort
ArrayList<Resource> resources = JsonUtils.jsoAsList(jso);
resources = new TableSorter<Resource>().sortByDescription(resources);
// if empty
if (resources.isEmpty() || resources == null) {
FlexTable ft = new FlexTable();
ft.setHTML(0, 0, "<p><strong>VO " + SafeHtmlUtils.fromString((vo.getName() != null) ? vo.getName() : "").asString() + " doesn't provide any resources to configure.</strong></p>");
vp.add(ft);
return;
}
// process
for (Resource r : resources) {
DisclosurePanel settings = new DisclosurePanel();
settings.setWidth("100%");
final FlexTable header = new FlexTable();
header.setWidth("100%");
header.setWidget(0, 0, new Image(LargeIcons.INSTANCE.databaseServerIcon()));
header.getFlexCellFormatter().setWidth(0, 0, "40px");
Anchor a = new Anchor("<p class=\"now-managing\">" + r.getDescription() + " (" + r.getName() + ")</p>", true);
header.setWidget(0, 1, a);
header.setTitle("Click to show setting for resource " + r.getName());
settings.setHeader(header);
// load content for each resource
loadSettings(settings, r);
vp.add(settings);
}
}
});
resourcesCallback.retrieveData();
return vp;
}
Aggregations