use of io.jmix.ui.component.data.meta.ContainerDataUnit 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.data.meta.ContainerDataUnit in project jmix by jmix-framework.
the class RemoveOperation method builder.
/**
* Creates a remove builder using list component, e.g. {@link Table} or {@link DataGrid}.
*
* @param listComponent list component
* @param <E> type of entity
*/
public <E> RemoveBuilder<E> builder(ListComponent<E> listComponent) {
checkNotNullArgument(listComponent);
checkNotNullArgument(listComponent.getFrame());
FrameOwner frameOwner = listComponent.getFrame().getFrameOwner();
Class<E> entityClass;
DataUnit items = listComponent.getItems();
if (items instanceof ContainerDataUnit) {
entityClass = ((ContainerDataUnit) items).getEntityMetaClass().getJavaClass();
} else {
throw new IllegalStateException(String.format("Component %s is not bound to data", listComponent));
}
return builder(entityClass, frameOwner).withListComponent(listComponent);
}
use of io.jmix.ui.component.data.meta.ContainerDataUnit in project jmix by jmix-framework.
the class ListPrintFormAction method printSelected.
protected void printSelected(Set selected) {
ContainerDataUnit unit = (ContainerDataUnit) target.getItems();
InstanceContainer container = unit.getContainer();
MetaClass metaClass = container.getEntityMetaClass();
Window window = ComponentsHelper.getWindowNN(target);
openRunReportScreen(window.getFrameOwner(), selected, metaClass);
}
use of io.jmix.ui.component.data.meta.ContainerDataUnit in project jmix by jmix-framework.
the class ListPrintFormAction method isDataAvailable.
protected boolean isDataAvailable() {
ContainerDataUnit unit = (ContainerDataUnit) target.getItems();
CollectionContainer container = unit.getContainer();
return container instanceof HasLoader && unit.getState() == BindingState.ACTIVE && !container.getItems().isEmpty();
}
use of io.jmix.ui.component.data.meta.ContainerDataUnit in project jmix by jmix-framework.
the class TestProgrammaticCommentaryPanel method addMessage.
protected void addMessage(String text) {
if (getCommentProvider() == null) {
return;
}
CommentObject comment = getCommentProvider().apply(text);
DataGridItems<CommentObject> items = commentsDataGrid.getItems();
if (items instanceof ContainerDataUnit) {
// noinspection unchecked
CollectionContainer<CommentObject> container = ((ContainerDataUnit<CommentObject>) items).getContainer();
container.getMutableItems().add(comment);
} else {
throw new IllegalStateException("Items must implement ContainerDataUnit");
}
}
Aggregations