/** * Copies the values of all properties to be able to compare them in case they * change outside a setter method. */ void copyValues() { for (final String property : propertyTypes.keySet()) { if (!"this".equals(property)) { knownValues.put(property, proxy.get(property)); } } }
/** * Copies the values of all properties to be able to compare them in case they * change outside a setter method. */ void copyValues() { for (final String property : propertyTypes.keySet()) { if (!"this".equals(property)) { knownValues.put(property, proxy.get(property)); } } }
/** * Ensures that the given list property is wrapped in a * {@link BindableListWrapper}, so changes to the list become observable. * * @param property * the name of the list property * * @return a new the wrapped (proxied) list or the provided list if already * proxied */ private List ensureBoundListIsProxied(final String property) { final List oldList = (List) proxy.get(property); final List newList = ensureBoundListIsProxied(property, oldList); if (oldList != newList) updateWidgetsAndFireEvent(true, property, proxy.get(property), newList); return newList; }
/** * Ensures that the given list property is wrapped in a * {@link BindableListWrapper}, so changes to the list become observable. * * @param property * the name of the list property * * @return a new the wrapped (proxied) list or the provided list if already * proxied */ private List ensureBoundListIsProxied(final String property) { final List oldList = (List) proxy.get(property); final List newList = ensureBoundListIsProxied(property, oldList); if (oldList != newList) updateWidgetsAndFireEvent(true, property, proxy.get(property), newList); return newList; }
protected Object readPropertyValue(BindableProxy proxy, String fieldBinding) { if (fieldBinding.indexOf(".") != -1) { // Nested property int separatorPosition = fieldBinding.indexOf("."); String nestedModelName = fieldBinding.substring(0, separatorPosition); String property = fieldBinding.substring(separatorPosition + 1); Object nestedModel = proxy.get(nestedModelName); if (nestedModel == null) { return null; } return readPropertyValue((BindableProxy) BindableProxyFactory.getBindableProxy(nestedModel), property); } return proxy.get(fieldBinding); }
/** * Updates all bound widgets if necessary (if a bound property's value has * changed). This method is invoked in case a bound property changed outside * the property's write method (when using a non accessor method). */ void updateWidgetsAndFireEvents() { for (final String property : propertyTypes.keySet()) { final Object knownValue = knownValues.get(property); final Object actualValue = proxy.get(property); if ((knownValue == null && actualValue != null) || (knownValue != null && !knownValue.equals(actualValue))) { final DataBinder nestedBinder = binders.get(property); if (nestedBinder != null) { nestedBinder.setModel(actualValue, StateSync.FROM_MODEL, true); proxy.set(property, nestedBinder.getModel()); } updateWidgetsAndFireEvent(true, property, knownValue, actualValue); } } }
/** * Updates all bound widgets if necessary (if a bound property's value has * changed). This method is invoked in case a bound property changed outside * the property's write method (when using a non accessor method). */ void updateWidgetsAndFireEvents() { for (final String property : propertyTypes.keySet()) { final Object knownValue = knownValues.get(property); final Object actualValue = proxy.get(property); if ((knownValue == null && actualValue != null) || (knownValue != null && !knownValue.equals(actualValue))) { final DataBinder nestedBinder = binders.get(property); if (nestedBinder != null) { nestedBinder.setModel(actualValue, StateSync.FROM_MODEL, true); proxy.set(property, nestedBinder.getModel()); } updateWidgetsAndFireEvent(true, property, knownValue, actualValue); } } }
private Consumer<Object> modelUpdater(final Object component, final Converter converter, final String lastSubProperty, final BindableProxyAgent<?> agent) { return uiValue -> { final Object oldValue = agent.proxy.get(lastSubProperty); final Object newValue = converter.toModelValue(uiValue); agent.trySettingModelProperty(lastSubProperty, converter, uiValue, newValue); agent.updateWidgetsAndFireEvent(false, lastSubProperty, oldValue, newValue, component); }; }
private Consumer<Object> modelUpdater(final Object component, final Converter converter, final String lastSubProperty, final BindableProxyAgent<?> agent) { return uiValue -> { final Object oldValue = agent.proxy.get(lastSubProperty); final Object newValue = converter.toModelValue(uiValue); agent.trySettingModelProperty(lastSubProperty, converter, uiValue, newValue); agent.updateWidgetsAndFireEvent(false, lastSubProperty, oldValue, newValue, component); }; }
private static <T> void deepCloneProxyProperty(BindableProxy<T> proxy, String propertyName, PropertyType type) { Object value = proxy.get(propertyName); if(type.isList() && value != null) { value = doDeepCloneList((List)value); } else { value = doDeepClone(value); } proxy.set(propertyName, value); }
final Object modelValue = proxy.get(property); final Optional<Object> uiValue = uiGetter.map(f -> f.get());
final Object modelValue = proxy.get(property); final Optional<Object> uiValue = uiGetter.map(f -> f.get());