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