use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class StateNodeTest method collectChanges_initiallyActiveElement_sendOnlyDisalowFeatureChangesWhenInactive.
@Test
public void collectChanges_initiallyActiveElement_sendOnlyDisalowFeatureChangesWhenInactive() {
StateNode stateNode = createTestNode("Active node", ElementPropertyMap.class, ElementData.class);
ElementData visibility = stateNode.getFeature(ElementData.class);
ElementPropertyMap properties = stateNode.getFeature(ElementPropertyMap.class);
TestStateTree tree = new TestStateTree();
// attach the node to be able to get changes
tree.getRootNode().getFeature(ElementChildrenList.class).add(0, stateNode);
assertCollectChanges_initiallyVisible(stateNode, properties, isVisible -> {
visibility.setVisible(isVisible);
stateNode.updateActiveState();
});
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class PolymerTemplate method filterUnsetProperties.
private JsonArray filterUnsetProperties(List<String> properties) {
JsonArray array = Json.createArray();
ElementPropertyMap map = getStateNode().getFeature(ElementPropertyMap.class);
int i = 0;
for (String property : properties) {
if (!map.hasProperty(property)) {
array.set(i, property);
i++;
}
}
return array;
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class PolymerTemplate method removeSimpleProperties.
private List<String> removeSimpleProperties() {
ElementPropertyMap map = getStateNode().getFeature(ElementPropertyMap.class);
List<String> props = map.getPropertyNames().filter(name -> !(map.getProperty(name) instanceof StateNode)).collect(Collectors.toList());
props.forEach(map::removeProperty);
return props;
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class BeanModelTypeTest method modelToApplication.
@Test
public void modelToApplication() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, PropertyFilter.ACCEPT_ALL, false);
ElementPropertyMap model = createEmptyModel();
model.setProperty("string", "3");
model.setProperty("intValue", Integer.valueOf(3));
Bean bean = beanType.modelToApplication(model.getNode());
Assert.assertEquals("3", bean.getString());
Assert.assertEquals(3, bean.getIntValue());
Assert.assertNull(bean.getIntObject());
}
use of com.vaadin.flow.internal.nodefeature.ElementPropertyMap in project flow by vaadin.
the class BeanModelTypeTest method importBean_withImportFilter.
@Test
public void importBean_withImportFilter() {
BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, PropertyFilter.ACCEPT_ALL, false);
ElementPropertyMap model = createEmptyModel();
Bean bean = new Bean(3);
beanType.importProperties(model, bean, new PropertyFilter(name -> "intObject".equals(name)));
Assert.assertEquals(1, model.getPropertyNames().count());
Assert.assertEquals(Integer.valueOf(3), model.getProperty("intObject"));
}
Aggregations