Search in sources :

Example 11 with CollectionContainer

use of io.jmix.ui.model.CollectionContainer in project jmix by jmix-framework.

the class AbstractChartLoader method loadDataContainer.

protected void loadDataContainer(Chart chart, Element element) {
    String dataContainerId = element.attributeValue("dataContainer");
    if (StringUtils.isNotEmpty(dataContainerId)) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        CollectionContainer dataContainer;
        InstanceContainer container = screenData.getContainer(dataContainerId);
        if (container instanceof CollectionContainer) {
            dataContainer = (CollectionContainer) container;
        } else {
            throw new GuiDevelopmentException("Not a CollectionContainer: " + dataContainerId, context);
        }
        chart.setDataProvider(new ContainerDataProvider(dataContainer));
    }
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) CollectionContainer(io.jmix.ui.model.CollectionContainer) InstanceContainer(io.jmix.ui.model.InstanceContainer) ContainerDataProvider(io.jmix.ui.data.impl.ContainerDataProvider) ScreenData(io.jmix.ui.model.ScreenData)

Example 12 with CollectionContainer

use of io.jmix.ui.model.CollectionContainer in project jmix by jmix-framework.

the class ShowPivotAction method showPivotTable.

@SuppressWarnings("unchecked")
protected void showPivotTable(ShowPivotMode mode) {
    Frame frame = target.getFrame();
    if (frame == null) {
        throw new IllegalStateException(String.format("ShowPivotAction cannot be used by component '%s' which is not added to frame", target.getId()));
    }
    Collection items;
    if (ShowPivotMode.ALL_ROWS.equals(mode)) {
        if (target.getItems() instanceof ContainerDataUnit) {
            CollectionContainer container = ((ContainerDataUnit) target.getItems()).getContainer();
            items = container.getItems();
        } else {
            items = Collections.emptyList();
        }
    } else {
        items = target.getSelected();
    }
    PivotScreenBuilder showPivotManager = applicationContext.getBean(PivotScreenBuilder.class, target);
    showPivotManager.withItems(items).withIncludedProperties(parseProperties(includedProperties)).withExcludedProperties(parseProperties(excludedProperties)).build().show();
}
Also used : Frame(io.jmix.ui.component.Frame) Collection(java.util.Collection) CollectionContainer(io.jmix.ui.model.CollectionContainer) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit)

Example 13 with CollectionContainer

use of io.jmix.ui.model.CollectionContainer in project jmix by jmix-framework.

the class EntityFieldCreationSupport method createCollectionContainer.

public CollectionContainer createCollectionContainer(MetaClass metaClass) {
    CollectionContainer container = dataComponents.createCollectionContainer(metaClass.getJavaClass());
    List list = dataManager.load(metaClass.getJavaClass()).all().fetchPlan(FetchPlan.INSTANCE_NAME).sort(Sort.by(getInstanceNameSortOrders(metaClass))).list();
    container.setItems(list);
    return container;
}
Also used : CollectionContainer(io.jmix.ui.model.CollectionContainer) List(java.util.List)

Example 14 with CollectionContainer

use of io.jmix.ui.model.CollectionContainer in project jmix by jmix-framework.

the class TableFieldFactoryImpl method getOptions.

@SuppressWarnings("unchecked")
@Nullable
protected Options getOptions(EntityValueSource valueSource, String property) {
    MetaClass metaClass = valueSource.getEntityMetaClass();
    MetaPropertyPath metaPropertyPath = metadataTools.resolveMetaPropertyPathOrNull(metaClass, property);
    Table.Column columnConf = webTable.getColumnsInternal().get(metaPropertyPath);
    CollectionContainer collectionContainer = findOptionsContainer(columnConf);
    if (collectionContainer != null) {
        return new ContainerOptions(collectionContainer);
    }
    return null;
}
Also used : ContainerOptions(io.jmix.ui.component.data.options.ContainerOptions) AbstractTable(io.jmix.ui.component.impl.AbstractTable) MetaClass(io.jmix.core.metamodel.model.MetaClass) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) CollectionContainer(io.jmix.ui.model.CollectionContainer) Nullable(javax.annotation.Nullable)

Example 15 with CollectionContainer

use of io.jmix.ui.model.CollectionContainer in project jmix by jmix-framework.

the class TestCommentaryPanelLoader method loadDataContainer.

private void loadDataContainer(TestCommentaryPanel resultComponent, Element element) {
    String containerId = this.element.attributeValue("dataContainer");
    if (Strings.isNullOrEmpty(containerId)) {
        throw new GuiDevelopmentException("CommentaryPanel element doesn't have 'dataContainer' attribute", context, "CommentaryPanel ID", element.attributeValue("id"));
    }
    FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
    ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
    InstanceContainer container = screenData.getContainer(containerId);
    if (container instanceof CollectionContainer) {
        resultComponent.setDataContainer((CollectionContainer) container);
    } else {
        throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
    }
}
Also used : FrameOwner(io.jmix.ui.screen.FrameOwner) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) InstanceContainer(io.jmix.ui.model.InstanceContainer) CollectionContainer(io.jmix.ui.model.CollectionContainer) ScreenData(io.jmix.ui.model.ScreenData)

Aggregations

CollectionContainer (io.jmix.ui.model.CollectionContainer)17 InstanceContainer (io.jmix.ui.model.InstanceContainer)11 ScreenData (io.jmix.ui.model.ScreenData)10 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)9 FrameOwner (io.jmix.ui.screen.FrameOwner)9 MetaClass (io.jmix.core.metamodel.model.MetaClass)3 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)3 ContainerDataUnit (io.jmix.ui.component.data.meta.ContainerDataUnit)3 ContainerOptions (io.jmix.ui.component.data.options.ContainerOptions)3 ContainerDataProvider (io.jmix.ui.data.impl.ContainerDataProvider)3 Nullable (javax.annotation.Nullable)3 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 Datatypes (com.haulmont.chile.core.datatypes.Datatypes)1 CubaProperties (com.haulmont.cuba.CubaProperties)1 PersistenceManagerClient (com.haulmont.cuba.client.sys.PersistenceManagerClient)1 Lookup (com.haulmont.cuba.core.entity.annotation.Lookup)1 LookupType (com.haulmont.cuba.core.entity.annotation.LookupType)1 AppBeans (com.haulmont.cuba.core.global.AppBeans)1 Messages (com.haulmont.cuba.core.global.Messages)1