use of com.vaadin.client.flow.nodefeature.NodeList in project flow by vaadin.
the class GwtPropertyElementBinderTest method gwtSetUp.
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
Reactive.reset();
constantPool = new ConstantPool();
tree = new CollectingStateTree(constantPool, new ExistingElementMap());
node = createNode();
properties = node.getMap(NodeFeatures.ELEMENT_PROPERTIES);
synchronizedPropertyList = new NodeList(0, node);
element = Browser.getDocument().createElement("div");
}
use of com.vaadin.client.flow.nodefeature.NodeList in project flow by vaadin.
the class PolymerUtils method getListNotificationPath.
private static String getListNotificationPath(StateNode currentNode) {
int indexInTheList = -1;
NodeList children = currentNode.getParent().getList(NodeFeatures.TEMPLATE_MODELLIST);
for (int i = 0; i < children.length(); i++) {
Object object = children.get(i);
if (currentNode.equals(object)) {
indexInTheList = i;
break;
}
}
if (indexInTheList < 0) {
return null;
}
return String.valueOf(indexInTheList);
}
use of com.vaadin.client.flow.nodefeature.NodeList in project flow by vaadin.
the class TreeChangeProcessor method processClearChange.
private static void processClearChange(JsonObject change, StateNode node) {
int nsId = (int) change.getNumber(JsonConstants.CHANGE_FEATURE);
NodeList list = node.getList(nsId);
list.clear();
}
use of com.vaadin.client.flow.nodefeature.NodeList in project flow by vaadin.
the class ServerEventHandlerBinder method bindServerEventHandlerNames.
/**
* Registers all the server event handler names found in the feature with
* the {@code featureId} in the {@link ServerEventObject} {@code object}.
* Additionally listens to changes in the feature and updates server event
* object accordingly.
*
* @param objectProvider
* the provider of the event object to update
* @param node
* the state node containing the feature
* @param featureId
* the feature id which contains event handler methods
* @param returnValue
* <code>true</code> if the handler should return a promise that
* will reflect the server-side result; <code>false</code> to not
* return any value
* @return a handle which can be used to remove the listener for the feature
*/
public static EventRemover bindServerEventHandlerNames(Supplier<ServerEventObject> objectProvider, StateNode node, int featureId, boolean returnValue) {
NodeList serverEventHandlerNamesList = node.getList(featureId);
if (serverEventHandlerNamesList.length() > 0) {
ServerEventObject object = objectProvider.get();
for (int i = 0; i < serverEventHandlerNamesList.length(); i++) {
String serverEventHandlerName = (String) serverEventHandlerNamesList.get(i);
object.defineMethod(serverEventHandlerName, node, returnValue);
}
}
return serverEventHandlerNamesList.addSpliceListener(e -> {
ServerEventObject serverObject = objectProvider.get();
JsArray<?> remove = e.getRemove();
for (int i = 0; i < remove.length(); i++) {
serverObject.removeMethod((String) remove.get(i));
}
JsArray<?> add = e.getAdd();
for (int i = 0; i < add.length(); i++) {
serverObject.defineMethod((String) add.get(i), node, returnValue);
}
});
}
use of com.vaadin.client.flow.nodefeature.NodeList in project flow by vaadin.
the class GwtBasicElementBinderTest method testVirtualChild.
public void testVirtualChild() {
Binder.bind(node, element);
StateNode childNode = createChildNode("child");
NodeMap elementData = childNode.getMap(NodeFeatures.ELEMENT_DATA);
JsonObject object = Json.createObject();
object.put(NodeProperties.TYPE, NodeProperties.IN_MEMORY_CHILD);
elementData.getProperty(NodeProperties.PAYLOAD).setValue(object);
NodeList virtialChildren = node.getList(NodeFeatures.VIRTUAL_CHILDREN);
virtialChildren.add(0, childNode);
Reactive.flush();
assertEquals(element.getChildElementCount(), 0);
Element childElement = (Element) childNode.getDomNode();
assertEquals("SPAN", childElement.getTagName());
assertEquals("child", childElement.getId());
}
Aggregations