GuideDropDownList.java
2.66 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.wcm.foundation.forms.FormsHelper
* org.apache.commons.lang.StringUtils
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.ValueMap
*/
package com.adobe.aemds.guide.common;
import com.adobe.aemds.guide.common.GuideField;
import com.day.cq.wcm.foundation.forms.FormsHelper;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
public class GuideDropDownList
extends GuideField {
private boolean isFirstOptGroup = true;
public Map getOptions() {
Resource resLoadPath;
String[] options = null;
String loadPath = (String)this.resourceProps.get("optionsLoadPath", (Object)"");
if (loadPath.length() > 0 && (resLoadPath = this.slingRequest.getResourceResolver().getResource(loadPath)) != null) {
options = (String[])resLoadPath.adaptTo(String[].class);
}
if (options == null) {
options = (String[])this.resourceProps.get("options", String[].class);
}
if (options == null) {
return null;
}
LinkedHashMap<String, String> result = new LinkedHashMap<String, String>();
for (int i = 0; i < options.length; ++i) {
String value;
String[] option = StringUtils.split((String)options[i], (char)'=');
if (option.length == 0) continue;
String key = option[0];
String string = value = option.length == 1 ? key : option[1];
if ("afOptGroupName".equals(key)) {
key = key + i;
}
result.put(key, value);
}
return result;
}
public List getValues() {
return FormsHelper.getValuesAsList((SlingHttpServletRequest)this.slingRequest, (Resource)super.getResource());
}
public Boolean getIsMultiSelect() {
return FormsHelper.hasMultiSelection((Resource)super.getResource());
}
public String getGuideFieldType() {
return "guideDropDownList";
}
public boolean getIsFirstOptGroup() {
if (this.isFirstOptGroup) {
this.isFirstOptGroup = false;
return true;
}
return false;
}
public static boolean isKeyAnOptGroup(String key) {
return key.startsWith("afOptGroupName");
}
}