use of cz.metacentrum.perun.webgui.json.ownersManager.GetOwners in project perun by CESNET.
the class AddFacilityOwnerTabItem method draw.
public Widget draw() {
// TITLE
titleWidget.setText("Add owner");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu tabMenu = new TabMenu();
// CALLBACK
final GetOwners owners = new GetOwners();
CellTable<Owner> table = owners.getTable();
// ADD BUTTON
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addOwners());
// tab to be closed
final TabItem tab = this;
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// get
ArrayList<Owner> list = owners.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) {
AddOwner request = new AddOwner(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab, true));
request.addOwner(facilityId, list.get(i).getId());
} else {
AddOwner request = new AddOwner(JsonCallbackEvents.disableButtonEvents(addButton));
request.addOwner(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(owners.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
owners.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterOwners());
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(owners, 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();
}
use of cz.metacentrum.perun.webgui.json.ownersManager.GetOwners 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();
}
use of cz.metacentrum.perun.webgui.json.ownersManager.GetOwners 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();
// FIXME - maybe make it configurable in a future
List<String> names = Arrays.asList("e-INFRA CZ LM2018140", "ELIXIR CZ LM2018131", "CESNET LM2015042 (MetaCentrum)", "CERIT-SC LM2015085");
owners.setFilterByNames(names);
// 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, isRefreshParentOnClose());
}
}));
// 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