当前位置: 首页>>代码示例>>Java>>正文


Java Style类代码示例

本文整理汇总了Java中com.day.cq.wcm.api.designer.Style的典型用法代码示例。如果您正苦于以下问题:Java Style类的具体用法?Java Style怎么用?Java Style使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Style类属于com.day.cq.wcm.api.designer包,在下文中一共展示了Style类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, final TemplateContentModelImpl contentModel)
        throws ProcessException {
    try {
        SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);
        Resource resource = request.getResource();
        ResourceResolver resourceResolver = request.getResourceResolver();

        final Designer designer = resourceResolver.adaptTo(Designer.class);
        Style style = designer.getStyle(resource);

        if (style.getPath() != null) {
            Resource designResource = resourceResolver.getResource(style.getPath());
            Map<String, Object> designMap = (designResource != null) ? PropertyUtils.propsToMap(designResource) : new HashMap<String, Object>();
            contentModel.set(DESIGN_PROPERTIES_KEY, designMap);
        }
    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:21,代码来源:AddDesignPropertiesContextProcessor.java

示例2: process

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, TemplateContentModel contentModel)
        throws ProcessException {
    try {
        SlingHttpServletRequest request = (SlingHttpServletRequest) executionContext.get(SLING_HTTP_REQUEST);
        ResourceResolver resourceResolver = request.getResourceResolver();
        Style style = GeneralRequestObjects.getCurrentStyle(request);
        if (style != null) {
            Resource designResource = resourceResolver.getResource(style.getPath()); //get design resource
            if (designResource != null) {
                String imagePath = assetPathService.getComponentImagePath(designResource);
                contentModel.set(DESIGN_PROPERTIES_KEY + DOT + IMAGE_PATH, imagePath);
            }
        }
    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:19,代码来源:AddTransformedImagePathFromDesignContextProcessor.java

示例3: getBreadcrumbUnderTest

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
private Breadcrumb getBreadcrumbUnderTest(String resourcePath, Style style) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Did you forget to define test resource " + resourcePath + "?");
    }
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    request.setResource(resource);
    request.setContextPath("");
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    bindings.put(WCMBindings.CURRENT_PAGE, CONTEXT.pageManager().getPage(CURRENT_PAGE));
    if (style == null) {
        style = mock(Style.class);
        when(style.get(any(), any(Object.class))).thenAnswer(
                invocation -> invocation.getArguments()[1]
        );
    }
    bindings.put(WCMBindings.CURRENT_STYLE, style);
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(Breadcrumb.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:23,代码来源:BreadcrumbImplTest.java

示例4: getListUnderTest

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
private List getListUnderTest(String resourcePath) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Did you forget to defines test resource " + resourcePath + "?");
    }
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    request.setResource(resource);
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(SlingBindings.REQUEST, request);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    Style style = mock(Style.class);
    when(style.get(any(), any(Object.class))).thenAnswer(
            invocation -> invocation.getArguments()[1]
    );
    bindings.put(WCMBindings.CURRENT_STYLE, style);
    bindings.put(WCMBindings.CURRENT_PAGE, CONTEXT.pageManager().getPage(CURRENT_PAGE));
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(List.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:21,代码来源:ListImplTest.java

示例5: getTitleUnderTest

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
private Title getTitleUnderTest(String resourcePath, Style style) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Did you forget to define test resource " + resourcePath + "?");
    }
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(SlingBindings.REQUEST, request);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    bindings.put(WCMBindings.CURRENT_PAGE, CONTEXT.pageManager().getPage(TEST_PAGE));
    if (style == null) {
        style = mock(Style.class);
    }
    bindings.put(WCMBindings.CURRENT_STYLE, style);
    request.setResource(resource);
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(Title.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:20,代码来源:TitleImplTest.java

示例6: getListUnderTest

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
private List getListUnderTest(String resourcePath) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Did you forget to defines test resource " + resourcePath + "?");
    }
    MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    request.setResource(resource);
    request.setContextPath(CONTEXT_PATH);
    SlingBindings bindings = new SlingBindings();
    bindings.put(SlingBindings.RESOURCE, resource);
    bindings.put(SlingBindings.REQUEST, request);
    bindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    Style style = mock(Style.class);
    when(style.get(any(), any(Object.class))).thenAnswer(
            invocation -> invocation.getArguments()[1]
    );
    bindings.put(WCMBindings.CURRENT_STYLE, style);
    bindings.put(WCMBindings.CURRENT_PAGE, CONTEXT.pageManager().getPage(CURRENT_PAGE));
    request.setAttribute(SlingBindings.class.getName(), bindings);
    return request.adaptTo(List.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:22,代码来源:ListImplTest.java

示例7: getGlobalPropertiesPath

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
/**
 * Takes resource and resource resolver return the global property path from the resource
 *
 * @param resource The resource to get the global property path from
 * @return globalPropertiesPath
 */
public static String getGlobalPropertiesPath(Resource resource, ResourceResolver resourceResolver)
        throws RepositoryException, PersistenceException {
    String globalPropertiesPath = "";
    Designer designer = resourceResolver.adaptTo(Designer.class);
    Style style = designer.getStyle(resource);
    Design design;
    if (null != style) {
        design = style.getDesign();
        if (null != design) {
            if (null != design.getContentResource()) {
                if (null != design.getContentResource().getPath()) {
                    //add global node in design when it does not exist
                    Resource designResource = resourceResolver.getResource(design.getContentResource().getPath());
                    Node designNode = designResource.adaptTo(Node.class);
                    if (!designNode.hasNode(GLOBAL_PROPERTIES_KEY)) {
                        designNode.addNode(GLOBAL_PROPERTIES_KEY);
                        resourceResolver.commit();
                    }
                    // set global path
                    globalPropertiesPath = design.getContentResource().getPath() + GLOBAL_PATH;
                }
            }
        }
    }
    return globalPropertiesPath;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:33,代码来源:ResourceUtils.java

示例8: getImageUnderTest

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
protected <T> T getImageUnderTest(String resourcePath, Class<T> imageClass) {
    Resource resource = CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Does the test resource " + resourcePath + " exist?");
    }
    ContentPolicyMapping mapping = resource.adaptTo(ContentPolicyMapping.class);
    ContentPolicy contentPolicy = null;
    if (mapping != null) {
        contentPolicy = mapping.getPolicy();
    }
    SlingBindings slingBindings = new SlingBindings();
    Style style = null;
    if (contentPolicy != null) {
        when(contentPolicyManager.getPolicy(resource)).thenReturn(contentPolicy);
        style = new MockContentPolicyStyle(contentPolicy);
    }
    if (style == null) {
        style = mock(Style.class);
        when(style.get(anyString(), (Object) Matchers.anyObject())).thenAnswer(
                invocationOnMock -> invocationOnMock.getArguments()[1]
        );
    }
    slingBindings.put(SlingBindings.RESOURCE, resource);
    final MockSlingHttpServletRequest request =
            new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
    request.setContextPath(CONTEXT_PATH);
    request.setResource(resource);
    Page page = CONTEXT.pageManager().getPage(PAGE);
    slingBindings.put(WCMBindings.CURRENT_PAGE, page);
    slingBindings.put(WCMBindings.WCM_MODE, new SightlyWCMMode(request));
    slingBindings.put(WCMBindings.PAGE_MANAGER, CONTEXT.pageManager());
    slingBindings.put(WCMBindings.CURRENT_STYLE, style);
    slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
    request.setAttribute(SlingBindings.class.getName(), slingBindings);
    return request.adaptTo(imageClass);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:37,代码来源:ImageImplTest.java

示例9: getLanguageNavigationUnderTest

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
private LanguageNavigation getLanguageNavigationUnderTest(String resourcePath) {
    Resource resource = AEM_CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Does the test resource " + resourcePath + " exist?");
    }
    ContentPolicyMapping mapping = resource.adaptTo(ContentPolicyMapping.class);
    ContentPolicy contentPolicy = null;
    if (mapping != null) {
        contentPolicy = mapping.getPolicy();
    }
    final MockSlingHttpServletRequest request =
            new MockSlingHttpServletRequest(AEM_CONTEXT.resourceResolver(), AEM_CONTEXT.bundleContext());
    request.setContextPath(CONTEXT_PATH);
    request.setResource(resource);
    Page currentPage = AEM_CONTEXT.pageManager().getContainingPage(resource);
    SlingBindings slingBindings = new SlingBindings();
    Style currentStyle;
    if (contentPolicy != null) {
        ContentPolicyManager policyManager = mock(ContentPolicyManager.class);
        when(policyManager.getPolicy(resource)).thenReturn(contentPolicy);
        currentStyle = new MockContentPolicyStyle(contentPolicy);
    } else {
        currentStyle = mock(Style.class);
        when(currentStyle.get(anyString(), (Object) Matchers.anyObject())).thenAnswer(
                invocation -> invocation.getArguments()[1]
        );
    }
    slingBindings.put(SlingBindings.RESOURCE, resource);
    slingBindings.put(WCMBindings.CURRENT_PAGE, currentPage);
    slingBindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    slingBindings.put(WCMBindings.CURRENT_STYLE, currentStyle);
    request.setAttribute(SlingBindings.class.getName(), slingBindings);
    return request.adaptTo(LanguageNavigation.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:35,代码来源:LanguageNavigationImplTest.java

示例10: testStyleBasedBreadcrumb

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
@Test
public void testStyleBasedBreadcrumb() throws Exception {
    Style style = mock(Style.class);
    when(style.get(BreadcrumbImpl.PN_START_LEVEL, BreadcrumbImpl.PROP_START_LEVEL_DEFAULT)).thenReturn(3);
    when(style.get(BreadcrumbImpl.PN_HIDE_CURRENT, BreadcrumbImpl.PROP_SHOW_HIDDEN_DEFAULT)).thenReturn(false);
    when(style.get(BreadcrumbImpl.PN_SHOW_HIDDEN, BreadcrumbImpl.PROP_SHOW_HIDDEN_DEFAULT)).thenReturn(false);
    Breadcrumb breadcrumb = getBreadcrumbUnderTest(BREADCRUMB_5, style);
    checkBreadcrumbConsistency(breadcrumb, new String[]{"Devi Sleeveless Shirt"});
    Utils.testJSONExport(breadcrumb, Utils.getTestExporterJSONPath(TEST_BASE, BREADCRUMB_5));
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:11,代码来源:BreadcrumbImplTest.java

示例11: testGetTitleResourcePageStyleType

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
@Test
public void testGetTitleResourcePageStyleType() {
    Style style = mock(Style.class);
    when(style.get(Title.PN_DESIGN_DEFAULT_TYPE, String.class)).thenReturn("h2");
    Title title = getTitleUnderTest(TITLE_NOPROPS, style);
    assertEquals("h2", title.getType());
    Utils.testJSONExport(title, Utils.getTestExporterJSONPath(TEST_BASE, TITLE_NOPROPS));
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:9,代码来源:TitleImplTest.java

示例12: getNavigationUnderTest

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
private Navigation getNavigationUnderTest(String resourcePath) {
    Resource resource = AEM_CONTEXT.resourceResolver().getResource(resourcePath);
    if (resource == null) {
        throw new IllegalStateException("Does the test resource " + resourcePath + " exist?");
    }
    ContentPolicyMapping mapping = resource.adaptTo(ContentPolicyMapping.class);
    ContentPolicy contentPolicy = null;
    if (mapping != null) {
        contentPolicy = mapping.getPolicy();
    }
    final MockSlingHttpServletRequest request =
            new MockSlingHttpServletRequest(AEM_CONTEXT.resourceResolver(), AEM_CONTEXT.bundleContext());
    request.setContextPath(CONTEXT_PATH);
    request.setResource(resource);
    Page currentPage = AEM_CONTEXT.pageManager().getContainingPage(resource);
    SlingBindings slingBindings = new SlingBindings();
    Style currentStyle;
    if (contentPolicy != null) {
        when(POLICY_MANAGER.getPolicy(resource)).thenReturn(contentPolicy);
        currentStyle = new MockContentPolicyStyle(contentPolicy);
    } else {
        currentStyle = mock(Style.class);
        when(currentStyle.get(anyString(), (Object) Matchers.anyObject())).thenAnswer(
                invocation -> invocation.getArguments()[1]
        );
    }
    slingBindings.put(SlingBindings.RESOURCE, resource);
    slingBindings.put(WCMBindings.CURRENT_PAGE, currentPage);
    slingBindings.put(WCMBindings.PROPERTIES, resource.getValueMap());
    slingBindings.put(WCMBindings.CURRENT_STYLE, currentStyle);
    request.setAttribute(SlingBindings.class.getName(), slingBindings);
    return request.adaptTo(Navigation.class);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:34,代码来源:NavigationImplTest.java

示例13: getStyle

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
private Style getStyle(final SlingHttpServletRequest request) {
  Design currentDesign = getCurrentDesign(request);
  ComponentContext componentContext = getComponentContext(request);
  if (currentDesign != null && componentContext != null) {
    return currentDesign.getStyle(componentContext.getCell());
  }
  return null;
}
 
开发者ID:wcm-io,项目名称:wcm-io-cq5,代码行数:9,代码来源:AemObjectInjector.java

示例14: getCurrentStyle

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
/**
 * Get the current style.
 * 
 * @param adaptable a SlingHttpServletRequest
 * @return the current Style if the adaptable was a SlingHttpServletRequest, null otherwise
 */
private Style getCurrentStyle(Object adaptable) {
    Design currentDesign = getCurrentDesign(adaptable);
    ComponentContext componentContext = getComponentContext(adaptable);

    if (currentDesign != null && componentContext != null) {
        return currentDesign.getStyle(componentContext.getCell());
    }

    return null;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:17,代码来源:AemObjectInjector.java

示例15: StyleBuilder

import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
public StyleBuilder() {
	super(mock(Style.class));
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:4,代码来源:StyleBuilder.java


注:本文中的com.day.cq.wcm.api.designer.Style类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。