001/*
002 *  Copyright 2024 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.odf.tree;
017
018import java.util.List;
019import java.util.Map;
020
021import org.ametys.cms.repository.Content;
022import org.ametys.core.ui.ClientSideElement.Script;
023import org.ametys.runtime.i18n.I18nizableText;
024import org.ametys.runtime.plugin.component.Prioritizable;
025
026/**
027 * Interface for an ODF tree indicator
028 *
029 */
030public interface ODFTreeIndicator extends Prioritizable
031{
032    /**
033     * Determines if ODF tree indicator is enabled
034     * @return true if ODF tree indicator is enabled
035     */
036    default boolean isEnabled()
037    {
038        return true;
039    }
040    
041    /**
042     * Get the id
043     * @return the id
044     */
045    public String getId();
046    
047    /**
048     * Get the indicator label
049     * @return the label
050     */
051    public I18nizableText getLabel();
052    
053    /**
054     * Get the indicator description
055     * @return the description
056     */
057    public I18nizableText getDescription();
058    
059    /**
060     * The indicator glyph icon
061     * @return the CSS class for glyph icon
062     */
063    public String getIconGlyph();
064    
065    /**
066     * Get scripts that will be used on client side.
067     * @param contextParameters Contextuals parameters transmitted by the environment.
068     * @return The list of scripts or an empty list.
069     */
070    public List<Script> getScripts(Map<String, Object> contextParameters);
071    
072    /**
073     * Get the JS function to determines if indicator is available for a content. Can return <code>null</code> to use default one.
074     * @return the JS function or <code>null</code> to use default matcher
075     */
076    public String getMatchJSFunction();
077    
078    /**
079     * Get the JS function to display the indicator. Can return <code>null</code> to use default one.
080     * @return the JS function or <code>null</code> to use default applyier
081     */
082    public String getApplyJSFunction();
083    
084    /**
085     * Get the indicator values for a program item. Return <code>null</code> if the indicator is not available for this program item
086     * @param content the content
087     * @return the indicator data for this program item. Can be null.
088     */
089    public IndicatorData getIndicatorData(Content content);
090    
091    /**
092     * Record for indicator data
093     * @param tooltip The tooltip
094     * @param text The text value. Can be null
095     * @param cssClass the CSS class for the icon glyph. Can be null
096     * @param additionalData the additional data. Can be null or empty.
097     */
098    public record IndicatorData(I18nizableText tooltip, I18nizableText text, String cssClass, Map<String, Object> additionalData) { /* empty */ }
099        
100}