use of cz.metacentrum.perun.webgui.json.groupsManager.RemoveMember in project perun by CESNET.
the class MemberGroupsTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": groups");
// main widget panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
final GetMemberGroups groupsCall = new GetMemberGroups(memberId);
menu.addWidget(UiElements.getRefreshButton(this));
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, "Add member to new group", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new MemberAddToGroupTabItem(member), true);
}
});
if (session.isVoObserver(member.getVoId()) && !session.isVoAdmin(member.getVoId())) {
addButton.setEnabled(false);
groupsCall.setCheckable(false);
}
menu.addWidget(addButton);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove member from selected group(s)");
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
final ArrayList<Group> list = groupsCall.getTableSelectedList();
String confirmText = member.getUser().getFullName() + " will be removed from following groups.";
UiElements.showDeleteConfirm(list, confirmText, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
RemoveMember request = new RemoveMember(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(groupsCall)));
request.removeMemberFromGroups(member, list);
}
});
}
});
removeButton.setEnabled(false);
menu.addWidget(removeButton);
menu.addFilterWidget(new ExtendedSuggestBox(groupsCall.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
groupsCall.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
CellTable<Group> table = groupsCall.getTable(new FieldUpdater<Group, String>() {
@Override
public void update(int i, Group group, String s) {
if (session.isVoAdmin(group.getVoId()) || session.isVoObserver(group.getVoId()) || session.isGroupAdmin(group.getId())) {
session.getTabManager().addTab(new GroupDetailTabItem(group));
} else {
UiElements.generateInfo("Not privileged", "You are not manager of selected group or it's VO.");
}
}
});
if (session.isVoAdmin(member.getVoId()) || session.isGroupAdmin(groupId))
JsonUtils.addTableManagedButton(groupsCall, table, removeButton);
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 350, this);
vp.add(sp);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations