Search in sources :

Example 36 with EntityValueSource

use of com.haulmont.cuba.gui.components.data.meta.EntityValueSource in project cuba by cuba-platform.

the class WebMaskedField method convertToPresentation.

@Override
protected String convertToPresentation(V modelValue) throws ConversionException {
    if (datatype != null) {
        return nullToEmpty(datatype.format(modelValue, locale));
    }
    if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) {
        EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource();
        Range range = entityValueSource.getMetaPropertyPath().getRange();
        if (range.isDatatype()) {
            Datatype<V> propertyDataType = range.asDatatype();
            return nullToEmpty(propertyDataType.format(modelValue, locale));
        }
    }
    return nullToEmpty(super.convertToPresentation(modelValue));
}
Also used : EntityValueSource(com.haulmont.cuba.gui.components.data.meta.EntityValueSource) Range(com.haulmont.chile.core.model.Range)

Example 37 with EntityValueSource

use of com.haulmont.cuba.gui.components.data.meta.EntityValueSource in project cuba by cuba-platform.

the class WebPasswordField method valueBindingConnected.

@Override
protected void valueBindingConnected(ValueSource<String> valueSource) {
    super.valueBindingConnected(valueSource);
    if (valueSource instanceof EntityValueSource) {
        DataAwareComponentsTools dataAwareComponentsTools = beanLocator.get(DataAwareComponentsTools.class);
        EntityValueSource entityValueSource = (EntityValueSource) valueSource;
        dataAwareComponentsTools.setupMaxLength(this, entityValueSource);
    }
}
Also used : EntityValueSource(com.haulmont.cuba.gui.components.data.meta.EntityValueSource) DataAwareComponentsTools(com.haulmont.cuba.gui.components.data.DataAwareComponentsTools)

Example 38 with EntityValueSource

use of com.haulmont.cuba.gui.components.data.meta.EntityValueSource in project cuba by cuba-platform.

the class WebTableFieldFactory method applyPermissions.

protected void applyPermissions(com.haulmont.cuba.gui.components.Component columnComponent) {
    if (columnComponent instanceof HasValueSource && columnComponent instanceof com.haulmont.cuba.gui.components.Component.Editable) {
        HasValueSource component = (HasValueSource) columnComponent;
        MetaPropertyPath propertyPath = ((EntityValueSource) component.getValueSource()).getMetaPropertyPath();
        if (propertyPath != null) {
            com.haulmont.cuba.gui.components.Component.Editable editable = (com.haulmont.cuba.gui.components.Component.Editable) component;
            editable.setEditable(editable.isEditable() && security.isEntityAttrUpdatePermitted(propertyPath));
        }
    }
}
Also used : EntityValueSource(com.haulmont.cuba.gui.components.data.meta.EntityValueSource) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) HasValueSource(com.haulmont.cuba.gui.components.data.HasValueSource) Component(com.vaadin.ui.Component)

Example 39 with EntityValueSource

use of com.haulmont.cuba.gui.components.data.meta.EntityValueSource in project cuba by cuba-platform.

the class WebTokenList method convertToModel.

@Override
protected Collection<V> convertToModel(Collection<V> componentRawValue) throws ConversionException {
    ValueSource<Collection<V>> valueSource = getValueSource();
    if (valueSource != null) {
        Class<?> modelCollectionType = null;
        if (valueSource instanceof EntityValueSource) {
            MetaPropertyPath mpp = ((EntityValueSource) valueSource).getMetaPropertyPath();
            modelCollectionType = mpp.getMetaProperty().getJavaType();
        } else if (valueSource instanceof LegacyCollectionDsValueSource) {
            CollectionDatasource datasource = ((LegacyCollectionDsValueSource) valueSource).getDatasource();
            if (datasource instanceof NestedDatasource) {
                MetaProperty property = ((NestedDatasource) datasource).getProperty().getInverse();
                modelCollectionType = property == null ? null : property.getJavaType();
            }
        }
        if (modelCollectionType != null) {
            if (Set.class.isAssignableFrom(modelCollectionType)) {
                return new LinkedHashSet<>(componentRawValue);
            }
        }
    }
    return new ArrayList<>(componentRawValue);
}
Also used : EntityValueSource(com.haulmont.cuba.gui.components.data.meta.EntityValueSource) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) NestedDatasource(com.haulmont.cuba.gui.data.NestedDatasource) LegacyCollectionDsValueSource(com.haulmont.cuba.gui.components.data.value.LegacyCollectionDsValueSource) MetaProperty(com.haulmont.chile.core.model.MetaProperty)

Aggregations

EntityValueSource (com.haulmont.cuba.gui.components.data.meta.EntityValueSource)39 MetaProperty (com.haulmont.chile.core.model.MetaProperty)10 DataAwareComponentsTools (com.haulmont.cuba.gui.components.data.DataAwareComponentsTools)10 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)9 ValueSource (com.haulmont.cuba.gui.components.data.ValueSource)9 HasValueSource (com.haulmont.cuba.gui.components.data.HasValueSource)6 Messages (com.haulmont.cuba.core.global.Messages)5 ConversionException (com.haulmont.cuba.gui.components.data.ConversionException)5 Datatype (com.haulmont.chile.core.datatypes.Datatype)4 ValueConversionException (com.haulmont.chile.core.datatypes.ValueConversionException)4 Entity (com.haulmont.cuba.core.entity.Entity)4 ParseException (java.text.ParseException)4 MetaClass (com.haulmont.chile.core.model.MetaClass)3 Range (com.haulmont.chile.core.model.Range)2 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)2 Field (com.haulmont.cuba.gui.components.Field)2 DatasourceValueSource (com.haulmont.cuba.gui.components.data.value.DatasourceValueSource)2 Pair (com.haulmont.bali.datastruct.Pair)1 Subscription (com.haulmont.bali.events.Subscription)1 Preconditions (com.haulmont.bali.util.Preconditions)1