Search in sources :

Example 1 with Registry

use of com.vaadin.client.Registry in project flow by vaadin.

the class GwtBasicElementBinderTest method testAddTemplateChild.

public void testAddTemplateChild() {
    final int templateId = 43;
    TestElementTemplateNode templateNode = TestElementTemplateNode.create("child");
    TemplateRegistry templates = new TemplateRegistry();
    templates.register(templateId, templateNode);
    Registry registry = new Registry() {

        {
            set(TemplateRegistry.class, templates);
            set(ExistingElementMap.class, new ExistingElementMap());
        }
    };
    StateTree stateTree = new StateTree(registry);
    StateNode templateStateNode = new StateNode(345, stateTree);
    templateStateNode.getMap(NodeFeatures.TEMPLATE).getProperty(NodeProperties.ROOT_TEMPLATE_ID).setValue(Double.valueOf(templateId));
    StateNode parentElementNode = new StateNode(94, stateTree);
    parentElementNode.getMap(NodeFeatures.ELEMENT_DATA).getProperty(NodeProperties.TAG).setValue("div");
    parentElementNode.getList(NodeFeatures.ELEMENT_CHILDREN).add(0, templateStateNode);
    Element element = Browser.getDocument().createElement("div");
    Binder.bind(parentElementNode, element);
    Reactive.flush();
    assertEquals(1, element.getChildElementCount());
    assertEquals("CHILD", element.getFirstElementChild().getTagName());
}
Also used : TemplateRegistry(com.vaadin.client.flow.template.TemplateRegistry) TestElementTemplateNode(com.vaadin.client.flow.template.TestElementTemplateNode) Element(elemental.dom.Element) ExistingElementMap(com.vaadin.client.ExistingElementMap) Registry(com.vaadin.client.Registry) TemplateRegistry(com.vaadin.client.flow.template.TemplateRegistry)

Example 2 with Registry

use of com.vaadin.client.Registry in project flow by vaadin.

the class GwtEventHandlerTest method gwtSetUp.

@Override
protected void gwtSetUp() throws Exception {
    super.gwtSetUp();
    Reactive.reset();
    registry = new Registry() {

        {
            set(ConstantPool.class, new ConstantPool());
        }
    };
    tree = new StateTree(registry) {

        @Override
        public void sendTemplateEventToServer(StateNode node, String methodName, JsArray<?> argValues) {
            serverMethods.put(methodName, argValues);
            serverRpcNodes.put(methodName, node);
        }
    };
    node = new StateNode(0, tree);
    // populate "element data" feature to be able to bind node as a plain
    // element
    node.getMap(NodeFeatures.ELEMENT_DATA);
    element = Browser.getDocument().createElement("div");
}
Also used : Registry(com.vaadin.client.Registry)

Example 3 with Registry

use of com.vaadin.client.Registry in project flow by vaadin.

the class GwtMultipleBindingTest method gwtSetUp.

@Override
protected void gwtSetUp() throws Exception {
    super.gwtSetUp();
    Reactive.reset();
    registry = new Registry() {

        {
            set(ConstantPool.class, new ConstantPool());
            set(ExistingElementMap.class, new ExistingElementMap());
        }
    };
    tree = new StateTree(registry) {

        @Override
        public void sendTemplateEventToServer(StateNode node, String methodName, JsArray<?> argValues) {
        }
    };
    node = new TestStateNode(tree);
    // populate "element data" feature to be able to bind node as a plain
    // element
    node.getMap(NodeFeatures.ELEMENT_DATA);
    element = Browser.getDocument().createElement("div");
}
Also used : ExistingElementMap(com.vaadin.client.ExistingElementMap) Registry(com.vaadin.client.Registry)

Example 4 with Registry

use of com.vaadin.client.Registry in project flow by vaadin.

the class GwtRouterLinkHandlerTest method gwtSetUp.

@Override
protected void gwtSetUp() throws Exception {
    super.gwtSetUp();
    invocations = JsCollections.array();
    ServerConnector connector = new ServerConnector(null) {

        @Override
        public void sendNavigationMessage(String location, Object stateObject, boolean routerLinkEvent) {
            invocations.push(location);
        }
    };
    UILifecycle lifecycle = new UILifecycle();
    lifecycle.setState(UIState.RUNNING);
    registry = new Registry() {

        {
            set(UILifecycle.class, lifecycle);
            set(ServerConnector.class, connector);
            set(MessageHandler.class, new MessageHandler(this));
            set(RequestResponseTracker.class, new RequestResponseTracker(this));
            set(ScrollPositionHandler.class, new ScrollPositionHandler(this));
        }
    };
    boundElement = Browser.getDocument().createDivElement();
    Browser.getDocument().getBody().appendChild(boundElement);
    RouterLinkHandler.bind(registry, boundElement);
}
Also used : ServerConnector(com.vaadin.client.communication.ServerConnector) ScrollPositionHandler(com.vaadin.client.ScrollPositionHandler) MessageHandler(com.vaadin.client.communication.MessageHandler) UILifecycle(com.vaadin.client.UILifecycle) Registry(com.vaadin.client.Registry) RequestResponseTracker(com.vaadin.client.communication.RequestResponseTracker)

Example 5 with Registry

use of com.vaadin.client.Registry in project flow by vaadin.

the class GwtStateTreeTest method gwtSetUp.

@Override
protected void gwtSetUp() throws Exception {
    super.gwtSetUp();
    registry = new Registry() {

        {
            set(ServerConnector.class, new TestServerConnector(this));
            set(InitialPropertiesHandler.class, new InitialPropertiesHandler(this));
        }
    };
    tree = new StateTree(registry);
}
Also used : ServerConnector(com.vaadin.client.communication.ServerConnector) InitialPropertiesHandler(com.vaadin.client.InitialPropertiesHandler) Registry(com.vaadin.client.Registry)

Aggregations

Registry (com.vaadin.client.Registry)18 Test (org.junit.Test)11 JsElement (elemental.js.dom.JsElement)9 ExistingElementMap (com.vaadin.client.ExistingElementMap)4 JsonArray (elemental.json.JsonArray)4 JsonObject (elemental.json.JsonObject)4 InitialPropertiesHandler (com.vaadin.client.InitialPropertiesHandler)2 UILifecycle (com.vaadin.client.UILifecycle)2 MessageHandler (com.vaadin.client.communication.MessageHandler)2 RequestResponseTracker (com.vaadin.client.communication.RequestResponseTracker)2 ServerConnector (com.vaadin.client.communication.ServerConnector)2 DependencyLoader (com.vaadin.client.DependencyLoader)1 ResourceLoader (com.vaadin.client.ResourceLoader)1 ScrollPositionHandler (com.vaadin.client.ScrollPositionHandler)1 ServerRpcQueue (com.vaadin.client.communication.ServerRpcQueue)1 ConstantPool (com.vaadin.client.flow.ConstantPool)1 StateNode (com.vaadin.client.flow.StateNode)1 StateTree (com.vaadin.client.flow.StateTree)1 JsArray (com.vaadin.client.flow.collection.JsArray)1 TemplateRegistry (com.vaadin.client.flow.template.TemplateRegistry)1