use of cz.metacentrum.perun.webgui.json.ownersManager.DeleteOwner in project perun by CESNET.
the class OwnersTabItem method draw.
public Widget draw() {
// tab content
final VerticalPanel mainTab = new VerticalPanel();
mainTab.setSize("100%", "100%");
// horizontal menu
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
final GetOwners owners = new GetOwners();
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(owners);
// create button
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createOwner(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateOwnerTabItem());
}
}));
// remove button
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteOwner());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Owner> itemsToRemove = owners.getTableSelectedList();
String text = "Following owners will be removed.";
UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
DeleteOwner request;
if (i == itemsToRemove.size() - 1) {
request = new DeleteOwner(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new DeleteOwner(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteOwner(itemsToRemove.get(i).getId());
}
}
});
}
});
tabMenu.addWidget(removeButton);
tabMenu.addFilterWidget(new ExtendedSuggestBox(owners.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
owners.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterOwners());
// adding menu to the page
mainTab.add(tabMenu);
mainTab.setCellHeight(tabMenu, "30px");
CellTable<Owner> table = owners.getTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel();
sp.add(table);
sp.addStyleName("perun-tableScrollPanel");
mainTab.add(sp);
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(owners, table, removeButton);
// resize perun table to correct size on screen
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(mainTab);
return getWidget();
}
Aggregations