use of cz.metacentrum.perun.webgui.json.facilitiesManager.GetFacilityOwners in project perun by CESNET.
the class FacilityOwnersTabItem method draw.
public Widget draw() {
// TITLE
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Owners");
// CONTENT
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// MENU
TabMenu menu = new TabMenu();
// CALLBACK
final GetFacilityOwners jsonCallback = new GetFacilityOwners(facility);
// AUTHZ
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
// add button
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addNewOwners());
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddFacilityOwnerTabItem(facility), true);
}
});
// remove button
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedOwners());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Owner> list = jsonCallback.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) {
RemoveOwner request = new RemoveOwner(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback)));
request.removeFacilityOwner(facilityId, list.get(i).getId());
} else {
RemoveOwner request = new RemoveOwner(JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeFacilityOwner(facilityId, list.get(i).getId());
}
}
}
});
}
});
menu.addWidget(addButton);
menu.addWidget(removeButton);
menu.addFilterWidget(new ExtendedSuggestBox(jsonCallback.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
jsonCallback.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterOwners());
// TABLE
CellTable<Owner> table = jsonCallback.getTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations