Search in sources :

Example 1 with CollectionContainer

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

the class TableFieldFactoryImpl method findOptionsContainer.

@Nullable
protected CollectionContainer findOptionsContainer(Table.Column columnConf) {
    String optDcName = columnConf.getXmlDescriptor() != null ? columnConf.getXmlDescriptor().attributeValue("optionsContainer") : null;
    if (Strings.isNullOrEmpty(optDcName)) {
        return null;
    } else {
        ScreenData screenData = UiControllerUtils.getScreenData(webTable.getFrame().getFrameOwner());
        InstanceContainer container = screenData.getContainer(optDcName);
        if (container instanceof CollectionContainer) {
            return (CollectionContainer) container;
        }
        throw new IllegalStateException(String.format("'%s' is not an instance of CollectionContainer", optDcName));
    }
}
Also used : InstanceContainer(io.jmix.ui.model.InstanceContainer) CollectionContainer(io.jmix.ui.model.CollectionContainer) ScreenData(io.jmix.ui.model.ScreenData) Nullable(javax.annotation.Nullable)

Example 2 with CollectionContainer

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

the class AbstractComponentLoader method loadOptionsContainer.

protected Optional<CollectionContainer> loadOptionsContainer(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);
        }
        return Optional.of((CollectionContainer) container);
    }
    return Optional.empty();
}
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)

Example 3 with CollectionContainer

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

the class PivotTableLoader method loadDataContainer.

protected void loadDataContainer(PivotTable pivotTable, 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);
        }
        pivotTable.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 4 with CollectionContainer

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

the class EntityLinkFieldImpl method afterCommitOpenedEntity.

protected void afterCommitOpenedEntity(Object item) {
    MetaProperty metaProperty = getMetaPropertyForEditedValue();
    if (metaProperty != null && metaProperty.getRange().isClass()) {
        if (getValueSource() != null) {
            CollectionContainer ownerCollectionCont = null;
            if (getCollectionContainerFromOwner() != null) {
                ownerCollectionCont = ((ContainerDataUnit) owner.getItems()).getContainer();
                ownerCollectionCont.mute();
            }
            // noinspection unchecked
            setValueSilently((V) item);
            if (ownerCollectionCont != null) {
                ownerCollectionCont.unmute();
            }
        } else {
            // noinspection unchecked
            setValue((V) item);
        }
    // if we edit property with non Entity type and set ListComponent owner
    } else if (owner != null) {
        if (getCollectionContainerFromOwner() != null) {
            // do not listen changes in collection
            getCollectionContainerFromOwner().mute();
            // noinspection unchecked
            getCollectionContainerFromOwner().replaceItem(item);
            MetaPropertyPath metaPropertyPath = ((ContainerValueSource) getValueSource()).getMetaPropertyPath();
            setValueSilently(EntityValues.getValueEx(item, metaPropertyPath));
            // listen changes
            getCollectionContainerFromOwner().unmute();
        }
        if (owner instanceof Focusable) {
            // focus owner
            ((Focusable) owner).focus();
        }
    // if we edit property with non Entity type
    } else {
        // noinspection unchecked
        setValueSilently((V) item);
    }
}
Also used : MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) CollectionContainer(io.jmix.ui.model.CollectionContainer) MetaProperty(io.jmix.core.metamodel.model.MetaProperty)

Example 5 with CollectionContainer

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

the class StockChartLoader method loadDataSet.

protected void loadDataSet(DataSet dataSet, Element dataSetElement) {
    loadFieldMappings(dataSet, dataSetElement);
    loadStockEvents(dataSet, dataSetElement);
    String id = dataSetElement.attributeValue("id");
    if (StringUtils.isNotEmpty(id)) {
        dataSet.setId(id);
    }
    checkMultipleDatasources(dataSetElement);
    String categoryField = dataSetElement.attributeValue("categoryField");
    if (StringUtils.isNotEmpty(categoryField)) {
        dataSet.setCategoryField(categoryField);
    }
    String color = dataSetElement.attributeValue("color");
    if (StringUtils.isNotEmpty(color)) {
        dataSet.setColor(Color.valueOf(color));
    }
    String compared = dataSetElement.attributeValue("compared");
    if (StringUtils.isNotEmpty(compared)) {
        dataSet.setCompared(Boolean.valueOf(compared));
    }
    String dataContainerId = dataSetElement.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);
        }
        dataSet.setDataProvider(new ContainerDataProvider(dataContainer));
    }
    String showInCompare = dataSetElement.attributeValue("showInCompare");
    if (StringUtils.isNotEmpty(showInCompare)) {
        dataSet.setShowInCompare(Boolean.valueOf(showInCompare));
    }
    String showInSelect = dataSetElement.attributeValue("showInSelect");
    if (StringUtils.isNotEmpty(showInSelect)) {
        dataSet.setShowInSelect(Boolean.valueOf(showInSelect));
    }
    String title = dataSetElement.attributeValue("title");
    if (StringUtils.isNotEmpty(title)) {
        dataSet.setTitle(title);
    }
}
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)

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