本文整理汇总了Java中com.day.cq.wcm.api.designer.Style类的典型用法代码示例。如果您正苦于以下问题:Java Style类的具体用法?Java Style怎么用?Java Style使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Style类属于com.day.cq.wcm.api.designer包,在下文中一共展示了Style类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: currentStyle
import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
public Style currentStyle() {
return getValue("currentStyle", Style.class);
}
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:4,代码来源:PageContextBuilder.java
示例17: getPageUnderTest
import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
protected <T> T getPageUnderTest(Class<T> model, String pagePath, String designPath) {
Resource resource = CONTEXT.resourceResolver().getResource(pagePath + "/" + JcrConstants.JCR_CONTENT);
if (resource == null) {
throw new IllegalStateException("Did you forget to define test resource " + pagePath + "?");
}
com.day.cq.wcm.api.Page page = spy(CONTEXT.pageManager().getPage(pagePath));
MockSlingHttpServletRequest request = new MockSlingHttpServletRequest(CONTEXT.resourceResolver(), CONTEXT.bundleContext());
SlingBindings slingBindings = new SlingBindings();
Design design = mock(Design.class);
if (designPath != null) {
when(design.getPath()).thenReturn(designPath);
} else {
when(design.getPath()).thenReturn(Designer.DEFAULT_DESIGN_PATH);
}
Resource templateResource = CONTEXT.resourceResolver().getResource("/conf/coretest/settings/wcm/templates/product-page");
Template template = mock(Template.class);
when(template.hasStructureSupport()).thenReturn(true);
when(template.adaptTo(Resource.class)).thenReturn(templateResource);
when(page.getTemplate()).thenReturn(template);
contentPolicyManager = mock(ContentPolicyManager.class);
ContentPolicyMapping mapping = templateResource.getChild(POLICIES_MAPPING_PATH).adaptTo(ContentPolicyMapping.class);
ContentPolicy contentPolicy = mapping.getPolicy();
Style style;
slingBindings.put(WCMBindings.CURRENT_DESIGN, design);
if (contentPolicy != null) {
Resource contentPolicyResource = CONTEXT.resourceResolver().getResource(contentPolicy.getPath());
style = new MockStyle(contentPolicyResource, contentPolicyResource.adaptTo(ValueMap.class));
when(contentPolicyManager.getPolicy(page.getContentResource())).thenReturn(contentPolicy);
} else {
style = mock(Style.class);
when(style.get(anyString(), Matchers.anyObject())).thenAnswer(
invocationOnMock -> invocationOnMock.getArguments()[1]
);
}
ComponentContext componentContext = mock(ComponentContext.class);
Set<String> cssClassNames = new LinkedHashSet<>(Arrays.asList("class1", "class2"));
when(componentContext.getCssClassNames()).thenReturn(cssClassNames);
slingBindings.put(WCMBindings.CURRENT_STYLE, style);
slingBindings.put(SlingBindings.RESOLVER, request.getResourceResolver());
slingBindings.put(WCMBindings.CURRENT_PAGE, page);
slingBindings.put(WCMBindings.PAGE_MANAGER, CONTEXT.pageManager());
slingBindings.put(SlingBindings.RESOURCE, resource);
slingBindings.put(WCMBindings.PAGE_PROPERTIES, page.getProperties());
slingBindings.put(WCMBindings.COMPONENT_CONTEXT, componentContext);
request.setContextPath(CONTEXT_PATH);
request.setResource(resource);
slingBindings.put(SlingBindings.REQUEST, request);
request.setAttribute(SlingBindings.class.getName(), slingBindings);
return request.adaptTo(model);
}
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:51,代码来源:PageImplTest.java
示例18: getSubStyle
import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
@Override
public Style getSubStyle(String relPath) {
return null;
}
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:5,代码来源:MockStyle.java
示例19: getSubStyle
import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
@Override
public Style getSubStyle(String s) {
return null;
}
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:5,代码来源:MockContentPolicyStyle.java
示例20: getValue
import com.day.cq.wcm.api.designer.Style; //导入依赖的package包/类
@Override
public Object getValue(final Object adaptable, final String name, final Type type, final AnnotatedElement element,
final DisposalCallbackRegistry callbackRegistry) {
// only class types are supported
if (!(type instanceof Class<?>)) {
return null;
}
Class<?> requestedClass = (Class<?>)type;
if (adaptable instanceof SlingHttpServletRequest) {
SlingHttpServletRequest request = (SlingHttpServletRequest)adaptable;
if (requestedClass.equals(WCMMode.class)) {
return getWcmMode(request);
}
if (requestedClass.equals(ComponentContext.class)) {
return getComponentContext(request);
}
if (requestedClass.equals(Style.class)) {
return getStyle(request);
}
if (requestedClass.equals(XSSAPI.class)) {
return getXssApi(request);
}
}
if (requestedClass.equals(PageManager.class)) {
return getPageManager(adaptable);
}
else if (requestedClass.equals(Page.class)) {
if (StringUtils.equals(name, RESOURCE_PAGE)) {
return getResourcePage(adaptable);
}
else {
return getCurrentPage(adaptable);
}
}
else if (requestedClass.equals(Designer.class)) {
return getDesigner(adaptable);
}
else if (requestedClass.equals(Design.class)) {
return getCurrentDesign(adaptable);
}
return null;
}
开发者ID:wcm-io,项目名称:wcm-io-cq5,代码行数:47,代码来源:AemObjectInjector.java
注:本文中的com.day.cq.wcm.api.designer.Style类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论