DoRPanelElement.java 3.33 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.aemds.guide.addon.dor.DoRUtils
 *  com.adobe.xfa.AppModel
 *  com.adobe.xfa.Document
 *  com.adobe.xfa.Element
 *  com.adobe.xfa.Node
 *  com.adobe.xfa.content.IntegerValue
 *  com.adobe.xfa.template.TemplateModel
 *  com.adobe.xfa.template.Value
 */
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.aemds.guide.addon.dor.elements.DoRElementUtils;
import com.adobe.xfa.AppModel;
import com.adobe.xfa.Document;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.content.IntegerValue;
import com.adobe.xfa.template.TemplateModel;
import com.adobe.xfa.template.Value;
import java.util.Map;
import java.util.Properties;

public class DoRPanelElement
extends DoRElement {
    public DoRPanelElement(Element xfaElement) throws Exception {
        super(xfaElement);
        this.xPathExprs.put("jcr:title", "draw[@name=\"AF_PANELTITLE\"]/value/text/text()");
        this.xPathExprs.put("jcr:description", "draw[@name=\"AF_PANELDESCRIPTION\"]/value/text/text()");
        this.xPathExprs.put("minOccur", "occur/@min");
        this.xPathExprs.put("maxOccur", "occur/@max");
        this.xPathExprs.put("layout", "@layout");
        this.xPathExprs.put("dorNumCols", "extras/integer[@name=\"dorNumCols\"]/text()");
    }

    @Override
    public boolean isContainer() {
        return true;
    }

    @Override
    public String getCaptionValueSom() {
        return "AF_PANELTITLE.#value";
    }

    @Override
    public void applyProperties(Properties properties) throws Exception {
        String bindRef;
        int length;
        if (!properties.containsKey("jcr:title")) {
            this.removeNode("AF_PANELTITLE");
        }
        if (!properties.containsKey("jcr:description")) {
            this.removeNode("AF_PANELDESCRIPTION");
        } else {
            DoRUtils.enablePlainText((Value)((Value)this.xfaElement.resolveNode("AF_PANELDESCRIPTION.#value", true, false, true)));
        }
        if (properties.getProperty("dorRemoveEmptySpaceInPanel", "false").equals("true")) {
            this.removeNode("AF_PANELSPACE");
        }
        if (properties.containsKey("dorNumCols")) {
            TemplateModel templateModel = TemplateModel.getTemplateModel((AppModel)this.xfaElement.getOwnerDocument().getAppModel(), (boolean)false);
            Element extras = templateModel.createElement("extras", "", this.xfaElement);
            IntegerValue dorNumCols = (IntegerValue)templateModel.createElement("integer", "dorNumCols", extras);
            dorNumCols.setValue(properties.getProperty("dorNumCols"), false);
            properties.remove("dorNumCols");
        }
        if (DoRElementUtils.isRepeatable(properties) && (bindRef = properties.getProperty("bindRef")) != null && (length = bindRef.length()) > 3 && !bindRef.substring(length - 3).equals("[*]")) {
            bindRef = bindRef.concat("[*]");
            properties.put("bindRef", bindRef);
        }
        super.applyProperties(properties, true);
    }

    private void removeNode(String name) {
        Node node = this.xfaElement.resolveNode(this.xfaElement.getSOMExpression() + "." + name);
        if (node != null) {
            node.remove();
        }
    }
}