use of cz.metacentrum.perun.webgui.json.propagationStatsReader.GetTaskResultsByDestinations 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();
}
Aggregations