Search in sources :

Example 1 with RuntimePropsDatasource

use of com.haulmont.cuba.gui.data.RuntimePropsDatasource in project cuba by cuba-platform.

the class DatasourceValueSource method setBeanLocator.

@Override
public void setBeanLocator(BeanLocator beanLocator) {
    MetaClass metaClass = datasource instanceof RuntimePropsDatasource ? ((RuntimePropsDatasource<E>) datasource).resolveCategorizedEntityClass() : datasource.getMetaClass();
    MetadataTools metadataTools = beanLocator.get(MetadataTools.NAME);
    MetaPropertyPath metaPropertyPath = metadataTools.resolveMetaPropertyPath(metaClass, property);
    checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
    this.metaPropertyPath = metaPropertyPath;
    this.datasource.addStateChangeListener(this::datasourceStateChanged);
    this.datasource.addItemChangeListener(this::datasourceItemChanged);
    this.datasource.addItemPropertyChangeListener(this::datasourceItemPropertyChanged);
    if (datasource.getState() == Datasource.State.VALID) {
        setState(BindingState.ACTIVE);
    }
}
Also used : MetadataTools(com.haulmont.cuba.core.global.MetadataTools) MetaClass(com.haulmont.chile.core.model.MetaClass) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) RuntimePropsDatasource(com.haulmont.cuba.gui.data.RuntimePropsDatasource)

Example 2 with RuntimePropsDatasource

use of com.haulmont.cuba.gui.data.RuntimePropsDatasource in project jmix by jmix-framework.

the class DatasourceValueSource method setApplicationContext.

@Override
public void setApplicationContext(ApplicationContext applicationContext) {
    MetaClass metaClass = datasource instanceof RuntimePropsDatasource ? ((RuntimePropsDatasource<E>) datasource).resolveCategorizedEntityClass() : datasource.getMetaClass();
    MetadataTools metadataTools = applicationContext.getBean(MetadataTools.class);
    this.metaPropertyPath = metadataTools.resolveMetaPropertyPath(metaClass, property);
    this.datasource.addStateChangeListener(this::datasourceStateChanged);
    this.datasource.addItemChangeListener(this::datasourceItemChanged);
    this.datasource.addItemPropertyChangeListener(this::datasourceItemPropertyChanged);
    if (datasource.getState() == Datasource.State.VALID) {
        setState(BindingState.ACTIVE);
    }
}
Also used : MetadataTools(io.jmix.core.MetadataTools) MetaClass(io.jmix.core.metamodel.model.MetaClass) RuntimePropsDatasource(com.haulmont.cuba.gui.data.RuntimePropsDatasource)

Aggregations

RuntimePropsDatasource (com.haulmont.cuba.gui.data.RuntimePropsDatasource)2 MetaClass (com.haulmont.chile.core.model.MetaClass)1 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)1 MetadataTools (io.jmix.core.MetadataTools)1 MetaClass (io.jmix.core.metamodel.model.MetaClass)1