Search in sources :

Example 1 with ContainerPattern

use of com.qcadoo.view.internal.api.ContainerPattern in project qcadoo by qcadoo.

the class ComponentPatternTest method shouldReturnValidPath.

@Test
public void shouldReturnValidPath() throws Exception {
    // given
    ContainerPattern root = new WindowComponentPattern(getComponentDefinition("rootName", null));
    ContainerPattern child1 = new WindowComponentPattern(getComponentDefinition("child1", root, null));
    ComponentPattern child2 = new TextInputComponentPattern(getComponentDefinition("child2", root, null));
    ComponentPattern child11 = new TextInputComponentPattern(getComponentDefinition("child11", child1, null));
    // when
    String rootPathName = root.getPath();
    String child1PathName = child1.getPath();
    String child2PathName = child2.getPath();
    String child11PathName = child11.getPath();
    // then
    Assert.assertEquals("rootName", rootPathName);
    Assert.assertEquals("rootName.child1", child1PathName);
    Assert.assertEquals("rootName.child2", child2PathName);
    Assert.assertEquals("rootName.child1.child11", child11PathName);
}
Also used : ContainerPattern(com.qcadoo.view.internal.api.ContainerPattern) WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern) FormComponentPattern(com.qcadoo.view.internal.components.form.FormComponentPattern) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern) ComponentPattern(com.qcadoo.view.internal.api.ComponentPattern) TextInputComponentPattern(com.qcadoo.view.internal.components.TextInputComponentPattern) Test(org.junit.Test)

Example 2 with ContainerPattern

use of com.qcadoo.view.internal.api.ContainerPattern in project qcadoo by qcadoo.

the class ViewDefinitionImpl method getPatternsAsList.

private List<ComponentPattern> getPatternsAsList(final Collection<ComponentPattern> patterns) {
    List<ComponentPattern> list = new ArrayList<ComponentPattern>();
    list.addAll(patterns);
    for (ComponentPattern pattern : patterns) {
        if (pattern instanceof ContainerPattern) {
            list.addAll(getPatternsAsList(((ContainerPattern) pattern).getChildren().values()));
        }
    }
    return list;
}
Also used : ContainerPattern(com.qcadoo.view.internal.api.ContainerPattern) AbstractComponentPattern(com.qcadoo.view.internal.patterns.AbstractComponentPattern) ComponentPattern(com.qcadoo.view.internal.api.ComponentPattern) WindowComponentPattern(com.qcadoo.view.internal.components.window.WindowComponentPattern)

Aggregations

ComponentPattern (com.qcadoo.view.internal.api.ComponentPattern)2 ContainerPattern (com.qcadoo.view.internal.api.ContainerPattern)2 WindowComponentPattern (com.qcadoo.view.internal.components.window.WindowComponentPattern)2 TextInputComponentPattern (com.qcadoo.view.internal.components.TextInputComponentPattern)1 FormComponentPattern (com.qcadoo.view.internal.components.form.FormComponentPattern)1 AbstractComponentPattern (com.qcadoo.view.internal.patterns.AbstractComponentPattern)1 Test (org.junit.Test)1