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-2016 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  public enum LabelType
048  {
049    /** Primary label. */
050    PRIMARY,
051    /** Secondary label. */
052    SECONDARY
053  }
054
055  /**
056   * This enum contains the different type of fields that can be associated with
057   * this LabelFieldDescriptor.
058   */
059  public enum FieldType
060  {
061    /** Editable text field. */
062    TEXTFIELD,
063    /** Password field. */
064    PASSWORD,
065    /** Read only field. */
066    READ_ONLY
067  }
068
069  /**
070   * Constructor of this LabelFieldDescriptor.
071   * @param label the String of the label.
072   * @param tooltip the tooltip of the field.
073   * @param type the type of field.
074   * @param labelType the type of label.
075   * @param size the size of the field.
076   */
077  public LabelFieldDescriptor(LocalizableMessage label, LocalizableMessage tooltip, FieldType type,
078      LabelType labelType, int size)
079  {
080    this.label = label;
081    this.tooltip = tooltip;
082    this.type = type;
083    this.labelType = labelType;
084    this.size = size;
085  }
086
087  /**
088   * Returns the String displayed by the label.
089   * @return the String displayed by the label.
090   */
091  public LocalizableMessage getLabel()
092  {
093    return label;
094  }
095
096  /**
097   * Returns the size of the field.
098   * @return the size of the field.
099   */
100  public int getSize()
101  {
102    return size;
103  }
104
105  /**
106   * Returns the tooltip used in the field.
107   * @return the tooltip used in the field.
108   */
109  public LocalizableMessage getTooltip()
110  {
111    return tooltip;
112  }
113
114  /**
115   * Returns the field type.
116   * @return the field type.
117   */
118  public FieldType getType()
119  {
120    return type;
121  }
122
123  /**
124   * Returns the label type.
125   * @return the label type.
126   */
127  public LabelType getLabelType()
128  {
129    return labelType;
130  }
131}