@Override protected void valueBindingConnected(ValueSource<V> valueSource) { super.valueBindingConnected(valueSource); if (valueSource instanceof EntityValueSource) { DataAwareComponentsTools dataAwareComponentsTools = beanLocator.get(DataAwareComponentsTools.class); EntityValueSource entityValueSource = (EntityValueSource) valueSource; dataAwareComponentsTools.setupCaseConversion(this, entityValueSource); dataAwareComponentsTools.setupMaxLength(this, entityValueSource); } }
@Override protected void valueBindingConnected(ValueSource<V> valueSource) { super.valueBindingConnected(valueSource); if (valueSource instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueSource; DataAwareComponentsTools dataAwareComponentsTools = beanLocator.get(DataAwareComponentsTools.class); dataAwareComponentsTools.setupDateRange(this, entityValueSource); dataAwareComponentsTools.setupDateFormat(this, entityValueSource); dataAwareComponentsTools.setupZoneId(this, entityValueSource); } }
public void setupDateRange(HasRange component, EntityValueSource valueSource) { MetaProperty metaProperty = valueSource.getMetaPropertyPath().getMetaProperty(); Class javaType = metaProperty.getRange().asDatatype().getJavaClass(); TemporalType temporalType = getTemporalType(metaProperty, javaType); if (metaProperty.getAnnotations().get(Past.class.getName()) != null) { LocalDateTime dateTime = LocalDateTime.of(LocalDate.now(), LocalTime.MAX); ZonedDateTime zonedDateTime = ZonedDateTime.of(dateTime, ZoneId.systemDefault()); //noinspection unchecked component.setRangeEnd(dateTimeTransformations.transformFromZDT(zonedDateTime, javaType)); } else if (metaProperty.getAnnotations().get(Future.class.getName()) != null) { LocalDateTime dateTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN); // In case of date and time we can select the current date with future time, // so we start from the next day only if the time isn't displayed if (temporalType == TemporalType.DATE) { dateTime = dateTime.plusDays(1); } ZonedDateTime zonedDateTime = ZonedDateTime.of(dateTime, ZoneId.systemDefault()); //noinspection unchecked component.setRangeStart(dateTimeTransformations.transformFromZDT(zonedDateTime, javaType)); } }
@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); } }
@Override protected void valueBindingConnected(ValueSource<V> valueSource) { super.valueBindingConnected(valueSource); if (valueSource instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueSource; DataAwareComponentsTools dataAwareComponentsTools = beanLocator.get(DataAwareComponentsTools.class); dataAwareComponentsTools.setupDateRange(this, entityValueSource); } }
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); }
@Override protected void valueBindingConnected(ValueSource<V> valueSource) { super.valueBindingConnected(valueSource); if (valueSource instanceof EntityValueSource) { DataAwareComponentsTools dataAwareComponentsTools = beanLocator.get(DataAwareComponentsTools.class); EntityValueSource entityValueSource = (EntityValueSource) valueSource; dataAwareComponentsTools.setupCaseConversion(this, entityValueSource); dataAwareComponentsTools.setupMaxLength(this, entityValueSource); } } }