use of com.vaadin.data.provider.DataProvider in project opencms-core by alkacon.
the class CmsUserEditDialog method iniRole.
/**
* Initialized the role ComboBox. (Vaadin 8 version)<p>
*
* @param cms CmsObject
* @param ou to load roles for
* @param roleComboBox ComboBox
* @param log LOG
*/
protected static void iniRole(CmsObject cms, String ou, com.vaadin.ui.ComboBox<CmsRole> roleComboBox, Log log) {
try {
List<CmsRole> roles = OpenCms.getRoleManager().getRoles(cms, ou, false);
CmsRole.applySystemRoleOrder(roles);
DataProvider provider = new ListDataProvider<CmsRole>(roles);
roleComboBox.setDataProvider(provider);
roleComboBox.setItemCaptionGenerator(role -> {
try {
return role.getDisplayName(cms, A_CmsUI.get().getLocale());
} catch (CmsException e) {
return "";
}
});
roleComboBox.setEmptySelectionAllowed(false);
} catch (CmsException e) {
if (log != null) {
log.error("Unable to read roles.", e);
}
}
}
use of com.vaadin.data.provider.DataProvider in project SORMAS-Project by hzi-braunschweig.
the class EventSelectionGrid method setLazyDataProvider.
public void setLazyDataProvider() {
DataProvider<EventIndexDto, EventCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getEventFacade().getIndexList(query.getFilter().orElse(null), query.getOffset(), query.getLimit(), query.getSortOrders().stream().map(sortOrder -> new SortProperty(sortOrder.getSorted(), sortOrder.getDirection() == SortDirection.ASCENDING)).collect(Collectors.toList())).stream(), query -> (int) FacadeProvider.getEventFacade().count(query.getFilter().orElse(null)));
setDataProvider(dataProvider);
setSelectionMode(com.vaadin.ui.Grid.SelectionMode.NONE);
EventSelectionGrid tempGrid = this;
dataProvider.addDataProviderListener((DataProviderListener<EventIndexDto>) dataChangeEvent -> {
if (tempGrid.getItemCount() > 0) {
tempGrid.setHeightByRows(Math.min(tempGrid.getItemCount(), 5));
} else {
tempGrid.setHeightByRows(1);
}
});
}
use of com.vaadin.data.provider.DataProvider in project SORMAS-Project by hzi-braunschweig.
the class EventGroupSelectionGrid method setLazyDataProvider.
public void setLazyDataProvider() {
DataProvider<EventGroupIndexDto, EventGroupCriteria> dataProvider = DataProvider.fromFilteringCallbacks(query -> FacadeProvider.getEventGroupFacade().getIndexList(query.getFilter().orElse(null), query.getOffset(), query.getLimit(), query.getSortOrders().stream().map(sortOrder -> new SortProperty(sortOrder.getSorted(), sortOrder.getDirection() == SortDirection.ASCENDING)).collect(Collectors.toList())).stream(), query -> (int) FacadeProvider.getEventGroupFacade().count(query.getFilter().orElse(null)));
setDataProvider(dataProvider);
setSelectionMode(SelectionMode.NONE);
EventGroupSelectionGrid tempGrid = this;
dataProvider.addDataProviderListener((DataProviderListener<EventGroupIndexDto>) dataChangeEvent -> {
if (tempGrid.getItemCount() > 0) {
tempGrid.setHeightByRows(Math.min(tempGrid.getItemCount(), 5));
} else {
tempGrid.setHeightByRows(1);
}
});
}
Aggregations