ConfigPropertiesUtils.java 3.28 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.xfa.Attribute
 *  com.adobe.xfa.Element
 *  com.adobe.xfa.Node
 *  com.adobe.xfa.XFA
 *  com.adobe.xfa.template.containers.Subform
 *  org.apache.sling.commons.json.JSONObject
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.aemds.guide.addon.dor;

import com.adobe.aemds.guide.addon.dor.BrandingComponentUtils;
import com.adobe.aemds.guide.addon.dor.DoRUtils;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.XFA;
import com.adobe.xfa.template.containers.Subform;
import org.apache.sling.commons.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConfigPropertiesUtils {
    private static final Logger logger = LoggerFactory.getLogger(BrandingComponentUtils.class);

    public static JSONObject getConfigProperties(Subform rootSubform) {
        if (rootSubform == null) {
            return null;
        }
        Element font = (Element)rootSubform.resolveNode("#font", true, false, true);
        Element color = (Element)rootSubform.resolveNode("#fill.#color", true, false, true);
        JSONObject items = new JSONObject();
        try {
            if (color != null) {
                String colorValue = color.getAttribute(XFA.VALUETAG).getAttrValue();
                JSONObject accentColor = new JSONObject();
                accentColor.put("sling:resourceType", (Object)"fd/af/authoring/components/granite/form/colorpicker");
                accentColor.put("showproperties", (Object)"off");
                accentColor.put("fieldLabel", (Object)"Accent Color");
                accentColor.put("fieldDescription", (Object)"Specifies a color to emphasize a form object in Document of Record.");
                accentColor.put("name", (Object)"./accentColor");
                accentColor.put("showswatches", (Object)"on");
                accentColor.put("value", (Object)DoRUtils.convertColorToHEX(colorValue));
                items.put("accentColor", (Object)accentColor);
            }
            if (font != null) {
                String typeface = font.getAttribute(XFA.TYPEFACETAG).getAttrValue();
                JSONObject options = new JSONObject();
                options.put("sling:resourceType", (Object)"fd/af/dor/services/getFontList");
                JSONObject fontFamily = new JSONObject();
                fontFamily.put("sling:resourceType", (Object)"granite/ui/components/coral/foundation/form/autocomplete");
                fontFamily.put("emptyText", (Object)"Select");
                fontFamily.put("fieldLabel", (Object)"Font Family");
                fontFamily.put("fieldDescription", (Object)"Specifies a font for the form object. The specified font is used only in Document of Record.");
                fontFamily.put("name", (Object)"./fontFamily");
                fontFamily.put("variant", (Object)"quiet");
                fontFamily.put("value", (Object)typeface);
                fontFamily.put("options", (Object)options);
                items.put("fontFamily", (Object)fontFamily);
            }
        }
        catch (Exception e) {
            logger.error("Error while extracting configuration properties from template", (Throwable)e);
        }
        return items;
    }
}