Search in sources :

Example 16 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 17 with CollectionContainer

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

the class TokenListLoader method loadOptionsContainer.

protected void loadOptionsContainer(TokenList component, Element element) {
    String containerId = element.attributeValue("optionsContainer");
    if (containerId != null) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        InstanceContainer container = screenData.getContainer(containerId);
        if (!(container instanceof CollectionContainer)) {
            throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context);
        }
        // noinspection unchecked
        component.setOptions(new ContainerOptions((CollectionContainer) container));
    }
    if (component.getOptions() == null) {
        DatasourceLoaderHelper.loadOptionsDatasource(element, (ComponentLoaderContext) getComponentContext()).ifPresent(component::setOptions);
    }
}
Also used : ContainerOptions(io.jmix.ui.component.data.options.ContainerOptions) 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