001/*
002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Anahide Tchertchian
016 */
017
018package org.nuxeo.ecm.platform.forms.layout.api;
019
020import java.io.Serializable;
021import java.util.Map;
022
023/**
024 * Single select option top be held by the {@link WidgetDefinition} and {@link Widget} generated from the definition.
025 *
026 * @author Anahide Tchertchian
027 * @since 5.4.2
028 */
029public interface WidgetSelectOption extends Serializable {
030
031    /**
032     * Returns the value representing the option.
033     * <p>
034     * This value is optional when using static label and values, it can be useful to use it in conjunction with the
035     * {@link #getVar()} method to retrieve the id and label from the object.
036     */
037    Serializable getValue();
038
039    /**
040     * Returns the var representing the value returned by {@link #getValue()}
041     * <p>
042     * This value can be used in the potential EL expressions returned by {@link #getItemLabel()},
043     * {@link #getItemValue()}, {@link #getItemDisabled()} and {@link #getItemRendered()}.
044     */
045    String getVar();
046
047    /**
048     * Returns the item label for the select option.
049     * <p>
050     * This can be an EL expression if {@link #getValue()} and {@link #getVar()} return a non-null value.
051     */
052    String getItemLabel();
053
054    /**
055     * Getter to handle l10n localization of select options.
056     *
057     * @since 6.0
058     */
059    String getItemLabel(String locale);
060
061    /**
062     * Getter to handle l10n localization of select options.
063     *
064     * @since 6.0
065     */
066    Map<String, String> getItemLabels();
067
068    /**
069     * Returns the item value for the select option.
070     * <p>
071     * This can be an EL expression if {@link #getValue()} and {@link #getVar()} return a non-null value.
072     */
073    String getItemValue();
074
075    /**
076     * Returns the disabled behaviour for the select option.
077     * <p>
078     * This value can either be an EL expression that should resolve to a boolean value, either a string representing a
079     * boolean ("true" or "false") either a Boolean value.
080     */
081    Serializable getItemDisabled();
082
083    /**
084     * Returns the rendered behaviour for the select option.
085     * <p>
086     * This value can either be an EL expression that should resolve to a boolean value, either a string representing a
087     * boolean ("true" or "false") either a Boolean value.
088     */
089    Serializable getItemRendered();
090
091    /**
092     * Returns the unique identifier of this select option to be used in tag configuration.
093     *
094     * @see {@link Layout#getTagConfigId()}.
095     */
096    String getTagConfigId();
097
098    /**
099     * @since 5.5
100     */
101    WidgetSelectOption clone();
102
103}