use of cz.metacentrum.perun.webgui.json.securityTeamsManager.DeleteSecurityTeam in project perun by CESNET.
the class SecurityTeamSelectTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// Get vos request
final GetSecurityTeams teams = new GetSecurityTeams();
if (!session.isPerunAdmin()) {
teams.setCheckable(false);
}
// 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));
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createSecurityTeam(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateSecurityTeamTabItem());
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, buttonTranslation.deleteSecurityTeam());
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<SecurityTeam> 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++) {
DeleteSecurityTeam request;
if (i == itemsToRemove.size() - 1) {
request = new DeleteSecurityTeam(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new DeleteSecurityTeam(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteSecurityTeam(itemsToRemove.get(i).getId(), false);
}
}
});
}
});
tabMenu.addWidget(removeButton);
// filter
tabMenu.addFilterWidget(new ExtendedSuggestBox(teams.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
teams.filterTable(text);
}
}, buttonTranslation.filterSecurityTeam());
tabMenu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
tabMenu.addWidget(new HTML("<strong>Please select Team you want to manage.</strong>"));
final TabItem tab = this;
// get the table with custom onclick
CellTable<SecurityTeam> table = teams.getTable(new FieldUpdater<SecurityTeam, String>() {
@Override
public void update(int i, SecurityTeam securityTeam, String string) {
session.getTabManager().addTab(new SecurityTeamDetailTabItem(securityTeam));
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
});
// 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