use of cz.metacentrum.perun.webgui.json.cabinetManager.CreateThanks in project perun by CESNET.
the class CreateThanksTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// CALLBACK
final GetOwners owners = new GetOwners();
// MENU
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
// add button
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Add acknowledgement for selected owner(s)");
final TabItem tab = this;
// click handler
addButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ArrayList<Owner> list = owners.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i = 0; i < list.size(); i++) {
final String name = list.get(i).getName();
// add name events
JsonCallbackEvents thanksEvents = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
updateAlreadyAdded(name);
}
};
// merge with refresh?
if (i == list.size() - 1 && events != null) {
thanksEvents = JsonCallbackEvents.mergeEvents(thanksEvents, events);
}
CreateThanks request = new CreateThanks(publicationId, JsonCallbackEvents.disableButtonEvents(addButton, thanksEvents));
request.createThanks(list.get(i).getId());
if (i == list.size() - 1) {
owners.clearTableSelectedSet();
}
}
}
}
});
menu.addWidget(addButton);
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// trigger refresh of sub-tab via event
events.onFinished(null);
session.getTabManager().closeTab(tab, false);
}
}));
// add already added
vp.add(alreadyAddedOwners);
vp.setCellHeight(alreadyAddedOwners, "30px");
// TABLE
// show only administrative contacts
owners.setFilterByType("administrative");
CellTable<Owner> table = owners.getTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel();
sp.add(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
// resize small tab panel to correct size on screen
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(owners, table, addButton);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations