ConfigPropertiesUtils.java
3.28 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
/*
* 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.XFA
* com.adobe.xfa.template.containers.Subform
* org.apache.sling.commons.json.JSONObject
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.addon.dor;
import com.adobe.aemds.guide.addon.dor.BrandingComponentUtils;
import com.adobe.aemds.guide.addon.dor.DoRUtils;
import com.adobe.xfa.Attribute;
import com.adobe.xfa.Element;
import com.adobe.xfa.Node;
import com.adobe.xfa.XFA;
import com.adobe.xfa.template.containers.Subform;
import org.apache.sling.commons.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConfigPropertiesUtils {
private static final Logger logger = LoggerFactory.getLogger(BrandingComponentUtils.class);
public static JSONObject getConfigProperties(Subform rootSubform) {
if (rootSubform == null) {
return null;
}
Element font = (Element)rootSubform.resolveNode("#font", true, false, true);
Element color = (Element)rootSubform.resolveNode("#fill.#color", true, false, true);
JSONObject items = new JSONObject();
try {
if (color != null) {
String colorValue = color.getAttribute(XFA.VALUETAG).getAttrValue();
JSONObject accentColor = new JSONObject();
accentColor.put("sling:resourceType", (Object)"fd/af/authoring/components/granite/form/colorpicker");
accentColor.put("showproperties", (Object)"off");
accentColor.put("fieldLabel", (Object)"Accent Color");
accentColor.put("fieldDescription", (Object)"Specifies a color to emphasize a form object in Document of Record.");
accentColor.put("name", (Object)"./accentColor");
accentColor.put("showswatches", (Object)"on");
accentColor.put("value", (Object)DoRUtils.convertColorToHEX(colorValue));
items.put("accentColor", (Object)accentColor);
}
if (font != null) {
String typeface = font.getAttribute(XFA.TYPEFACETAG).getAttrValue();
JSONObject options = new JSONObject();
options.put("sling:resourceType", (Object)"fd/af/dor/services/getFontList");
JSONObject fontFamily = new JSONObject();
fontFamily.put("sling:resourceType", (Object)"granite/ui/components/coral/foundation/form/autocomplete");
fontFamily.put("emptyText", (Object)"Select");
fontFamily.put("fieldLabel", (Object)"Font Family");
fontFamily.put("fieldDescription", (Object)"Specifies a font for the form object. The specified font is used only in Document of Record.");
fontFamily.put("name", (Object)"./fontFamily");
fontFamily.put("variant", (Object)"quiet");
fontFamily.put("value", (Object)typeface);
fontFamily.put("options", (Object)options);
items.put("fontFamily", (Object)fontFamily);
}
}
catch (Exception e) {
logger.error("Error while extracting configuration properties from template", (Throwable)e);
}
return items;
}
}