use of cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveSecurityTeam in project perun by CESNET.
the class FacilitySecurityTeamsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Security teams");
// main panel
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
final GetAssignedSecurityTeams securityTeams = new GetAssignedSecurityTeams(facilityId);
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignSecurityTeam(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AssignSecurityTeamTabItem(facility), true);
}
}));
// remove button
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedSecurityTeams());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<SecurityTeam> list = securityTeams.getTableSelectedList();
UiElements.showDeleteConfirm(list, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
RemoveSecurityTeam request = new RemoveSecurityTeam(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(securityTeams)));
request.removeSecurityTeam(facilityId, list.get(i).getId());
} else {
RemoveSecurityTeam request = new RemoveSecurityTeam(JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeSecurityTeam(facilityId, list.get(i).getId());
}
}
}
});
}
});
menu.addWidget(removeButton);
menu.addFilterWidget(new ExtendedSuggestBox(securityTeams.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
securityTeams.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterSecurityTeam());
CellTable<SecurityTeam> table;
if (session.isPerunAdmin() || session.isSecurityAdmin()) {
table = securityTeams.getTable(new FieldUpdater<SecurityTeam, String>() {
@Override
public void update(int index, SecurityTeam object, String value) {
session.getTabManager().addTab(new SecurityTeamDetailTabItem(object));
}
});
} else {
table = securityTeams.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 menu and the table to the main panel
firstTabPanel.add(menu);
firstTabPanel.setCellHeight(menu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations