All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.cq.editor.model.inplaceediting.config.PluginFeature Maven / Gradle / Ivy

/*************************************************************************
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2016 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 *
 **************************************************************************/
package com.adobe.cq.editor.model.inplaceediting.config;

import java.util.Arrays;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;

/**
 * Representation suitable for configuring the feature of a plugin resource in the context of the In Place Editors
 */
@Model(adaptables = SlingHttpServletRequest.class)
public class PluginFeature extends Plugin {

    private static final String PLUGIN_FEATURE_CLASS_NAMES = "js-cq-IPEPlugin js-cq-IPEPlugin-feature coral-Form-field";

    /**
     * Name of the plugin
     *
     * @return The plugin name
     */
    @Override
    public String getPluginName() {
        return getParentName();
    }

    /**
     * Name of the feature
     *
     * @return The feature name
     */
    @Override
    public String getFeatures() {
        return name;
    }

    /**
     * Returns the name of the plugin feature from its parent
     * 

* This implies its parent represents the plugin * * @return Parent Name of the plugin feature */ private String getParentName() { Resource pluginConfig = getPluginContainerConfiguration(); if (pluginConfig == null) { return ""; } String name = pluginConfig.getValueMap().get("name", String.class); return StringUtils.isNotEmpty(name) ? name : ""; } @Override protected Boolean hasFeatures(Resource pluginConfig) { if (pluginConfig == null) { return null; } String[] featuresValue = pluginConfig.getValueMap().get(PLUGIN_CONFIGURATION_FEATURES_PROPERTY, String[].class); if (featuresValue == null || featuresValue.length == 0) { return Boolean.FALSE; } List configFeatureList; if (featuresValue.length > 1) { // Multi-valued list of features configFeatureList = Arrays.asList(featuresValue); } else { // Comma separated list of features configFeatureList = Arrays.asList(featuresValue[0].split(FEATURE_LIST_SEPARATOR)); } String firstFeature = configFeatureList.get(0); if (CONFIGURATION_ALL_PLUGINS.equals(firstFeature)) { return Boolean.TRUE; } if (CONFIGURATION_NO_PLUGIN.equals(firstFeature)) { return Boolean.FALSE; } if (configFeatureList.contains(name)) { return Boolean.TRUE; } return Boolean.FALSE; } /** * Should the feature be enabled * * @return Status of the feature */ @Override public Boolean isEnabled() { return isPluginEnabled(getParentName()); } @Override public String getClassNames() { if (StringUtils.isEmpty(classNames)) { return PLUGIN_FEATURE_CLASS_NAMES; } return PLUGIN_FEATURE_CLASS_NAMES + " " + classNames; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy