Search in sources :

Example 1 with Region

use of com.enonic.xp.region.Region in project xp by enonic.

the class ComponentMapper method serialize.

private void serialize(final MapGenerator gen, final LayoutComponent comp) {
    gen.map(REGIONS);
    for (final Region region : comp.getRegions()) {
        new RegionMapper(region).serialize(gen);
    }
    gen.end();
}
Also used : Region(com.enonic.xp.region.Region)

Example 2 with Region

use of com.enonic.xp.region.Region in project xp by enonic.

the class ProjectContentEventListenerTest method createPage.

private Page createPage() {
    PropertyTree componentConfig = new PropertyTree();
    componentConfig.setString("my-prop", "value");
    PartComponent component = PartComponent.create().descriptor(DescriptorKey.from("mainapplication:partTemplateName")).config(componentConfig).build();
    Region region = Region.create().name("my-region").add(component).build();
    PageRegions regions = PageRegions.create().add(region).build();
    PropertyTree pageConfig = new PropertyTree();
    pageConfig.setString("background-color", "blue");
    Mockito.when(partDescriptorService.getByKey(DescriptorKey.from("mainapplication:partTemplateName"))).thenReturn(PartDescriptor.create().key(DescriptorKey.from("mainapplication:partTemplateName")).displayName("my-component").config(Form.create().build()).build());
    return Page.create().template(PageTemplateKey.from("mypagetemplate")).regions(regions).build();
}
Also used : PageRegions(com.enonic.xp.page.PageRegions) PropertyTree(com.enonic.xp.data.PropertyTree) Region(com.enonic.xp.region.Region) PartComponent(com.enonic.xp.region.PartComponent)

Example 3 with Region

use of com.enonic.xp.region.Region in project xp by enonic.

the class TestDataFixtures method createLayoutComponent.

private static LayoutComponent createLayoutComponent() {
    final Region region1 = Region.create().name("left").add(PartComponent.create().build()).add(TextComponent.create().text("text text text").build()).add(TextComponent.create().build()).build();
    final Region region2 = Region.create().name("right").add(createImageComponent("image-id", "Some Image", null)).add(createFragmentComponent("213sda-ss222", "My Fragment")).build();
    final LayoutRegions layoutRegions = LayoutRegions.create().add(region1).add(region2).build();
    return LayoutComponent.create().descriptor("layoutDescriptor:name").regions(layoutRegions).build();
}
Also used : Region(com.enonic.xp.region.Region) LayoutRegions(com.enonic.xp.region.LayoutRegions)

Example 4 with Region

use of com.enonic.xp.region.Region in project xp by enonic.

the class PortalUrlServiceImpl_componentUrlTest method addComponent.

private void addComponent() {
    final PartComponent component = PartComponent.create().descriptor("myapp:mycomp").build();
    final Region region = Region.create().name("main").add(component).build();
    this.portalRequest.setComponent(component);
}
Also used : Region(com.enonic.xp.region.Region) PartComponent(com.enonic.xp.region.PartComponent)

Example 5 with Region

use of com.enonic.xp.region.Region in project xp by enonic.

the class PageTest method equals.

@Test
public void equals() {
    final PropertyTree config1 = new PropertyTree();
    config1.addString("some", "config");
    final PropertyTree config2 = new PropertyTree();
    config2.addString("other", "config");
    final Region region1 = Region.create().name("main").add(PartComponent.create().descriptor("descriptor-x").config(new PropertyTree()).build()).add(PartComponent.create().descriptor("descriptor-y").config(new PropertyTree()).build()).build();
    final Region region2 = Region.create().name("apart").add(PartComponent.create().descriptor("descriptor-x").config(new PropertyTree()).build()).add(PartComponent.create().descriptor("descriptor-y").config(new PropertyTree()).build()).build();
    AbstractEqualsTest equalsTest = new AbstractEqualsTest() {

        @Override
        public Object getObjectX() {
            return Page.create().config(config1).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region1).build()).build();
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            Page notX1 = Page.create().config(config1).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region2).build()).build();
            Page notX2 = Page.create().config(config1).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region1).add(region2).build()).build();
            Page notX3 = Page.create().config(config2).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region1).build()).build();
            Page notX4 = Page.create().config(config1).template(PageTemplateKey.from("template-y")).regions(PageRegions.create().add(region1).build()).build();
            return new Object[] { notX1, notX2, notX3, notX4, new Object() };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return Page.create().config(config1).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region1).build()).build();
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            return Page.create().config(config1).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region1).build()).build();
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Region(com.enonic.xp.region.Region) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Aggregations

Region (com.enonic.xp.region.Region)17 PropertyTree (com.enonic.xp.data.PropertyTree)8 Component (com.enonic.xp.region.Component)4 LayoutComponent (com.enonic.xp.region.LayoutComponent)4 DescriptorKey (com.enonic.xp.page.DescriptorKey)3 Page (com.enonic.xp.page.Page)3 PageRegions (com.enonic.xp.page.PageRegions)3 ComponentPath (com.enonic.xp.region.ComponentPath)3 LayoutRegions (com.enonic.xp.region.LayoutRegions)3 PartComponent (com.enonic.xp.region.PartComponent)3 Test (org.junit.jupiter.api.Test)3 Form (com.enonic.xp.form.Form)2 LayoutDescriptor (com.enonic.xp.region.LayoutDescriptor)2 AbstractEqualsTest (com.enonic.xp.support.AbstractEqualsTest)2 AbstractDataSerializerTest (com.enonic.xp.core.impl.content.page.AbstractDataSerializerTest)1 PropertySet (com.enonic.xp.data.PropertySet)1 FormDefaultValuesProcessor (com.enonic.xp.form.FormDefaultValuesProcessor)1 PageDescriptor (com.enonic.xp.page.PageDescriptor)1 PageDescriptorService (com.enonic.xp.page.PageDescriptorService)1 DescriptorBasedComponent (com.enonic.xp.region.DescriptorBasedComponent)1