use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.
the class GetFacilityOwners method setList.
public void setList(ArrayList<Owner> list) {
clearTable();
this.list.addAll(list);
for (Owner o : list) {
oracle.add(o.getName());
oracle.add(o.getContact());
oracle.add(Owner.getTranslatedType(o.getType()));
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.
the class GetFacilityOwners method filterTable.
@Override
public void filterTable(String filter) {
// store list only for first time
if (backupList.isEmpty() || backupList == null) {
backupList.addAll(list);
}
// always clear selected items
selectionModel.clear();
list.clear();
if (filter.equalsIgnoreCase("")) {
list.addAll(backupList);
} else {
for (Owner o : backupList) {
// store owner by filter
if (o.getName().toLowerCase().contains(filter.toLowerCase()) || o.getContact().toLowerCase().contains(filter.toLowerCase()) || Owner.getTranslatedType(o.getType()).toLowerCase().startsWith(Owner.getTranslatedType(filter).toLowerCase())) {
list.add(o);
}
}
}
if (list.isEmpty() && !filter.isEmpty()) {
loaderImage.setEmptyResultMessage("No facility owner matching '" + filter + "' found.");
} else {
loaderImage.setEmptyResultMessage("Facility has no owners.");
}
loaderImage.loadingFinished();
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.
the class GetOwners method onFinished.
/**
* Called when loading successfully finishes.
*/
public void onFinished(JavaScriptObject jso) {
if (type.isEmpty()) {
// don't filter
setList(JsonUtils.<Owner>jsoAsList(jso));
} else {
// filter
for (Owner o : JsonUtils.<Owner>jsoAsList(jso)) {
if (type.equalsIgnoreCase(o.getType())) {
addToTable(o);
}
}
}
sortTable();
loaderImage.loadingFinished();
session.getUiElements().setLogText("Owners loaded: " + list.size());
events.onFinished(jso);
}
use of cz.metacentrum.perun.webgui.model.Owner 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));
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, false);
}
}));
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.model.Owner 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