GuideImage.java
2.81 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.wcm.foundation.Image
* com.day.cq.wcm.foundation.Placeholder
* javax.jcr.Property
* javax.jcr.RepositoryException
* javax.servlet.ServletRequest
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.api.resource.Resource
* 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.Image;
import com.day.cq.wcm.foundation.Placeholder;
import java.io.IOException;
import java.io.Serializable;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.servlet.ServletRequest;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
public class GuideImage
extends GuideField
implements Serializable {
private Image image;
public String getImageSrc() throws RepositoryException, IOException {
this.image = new Image(this.resource);
Boolean containsData = this.image.getData() != null;
Boolean containsBindRef = !this.image.get("bindRef").isEmpty();
Boolean isTouchMode = Placeholder.isAuthoringUIModeTouch((ServletRequest)this.slingRequest);
this.image.setIsInUITouchMode(isTouchMode.booleanValue());
if (containsData.booleanValue()) {
this.image.setSelector(".img");
return this.image.getSrc();
}
if (containsBindRef.booleanValue()) {
return "";
}
return "/libs/fd/af/components/guideimage/icon.jpg";
}
public String getStyles() {
String style = "";
String width = this.getWidth();
String height = this.getHeight();
style = style + (width.length() > 0 ? new StringBuilder().append("width:").append(width).append("%;").toString() : "");
style = style + (height.length() > 0 ? new StringBuilder().append("height:").append(height).append("px;").toString() : "");
return style;
}
public String getDropTargetClass() throws RepositoryException {
if (this.image.getData() == null) {
return "cq-placeholder cq-dd-image";
}
return "cq-dd-image";
}
public String getAltText() {
String altText = (String)this.resourceProps.get("altText", (Object)"");
if ("".equals(altText)) {
String title = (String)this.resourceProps.get("jcr:title", (Object)"");
altText = "".equals(title) ? (String)this.resourceProps.get("name", (Object)"") : title;
}
return this.externalize(altText);
}
public String getHeight() {
return (String)this.resourceProps.get("height", (Object)"");
}
public String getGuideFieldType() {
return "guideImage";
}
}