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     * Get the id
034     * @return the id
035     */
036    public String getId();
037    
038    /**
039     * Get the indicator label
040     * @return the label
041     */
042    public I18nizableText getLabel();
043    
044    /**
045     * Get the indicator description
046     * @return the description
047     */
048    public I18nizableText getDescription();
049    
050    /**
051     * The indicator glyph icon
052     * @return the CSS class for glyph icon
053     */
054    public String getIconGlyph();
055    
056    /**
057     * Get scripts that will be used on client side.
058     * @param contextParameters Contextuals parameters transmitted by the environment.
059     * @return The list of scripts or an empty list.
060     */
061    public List<Script> getScripts(Map<String, Object> contextParameters);
062    
063    /**
064     * Get the JS function to determines if indicator is available for a content. Can return <code>null</code> to use default one.
065     * @return the JS function or <code>null</code> to use default matcher
066     */
067    public String getMatchJSFunction();
068    
069    /**
070     * Get the JS function to display the indicator. Can return <code>null</code> to use default one.
071     * @return the JS function or <code>null</code> to use default applyier
072     */
073    public String getApplyJSFunction();
074    
075    /**
076     * Get the indicator values for a program item. Return <code>null</code> if the indicator is not available for this program item
077     * @param content the content
078     * @return the indicator data for this program item. Can be null.
079     */
080    public IndicatorData getIndicatorData(Content content);
081    
082    /**
083     * Record for indicator data
084     * @param tooltip The tooltip
085     * @param text The text value. Can be null
086     * @param cssClass the CSS class for the icon glyph. Can be null
087     * @param additionalData the additional data. Can be null or empty.
088     */
089    public record IndicatorData(I18nizableText tooltip, I18nizableText text, String cssClass, Map<String, Object> additionalData) { /* empty */ }
090        
091}