use of com.vaadin.client.flow.nodefeature.NodeMap 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;
}
use of com.vaadin.client.flow.nodefeature.NodeMap 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)));
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class SimpleElementBindingStrategy method verifyAttachedElement.
private boolean verifyAttachedElement(Element element, StateNode attachNode, String id, String address, BindingContext context) {
StateNode node = context.node;
String tag = getTag(attachNode);
boolean failure = false;
if (element == null) {
failure = true;
Console.warn(ELEMENT_ATTACH_ERROR_PREFIX + address + " is not found. The requested tag name is '" + tag + "'");
} else if (!ElementUtil.hasTag(element, tag)) {
failure = true;
Console.warn(ELEMENT_ATTACH_ERROR_PREFIX + address + " has the wrong tag name '" + element.getTagName() + "', the requested tag name is '" + tag + "'");
}
if (failure) {
node.getTree().sendExistingElementWithIdAttachToServer(node, attachNode.getId(), -1, id);
return false;
}
if (!node.hasFeature(NodeFeatures.SHADOW_ROOT_DATA)) {
return true;
}
NodeMap map = node.getMap(NodeFeatures.SHADOW_ROOT_DATA);
StateNode shadowRootNode = (StateNode) map.getProperty(NodeProperties.SHADOW_ROOT).getValue();
if (shadowRootNode == null) {
return true;
}
NodeList list = shadowRootNode.getList(NodeFeatures.ELEMENT_CHILDREN);
Integer existingId = null;
for (int i = 0; i < list.length(); i++) {
StateNode stateNode = (StateNode) list.get(i);
Node domNode = stateNode.getDomNode();
if (domNode.equals(element)) {
existingId = stateNode.getId();
break;
}
}
if (existingId != null) {
Console.warn(ELEMENT_ATTACH_ERROR_PREFIX + address + " has been already attached previously via the node id='" + existingId + "'");
node.getTree().sendExistingElementWithIdAttachToServer(node, attachNode.getId(), existingId, id);
return false;
}
return true;
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class SimpleElementBindingStrategy method attachShadow.
private void attachShadow(BindingContext context) {
NodeMap map = context.node.getMap(NodeFeatures.SHADOW_ROOT_DATA);
StateNode shadowRootNode = (StateNode) map.getProperty(NodeProperties.SHADOW_ROOT).getValue();
if (shadowRootNode != null) {
NativeFunction function = NativeFunction.create("element", "if ( element.shadowRoot ) { return element.shadowRoot; } " + "else { return element.attachShadow({'mode' : 'open'});}");
Node shadowRoot = (Node) function.call(null, context.htmlNode);
if (shadowRootNode.getDomNode() == null) {
shadowRootNode.setDomNode(shadowRoot);
}
BindingContext newContext = new BindingContext(shadowRootNode, shadowRoot, context.binderContext);
bindChildren(newContext);
}
}
use of com.vaadin.client.flow.nodefeature.NodeMap in project flow by vaadin.
the class SimpleElementBindingStrategy method bindDomEventListeners.
private EventRemover bindDomEventListeners(BindingContext context) {
NodeMap elementListeners = getDomEventListenerMap(context.node);
elementListeners.forEachProperty((property, name) -> {
Computation computation = bindEventHandlerProperty(property, context);
// Run eagerly to add initial listeners before element is attached
computation.recompute();
});
return elementListeners.addPropertyAddListener(event -> bindEventHandlerProperty(event.getProperty(), context));
}
Aggregations