private Binding createBinding(final Object component, final String property, final Converter converter, final Supplier<Map<Class<? extends GwtEvent>, HandlerRegistration>> handlerRegistrar) { final Binding binding = new Binding(property, component, converter, handlerRegistrar.get()); bindings.put(property, binding); if (propertyTypes.get(property).isList()) { if ("this".equals(property) && proxy instanceof BindableListWrapper) { addHandlersForBindableListWrapper("this", (BindableListWrapper) proxy); } else { proxy.set(property, ensureBoundListIsProxied(property)); } } return binding; }
private void trySettingModelProperty(final String property, final Converter converter, final Object uiValue, final Object newValue) { try { proxy.set(property, newValue); } catch (final Throwable t) { if (newValue == null && isCausedByNullOrUndefined(t)) { /* * Don't fail here because likely this is an error from trying to unbox a null value to a primitive. * XXX Maybe we should check for boxed types before trying to set the property. */ logger.warn("Encountered a null while trying to set the property [" + property + "] to [" + newValue + "].", t); } else { throw new RuntimeException("Error while setting property [" + property + "] to [" + newValue + "] converted from [" + uiValue + "] with converter [" + converter.getComponentType().getName() + " -> " + converter.getModelType().getName() + "].", t); } } }
private Binding createBinding(final Object component, final String property, final Converter converter, final Supplier<Map<Class<? extends GwtEvent>, HandlerRegistration>> handlerRegistrar) { final Binding binding = new Binding(property, component, converter, handlerRegistrar.get()); bindings.put(property, binding); if (propertyTypes.get(property).isList()) { if ("this".equals(property) && proxy instanceof BindableListWrapper) { addHandlersForBindableListWrapper("this", (BindableListWrapper) proxy); } else { proxy.set(property, ensureBoundListIsProxied(property)); } } return binding; }
private void trySettingModelProperty(final String property, final Converter converter, final Object uiValue, final Object newValue) { try { proxy.set(property, newValue); } catch (final Throwable t) { if (newValue == null && isCausedByNullOrUndefined(t)) { /* * Don't fail here because likely this is an error from trying to unbox a null value to a primitive. * XXX Maybe we should check for boxed types before trying to set the property. */ logger.warn("Encountered a null while trying to set the property [" + property + "] to [" + newValue + "].", t); } else { throw new RuntimeException("Error while setting property [" + property + "] to [" + newValue + "] converted from [" + uiValue + "] with converter [" + converter.getComponentType().getName() + " -> " + converter.getModelType().getName() + "].", t); } } }
/** * 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 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); }
proxy.set(property, newValue); maybeFirePropertyChangeEvent(property, knownValues.get(property), newValue); updateWidgetsAndFireEvent(true, property, knownValues.get(property), newValue, component);
proxy.set(property, newValue); maybeFirePropertyChangeEvent(property, knownValues.get(property), newValue); updateWidgetsAndFireEvent(true, property, knownValues.get(property), newValue, component);
binder.setModel(proxy.get(bindableProperty), initialState, true); proxy.set(bindableProperty, binder.getModel()); knownValues.put(bindableProperty, binder.getModel());
binder.setModel(proxy.get(bindableProperty), initialState, true); proxy.set(bindableProperty, binder.getModel()); knownValues.put(bindableProperty, binder.getModel());