Search in sources :

Example 6 with MapProperty

use of com.vaadin.client.flow.nodefeature.MapProperty in project flow by vaadin.

the class GwtMultipleBindingTest method testBindTextNodeDoubleBind.

public void testBindTextNodeDoubleBind() {
    TestStateNode textNode = new TestStateNode(1, node.getTree());
    Text domNode = Browser.getDocument().createTextNode("");
    MapProperty textProperty = textNode.getMap(NodeFeatures.TEXT_NODE).getProperty(NodeProperties.TEXT);
    Binder.bind(textNode, domNode);
    textProperty.setValue("foo");
    Reactive.flush();
    node.setBound();
    Binder.bind(textNode, domNode);
}
Also used : MapProperty(com.vaadin.client.flow.nodefeature.MapProperty) Text(elemental.dom.Text)

Example 7 with MapProperty

use of com.vaadin.client.flow.nodefeature.MapProperty in project flow by vaadin.

the class TreeChangeProcessorTest method testMapRemoveChange.

@Test
public void testMapRemoveChange() {
    MapProperty property = tree.getRootNode().getMap(ns).getProperty(myKey);
    property.setValue(myValue);
    JsonObject change = removeChange(rootId, ns, myKey);
    StateNode node = TreeChangeProcessor.processChange(tree, change);
    Assert.assertFalse(property.hasValue());
    Assert.assertEquals(tree.getRootNode(), node);
}
Also used : MapProperty(com.vaadin.client.flow.nodefeature.MapProperty) JsonObject(elemental.json.JsonObject) Test(org.junit.Test)

Example 8 with MapProperty

use of com.vaadin.client.flow.nodefeature.MapProperty in project flow by vaadin.

the class StateTreeTest method sendNodePropertySyncToServer_initialProperty_propertyIsNoSent.

@Test
public void sendNodePropertySyncToServer_initialProperty_propertyIsNoSent() {
    tree.registerNode(node);
    NodeMap map = node.getMap(NodeFeatures.ELEMENT_PROPERTIES);
    MapProperty property = new MapProperty("foo", map);
    property.setValue("bar");
    Mockito.when(propertyHandler.handlePropertyUpdate(property)).thenReturn(true);
    connector.clear();
    tree.sendNodePropertySyncToServer(property);
    connector.assertMessage(null, null, null);
}
Also used : MapProperty(com.vaadin.client.flow.nodefeature.MapProperty) NodeMap(com.vaadin.client.flow.nodefeature.NodeMap) Test(org.junit.Test)

Example 9 with MapProperty

use of com.vaadin.client.flow.nodefeature.MapProperty in project flow by vaadin.

the class PollConfigurator method observe.

/**
 * Observes the given node for poll configuration changes and configures the
 * given poller accordingly.
 *
 * @param node
 *            the node containing the poll configuration
 * @param poller
 *            the poller to configure
 */
public static void observe(StateNode node, Poller poller) {
    NodeMap configurationMap = node.getMap(NodeFeatures.POLL_CONFIGURATION);
    MapProperty pollIntervalProperty = configurationMap.getProperty(PollConfigurationMap.POLL_INTERVAL_KEY);
    pollIntervalProperty.addChangeListener(e -> {
        int interval = (int) (double) e.getNewValue();
        poller.setInterval(interval);
    });
}
Also used : MapProperty(com.vaadin.client.flow.nodefeature.MapProperty) NodeMap(com.vaadin.client.flow.nodefeature.NodeMap)

Example 10 with MapProperty

use of com.vaadin.client.flow.nodefeature.MapProperty in project flow by vaadin.

the class PushConfiguration method getParameters.

/**
 * Gets all configured push parameters.
 *
 * The parameters configured on the server, including transports.
 *
 * @return a map of all parameters configured on the server
 */
public JsMap<String, String> getParameters() {
    MapProperty p = getConfigurationMap().getProperty(PushConfigurationMap.PARAMETERS_KEY);
    StateNode parametersNode = (StateNode) p.getValue();
    NodeMap parametersMap = parametersNode.getMap(NodeFeatures.UI_PUSHCONFIGURATION_PARAMETERS);
    JsMap<String, String> parameters = JsCollections.map();
    parametersMap.forEachProperty((property, key) -> {
        parameters.set(key, (String) property.getValue());
    });
    return parameters;
}
Also used : MapProperty(com.vaadin.client.flow.nodefeature.MapProperty) StateNode(com.vaadin.client.flow.StateNode) NodeMap(com.vaadin.client.flow.nodefeature.NodeMap)

Aggregations

MapProperty (com.vaadin.client.flow.nodefeature.MapProperty)40 NodeMap (com.vaadin.client.flow.nodefeature.NodeMap)18 StateNode (com.vaadin.client.flow.StateNode)12 Test (org.junit.Test)8 Element (elemental.dom.Element)7 JsonObject (elemental.json.JsonObject)6 UpdatableModelProperties (com.vaadin.client.flow.model.UpdatableModelProperties)5 JsonValue (elemental.json.JsonValue)3 NodeFeature (com.vaadin.client.flow.nodefeature.NodeFeature)2 SchedulerImpl (com.google.gwt.core.client.impl.SchedulerImpl)1 Computation (com.vaadin.client.flow.reactive.Computation)1 FlushListener (com.vaadin.client.flow.reactive.FlushListener)1 Node (elemental.dom.Node)1 NodeList (elemental.dom.NodeList)1 Text (elemental.dom.Text)1 EventRemover (elemental.events.EventRemover)1 MouseEvent (elemental.events.MouseEvent)1 JsonArray (elemental.json.JsonArray)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1