Search in sources :

Example 1 with GetFacilityAssignedServicesForGUI

use of cz.metacentrum.perun.webgui.json.generalServiceManager.GetFacilityAssignedServicesForGUI in project perun by CESNET.

the class DestinationResultsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText("Tasks results: " + destination);
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    final ListBoxWithObjects<RichService> listbox = new ListBoxWithObjects<RichService>();
    final CustomButton cb = new CustomButton(ButtonTranslation.INSTANCE.forcePropagationButton(), ButtonTranslation.INSTANCE.forcePropagation(), SmallIcons.INSTANCE.arrowRightIcon());
    GetFacilityAssignedServicesForGUI servCall = new GetFacilityAssignedServicesForGUI(facilityId);
    servCall.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            listbox.clear();
            ArrayList<RichService> list = JsonUtils.jsoAsList(jso);
            list = new TableSorter<RichService>().sortByName(list);
            for (RichService s : list) {
                if (s.getAllowedOnFacility().equalsIgnoreCase("allowed") && (s.getGenExecService() != null && s.getGenExecService().isEnabled()) && (s.getSendExecService() != null && s.getSendExecService().isEnabled())) {
                    listbox.addItem(s);
                }
            }
            if (listbox.isEmpty()) {
                listbox.addItem("No service available");
                cb.setEnabled(false);
            }
        }

        @Override
        public void onError(PerunError error) {
            listbox.clear();
            listbox.addItem("Error while loading");
            cb.setEnabled(false);
        }

        @Override
        public void onLoadingStart() {
            listbox.clear();
            listbox.addItem("Loading...");
        }
    });
    if (facilityId != 0) {
        servCall.retrieveData();
    }
    cb.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            ForceServicePropagation force = new ForceServicePropagation(JsonCallbackEvents.disableButtonEvents(cb));
            force.forcePropagation(facilityId, listbox.getSelectedObject().getId());
        }
    });
    menu.addWidget(cb);
    menu.addWidget(new HTML("<strong>Service: </strong>"));
    menu.addWidget(listbox);
    Anchor a = new Anchor("View facility details >>");
    a.setStyleName("pointer");
    a.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTab(new FacilityDetailTabItem(facility));
        }
    });
    menu.addWidget(a);
    ArrayList<String> dest = new ArrayList<String>();
    dest.add(destination);
    final GetTaskResultsByDestinations callback = new GetTaskResultsByDestinations(dest);
    CellTable<TaskResult> table = callback.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ForceServicePropagation(cz.metacentrum.perun.webgui.json.generalServiceManager.ForceServicePropagation) GetTaskResultsByDestinations(cz.metacentrum.perun.webgui.json.propagationStatsReader.GetTaskResultsByDestinations) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) GetFacilityAssignedServicesForGUI(cz.metacentrum.perun.webgui.json.generalServiceManager.GetFacilityAssignedServicesForGUI) ArrayList(java.util.ArrayList) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 ForceServicePropagation (cz.metacentrum.perun.webgui.json.generalServiceManager.ForceServicePropagation)1 GetFacilityAssignedServicesForGUI (cz.metacentrum.perun.webgui.json.generalServiceManager.GetFacilityAssignedServicesForGUI)1 GetTaskResultsByDestinations (cz.metacentrum.perun.webgui.json.propagationStatsReader.GetTaskResultsByDestinations)1 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)1 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)1 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1 ArrayList (java.util.ArrayList)1