public <U> void setProperty(String name, U value) m_properties.put(name, new PropertyType(name, value, String.class)); }
private static <T> BindableProxy<T> doDeepClone(T instance) { final BindableProxy<T> proxy; if(instance instanceof BindableProxy) { proxy = (BindableProxy<T>) instance; } else { proxy = (BindableProxy<T>) BindableProxyFactory.getBindableProxy(instance); } if(proxy != null) { proxy.getBeanProperties() .entrySet() .stream() .filter(entry -> isProxy(entry.getValue().getType())) .forEach(entry -> deepCloneProxyProperty(proxy, entry.getKey(), entry.getValue())); } return proxy; }
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; }
if (!propertyTypes.get(bindableProperty).isBindable()) { throw new RuntimeException("The type of property " + bindableProperty + " (" + propertyTypes.get(bindableProperty).getType().getName() + ") is not a @Bindable type!"); binder = DataBinder.forType(propertyTypes.get(bindableProperty).getType());
if (propertyType.isList() && value instanceof List) { value = agent.ensureBoundListIsProxied(key, (List<?>) value); else if (propertyType.isBindable() && !(value instanceof BindableProxy)) { DataBinder nestedBinder = agent.binders.get(key); if (nestedBinder == null) {
if (!propertyTypes.get(bindableProperty).isBindable()) { throw new RuntimeException("The type of property " + bindableProperty + " (" + propertyTypes.get(bindableProperty).getType().getName() + ") is not a @Bindable type!"); binder = DataBinder.forType(propertyTypes.get(bindableProperty).getType());
if (propertyType.isList() && value instanceof List) { value = agent.ensureBoundListIsProxied(key, (List<?>) value); else if (propertyType.isBindable() && !(value instanceof BindableProxy)) { DataBinder nestedBinder = agent.binders.get(key); if (nestedBinder == null) {
public BindableListWrapper(List<M> list) { Assert.notNull(list); if (list instanceof BindableListWrapper) { throw new IllegalArgumentException("Wrap a BindableListWrapper in a BindableListWrapper."); } this.list = list; for (int i = 0; i < this.list.size(); i++) { this.list.set(i, (M) convertToProxy(this.list.get(i))); } agent = new BindableProxyAgent<List<M>>(this, list); agent.propertyTypes.put("this", new PropertyType(List.class, true, true)); }
private static PropertyType getPropertyType(final BindableProxy<?> proxy, final String property) { final BindableProxyAgent<?> agent = proxy.getBindableProxyAgent(); if (property.contains(".")) { final int firstDot = property.indexOf("."); final String topLevelProperty = property.substring(0, firstDot); final String childProperty = property.substring(firstDot+1); final PropertyType topLevelType = getPropertyType(proxy, topLevelProperty); final BindableProxy<?> topLevelProxy; if (topLevelType instanceof MapPropertyType) { topLevelProxy = (BindableProxy<?>) DataBinder.forMap(((MapPropertyType) topLevelType).getPropertyTypes()).getModel(); } else { topLevelProxy = BindableProxyFactory.getBindableProxy(topLevelType.getType().getName()); } return getPropertyType(topLevelProxy, childProperty); } else if (agent.propertyTypes.containsKey(property)) { return agent.propertyTypes.get(property); } else { final String type = proxy.getClass().getSuperclass().getSimpleName(); throw new NonExistingPropertyException(type, property); } }
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; }
public BindableListWrapper(List<M> list) { Assert.notNull(list); if (list instanceof BindableListWrapper) { throw new IllegalArgumentException("Wrap a BindableListWrapper in a BindableListWrapper."); } this.list = list; for (int i = 0; i < this.list.size(); i++) { this.list.set(i, (M) convertToProxy(this.list.get(i))); } agent = new BindableProxyAgent<List<M>>(this, list); agent.propertyTypes.put("this", new PropertyType(List.class, true, true)); }
private static PropertyType getPropertyType(final BindableProxy<?> proxy, final String property) { final BindableProxyAgent<?> agent = proxy.getBindableProxyAgent(); if (property.contains(".")) { final int firstDot = property.indexOf("."); final String topLevelProperty = property.substring(0, firstDot); final String childProperty = property.substring(firstDot+1); final PropertyType topLevelType = getPropertyType(proxy, topLevelProperty); final BindableProxy<?> topLevelProxy; if (topLevelType instanceof MapPropertyType) { topLevelProxy = (BindableProxy<?>) DataBinder.forMap(((MapPropertyType) topLevelType).getPropertyTypes()).getModel(); } else { topLevelProxy = BindableProxyFactory.getBindableProxy(topLevelType.getType().getName()); } return getPropertyType(topLevelProxy, childProperty); } else if (agent.propertyTypes.containsKey(property)) { return agent.propertyTypes.get(property); } else { final String type = proxy.getClass().getSuperclass().getSimpleName(); throw new NonExistingPropertyException(type, property); } }
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); }
public MapPropertyType getModeldefinitionFor(MultipleSubFormFieldDefinition subFormField, MapModelRenderingContext context, Map<String, Map<String, PropertyType>> availableModels) { FormDefinition creationForms = context.getAvailableForms().get(subFormField.getCreationForm()); Map<String, PropertyType> modelDefinition = generateModelDefinition(creationForms, context, availableModels); FormDefinition editionForm = context.getAvailableForms().get(subFormField.getCreationForm()); modelDefinition.putAll(generateModelDefinition(editionForm, context, availableModels)); modelDefinition.put(MapModelRenderingContext.FORM_ENGINE_OBJECT_IDX, new PropertyType(Integer.class)); modelDefinition.put(MapModelRenderingContext.FORM_ENGINE_EDITED_OBJECT, new PropertyType(Boolean.class)); return new MapPropertyType(modelDefinition); } }
logger.debug("Binding property {} to component {}", property, component); final Converter converter = findConverter(property, getPropertyType(property).getType(), component, providedConverter); logger.debug("Using converter: {} <--> {}", converter.getModelType().getSimpleName(), converter.getComponentType().getSimpleName());
protected Map<String, PropertyType> generateModelDefinition(FormDefinition form, MapModelRenderingContext context, Map<String, Map<String, PropertyType>> availableModels) { if (availableModels.containsKey(form.getId())) { return availableModels.get(form.getId()); } Map<String, PropertyType> formTypes = new HashMap<>(); availableModels.put(form.getId(), formTypes); form.getFields().forEach(field -> { PropertyType propertyType = null; if (basicProperties.containsKey(field.getStandaloneClassName())) { propertyType = new PropertyType(basicProperties.get(field.getStandaloneClassName())); } else if (propertiesGenerator.containsKey(field.getClass())) { PropertyGenerator generator = propertiesGenerator.get(field.getClass()); propertyType = generator.generatePropertyType(field); } else if (field instanceof SubFormFieldDefinition) { propertyType = getModeldefinitionFor((SubFormFieldDefinition) field, context, availableModels); } else if (field instanceof MultipleSubFormFieldDefinition) { propertyType = new PropertyType(List.class); } if (propertyType != null) { formTypes.put(field.getBinding(), propertyType); } }); return formTypes; }
logger.debug("Binding property {} to component {}", property, component); final Converter converter = findConverter(property, getPropertyType(property).getType(), component, providedConverter); logger.debug("Using converter: {} <--> {}", converter.getModelType().getSimpleName(), converter.getComponentType().getSimpleName());
final PropertyType property = new PropertyType(); m_collection.getProperty().add(property); final DefaultHandler handler = new PropertyHandler(m_elementStack, property, attributes, m_parser, this);
type = hasProperties.getBeanProperties().get(meta.getProperty()).getType().getName();