DoRTnCElement.java
3.9 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* 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.StringAttr
* com.adobe.xfa.XFA
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.addon.dor.elements;
import com.adobe.aemds.guide.addon.dor.elements.DoRElement;
import com.adobe.aemds.guide.addon.dor.elements.DoRElementUtils;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.StringAttr;
import com.adobe.xfa.XFA;
import java.util.Map;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DoRTnCElement
extends DoRElement {
private static Logger logger = LoggerFactory.getLogger(DoRTnCElement.class);
public DoRTnCElement(Element xfaElement) throws Exception {
super(xfaElement);
this.xPathExprs.put("jcr:title", "field[ui[textEdit]]/caption/value/text/text()");
this.xPathExprs.put("tncTextContent", "field[ui[textEdit]]/value/text/text()");
this.xPathExprs.put("tncCheckBoxContent", "field[ui[checkButton]]/caption/value/text/text()");
this.xPathExprs.put("items.reviewDocument.name", "field[ui[textEdit]]/@name");
this.xPathExprs.put("items.reviewStatus.name", "field[ui[checkButton]]/@name");
this.xPathExprs.put("assistPriority", "field[ui[textEdit]]/assist/speak/@priority");
this.xPathExprs.put("custom", "field[ui[textEdit]]/assist/speak/text()");
this.xPathExprs.put("shortDescription", "field[ui[textEdit]]/assist/toolTip/text()");
this.xPathExprs.put("bindRef", "field[ui[checkButton]]/bind/@ref");
this.xPathExprs.put("bindMatch", "field[ui[checkButton]]/bind/@match");
}
@Override
public String getCaptionValueSom() {
return "#field[*].#ui.#textEdit.parent.parent.#caption.#value";
}
@Override
public void applyProperties(Properties properties) throws Exception {
this.adaptForBackwardCompatibility();
this.adaptToTable();
super.applyProperties(properties, true);
this.setWidth(this.xfaElement.getAttribute(XFA.WTAG).getAttrValue());
}
private void adaptToTable() {
Element parent = this.xfaElement.getXFAParent();
try {
if (parent.getAttribute(XFA.LAYOUTTAG).getAttrValue().equals("row")) {
String width = DoRElementUtils.getColumnWidthFromParent(this.xfaElement);
int childCount = this.xfaElement.getXFAChildCount();
for (int i = 0; i < childCount; ++i) {
Element element = (Element)this.xfaElement.getXFAChild(i);
if (!element.getClassName().equals("field")) continue;
DoRElementUtils.adaptToTableCell(element, width);
}
}
}
catch (NullPointerException e) {
logger.debug("TnC is not inside table", (Throwable)e);
}
}
private void setWidth(String width) {
int childCount = this.xfaElement.getXFAChildCount();
for (int i = 0; i < childCount; ++i) {
Element element = (Element)this.xfaElement.getXFAChild(i);
if (element == null || !element.getClassName().equals("field")) continue;
element.setAttribute((Attribute)new StringAttr("maxW", width), XFA.MAXWTAG);
}
}
private void adaptForBackwardCompatibility() {
Element node = (Element)this.xfaElement.resolveNode("bind");
if (node != null) {
this.xfaElement.removeChild((Node)node);
}
}
@Override
protected void modifyCaptionAttributes(Element node, double scalingFactor) {
int noOfChild = node.getXFAChildCount();
for (int i = 0; i < noOfChild; ++i) {
Element child = (Element)node.getXFAChild(i);
super.modifyCaptionAttributes(child, scalingFactor);
}
}
}