Search in sources :

Example 26 with MetaPropertyPath

use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.

the class DynamicAttributesMetaClass method getPropertyPath.

@Override
public MetaPropertyPath getPropertyPath(String propertyPath) {
    MetaProperty currentProperty;
    currentProperty = this.getProperty(propertyPath);
    if (currentProperty == null)
        return null;
    return new MetaPropertyPath(this, currentProperty);
}
Also used : MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) MetaProperty(com.haulmont.chile.core.model.MetaProperty)

Example 27 with MetaPropertyPath

use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.

the class RuntimePropertiesFrame method loadEditable.

protected void loadEditable(FieldGroup fieldGroup, FieldGroup.FieldConfig field) {
    if (fieldGroup.isEditable()) {
        MetaClass metaClass = rds.resolveCategorizedEntityClass();
        MetaPropertyPath propertyPath = DynamicAttributesUtils.getMetaPropertyPath(metaClass, field.getProperty());
        checkNotNullArgument(propertyPath, "Could not resolve property path '%s' in '%s'", field.getId(), metaClass);
        boolean editableFromPermissions = security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString());
        if (!editableFromPermissions) {
            field.setEditable(false);
        }
        boolean visibleFromPermissions = security.isEntityAttrReadPermitted(metaClass, propertyPath.toString());
        if (!visibleFromPermissions) {
            field.setVisible(false);
        }
    }
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath)

Example 28 with MetaPropertyPath

use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.

the class RuntimePropertiesFrame method loadValidators.

protected void loadValidators(FieldGroup fieldGroup, FieldGroup.FieldConfig field) {
    MetaPropertyPath metaPropertyPath = rds.getMetaClass().getPropertyPath(field.getProperty());
    if (metaPropertyPath != null) {
        MetaProperty metaProperty = metaPropertyPath.getMetaProperty();
        Field.Validator validator = getValidator(metaProperty);
        if (validator != null) {
            field.addValidator(validator);
        }
    }
}
Also used : MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) DynamicAttributesMetaProperty(com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributesMetaProperty) MetaProperty(com.haulmont.chile.core.model.MetaProperty)

Example 29 with MetaPropertyPath

use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.

the class TableModelAdapter method setValueAt.

@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    Table.Column column = columns.get(columnIndex);
    if (!column.isEditable())
        return;
    if (generatedColumns.contains(column))
        return;
    Object id = getItemId(rowIndex);
    Entity item = datasource.getItem(id);
    if (column.getId() instanceof MetaPropertyPath) {
        String property = column.getId().toString();
        item.setValueEx(property, aValue);
    }
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) Table(com.haulmont.cuba.gui.components.Table) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath)

Example 30 with MetaPropertyPath

use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.

the class TableModelAdapter method getValueAt.

@SuppressWarnings("unchecked")
public Object getValueAt(Entity item, int columnIndex) {
    Table.Column column = columns.get(columnIndex);
    if (column.getId() instanceof MetaPropertyPath) {
        String property = column.getId().toString();
        Object value;
        if (ignoreUnfetchedAttributes) {
            value = getValueExIgnoreUnfetched(item, InstanceUtils.parseValuePath(property));
        } else {
            value = item.getValueEx(property);
        }
        if (column.getFormatter() != null) {
            return column.getFormatter().format(value);
        }
        MetaPropertyPath metaProperty = ((MetaPropertyPath) column.getId());
        boolean isDataType = (metaProperty.getRange().isDatatype());
        if (isDataType && hasDefaultFormatting(metaProperty.getRangeJavaClass())) {
            if (value != null)
                return value;
            else
                return getDefaultValue(metaProperty.getRangeJavaClass());
        } else {
            if (value == null)
                return null;
            return metadataTools.format(value, ((MetaPropertyPath) column.getId()).getMetaProperty());
        }
    } else {
        return null;
    }
}
Also used : Table(com.haulmont.cuba.gui.components.Table) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath)

Aggregations

MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)84 MetaClass (com.haulmont.chile.core.model.MetaClass)34 MetaProperty (com.haulmont.chile.core.model.MetaProperty)27 Element (org.dom4j.Element)16 CategoryAttribute (com.haulmont.cuba.core.entity.CategoryAttribute)11 Entity (com.haulmont.cuba.core.entity.Entity)9 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)9 Datasource (com.haulmont.cuba.gui.data.Datasource)6 Table (com.haulmont.cuba.gui.components.Table)5 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)5 MessageTools (com.haulmont.cuba.core.global.MessageTools)4 Instance (com.haulmont.chile.core.model.Instance)3 Op (com.haulmont.cuba.core.global.filter.Op)3 FocusableTable (com.haulmont.cuba.desktop.sys.vcl.FocusableTable)3 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)3 Formatter (com.haulmont.cuba.gui.components.Formatter)3 Window (com.haulmont.cuba.gui.components.Window)3 CollectionFormatter (com.haulmont.cuba.gui.components.formatters.CollectionFormatter)3 GroupInfo (com.haulmont.cuba.gui.data.GroupInfo)3 java.util (java.util)3