use of io.jmix.ui.component.pagination.data.PaginationDataBinder in project jmix by jmix-framework.
the class AbstractDataGrid method setupPaginationDataSourceProvider.
public void setupPaginationDataSourceProvider() {
if (pagination == null) {
return;
}
DataUnit items = getItems();
PaginationDataBinder provider;
if (items instanceof ContainerDataUnit) {
provider = applicationContext.getBean(PaginationDataUnitBinder.class, items);
} else if (items instanceof EmptyDataUnit && items instanceof EntityDataUnit) {
provider = new PaginationEmptyBinder(((EntityDataUnit) items).getEntityMetaClass());
} else {
throw new IllegalStateException("Unsupported data unit type: " + items);
}
pagination.setDataBinder(provider);
}
use of io.jmix.ui.component.pagination.data.PaginationDataBinder in project jmix by jmix-framework.
the class AbstractPaginationLoader method loadDataSourceProvider.
protected void loadDataSourceProvider(Element element) {
Element loaderProvider = element.element("loaderProvider");
Element containerProvider = element.element("containerProvider");
if (loaderProvider != null && containerProvider != null) {
throw new GuiDevelopmentException("Pagination must have only one provider: 'loaderProvider' or 'containerProvider'", getContext());
}
if (loaderProvider != null) {
loadString(loaderProvider, "loaderId", id -> {
ScreenData screenData = UiControllerUtils.getScreenData(getComponentContext().getFrame().getFrameOwner());
DataLoader loader = screenData.getLoader(id);
if (loader instanceof BaseCollectionLoader) {
PaginationDataBinder dataSourceProvider = applicationContext.getBean(PaginationLoaderBinder.class, loader);
resultComponent.setDataBinder(dataSourceProvider);
} else {
throw new GuiDevelopmentException(String.format("PaginationDataSourceProvider does not support %s loader type", loader.getClass().getCanonicalName()), getContext());
}
});
if (resultComponent.getDataBinder() == null) {
throw new GuiDevelopmentException("Specify 'loaderId' attribute of `loaderProvider` element", getContext());
}
}
if (containerProvider != null) {
loadString(containerProvider, "dataContainer", containerId -> {
ScreenData screenData = UiControllerUtils.getScreenData(getComponentContext().getFrame().getFrameOwner());
InstanceContainer container = screenData.getContainer(containerId);
if (container instanceof CollectionContainer) {
PaginationDataBinder dataSourceProvider = applicationContext.getBean(PaginationContainerBinder.class, container);
resultComponent.setDataBinder(dataSourceProvider);
} else {
throw new GuiDevelopmentException(String.format("PaginationDataSourceProvider does not support %s container type", container.getClass().getCanonicalName()), getContext());
}
});
if (resultComponent.getDataBinder() == null) {
throw new GuiDevelopmentException("Specify 'dataContainer' attribute of `containerProvider` element", getContext());
}
}
}
use of io.jmix.ui.component.pagination.data.PaginationDataBinder in project jmix by jmix-framework.
the class AbstractTable method setupPaginationDataSourceProvider.
public void setupPaginationDataSourceProvider() {
if (pagination == null) {
return;
}
DataUnit items = getItems();
PaginationDataBinder provider;
if (items instanceof ContainerDataUnit) {
provider = applicationContext.getBean(PaginationDataUnitBinder.class, items);
} else if (items instanceof EmptyDataUnit && items instanceof EntityDataUnit) {
provider = new PaginationEmptyBinder(((EntityDataUnit) items).getEntityMetaClass());
} else {
throw new IllegalStateException("Unsupported data unit type: " + items);
}
pagination.setDataBinder(provider);
}
Aggregations