DoRPanelElement.java
3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* 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();
}
}
}