use of cz.metacentrum.perun.webgui.json.resourcesManager.RemoveResourceTag in project perun by CESNET.
the class ResourceTagsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": manage assigned tags");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
final GetAllResourcesTags tags = new GetAllResourcesTags(PerunEntity.RESOURCE, resourceId);
final JsonCallbackEvents localEvents = JsonCallbackEvents.refreshTableEvents(tags);
CustomButton assignTagsButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignTagsToResource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AssignTagTabItem(resource), true);
}
});
final CustomButton removeTagsButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedTagsFromResource());
removeTagsButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ResourceTag> tagsToRemove = tags.getTableSelectedList();
String text = "Following groups will be removed from resource.";
UiElements.showDeleteConfirm(tagsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD USE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < tagsToRemove.size(); i++) {
if (i == tagsToRemove.size() - 1) {
RemoveResourceTag request = new RemoveResourceTag(resource.getId(), JsonCallbackEvents.disableButtonEvents(removeTagsButton, localEvents));
request.removeResourceTag(tagsToRemove.get(i));
} else {
RemoveResourceTag request = new RemoveResourceTag(resource.getId(), JsonCallbackEvents.disableButtonEvents(removeTagsButton));
request.removeResourceTag(tagsToRemove.get(i));
}
}
}
});
}
});
if (!session.isVoAdmin(resource.getVoId())) {
assignTagsButton.setEnabled(false);
removeTagsButton.setEnabled(false);
tags.setCheckable(false);
}
menu.addWidget(assignTagsButton);
menu.addWidget(removeTagsButton);
menu.addFilterWidget(new ExtendedSuggestBox(tags.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
tags.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterTags());
// display menu to vo admin only
vp.add(menu);
vp.setCellHeight(menu, "30px");
// table with field updater which leads to group detail
CellTable<ResourceTag> table = tags.getTable();
removeTagsButton.setEnabled(false);
JsonUtils.addTableManagedButton(tags, table, removeTagsButton);
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();
}
Aggregations