Search in sources :

Example 6 with ContainerDataUnit

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);
}
Also used : PaginationDataUnitBinder(io.jmix.ui.component.pagination.data.PaginationDataUnitBinder) PaginationEmptyBinder(io.jmix.ui.component.pagination.data.PaginationEmptyBinder) EmptyDataUnit(io.jmix.ui.component.data.meta.EmptyDataUnit) DataUnit(io.jmix.ui.component.data.DataUnit) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) EmptyDataUnit(io.jmix.ui.component.data.meta.EmptyDataUnit) PaginationDataBinder(io.jmix.ui.component.pagination.data.PaginationDataBinder) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit)

Example 7 with ContainerDataUnit

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);
}
Also used : ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) DataUnit(io.jmix.ui.component.data.DataUnit) FrameOwner(io.jmix.ui.screen.FrameOwner) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit)

Example 8 with ContainerDataUnit

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);
}
Also used : Window(io.jmix.ui.component.Window) MetaClass(io.jmix.core.metamodel.model.MetaClass) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit)

Example 9 with ContainerDataUnit

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();
}
Also used : ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit)

Example 10 with ContainerDataUnit

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");
    }
}
Also used : ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) CommentObject(test_support.entity.model_objects.CommentObject)

Aggregations

ContainerDataUnit (io.jmix.ui.component.data.meta.ContainerDataUnit)20 MetaClass (io.jmix.core.metamodel.model.MetaClass)8 DataUnit (io.jmix.ui.component.data.DataUnit)6 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)5 Nested (io.jmix.ui.model.Nested)4 UiEntityAttributeContext (io.jmix.ui.accesscontext.UiEntityAttributeContext)3 EmptyDataUnit (io.jmix.ui.component.data.meta.EmptyDataUnit)3 EntityDataUnit (io.jmix.ui.component.data.meta.EntityDataUnit)3 CollectionContainer (io.jmix.ui.model.CollectionContainer)3 Screens (io.jmix.ui.Screens)2 io.jmix.ui.component (io.jmix.ui.component)2 Frame (io.jmix.ui.component.Frame)2 Window (io.jmix.ui.component.Window)2 PaginationDataBinder (io.jmix.ui.component.pagination.data.PaginationDataBinder)2 PaginationDataUnitBinder (io.jmix.ui.component.pagination.data.PaginationDataUnitBinder)2 PaginationEmptyBinder (io.jmix.ui.component.pagination.data.PaginationEmptyBinder)2 DataContext (io.jmix.ui.model.DataContext)2 DataLoader (io.jmix.ui.model.DataLoader)2 HasLoader (io.jmix.ui.model.HasLoader)2 FrameOwner (io.jmix.ui.screen.FrameOwner)2