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