本文整理汇总了Java中com.day.cq.wcm.api.AuthoringUIMode类的典型用法代码示例。如果您正苦于以下问题:Java AuthoringUIMode类的具体用法?Java AuthoringUIMode怎么用?Java AuthoringUIMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthoringUIMode类属于com.day.cq.wcm.api包,在下文中一共展示了AuthoringUIMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJSONResults
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
private JSONObject getJSONResults(Command cmd, SlingHttpServletRequest request, final Collection<Result> results) throws
JSONException {
final JSONObject json = new JSONObject();
json.put(KEY_RESULTS, new JSONArray());
final ValueMap requestConfig = new ValueMapDecorator(new HashMap<String, Object>());
// Collect all items collected from OSGi Properties
requestConfig.putAll(this.config);
// Add Request specific configurations
requestConfig.put(AuthoringUIMode.class.getName(),
authoringUIModeService.getAuthoringUIMode(request));
for (final Result result : results) {
final JSONObject tmp = resultBuilder.toJSON(cmd, result, requestConfig);
if (tmp != null) {
json.accumulate(KEY_RESULTS, tmp);
}
}
return json;
}
示例2: getGlobalDialogPath
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
private String getGlobalDialogPath(Resource resource, ResourceResolver resourceResolver, SlingHttpServletRequest request) {
String currentGlobalDialogPath = GLOBAL_DIALOG_PATH;
if (AuthoringUIMode.fromRequest(request) == AuthoringUIMode.TOUCH) {
currentGlobalDialogPath = GLOBAL_DIALOG_PATH_TOUCH;
}
String globalDialogPath = APPS_ROOT + "/" + ResourceUtils.getAppName(resource) + currentGlobalDialogPath;
if (null == resourceResolver.getResource(globalDialogPath)) {
globalDialogPath = BLANK;
}
return globalDialogPath;
}
示例3: execute
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
@Override
public CharSequence execute(final Object valueObj)
throws Exception {
StringBuffer buffer = new StringBuffer();
TemplateContentModelImpl contentModel = contentModel();
SlingHttpServletRequest slingRequest = contentModel.request();
WCMMode wcmMode = WCMMode.fromRequest(slingRequest);
ClientLibraryUtil clientLibUtil = new ClientLibraryUtil(htmlLibraryManager, slingRequest);
clientLibUtil.setOptions(true, true, false, false, false, BLANK);
if (wcmMode != WCMMode.DISABLED) {
ComponentContext componentContext = WCMUtils.getComponentContext(slingRequest);
EditContext editContext = componentContext.getEditContext();
String dlgPath = null;
if (editContext != null && editContext.getComponent() != null) {
dlgPath = editContext.getComponent().getDialogPath();
}
if (AuthoringUIMode.fromRequest(slingRequest) == AuthoringUIMode.TOUCH) {
buffer.append(clientLibUtil.generateClientLibrariesPristine("cq.authoring.page"));
} else
if (AuthoringUIMode.fromRequest(slingRequest) == AuthoringUIMode.CLASSIC) {
buffer.append(clientLibUtil.generateClientLibrariesPristine("cq.wcm.edit"));
boolean isEditMode = (wcmMode == WCMMode.EDIT) ? true : false;
String dialogPath = dlgPath == null ? "" : dlgPath;
buffer.append(this.getJavaScript(slingRequest, isEditMode, dialogPath));
}
}
return new Handlebars.SafeString(buffer);
}
示例4: doTag
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
@Override
public void doTag() throws JspException, IOException {
classicMode = AuthoringUIMode.fromRequest(getRequest()) == AuthoringUIMode.CLASSIC;
touchMode = AuthoringUIMode.fromRequest(getRequest()) == AuthoringUIMode.TOUCH;
getPageContext().setAttribute(JSP_ATTR_AUTHOR_TOUCHI_UI, touchMode);
getPageContext().setAttribute(JSP_ATTR_AUTHOR_CLASSIC_UI, classicMode);
}
示例5: acceptsAuthoringUIMode
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
@SuppressWarnings("checkstyle:abbreviationaswordinname")
protected final boolean acceptsAuthoringUIMode(Result result, AuthoringUIMode authoringUIMode) {
if (result.getAuthoringMode() == null) {
// All Authoring Modes
return true;
} else if (result.getAuthoringMode().equals(authoringUIMode)) {
return true;
} else {
return false;
}
}
示例6: toJSON
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
public JSONObject toJSON(final Result result, final ValueMap config) throws JSONException {
final AuthoringUIMode authoringUIMode = config.get(AuthoringUIMode.class.getName(), AuthoringUIMode.TOUCH);
if(authoringUIMode != null && AuthoringUIMode.CLASSIC.equals(authoringUIMode)) {
// Classic
result.getAction().setUri("/cf#" + result.getPath() + ".html");
} else {
// TouchUI
result.getAction().setUri("/editor.html" + result.getPath() + ".html");
}
return super.toJSON(result);
}
示例7: testIsClassic
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
@Test
public void testIsClassic() {
when(request.getAttribute(AuthoringUIMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(AuthoringUIMode.CLASSIC);
assertTrue(ModeUtil.isClassic(request));
verify(request, times(1)).getAttribute(AuthoringUIMode.class.getName());
verifyNoMoreInteractions(request);
}
示例8: testIsNotClassic
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
@Test
public void testIsNotClassic() {
when(request.getAttribute(AuthoringUIMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(AuthoringUIMode.TOUCH);
assertFalse(ModeUtil.isClassic(request));
verify(request, times(1)).getAttribute(AuthoringUIMode.class.getName());
verifyNoMoreInteractions(request);
}
示例9: testIsTouch
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
@Test
public void testIsTouch() {
when(request.getAttribute(AuthoringUIMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(AuthoringUIMode.TOUCH);
assertTrue(ModeUtil.isTouch(request));
verify(request, times(1)).getAttribute(AuthoringUIMode.class.getName());
verifyNoMoreInteractions(request);
}
示例10: testIsNotTouch
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
@Test
public void testIsNotTouch() {
when(request.getAttribute(AuthoringUIMode.REQUEST_ATTRIBUTE_NAME)).thenReturn(AuthoringUIMode.CLASSIC);
assertFalse(ModeUtil.isTouch(request));
verify(request, times(1)).getAttribute(AuthoringUIMode.class.getName());
verifyNoMoreInteractions(request);
}
示例11: process
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
/**
* @param executionContext
* @param contentModel
* @throws Exception
*/
@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();
log.debug("for {}", resource.getPath());
if (resource != null) {
ResourceResolver resourceResolver = request.getResourceResolver();
Designer designer = resourceResolver.adaptTo(Designer.class);
final PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
final TagManager tm = (TagManager) resource.getResourceResolver().adaptTo(TagManager.class);
Page page = pageManager.getContainingPage(resource);
if (page != null) {
if (!contentModel.has(PAGE_PROPERTIES_KEY)) {
Configuration configuration = configurationProvider.getFor(page.getContentResource().getResourceType());
Collection<String> bodyClasses = configuration.asStrings(XK_CONTAINER_CLASSES_CP, Mode.MERGE);
Node pageContentNode = page.getContentResource().adaptTo(Node.class);
Map<String, Object> pageContent = propsToMap(pageContentNode.getProperties());
pageContent.put(PATH, page.getPath());
pageContent.put(PAGE_NAME, page.getName());
pageContent.put(LINK, page.getPath() + HTML_EXT);
pageContent.put(BODY_CLASSES, bodyClasses);
pageContent.put(TITLE, page.getTitle());
pageContent.put(DESCRIPTION, page.getProperties().get(JCR_DESCRIPTION, ""));
pageContent.put(PAGE_TITLE, page.getProperties().get(PAGE_TITLE, ""));
pageContent.put(SUBTITLE, page.getProperties().get(SUBTITLE, ""));
pageContent.put(HIDE_IN_NAV, page.getProperties().get(HIDE_IN_NAV, ""));
pageContent.put(KEYWORDS, PageUtils.getKeywords(pageContent, tm));
pageContent.put(TAGS, PageUtils.getTags(pageContent));
pageContent.put(WCM_MODE, GeneralRequestObjects.getWCMModeString(request));
pageContent.put(IS_EDIT_MODE, GeneralRequestObjects.isEditMode(request));
pageContent.put(IS_DESIGN_MODE, GeneralRequestObjects.isDesignMode(request));
pageContent.put(IS_EDIT_OR_DESIGN_MODE, GeneralRequestObjects.isEditOrDesignMode(request));
if (designer != null) {
Design design = designer.getDesign(page);
if (design != null && design.getPath() != null) {
pageContent.put(FAVICON, design.getPath() + "/" + FAVICON + ICO_EXT);
}
}
String navigationTitle = PageUtils.getNavigationTitle(page);
if (null != navigationTitle) {
pageContent.put(NAVIGATION_TITLE, PageUtils.getNavigationTitle(page));
}
// add transformed path image
String pageImagePath = assetPathService.getPageImagePath(page, page.getContentResource());
if(StringUtils.isNotEmpty(pageImagePath)){
pageContent.put(IMAGE_PATH, pageImagePath);
}
// add interface mode
if (AuthoringUIMode.fromRequest(request) == AuthoringUIMode.TOUCH) {
pageContent.put(IS_TOUCH_UI_MODE, true);
pageContent.put(IS_CLASSIC_UI_MODE, false);
} else {
pageContent.put(IS_CLASSIC_UI_MODE, true);
pageContent.put(IS_TOUCH_UI_MODE, false);
}
contentModel.set(PAGE_PROPERTIES_KEY, pageContent);
}
}
}
} catch (Exception e) {
throw new ProcessException(e);
}
}
示例12: getAuthoringMode
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
public AuthoringUIMode getAuthoringMode() {
return authoringMode;
}
示例13: setAuthoringMode
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
public void setAuthoringMode(final AuthoringUIMode authoringMode) {
this.authoringMode = authoringMode;
}
示例14: classic
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
public Builder classic() {
this.authoringMode = AuthoringUIMode.CLASSIC;
return this;
}
示例15: touch
import com.day.cq.wcm.api.AuthoringUIMode; //导入依赖的package包/类
public Builder touch() {
this.authoringMode = AuthoringUIMode.TOUCH;
return this;
}