GuideImage.java 2.81 KB
/*
 * 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";
    }
}