use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class EntityFieldCreationSupport method addDefaultActions.
public boolean addDefaultActions(EntityPicker entityPicker) {
ValueSource valueSource = entityPicker.getValueSource();
if (!(valueSource instanceof EntityValueSource)) {
return false;
}
EntityValueSource entityValueSource = (EntityValueSource) entityPicker.getValueSource();
MetaPropertyPath mpp = entityValueSource.getMetaPropertyPath();
MetaClass metaClass = mpp.getMetaProperty().getRange().asClass();
List<String> actionIds = componentProperties.getEntityFieldActions().get(metaClass.getName());
if (actionIds == null || actionIds.isEmpty()) {
return false;
}
addActions(entityPicker, actionIds);
return true;
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class CurrencyFieldImpl method convertToModel.
@Nullable
@Override
protected V convertToModel(@Nullable String componentRawValue) throws ConversionException {
String value = StringUtils.trimToNull(emptyToNull(componentRawValue));
Datatype<V> datatype = getDatatypeInternal();
if (datatype != null) {
try {
return datatype.parse(value, locale);
} catch (ValueConversionException e) {
throw new ConversionException(e.getLocalizedMessage(), e);
} catch (ParseException e) {
throw new ConversionException(getConversionErrorMessageInternal(), e);
}
}
if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) {
EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource();
Datatype<V> propertyDataType = entityValueSource.getMetaPropertyPath().getRange().asDatatype();
try {
return propertyDataType.parse(componentRawValue, locale);
} catch (ValueConversionException e) {
throw new ConversionException(e.getLocalizedMessage(), e);
} catch (ParseException e) {
throw new ConversionException(getConversionErrorMessageInternal(), e);
}
}
return super.convertToModel(componentRawValue);
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class DateFieldImpl method valueBindingConnected.
@Override
protected void valueBindingConnected(ValueSource<V> valueSource) {
super.valueBindingConnected(valueSource);
if (valueSource instanceof EntityValueSource) {
EntityValueSource entityValueSource = (EntityValueSource) valueSource;
DataAwareComponentsTools dataAwareComponentsTools = applicationContext.getBean(DataAwareComponentsTools.class);
dataAwareComponentsTools.setupDateFormat(this, entityValueSource);
dataAwareComponentsTools.setupZoneId(this, entityValueSource);
if (valueSourceStateChangeSubscription != null) {
valueSourceStateChangeSubscription.remove();
}
// setup dateRange after valueSource is activated and value is set because
// Vaadin dateField rejects value if it is not in range
valueSourceStateChangeSubscription = valueSource.addStateChangeListener(event -> {
if (event.getState() == BindingState.ACTIVE) {
dataAwareComponentsTools.setupDateRange(this, entityValueSource);
}
});
}
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class CheckBoxGroupImpl method valueBindingConnected.
@Override
protected void valueBindingConnected(ValueSource<Collection<V>> valueSource) {
super.valueBindingConnected(valueSource);
if (valueSource instanceof EntityValueSource) {
DataAwareComponentsTools dataAwareComponentsTools = applicationContext.getBean(DataAwareComponentsTools.class);
dataAwareComponentsTools.setupOptions(this, (EntityValueSource) valueSource);
}
}
use of io.jmix.ui.component.data.meta.EntityValueSource in project jmix by jmix-framework.
the class ComboBoxImpl method valueBindingConnected.
@Override
protected void valueBindingConnected(ValueSource<V> valueSource) {
super.valueBindingConnected(valueSource);
if (valueSource instanceof EntityValueSource) {
DataAwareComponentsTools dataAwareComponentsTools = applicationContext.getBean(DataAwareComponentsTools.class);
dataAwareComponentsTools.setupOptions(this, (EntityValueSource) valueSource);
}
}
Aggregations