use of cz.metacentrum.perun.webgui.json.authzResolver.GetAdmins in project perun by CESNET.
the class SecurityTeamMembersTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(securityTeam.getName()) + ": " + "members");
// Get vos request
final GetAdmins teams = new GetAdmins(PerunEntity.SECURITY_TEAM, securityTeamId);
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(teams);
TabMenu tabMenu = new TabMenu();
// add menu to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
tabMenu.addWidget(UiElements.getRefreshButton(this));
// do not display to sec admins only
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addMemberToSecurityTeam(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddSecurityTeamManagerTabItem(securityTeam), true);
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, buttonTranslation.removeMemberOfSecurityTeam());
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<User> itemsToRemove = teams.getTableSelectedList();
UiElements.showDeleteConfirm(itemsToRemove, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
RemoveAdmin request;
if (i == itemsToRemove.size() - 1) {
request = new RemoveAdmin(PerunEntity.SECURITY_TEAM, JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveAdmin(PerunEntity.SECURITY_TEAM, JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeSecurityTeamAdmin(securityTeam, itemsToRemove.get(i));
}
}
});
}
});
tabMenu.addWidget(removeButton);
final TabItem tab = this;
CellTable<User> table;
if (session.isPerunAdmin()) {
// get the table with custom onclick
table = teams.getTable(new FieldUpdater<User, String>() {
@Override
public void update(int i, User user, String string) {
session.getTabManager().addTab(new UserDetailTabItem(user));
session.getTabManager().closeTab(tab, false);
}
});
} else {
table = teams.getTable();
}
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add the table to the main panel
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, 0, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations