Search in sources :

Example 1 with GenericStyle

use of com.enonic.xp.style.GenericStyle in project xp by enonic.

the class XmlStyleDescriptorParserTest method assertResult.

private void assertResult() throws Exception {
    final StyleDescriptor result = this.builder.build();
    assertEquals("myapplication", result.getApplicationKey().toString());
    assertEquals("assets/styles.css", result.getCssPath());
    assertEquals(4, result.getElements().size());
    final GenericStyle element0 = (GenericStyle) result.getElements().get(0);
    final ImageStyle element1 = (ImageStyle) result.getElements().get(1);
    final ImageStyle element2 = (ImageStyle) result.getElements().get(2);
    final ImageStyle element3 = (ImageStyle) result.getElements().get(3);
    assertEquals("style", element0.getElement());
    assertEquals("warning", element0.getName());
    assertEquals("Warning", element0.getDisplayName());
    assertEquals("warning.displayName", element0.getDisplayNameI18nKey());
    assertEquals("image", element1.getElement());
    assertEquals("editor-align-justify", element1.getName());
    assertEquals("Justify", element1.getDisplayName());
    assertEquals("style.editor.align.justify", element1.getDisplayNameI18nKey());
    assertEquals("image", element2.getElement());
    assertEquals("editor-width-auto", element2.getName());
    assertEquals("Override ${width}", element2.getDisplayName());
    assertEquals("editor-width-auto-text", element2.getDisplayNameI18nKey());
    assertEquals("image", element3.getElement());
    assertEquals("editor-style-cinema", element3.getName());
    assertEquals("Cinema", element3.getDisplayName());
    assertEquals("editor-style-cinema-text", element3.getDisplayNameI18nKey());
    assertEquals("21:9", element3.getAspectRatio());
    assertEquals("pixelate(10)", element3.getFilter());
}
Also used : GenericStyle(com.enonic.xp.style.GenericStyle) StyleDescriptor(com.enonic.xp.style.StyleDescriptor) ImageStyle(com.enonic.xp.style.ImageStyle)

Example 2 with GenericStyle

use of com.enonic.xp.style.GenericStyle in project xp by enonic.

the class XmlStyleDescriptorParser method toGenericStyle.

private GenericStyle toGenericStyle(final DomElement styleElement) {
    final GenericStyle.Builder builder = GenericStyle.create();
    builder.name(styleElement.getAttribute(ELEMENT_NAME_ATTRIBUTE_NAME));
    final DomElement displayName = styleElement.getChild(DISPLAY_NAME_TAG_NAME);
    if (displayName != null) {
        builder.displayName(displayName.getValue());
        builder.displayNameI18nKey(displayName.getAttribute(I18N_ATTRIBUTE_NAME));
    }
    return builder.build();
}
Also used : GenericStyle(com.enonic.xp.style.GenericStyle) DomElement(com.enonic.xp.xml.DomElement)

Aggregations

GenericStyle (com.enonic.xp.style.GenericStyle)2 ImageStyle (com.enonic.xp.style.ImageStyle)1 StyleDescriptor (com.enonic.xp.style.StyleDescriptor)1 DomElement (com.enonic.xp.xml.DomElement)1