GuideField.java 4.24 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.day.cq.wcm.foundation.forms.FormsHelper
 *  org.apache.commons.lang3.StringUtils
 *  org.apache.sling.api.SlingHttpServletRequest
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ResourceResolver
 *  org.apache.sling.api.resource.ValueMap
 */
package com.adobe.aemds.guide.common;

import com.adobe.aemds.guide.common.GuideNode;
import com.adobe.aemds.guide.taglibs.GuideELUtils;
import com.adobe.aemds.guide.utils.GuideUtils;
import com.day.cq.wcm.foundation.forms.FormsHelper;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;

public class GuideField
extends GuideNode {
    protected String helpQuestionMarkContent = "";
    private String displayNoneStyle = ";display:none";

    public Boolean getIsRequired() {
        return FormsHelper.isRequired((Resource)super.getResource());
    }

    public Boolean getIsReadOnly() {
        return FormsHelper.isReadOnly((SlingHttpServletRequest)this.slingRequest, (Resource)super.getResource());
    }

    public boolean getIsOldFieldLayout() {
        String fieldLayout = (String)this.resourceProps.get("fieldLayout", (Object)"");
        if (fieldLayout != null && fieldLayout.length() > 0 && !fieldLayout.equals("/libs/fd/af/layouts/field/defaultFieldLayout/defaultFieldLayout.jsp")) {
            return this.checkIfPathIsAbsolute(fieldLayout);
        }
        return false;
    }

    public String getFieldLayout() {
        String fieldLayout = (String)this.resourceProps.get("fieldLayout", (Object)"");
        if (fieldLayout != null && fieldLayout.length() > 0 && fieldLayout.indexOf("defaultFieldLayout") < 0) {
            return fieldLayout;
        }
        Resource guideContainerResource = this.resource.getResourceResolver().getResource(GuideELUtils.getGuideContainerPath(this.slingRequest, this.resource));
        return GuideUtils.getFieldLayout(guideContainerResource, "fieldLayout", "fd/af/layouts/field/defaultFieldLayout");
    }

    public String getFieldLayoutName() {
        String fieldLayout = this.getFieldLayout();
        String fieldLayoutName = "defaultFieldLayout";
        if (fieldLayout != null && fieldLayout.length() > 0) {
            fieldLayoutName = StringUtils.substringAfterLast((String)fieldLayout, (String)"/");
            fieldLayoutName = StringUtils.substringBeforeLast((String)fieldLayoutName, (String)".jsp");
        }
        return fieldLayoutName;
    }

    public boolean getHideTitle() {
        return (Boolean)this.resourceProps.get("hideTitle", (Object)false);
    }

    public String getShortDescription() {
        return this.externalize((String)this.resourceProps.get("shortDescription", (Object)""));
    }

    public String getLongDescription() {
        return this.externalize((String)this.resourceProps.get("longDescription", (Object)""));
    }

    public Boolean getDescriptionVisibility() {
        return (Boolean)this.resourceProps.get("shortVisible", (Object)false);
    }

    public String getValue() {
        return (String)this.resourceProps.get("_value", String.class);
    }

    public String getCaptionInlineStyles() {
        if (this.getHideTitle()) {
            return this.getInlineStyles("Caption") + this.displayNoneStyle;
        }
        return this.getInlineStyles("Caption");
    }

    public String getWidgetInlineStyles() {
        return this.getInlineStyles("Widget");
    }

    public void setHelpIndicatorContent(String helpQuestionMarkContent) {
        this.helpQuestionMarkContent = helpQuestionMarkContent != null ? helpQuestionMarkContent : "";
    }

    public String getHelpIndicatorContent() {
        return this.helpQuestionMarkContent;
    }

    public String getShortDescriptionInlineStyles() {
        if (this.getDescriptionVisibility().booleanValue()) {
            return this.getInlineStyles("ShortDescription");
        }
        return this.getInlineStyles("ShortDescription") + this.displayNoneStyle;
    }

    public String getPlaceholderText() {
        return (String)this.resourceProps.get("placeholderText", (Object)"");
    }
}