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 */
017package org.nuxeo.ecm.platform.forms.layout.descriptors;
018
019import java.io.Serializable;
020import java.util.HashMap;
021import java.util.Map;
022
023import org.nuxeo.common.xmap.annotation.XNode;
024import org.nuxeo.common.xmap.annotation.XNodeMap;
025import org.nuxeo.common.xmap.annotation.XObject;
026import org.nuxeo.ecm.platform.forms.layout.api.WidgetSelectOption;
027import org.nuxeo.ecm.platform.forms.layout.api.impl.WidgetSelectOptionImpl;
028
029/**
030 * @author Anahide Tchertchian
031 * @since 5.4.2
032 */
033@XObject("option")
034public class WidgetSelectOptionDescriptor {
035
036    @XNode("@value")
037    protected String value;
038
039    @XNode("@var")
040    protected String var;
041
042    @XNode("@itemLabel")
043    protected String itemLabel;
044
045    @XNodeMap(value = "itemLabel", key = "@locale", type = HashMap.class, componentType = String.class)
046    protected Map<String, String> itemLabels = new HashMap<String, String>();
047
048    @XNode("@itemValue")
049    protected String itemValue;
050
051    @XNode("@itemDisabled")
052    protected String itemDisabled;
053
054    @XNode("@itemRendered")
055    protected String itemRendered;
056
057    public Serializable getValue() {
058        return value;
059    }
060
061    public String getVar() {
062        return var;
063    }
064
065    public String getItemLabel() {
066        return itemLabel;
067    }
068
069    public String getItemValue() {
070        return itemValue;
071    }
072
073    public Serializable getItemDisabled() {
074        return itemDisabled;
075    }
076
077    public Serializable getItemRendered() {
078        return itemRendered;
079    }
080
081    public WidgetSelectOption getWidgetSelectOption() {
082        WidgetSelectOptionImpl res = new WidgetSelectOptionImpl(value, var, itemLabel, itemValue, itemDisabled,
083                itemRendered);
084        res.setItemLabels(itemLabels);
085        return res;
086    }
087
088}