use of cz.metacentrum.perun.webgui.json.resourcesManager.RemoveGroupsFromResource in project perun by CESNET.
the class ResourceAssignedGroupsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": manage assigned groups");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
final GetAssignedGroups resourceGroups = new GetAssignedGroups(resourceId);
final JsonCallbackEvents localEvents = JsonCallbackEvents.refreshTableEvents(resourceGroups);
CustomButton assignGroupButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignGroupToResource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AssignGroupTabItem(resource), true);
}
});
final CustomButton removeGroupButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupFromResource());
removeGroupButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Group> groupsForRemoving = resourceGroups.getTableSelectedList();
String text = "Following groups will be removed from resource.";
UiElements.showDeleteConfirm(groupsForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
RemoveGroupsFromResource request = new RemoveGroupsFromResource(JsonCallbackEvents.disableButtonEvents(removeGroupButton, localEvents));
request.removeGroupsFromResource(groupsForRemoving, resource);
}
});
}
});
if (!session.isVoAdmin(resource.getVoId())) {
resourceGroups.setCheckable(false);
assignGroupButton.setEnabled(false);
}
menu.addWidget(assignGroupButton);
menu.addWidget(removeGroupButton);
menu.addFilterWidget(new ExtendedSuggestBox(resourceGroups.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
resourceGroups.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
// display menu to vo admin only
if (session.isVoAdmin(resource.getVoId())) {
resourceGroups.setCheckable(true);
vp.add(menu);
vp.setCellHeight(menu, "30px");
} else {
resourceGroups.setCheckable(false);
}
// table with field updater which leads to group detail
CellTable<Group> table = resourceGroups.getTable(new FieldUpdater<Group, String>() {
public void update(int index, Group object, String value) {
session.getTabManager().addTab(new GroupDetailTabItem(object));
}
});
removeGroupButton.setEnabled(false);
if (session.isVoAdmin(resource.getVoId()))
JsonUtils.addTableManagedButton(resourceGroups, table, removeGroupButton);
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