Search in sources :

Example 11 with MapProperty

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

the class LoadingIndicatorConfigurator method observe.

/**
 * Observes the given node for loading indicator configuration changes and
 * configures the loading indicator singleton accordingly.
 *
 * @param node
 *            the node containing the loading indicator configuration
 */
public static void observe(StateNode node) {
    NodeMap configMap = node.getMap(NodeFeatures.LOADING_INDICATOR_CONFIGURATION);
    bindInteger(configMap, LoadingIndicatorConfigurationMap.FIRST_DELAY_KEY, LoadingIndicatorConfigurator::setFirstDelay, LoadingIndicatorConfigurationMap.FIRST_DELAY_DEFAULT);
    bindInteger(configMap, LoadingIndicatorConfigurationMap.SECOND_DELAY_KEY, LoadingIndicatorConfigurator::setSecondDelay, LoadingIndicatorConfigurationMap.SECOND_DELAY_DEFAULT);
    bindInteger(configMap, LoadingIndicatorConfigurationMap.THIRD_DELAY_KEY, LoadingIndicatorConfigurator::setThirdDelay, LoadingIndicatorConfigurationMap.THIRD_DELAY_DEFAULT);
    MapProperty defaultThemeProperty = configMap.getProperty(LoadingIndicatorConfigurationMap.DEFAULT_THEME_APPLIED_KEY);
    defaultThemeProperty.addChangeListener(event -> setApplyDefaultTheme(event.getSource().getValueOrDefault(LoadingIndicatorConfigurationMap.DEFAULT_THEME_APPLIED_DEFAULT)));
}
Also used : MapProperty(com.vaadin.client.flow.nodefeature.MapProperty) NodeMap(com.vaadin.client.flow.nodefeature.NodeMap)

Example 12 with MapProperty

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

the class SimpleElementBindingStrategy method restoreInitialHiddenAttribute.

private void restoreInitialHiddenAttribute(Element element, NodeMap visibilityData) {
    storeInitialHiddenAttribute(element, visibilityData);
    MapProperty initialVisibility = visibilityData.getProperty(NodeProperties.VISIBILITY_HIDDEN_PROPERTY);
    if (initialVisibility.hasValue()) {
        updateAttributeValue(visibilityData.getNode().getTree().getRegistry().getApplicationConfiguration(), element, HIDDEN_ATTRIBUTE, initialVisibility.getValue());
    }
    MapProperty initialDisplay = visibilityData.getProperty(NodeProperties.VISIBILITY_STYLE_DISPLAY_PROPERTY);
    if (initialDisplay.hasValue()) {
        final String initialValue = initialDisplay.getValue().toString();
        element.getStyle().setDisplay(initialValue);
    }
}
Also used : MapProperty(com.vaadin.client.flow.nodefeature.MapProperty)

Example 13 with MapProperty

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

the class SimpleElementBindingStrategy method storeInitialHiddenAttribute.

private void storeInitialHiddenAttribute(Element element, NodeMap visibilityData) {
    MapProperty initialVisibility = visibilityData.getProperty(NodeProperties.VISIBILITY_HIDDEN_PROPERTY);
    if (!initialVisibility.hasValue()) {
        initialVisibility.setValue(element.getAttribute(HIDDEN_ATTRIBUTE));
    }
    MapProperty initialDisplay = visibilityData.getProperty(NodeProperties.VISIBILITY_STYLE_DISPLAY_PROPERTY);
    if (PolymerUtils.isInShadowRoot(element) && !initialDisplay.hasValue() && element.getStyle() != null) {
        initialDisplay.setValue(element.getStyle().getDisplay());
    }
}
Also used : MapProperty(com.vaadin.client.flow.nodefeature.MapProperty)

Example 14 with MapProperty

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

the class InitialPropertiesHandler method doFlushPropertyUpdates.

private void doFlushPropertyUpdates(JsMap<Double, JsMap<String, Object>> properties) {
    newNodeDuringUpdate.clear();
    while (propertyUpdateQueue.length() > 0) {
        MapProperty property = propertyUpdateQueue.remove(0);
        if (!resetProperty(property, properties)) {
            getRegistry().getStateTree().sendNodePropertySyncToServer(property);
        }
        /*
             * Do flush after each property update. There may be several
             * properties and it looks like a property update may trigger
             * default values of other properties back.
             *
             * See https://github.com/vaadin/flow/issues/2304
             */
        Reactive.flush();
    }
}
Also used : MapProperty(com.vaadin.client.flow.nodefeature.MapProperty)

Example 15 with MapProperty

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

the class GwtBasicElementBinderTest method testRemovedEventNotFired.

public void testRemovedEventNotFired() {
    Binder.bind(node, element);
    MapProperty clickEvent = node.getMap(NodeFeatures.ELEMENT_LISTENERS).getProperty("click");
    clickEvent.setValue(Double.valueOf(1));
    Reactive.flush();
    clickEvent.removeValue();
    Reactive.flush();
    element.click();
    assertEquals(0, tree.collectedNodes.length());
}
Also used : MapProperty(com.vaadin.client.flow.nodefeature.MapProperty)

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