DoRDropDownElement.java
2.3 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.xfa.AppModel
* com.adobe.xfa.Attribute
* com.adobe.xfa.Element
* com.adobe.xfa.Node
* com.adobe.xfa.StringAttr
* com.adobe.xfa.XFA
* com.adobe.xfa.content.TextValue
* com.adobe.xfa.template.TemplateModel
*/
package com.adobe.aemds.guide.addon.dor.elements;
import com.adobe.aemds.guide.addon.dor.elements.DoRElement;
import com.adobe.xfa.AppModel;
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 com.adobe.xfa.content.TextValue;
import com.adobe.xfa.template.TemplateModel;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
public class DoRDropDownElement
extends DoRElement {
public DoRDropDownElement(Element xfaElement) throws Exception {
super(xfaElement);
this.xPathExprs.put("multiSelect", "ui/choiceList/@open");
this.xPathExprs.put("displayValue", "value/text/text()");
}
@Override
public void applyProperties(Properties properties) throws Exception {
Map map = (Map)properties.get("options");
if (map != null) {
this.applyOptionsProperty(map);
}
super.applyProperties(properties, true);
}
private void applyOptionsProperty(Map<String, String> map) {
TemplateModel templateModel = TemplateModel.getTemplateModel((AppModel)this.xfaElement.getAppModel(), (boolean)true);
Element itemsTexts = templateModel.createElement("items", "", this.xfaElement);
Element itemsValues = templateModel.createElement("items", "", this.xfaElement);
StringAttr stringAttr = new StringAttr("save", "1");
itemsValues.setAttribute((Attribute)stringAttr, XFA.SAVETAG);
stringAttr = new StringAttr("presence", "hidden");
itemsValues.setAttribute((Attribute)stringAttr, XFA.PRESENCETAG);
for (Map.Entry<String, String> entry : map.entrySet()) {
String valueString = entry.getKey();
String textString = entry.getValue();
TextValue textValue = new TextValue(itemsValues, null);
textValue.setValue(valueString);
textValue = new TextValue(itemsTexts, null);
textValue.setValue(textString);
}
}
}