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));
}
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);
}
}
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));
}
}
}
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);
}
Aggregations