Search in sources :

Example 1 with GetAllowedResources

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;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) ArrayList(java.util.ArrayList) ImageResource(com.google.gwt.resources.client.ImageResource) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) GetAllowedResources(cz.metacentrum.perun.webgui.json.resourcesManager.GetAllowedResources) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ImageResource (com.google.gwt.resources.client.ImageResource)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 GetAllowedResources (cz.metacentrum.perun.webgui.json.resourcesManager.GetAllowedResources)1 AjaxLoaderImage (cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)1 ArrayList (java.util.ArrayList)1