use of cz.metacentrum.perun.webgui.json.facilitiesManager.GetAssignedRichResources in project perun by CESNET.
the class FacilityResourcesTabItem method draw.
public Widget draw() {
// set title
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Resources");
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
// get VO resources
final GetAssignedRichResources resources = new GetAssignedRichResources(facility.getId());
// custom events for viewResource
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
// create resource button
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createResource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateFacilityResourceTabItem(facility), false);
}
}));
final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResource());
menu.addWidget(deleteButton);
deleteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
final ArrayList<RichResource> toDelete = resources.getTableSelectedList();
String text = "Following resources will be deleted.";
UiElements.showDeleteConfirm(toDelete, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < toDelete.size(); i++) {
if (i == toDelete.size() - 1) {
DeleteResource request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
request.deleteResource(toDelete.get(i).getId());
} else {
DeleteResource request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(deleteButton));
request.deleteResource(toDelete.get(i).getId());
}
}
}
});
}
});
menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
resources.filterTable(text);
}
}, "Filter resources by name or VO name");
CellTable<RichResource> table = resources.getTable(new FieldUpdater<RichResource, String>() {
public void update(int index, RichResource object, String value) {
session.getTabManager().addTab(new ResourceDetailTabItem(object, facilityId));
}
});
deleteButton.setEnabled(false);
JsonUtils.addTableManagedButton(resources, table, deleteButton);
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 350, this);
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.add(sp);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations