Search in sources :

Example 1 with StyleDescriptors

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

the class HtmlLinkProcessor method getImageStyleMap.

private ImmutableMap<String, ImageStyle> getImageStyleMap(final PortalRequest portalRequest) {
    final ImmutableMap.Builder<String, ImageStyle> imageStyleMap = ImmutableMap.builder();
    final StyleDescriptors styleDescriptors = getStyleDescriptors(portalRequest);
    styleDescriptors.stream().flatMap(styleDescriptor -> styleDescriptor.getElements().stream()).filter(elementStyle -> ImageStyle.STYLE_ELEMENT_NAME.equals(elementStyle.getElement())).forEach(elementStyle -> imageStyleMap.put(elementStyle.getName(), (ImageStyle) elementStyle));
    return imageStyleMap.build();
}
Also used : PortalUrlService(com.enonic.xp.portal.url.PortalUrlService) ImmutableSet(com.google.common.collect.ImmutableSet) ImageStyle(com.enonic.xp.style.ImageStyle) ImmutableMap(com.google.common.collect.ImmutableMap) Collectors(java.util.stream.Collectors) PageUrlParams(com.enonic.xp.portal.url.PageUrlParams) ApplicationKey(com.enonic.xp.app.ApplicationKey) Objects(java.util.Objects) AttachmentUrlParams(com.enonic.xp.portal.url.AttachmentUrlParams) StyleDescriptors(com.enonic.xp.style.StyleDescriptors) List(java.util.List) Site(com.enonic.xp.site.Site) Matcher(java.util.regex.Matcher) ImmutableList(com.google.common.collect.ImmutableList) PortalRequest(com.enonic.xp.portal.PortalRequest) ImageUrlParams(com.enonic.xp.portal.url.ImageUrlParams) StyleDescriptorService(com.enonic.xp.style.StyleDescriptorService) Map(java.util.Map) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) Splitter(com.google.common.base.Splitter) ApplicationKeys(com.enonic.xp.app.ApplicationKeys) StyleDescriptors(com.enonic.xp.style.StyleDescriptors) ImageStyle(com.enonic.xp.style.ImageStyle) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with StyleDescriptors

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

the class StyleDescriptorServiceImplTest method getAll.

@Test
public void getAll() {
    final ApplicationKey appKey = ApplicationKey.from("myapp1");
    final StyleDescriptors descriptors = this.service.getAll();
    assertNotNull(descriptors);
    assertEquals(2, descriptors.getSize());
}
Also used : ApplicationKey(com.enonic.xp.app.ApplicationKey) StyleDescriptors(com.enonic.xp.style.StyleDescriptors) Test(org.junit.jupiter.api.Test)

Example 3 with StyleDescriptors

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

the class StyleDescriptorServiceImplTest method getByApplications.

@Test
public void getByApplications() {
    final ApplicationKeys appKeys = ApplicationKeys.from("myapp1", "myapp2");
    final StyleDescriptors descriptors = this.service.getByApplications(appKeys);
    assertNotNull(descriptors);
    assertEquals(2, descriptors.getSize());
}
Also used : ApplicationKeys(com.enonic.xp.app.ApplicationKeys) StyleDescriptors(com.enonic.xp.style.StyleDescriptors) Test(org.junit.jupiter.api.Test)

Aggregations

StyleDescriptors (com.enonic.xp.style.StyleDescriptors)3 ApplicationKey (com.enonic.xp.app.ApplicationKey)2 ApplicationKeys (com.enonic.xp.app.ApplicationKeys)2 Test (org.junit.jupiter.api.Test)2 PortalRequest (com.enonic.xp.portal.PortalRequest)1 AttachmentUrlParams (com.enonic.xp.portal.url.AttachmentUrlParams)1 ImageUrlParams (com.enonic.xp.portal.url.ImageUrlParams)1 PageUrlParams (com.enonic.xp.portal.url.PageUrlParams)1 PortalUrlService (com.enonic.xp.portal.url.PortalUrlService)1 Site (com.enonic.xp.site.Site)1 ImageStyle (com.enonic.xp.style.ImageStyle)1 StyleDescriptorService (com.enonic.xp.style.StyleDescriptorService)1 Splitter (com.google.common.base.Splitter)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1