DoRTextBoxElement.java 2.05 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.aemds.guide.addon.dor.DoRUtils
 *  com.adobe.xfa.Element
 *  com.adobe.xfa.Node
 *  com.adobe.xfa.content.Content
 *  com.adobe.xfa.template.Value
 *  org.apache.commons.lang3.StringUtils
 */
package com.adobe.aemds.guide.addon.dor.elements;

import com.adobe.aemds.guide.addon.dor.DoRUtils;
import com.adobe.aemds.guide.addon.dor.elements.DoRElement;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.content.Content;
import com.adobe.xfa.template.Value;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;

public class DoRTextBoxElement
extends DoRElement {
    public DoRTextBoxElement(Element xfaElement) throws Exception {
        super(xfaElement);
        this.xPathExprs.put("multiLine", "ui/textEdit/@multiLine");
        this.xPathExprs.put("maxChars", "value/text/@maxChars");
    }

    @Override
    public void applyProperties(Properties properties) throws Exception {
        String allowRichText = properties.getProperty("allowRichText", "false");
        Value valueNode = (Value)this.xfaElement.resolveNode("#value");
        if (StringUtils.equals((CharSequence)allowRichText, (CharSequence)"true")) {
            DoRUtils.enableRichText((Value)valueNode);
            if (properties.containsKey("_value") && valueNode != null) {
                String plainText = properties.getProperty("_value");
                plainText = DoRUtils.convertToPlainText((String)plainText);
                DoRUtils.setValue((Content)((Content)valueNode.getOneOfChild()), (String)plainText, (String)"text/html");
            }
        } else {
            DoRUtils.enablePlainText((Value)valueNode);
            if (properties.containsKey("_value") && valueNode != null) {
                DoRUtils.setValue((Content)((Content)valueNode.getOneOfChild()), (String)properties.getProperty("_value"), (String)null);
            }
        }
        properties.remove("_value");
        super.applyProperties(properties, true);
    }
}