@Override public boolean isModified() { return !Objects.equals(component.getValue(), source.getValue()); }
@Override public void setBuffered(boolean buffered) { this.buffered = buffered; if (!buffered && source.getState() == BindingState.ACTIVE) { // reset value of the component component.setValue(source.getValue()); } }
@Nonnull protected Collection<V> getValueSourceValue() { ValueSource<Collection<V>> valueSource = getValueSource(); if (valueSource == null) { return Collections.emptyList(); } Collection<V> modelValue; if (valueSource instanceof EntityValueSource) { Class<?> modelCollectionType = ((EntityValueSource) valueSource) .getMetaPropertyPath().getMetaProperty().getJavaType(); Collection<V> valueSourceValue = valueSource.getValue() == null ? Collections.emptyList() : valueSource.getValue(); if (Set.class.isAssignableFrom(modelCollectionType)) { modelValue = new LinkedHashSet<>(valueSourceValue); } else { modelValue = new ArrayList<>(valueSourceValue); } } else { modelValue = new ArrayList<>(valueSource.getValue()); } return modelValue; }
@Override public void activate() { if (source.getState() == BindingState.ACTIVE) { component.setValue(source.getValue()); } }
protected void valueSourceStateChanged(ValueSource.StateChangeEvent event) { if (event.getState() == BindingState.ACTIVE) { // read value to component component.setValue(source.getValue()); } }
@Override public boolean isEmpty() { return owner.getValueSource() != null ? CollectionUtils.isEmpty(owner.getValueSource().getValue()) : CollectionUtils.isEmpty(getValue()); }
protected void updateComponent() { Object propertyValue = valueSource.getValue(); Resource resource = createImageResource(propertyValue); updateValue(resource); }
protected void sourceInstanceChanged(@SuppressWarnings("unused") EntityValueSource.InstanceChangeEvent<Entity> event) { if (source.getState() == BindingState.ACTIVE && !isBuffered()) { // read value to component component.setValue(source.getValue()); } } }
@Override public void discard() { if (source.getState() == BindingState.ACTIVE && isBuffered() && isModified()) { component.setValue(source.getValue()); } }