use of com.vaadin.client.ExistingElementMap in project flow by vaadin.
the class GwtTemplateBinderTest method gwtSetUp.
@Override
protected void gwtSetUp() throws Exception {
super.gwtSetUp();
registry = new Registry() {
{
set(TemplateRegistry.class, new TemplateRegistry());
set(ConstantPool.class, new ConstantPool());
set(ExistingElementMap.class, new ExistingElementMap());
set(InitialPropertiesHandler.class, new InitialPropertiesHandler(this));
set(StateTree.class, new StateTree(this) {
@Override
public void sendTemplateEventToServer(StateNode node, String methodName, JsArray<?> argValues) {
serverMethods.put(methodName, argValues);
serverRpcNodes.put(methodName, node);
}
});
}
};
tree = registry.getStateTree();
/**
* This state node is ALWAYS a template !!!
*/
stateNode = new StateNode(0, tree) {
@Override
public boolean hasFeature(int id) {
if (id == NodeFeatures.TEMPLATE) {
return true;
}
return super.hasFeature(id);
}
};
// Use the most common model structure by default
JsonObject modelType = Json.createObject();
modelType.put(MODEL_KEY, "String");
setModelType(stateNode, modelType);
}
use of com.vaadin.client.ExistingElementMap in project flow by vaadin.
the class ExecuteJavaScriptProcessorTest method execute_nodeParametersAreCorrectlyPassed.
@Test
public void execute_nodeParametersAreCorrectlyPassed() {
Registry registry = new Registry() {
{
StateTree tree = new StateTree(this);
set(StateTree.class, tree);
set(ExistingElementMap.class, new ExistingElementMap());
}
};
CollectingExecuteJavaScriptProcessor processor = new CollectingExecuteJavaScriptProcessor(registry);
StateNode node = new StateNode(10, registry.getStateTree());
registry.getStateTree().registerNode(node);
JsElement element = new JsElement() {
};
node.setDomNode(element);
JsonArray json = JsonUtils.createArray(Json.create(JsonCodec.NODE_TYPE), Json.create(node.getId()));
JsonArray invocation = Stream.of(json, Json.create("$0")).collect(JsonUtils.asArray());
// JRE impl of the array uses
processor.execute(JsonUtils.createArray(invocation));
Assert.assertEquals(1, processor.nodeParametersList.size());
Assert.assertEquals(1, processor.nodeParametersList.get(0).size());
JsMap<Object, StateNode> map = processor.nodeParametersList.get(0);
StateNode stateNode = map.get(element);
Assert.assertEquals(node, stateNode);
}
use of com.vaadin.client.ExistingElementMap 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");
}
Aggregations