use of cz.metacentrum.perun.webgui.json.facilitiesManager.AssignSecurityTeam in project perun by CESNET.
the class AssignSecurityTeamTabItem method draw.
public Widget draw() {
// TITLE
titleWidget.setText("Add security team");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// CALLBACK
final GetSecurityTeams secTeams = new GetSecurityTeams();
secTeams.setEvents(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (secTeams.getList().size() == 1) {
secTeams.getSelectionModel().setSelected(secTeams.getList().get(0), true);
}
}
});
secTeams.setForceAll(true);
CellTable<SecurityTeam> table = secTeams.getTable();
// ADD BUTTON
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSecurityTeam());
// tab to be closed
final TabItem tab = this;
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// get
ArrayList<SecurityTeam> list = secTeams.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
AssignSecurityTeam request = new AssignSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab, true));
request.assignSecurityTeam(facilityId, list.get(i).getId());
} else {
AssignSecurityTeam request = new AssignSecurityTeam(JsonCallbackEvents.disableButtonEvents(addButton));
request.assignSecurityTeam(facilityId, list.get(i).getId());
}
}
}
}
});
tabMenu.addWidget(addButton);
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
tabMenu.addFilterWidget(new ExtendedSuggestBox(secTeams.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
secTeams.filterTable(text);
if (secTeams.getList().size() == 1) {
secTeams.getSelectionModel().setSelected(secTeams.getList().get(0), true);
}
}
}, ButtonTranslation.INSTANCE.filterSecurityTeam());
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(secTeams, table, addButton);
// 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(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations