use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class StateTreeTest method sendNodePropertySyncToServer_notInitialProperty_propertyIsSent.
@Test
public void sendNodePropertySyncToServer_notInitialProperty_propertyIsSent() {
tree.registerNode(node);
NodeMap map = node.getMap(NodeFeatures.ELEMENT_PROPERTIES);
MapProperty property = new MapProperty("foo", map);
property.setValue("bar");
connector.clear();
tree.sendNodePropertySyncToServer(property);
connector.assertMessage(node, "foo", "bar");
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class StateTreeTest method sendNodePropertySyncToServer_nodeDetached_propertyNotIsSent.
@Test
public void sendNodePropertySyncToServer_nodeDetached_propertyNotIsSent() {
tree.registerNode(node);
NodeMap map = node.getMap(NodeFeatures.ELEMENT_PROPERTIES);
MapProperty property = new MapProperty("foo", map);
property.setValue("bar");
connector.clear();
tree.unregisterNode(node);
tree.sendNodePropertySyncToServer(property);
connector.assertMessage(null, null, null);
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class InitialPropertiesHandlerTest method flushPropertyUpdates_updateIsNotInProgress_collectInitialProperties.
@Test
public void flushPropertyUpdates_updateIsNotInProgress_collectInitialProperties() {
Mockito.when(tree.isUpdateInProgress()).thenReturn(false);
StateNode node = new StateNode(1, tree);
NodeMap properties = node.getMap(NodeFeatures.ELEMENT_PROPERTIES);
MapProperty serverSidePropertyUpdatedByClient = properties.getProperty("foo");
serverSidePropertyUpdatedByClient.setValue("bar");
MapProperty serverSideProperty = properties.getProperty("other");
serverSideProperty.setValue("value");
handler.nodeRegistered(node);
Mockito.when(tree.getNode(node.getId())).thenReturn(node);
handler.flushPropertyUpdates();
serverSidePropertyUpdatedByClient.setValue("updated");
MapProperty clientSideProperty = properties.getProperty("client");
clientSideProperty.setValue("baz");
handler.handlePropertyUpdate(serverSidePropertyUpdatedByClient);
handler.handlePropertyUpdate(clientSideProperty);
Reactive.flush();
Assert.assertEquals("bar", properties.getProperty("foo").getValue());
Assert.assertEquals("value", properties.getProperty("other").getValue());
Assert.assertEquals("baz", properties.getProperty("client").getValue());
Mockito.verify(tree, Mockito.times(0)).sendNodePropertySyncToServer(serverSidePropertyUpdatedByClient);
Mockito.verify(tree, Mockito.times(0)).sendNodePropertySyncToServer(serverSideProperty);
Mockito.verify(tree).sendNodePropertySyncToServer(clientSideProperty);
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class StateTree method sendNodePropertySyncToServer.
/**
* Sends a map property sync to the server.
*
* @param property
* the property that should have its value synced to the server,
* not <code>null</code>
*/
public void sendNodePropertySyncToServer(MapProperty property) {
assert property != null;
NodeMap nodeMap = property.getMap();
StateNode node = nodeMap.getNode();
if (getRegistry().getInitialPropertiesHandler().handlePropertyUpdate(property) || !isValidNode(node)) {
return;
}
registry.getServerConnector().sendNodeSyncMessage(node, nodeMap.getId(), property.getName(), property.getValue());
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class StateTree method isVisible.
/**
* Returns the visibility state of the {@code node}.
*
* @param node
* the node whose visibility is tested
* @return {@code true} is the node is visible, {@code false} otherwise
*/
public boolean isVisible(StateNode node) {
if (!node.hasFeature(NodeFeatures.ELEMENT_DATA)) {
return true;
}
NodeMap visibilityMap = node.getMap(NodeFeatures.ELEMENT_DATA);
Boolean visibility = (Boolean) visibilityMap.getProperty(NodeProperties.VISIBLE).getValue();
/*
* Absence of value or "true" means that the node should be visible. So
* only "false" means "hide".
*/
return !Boolean.FALSE.equals(visibility);
}
Aggregations