use of cz.metacentrum.perun.webgui.model.RichResource 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();
}
use of cz.metacentrum.perun.webgui.model.RichResource in project perun by CESNET.
the class GetAssignedRichResources method setList.
public void setList(ArrayList<RichResource> list) {
clearTable();
this.list.addAll(list);
for (RichResource rr : list) {
oracle.add(rr.getVo().getName());
oracle.add(rr.getVo().getShortName());
oracle.add(rr.getName());
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.RichResource in project perun by CESNET.
the class VoResourcesTabItem method draw.
public Widget draw() {
// set title
titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": resources");
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
// refresh
menu.addWidget(UiElements.getRefreshButton(this));
// get VO resources
final GetRichResources resources = new GetRichResources(voId);
if (!session.isVoAdmin(voId))
resources.setCheckable(false);
// custom events for viewResource
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResource());
menu.addWidget(removeButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<RichResource> resourcesForDeleting = resources.getTableSelectedList();
String text = "Following resources will be deleted and VO members won't be able to access them anymore.";
UiElements.showDeleteConfirm(resourcesForDeleting, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < resourcesForDeleting.size(); i++) {
DeleteResource request;
if (i == resourcesForDeleting.size() - 1) {
request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteResource(resourcesForDeleting.get(i).getId());
}
}
});
}
});
// add menu to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
// filter box
menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
resources.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterResources());
CellTable<RichResource> table = resources.getTable(new FieldUpdater<RichResource, String>() {
public void update(int index, RichResource object, String value) {
session.getTabManager().addTab(new ResourceDetailTabItem(object, 0));
}
});
removeButton.setEnabled(false);
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(resources, table, removeButton);
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.RichResource in project perun by CESNET.
the class GetAssignedRichResources method setList.
public void setList(ArrayList<RichResource> list) {
clearTable();
this.list.addAll(list);
for (RichResource r : list) {
oracle.add(r.getName());
for (ResourceTag rt : r.getResourceTags()) {
oracle.add(rt.getName() + " (tag)");
}
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.RichResource in project perun by CESNET.
the class GetAssignedRichResources method filterTable.
public void filterTable(String filter) {
// store list only for first time
if (fullBackup.isEmpty() || fullBackup == null) {
fullBackup.addAll(list);
}
// always clear selected items
selectionModel.clear();
list.clear();
if (filter.equalsIgnoreCase("")) {
list.addAll(fullBackup);
} else {
for (RichResource res : fullBackup) {
// store resource by filter
if (res.getName().toLowerCase().contains(filter.toLowerCase())) {
list.add(res);
}
for (ResourceTag r : res.getResourceTags()) {
// remove " (tag)" after tag name
if (r.getName().contains(filter.substring(0, (filter.length() > 6) ? filter.length() - 6 : filter.length()).trim())) {
list.add(res);
break;
}
}
}
}
if (list.isEmpty() && !filter.isEmpty()) {
loaderImage.setEmptyResultMessage("No resource matching '" + filter + "' found.");
} else {
if (PerunEntity.GROUP.equals(entity)) {
loaderImage.setEmptyResultMessage("Group is not assigned to any resource.");
} else if (PerunEntity.MEMBER.equals(entity)) {
loaderImage.setEmptyResultMessage("Member has no access to VO resources.");
}
}
dataProvider.flush();
dataProvider.refresh();
loaderImage.loadingFinished();
}
Aggregations