001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2006-2008 Sun Microsystems, Inc.
015 * Portions Copyright 2014 ForgeRock AS.
016 */
017
018package org.opends.quicksetup.ui;
019
020import org.forgerock.i18n.LocalizableMessage;
021
022/**
023 * This is a commodity class used to couple a label and a text component with
024 * a FieldName.  It is mainly used by the QuickSetupStepPanel classes to
025 * retrieve easily the labels and fields associated with a FieldName to provide
026 * its content or to mark the labels as valid or invalid.  It is also used
027 * during the creation of the components as it describes the different
028 * properties.
029 */
030
031public class LabelFieldDescriptor
032{
033  private LocalizableMessage label;
034
035  private LocalizableMessage tooltip;
036
037  private FieldType type;
038
039  private LabelType labelType;
040
041  private int size;
042
043  /**
044   * This enum contains the different type of labels that can be associated with
045   * this LabelFieldDescriptor.
046   *
047   */
048  public enum LabelType
049  {
050    /**
051     * Primary label.
052     */
053    PRIMARY,
054    /**
055     * Secondary label.
056     */
057    SECONDARY
058  }
059
060  /**
061   * This enum contains the different type of fields that can be associated with
062   * this LabelFieldDescriptor.
063   *
064   */
065  public enum FieldType
066  {
067    /**
068     * Editable text field.
069     */
070    TEXTFIELD,
071    /**
072     * Password field.
073     */
074    PASSWORD,
075    /**
076     * Read only field.
077     */
078    READ_ONLY
079  }
080
081  /**
082   * Constructor of this LabelFieldDescriptor.
083   * @param label the String of the label.
084   * @param tooltip the tooltip of the field.
085   * @param type the type of field.
086   * @param labelType the type of label.
087   * @param size the size of the field.
088   */
089  public LabelFieldDescriptor(LocalizableMessage label, LocalizableMessage tooltip, FieldType type,
090      LabelType labelType, int size)
091  {
092    this.label = label;
093    this.tooltip = tooltip;
094    this.type = type;
095    this.labelType = labelType;
096    this.size = size;
097  }
098
099  /**
100   * Returns the String displayed by the label.
101   * @return the String displayed by the label.
102   */
103  public LocalizableMessage getLabel()
104  {
105    return label;
106  }
107
108  /**
109   * Returns the size of the field.
110   * @return the size of the field.
111   */
112  public int getSize()
113  {
114    return size;
115  }
116
117  /**
118   * Returns the tooltip used in the field.
119   * @return the tooltip used in the field.
120   */
121  public LocalizableMessage getTooltip()
122  {
123    return tooltip;
124  }
125
126  /**
127   * Returns the field type.
128   * @return the field type.
129   */
130  public FieldType getType()
131  {
132    return type;
133  }
134
135  /**
136   * Returns the label type.
137   * @return the label type.
138   */
139  public LabelType getLabelType()
140  {
141    return labelType;
142  }
143}