/** * @return return null if value source is not EntityValueSource or value source is not defined */ @Nullable default MetaPropertyPath getMetaPropertyPath() { if (getValueSource() == null) { return null; } ValueSource<FileDescriptor> valueSource = getValueSource(); return valueSource instanceof EntityValueSource ? ((EntityValueSource) valueSource).getMetaPropertyPath() : null; }
protected MetaProperty getMetaPropertyForEditedValue() { ValueSource<V> valueSource = getValueSource(); if (valueSource instanceof EntityValueSource) { MetaPropertyPath metaPropertyPath = ((EntityValueSource) valueSource).getMetaPropertyPath(); return metaPropertyPath.getMetaProperty(); } return null; }
@Override protected String convertToPresentation(V modelValue) throws ConversionException { // Vaadin TextField does not permit `null` value if (datatype != null) { return nullToEmpty(datatype.format(modelValue, locale)); } if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); Datatype<V> propertyDataType = entityValueSource.getMetaPropertyPath().getRange().asDatatype(); return nullToEmpty(propertyDataType.format(modelValue)); } return nullToEmpty(super.convertToPresentation(modelValue)); }
protected String convertToPresentation(V modelValue) { if (formatter != null) { return formatter.apply(modelValue); } if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); MetaProperty metaProperty = entityValueSource.getMetaPropertyPath().getMetaProperty(); return metadataTools.format(modelValue, metaProperty); } return metadataTools.format(modelValue); }
@Override public MetaClass getMetaClass() { ValueSource<V> valueSource = getValueSource(); if (valueSource instanceof EntityValueSource) { MetaProperty metaProperty = ((EntityValueSource) valueSource).getMetaPropertyPath().getMetaProperty(); return metaProperty.getRange().asClass(); } else { return metaClass; } }
@Override protected String convertToPresentation(V modelValue) throws ConversionException { Datatype<V> datatype = getDatatypeInternal(); // Vaadin TextField does not permit `null` value if (datatype != null) { return nullToEmpty(datatype.format(modelValue, locale)); } if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); Datatype<V> propertyDataType = entityValueSource.getMetaPropertyPath().getRange().asDatatype(); return nullToEmpty(propertyDataType.format(modelValue, locale)); } return nullToEmpty(super.convertToPresentation(modelValue)); }
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)); } } }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(I item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(I item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected Entity initEntity() { EntityValueSource entityValueSource = (EntityValueSource) pickerField.getValueSource(); Entity entity = AppBeans.get(Metadata.class).create( entityValueSource.getMetaPropertyPath().getMetaProperty().getRange().asClass()); Entity ownerEntity = entityValueSource.getItem(); MetaProperty inverseProp = entityValueSource.getMetaPropertyPath().getMetaProperty().getInverse(); if (inverseProp != null) { entity.setValue(inverseProp.getName(), ownerEntity); } return entity; }
@SuppressWarnings("unchecked") @Override protected V convertToModel(LocalDate componentRawValue) throws ConversionException { if (componentRawValue == null) { return null; } LocalDateTime localDateTime = LocalDateTime.of(componentRawValue, LocalTime.MIDNIGHT); ValueSource<V> valueSource = getValueSource(); if (valueSource instanceof EntityValueSource) { MetaProperty metaProperty = ((EntityValueSource) valueSource).getMetaPropertyPath().getMetaProperty(); return (V) convertFromLocalDateTime(localDateTime, metaProperty.getRange().asDatatype().getJavaClass()); } return (V) convertFromLocalDateTime(localDateTime, datatype == null ? Date.class : datatype.getJavaClass()); }
public void setupZoneId(DateField component, EntityValueSource valueSource) { if (component.getZoneId() == null) { MetaProperty metaProperty = valueSource.getMetaPropertyPath().getMetaProperty(); Class javaType = metaProperty.getRange().asDatatype().getJavaClass(); if (dateTimeTransformations.isDateTypeSupportsTimeZones(javaType)) { Boolean ignoreUserTimeZone = metadataTools.getMetaAnnotationValue(metaProperty, IgnoreUserTimeZone.class); if (!Boolean.TRUE.equals(ignoreUserTimeZone)) { TimeZone timeZone = userSessionSource.getUserSession().getTimeZone(); component.setTimeZone(timeZone); } } } }
public void setupDateFormat(DateField component, EntityValueSource valueSource) { MetaProperty metaProperty = valueSource.getMetaPropertyPath().getMetaProperty(); Class javaType = metaProperty.getRange().asDatatype().getJavaClass(); TemporalType temporalType = getTemporalType(metaProperty, javaType); component.setResolution(temporalType == TemporalType.DATE ? DateField.Resolution.DAY : DateField.Resolution.MIN); String formatStr = messageTools.getDefaultDateFormat(temporalType); component.setDateFormat(formatStr); }