Search in sources :

Example 1 with RegionDescriptors

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

the class XmlPageDescriptorParserTest method assertResult.

private void assertResult() throws Exception {
    final PageDescriptor result = this.builder.build();
    assertEquals("myapplication:mypage", result.getKey().toString());
    assertEquals("mypage", result.getName());
    assertEquals("Landing page", result.getDisplayName());
    assertEquals("key.display-name", result.getDisplayNameI18nKey());
    assertEquals("My Page Description", result.getDescription());
    assertEquals("key.description", result.getDescriptionI18nKey());
    final Form config = result.getConfig();
    assertNotNull(config);
    assertEquals(InputTypeName.DOUBLE, config.getFormItem("pause").toInput().getInputType());
    assertEquals("Pause parameter", config.getFormItem("pause").toInput().getLabel());
    assertEquals("key1.label", config.getFormItem("pause").toInput().getLabelI18nKey());
    assertEquals("key1.help-text", config.getFormItem("pause").toInput().getHelpTextI18nKey());
    assertNotNull(config.getFormItem("myFormItemSet").toFormItemSet());
    assertEquals("My form item set", config.getFormItem("myFormItemSet").toFormItemSet().getLabel());
    assertEquals(InputTypeName.TEXT_LINE, config.getFormItem("myFormItemSet.fieldSetItem").toInput().getInputType());
    assertEquals("Field set Item", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getLabel());
    assertEquals("key2.label", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getLabelI18nKey());
    assertEquals("key2.help-text", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getHelpTextI18nKey());
    final RegionDescriptors regions = result.getRegions();
    assertNotNull(regions);
    assertEquals(3, regions.numberOfRegions());
    assertNotNull(regions.getRegionDescriptor("header"));
}
Also used : PageDescriptor(com.enonic.xp.page.PageDescriptor) Form(com.enonic.xp.form.Form) RegionDescriptors(com.enonic.xp.region.RegionDescriptors)

Example 2 with RegionDescriptors

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

the class XmlLayoutDescriptorParserTest method assertResult.

private void assertResult() throws Exception {
    final LayoutDescriptor result = this.builder.build();
    assertEquals("myapplication:mylayout", result.getKey().toString());
    assertEquals("mylayout", result.getName());
    assertEquals("My Layout", result.getDisplayName());
    assertEquals("key.display-name", result.getDisplayNameI18nKey());
    assertEquals("My Layout Description", result.getDescription());
    assertEquals("key.description", result.getDescriptionI18nKey());
    final Form config = result.getConfig();
    assertNotNull(config);
    assertEquals(InputTypeName.DOUBLE, config.getFormItem("pause").toInput().getInputType());
    assertEquals("Pause parameter", config.getFormItem("pause").toInput().getLabel());
    assertEquals("key1.label", config.getFormItem("pause").toInput().getLabelI18nKey());
    assertEquals("key1.help-text", config.getFormItem("pause").toInput().getHelpTextI18nKey());
    assertNotNull(config.getFormItem("myFormItemSet").toFormItemSet());
    assertEquals("My form item set", config.getFormItem("myFormItemSet").toFormItemSet().getLabel());
    assertEquals(InputTypeName.TEXT_LINE, config.getFormItem("myFormItemSet.fieldSetItem").toInput().getInputType());
    assertEquals("Field set Item", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getLabel());
    assertEquals("key2.label", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getLabelI18nKey());
    assertEquals("key2.help-text", config.getFormItem("myFormItemSet.fieldSetItem").toInput().getHelpTextI18nKey());
    final RegionDescriptors regions = result.getRegions();
    assertNotNull(regions);
    assertEquals(3, regions.numberOfRegions());
    assertNotNull(regions.getRegionDescriptor("header"));
}
Also used : LayoutDescriptor(com.enonic.xp.region.LayoutDescriptor) Form(com.enonic.xp.form.Form) RegionDescriptors(com.enonic.xp.region.RegionDescriptors)

Example 3 with RegionDescriptors

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

the class PageDataSerializer method getPageRegions.

private PageRegions getPageRegions(final DescriptorKey descriptorKey, final List<PropertySet> componentsAsData) {
    final PageDescriptor pageDescriptor = pageDescriptorService.getByKey(descriptorKey);
    final RegionDescriptors regionDescriptors = pageDescriptor.getRegions();
    if (regionDescriptors.numberOfRegions() == 0) {
        return null;
    }
    final PageRegions.Builder pageRegionsBuilder = PageRegions.create();
    regionDescriptors.forEach(regionDescriptor -> {
        pageRegionsBuilder.add(componentDataSerializerProvider.getRegionDataSerializer().fromData(regionDescriptor, ComponentPath.DIVIDER, componentsAsData));
    });
    return pageRegionsBuilder.build();
}
Also used : PageRegions(com.enonic.xp.page.PageRegions) PageDescriptor(com.enonic.xp.page.PageDescriptor) RegionDescriptors(com.enonic.xp.region.RegionDescriptors)

Aggregations

RegionDescriptors (com.enonic.xp.region.RegionDescriptors)3 Form (com.enonic.xp.form.Form)2 PageDescriptor (com.enonic.xp.page.PageDescriptor)2 PageRegions (com.enonic.xp.page.PageRegions)1 LayoutDescriptor (com.enonic.xp.region.LayoutDescriptor)1