Search in sources :

Example 1 with ImageComponent

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

the class ImageComponentDataSerializer method fromData.

@Override
public ImageComponent fromData(final PropertySet data) {
    final ImageComponent.Builder component = ImageComponent.create();
    final PropertySet specialBlockSet = data.getSet(ImageComponentType.INSTANCE.toString());
    if (specialBlockSet != null) {
        if (specialBlockSet.isNotNull(ID)) {
            final ContentId contentId = ContentId.from(specialBlockSet.getString(ID));
            component.image(contentId);
        }
        if (specialBlockSet.hasProperty(CAPTION)) {
            final PropertyTree config = new PropertyTree();
            config.addString(CAPTION, specialBlockSet.getString(CAPTION));
            component.config(config);
        }
    }
    return component.build();
}
Also used : ImageComponent(com.enonic.xp.region.ImageComponent) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) ContentId(com.enonic.xp.content.ContentId)

Aggregations

ContentId (com.enonic.xp.content.ContentId)1 PropertySet (com.enonic.xp.data.PropertySet)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 ImageComponent (com.enonic.xp.region.ImageComponent)1