GuidePanelElement.java
3.12 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemds.guide.addon.dor.DoRThreadLocal
* com.adobe.xfa.Element
* org.apache.commons.lang3.StringUtils
* org.apache.sling.commons.json.JSONObject
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.addon.dor.elements;
import com.adobe.aemds.guide.addon.dor.DoRThreadLocal;
import com.adobe.aemds.guide.addon.dor.elements.DoRElement;
import com.adobe.aemds.guide.addon.dor.elements.DoRPanelElement;
import com.adobe.aemds.guide.addon.dor.elements.GuideElement;
import com.adobe.aemds.guide.addon.dor.elements.GuideElementProperties;
import com.adobe.xfa.Element;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.commons.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GuidePanelElement
extends GuideElement {
private static Logger logger = LoggerFactory.getLogger(GuidePanelElement.class);
public GuidePanelElement(JSONObject jsonObject) {
String dorNumCols;
boolean dorExcludeDescription;
String dorLayoutType;
super(jsonObject);
for (String key : GuideElementProperties.PANEL_PROPERTIES) {
String value = jsonObject.optString(key);
if (value == null || value.isEmpty()) continue;
this.properties.setProperty(key, value);
}
boolean hidePanelDescription = StringUtils.equals((CharSequence)"true", (CharSequence)((CharSequence)DoRThreadLocal.getFormProperties().get("hidePanelDescriptions")));
boolean dorExcludeTitle = this.properties.getProperty("dorExcludeTitle", "false").equals("true");
boolean bl = dorExcludeDescription = this.properties.getProperty("dorExcludeDescription", "false").equals("true") || hidePanelDescription;
if (dorExcludeTitle) {
this.properties.remove("jcr:title");
}
if (dorExcludeDescription) {
this.properties.remove("jcr:description");
}
if (dorExcludeTitle && dorExcludeDescription) {
this.properties.put("dorRemoveEmptySpaceInPanel", "true");
}
if (jsonObject.has("layout") && "columnar".equals(dorLayoutType = jsonObject.optJSONObject("layout").optString("dorLayoutType")) && Integer.parseInt(dorNumCols = jsonObject.optJSONObject("layout").optString("dorNumCols", "1")) > 1) {
this.properties.setProperty("layout", "lr-tb");
this.properties.setProperty("dorNumCols", dorNumCols);
}
String minOccur = "minOccur";
String maxOccur = "maxOccur";
if (jsonObject.has(minOccur) && !jsonObject.has(maxOccur)) {
String maxOccurValue = String.valueOf(Math.max(1, Integer.parseInt(jsonObject.optString(minOccur))));
this.properties.setProperty(maxOccur, maxOccurValue);
} else if (jsonObject.has(maxOccur) && !jsonObject.has(minOccur)) {
this.properties.setProperty(minOccur, "1");
}
}
@Override
public DoRElement createDoRElement(Element xfaElement) throws Exception {
return new DoRPanelElement(xfaElement);
}
}