Class TextControl<V>

Type Parameters:
V - The type of value the input text is to represent.
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, com.globalmentor.model.MutableValued<V>, com.globalmentor.model.Valued<V>, Component, Control, EditComponent, InputFocusableComponent, ValueControl<V>, ValuedComponent<V>, EditListenable, Displayable, Enableable, InfoModel, LabelModel, Model, PresentationModel, ValueModel<V>, DepictedObject

public class TextControl<V> extends AbstractTextControl<V>
Control to accept text input from the user representing a particular value type. This control keeps track of literal text entered by the user, distinct from the value stored in the model. If line wrap is not specified in the constructor, it defaults to true. If multiline is not specified in the constructor, it defaults to true only when there is more than one row and line wrap is turned off. Default converters are available for the following types:
  • char[]
  • java.lang.Boolean
  • java.lang.Float
  • java.lang.Integer
  • java.lang.String
This component installs a default export strategy supporting export of the following content types:
  • text/plain
This component installs a default import strategy supporting import of the following content types:
  • text/*
This control uses a single line feed character to represent each line break.
Author:
Garret Wilson
  • Field Details

    • LINE_WRAP_PROPERTY

      public static final String LINE_WRAP_PROPERTY
      The line wrap bound property.
    • MASKED_PROPERTY

      public static final String MASKED_PROPERTY
      The masked bound property.
    • MAXIMUM_LENGTH_PROPERTY

      public static final String MAXIMUM_LENGTH_PROPERTY
      The maximum length bound property.
    • MULTILINE_PROPERTY

      public static final String MULTILINE_PROPERTY
      The multiline bound property.
    • ROW_COUNT_PROPERTY

      public static final String ROW_COUNT_PROPERTY
      The row count bound property.
    • DEFAULT_EXPORT_STRATEGY

      protected static final ExportStrategy<TextControl<?>> DEFAULT_EXPORT_STRATEGY
      The default export strategy for this component type.
    • DEFAULT_IMPORT_STRATEGY

      protected static final ImportStrategy<TextControl<?>> DEFAULT_IMPORT_STRATEGY
      The default import strategy for this component type.
  • Constructor Details

    • TextControl

      public TextControl(Class<V> valueClass)
      Value class constructor with a default data model to represent a given type and a default converter.
      Parameters:
      valueClass - The class indicating the type of value held in the model.
      Throws:
      NullPointerException - if the given value class is null.
    • TextControl

      public TextControl(Class<V> valueClass, V defaultValue)
      Value class and default value constructor with a default data model to represent a given type and a default converter.
      Parameters:
      valueClass - The class indicating the type of value held in the model.
      defaultValue - The default value, which will not be validated.
      Throws:
      NullPointerException - if the given value class is null.
    • TextControl

      public TextControl(Class<V> valueClass, int columnCount)
      Value class and column count constructor with one row and a default converter.
      Parameters:
      valueClass - The class indicating the type of value held in the model.
      columnCount - The requested number of visible columns, or -1 if no column count is specified.
      Throws:
      NullPointerException - if the given value class is null.
    • TextControl

      public TextControl(Class<V> valueClass, int rowCount, int columnCount)
      Value class, row count, and column count constructor with a default converter.
      Parameters:
      valueClass - The class indicating the type of value held in the model.
      rowCount - The requested number of visible rows, or -1 if no row count is specified.
      columnCount - The requested number of visible columns, or -1 if no column count is specified.
      Throws:
      NullPointerException - if the given value class is null.
    • TextControl

      public TextControl(Class<V> valueClass, V defaultValue, int columnCount)
      Value class, defaultValue, and column count constructor with one row a default converter.
      Parameters:
      valueClass - The class indicating the type of value held in the model.
      defaultValue - The default value, which will not be validated.
      columnCount - The requested number of visible columns, or -1 if no column count is specified.
      Throws:
      NullPointerException - if the given value class is null.
    • TextControl

      public TextControl(Class<V> valueClass, V defaultValue, int rowCount, int columnCount)
      Value class, defaultValue, row count, and column count constructor with a default converter.
      Parameters:
      valueClass - The class indicating the type of value held in the model.
      defaultValue - The default value, which will not be validated.
      rowCount - The requested number of visible rows, or -1 if no row count is specified.
      columnCount - The requested number of visible columns, or -1 if no column count is specified.
      Throws:
      NullPointerException - if the given value class is null.
    • TextControl

      public TextControl(Class<V> valueClass, int rowCount, int columnCount, boolean lineWrap)
      Value class, row count, column count, and line wrap constructor with a default converter.
      Parameters:
      valueClass - The class indicating the type of value held in the model.
      rowCount - The requested number of visible rows, or -1 if no row count is specified.
      columnCount - The requested number of visible columns, or -1 if no column count is specified.
      lineWrap - Whether lines should be wrapped in the view if needed.
      Throws:
      NullPointerException - if the given value class is null.
    • TextControl

      public TextControl(Class<V> valueClass, V defaultValue, int rowCount, int columnCount, boolean lineWrap)
      Value class, default value, row count, column count, and line wrap constructor with a default converter.
      Parameters:
      valueClass - The class indicating the type of value held in the model.
      defaultValue - The default value, which will not be validated.
      rowCount - The requested number of visible rows, or -1 if no row count is specified.
      columnCount - The requested number of visible columns, or -1 if no column count is specified.
      lineWrap - Whether lines should be wrapped in the view if needed.
      Throws:
      NullPointerException - if the given value class is null.
    • TextControl

      public TextControl(ValueModel<V> valueModel, int rowCount, int columnCount)
      Value model, row count, and column count constructor with a default converter.
      Parameters:
      valueModel - The component value model.
      rowCount - The requested number of visible rows, or -1 if no row count is specified.
      columnCount - The requested number of visible columns, or -1 if no column count is specified.
      Throws:
      NullPointerException - if the given value model is null.
    • TextControl

      public TextControl(ValueModel<V> valueModel, int rowCount, int columnCount, boolean lineWrap)
      Value model, row count, column count, and line wrap constructor with a default converter.
      Parameters:
      valueModel - The component value model.
      rowCount - The requested number of visible rows, or -1 if no row count is specified.
      columnCount - The requested number of visible columns, or -1 if no column count is specified.
      lineWrap - Whether lines should be wrapped in the view if needed.
      Throws:
      NullPointerException - if the given value model is null.
    • TextControl

      public TextControl(ValueModel<V> valueModel)
      Value model constructor with a default converter.
      Parameters:
      valueModel - The component value model.
      Throws:
      NullPointerException - if the given value model is null.
    • TextControl

      public TextControl(ValueModel<V> valueModel, Converter<V,String> converter)
      Value model and converter constructor.
      Parameters:
      valueModel - The component value model.
      converter - The converter for this component.
      Throws:
      NullPointerException - if the given value model and/or converter is null.
    • TextControl

      public TextControl(ValueModel<V> valueModel, Converter<V,String> converter, int rowCount, int columnCount, boolean lineWrap)
      Value model, converter, row count, column count, and line wrap constructor.
      Parameters:
      valueModel - The component value model.
      converter - The converter for this component.
      rowCount - The requested number of visible rows, or -1 if no row count is specified.
      columnCount - The requested number of visible columns, or -1 if no column count is specified.
      lineWrap - Whether lines should be wrapped in the view if needed.
      Throws:
      NullPointerException - if the given value model and/or converter is null.
    • TextControl

      public TextControl(ValueModel<V> valueModel, Converter<V,String> converter, int rowCount, int columnCount, boolean lineWrap, boolean multiline)
      Value model, converter, row count, column count, and line wrap constructor.
      Parameters:
      valueModel - The component value model.
      converter - The converter for this component.
      rowCount - The requested number of visible rows, or -1 if no row count is specified.
      columnCount - The requested number of visible columns, or -1 if no column count is specified.
      lineWrap - Whether lines should be wrapped in the view if needed.
      multiline - Whether the user should be allowed to enter multiple physical lines if the control has multiple rows.
      Throws:
      NullPointerException - if the given value model and/or converter is null.
  • Method Details

    • isMasked

      public boolean isMasked()
      Returns:
      Whether the user input text is masked to prevent viewing of the literal entered value.
    • setMasked

      public void setMasked(boolean newMasked)
      Sets whether the user input text is masked to prevent viewing of the literal entered value. This is a bound property of type Boolean.
      Parameters:
      newMasked - true if the user input text should be masked.
      See Also:
    • getMaximumLength

      public int getMaximumLength()
      Returns:
      The maximum number of input characters to allow, or -1 if there is no maximum length.
    • setMaximumLength

      public void setMaximumLength(int newMaximumLength)
      Sets the maximum number of input characters to allow. This is a bound property of type Integer.
      Parameters:
      newMaximumLength - The new maximum number of input characters to allow, or -1 if there is no maximum length.
      See Also:
    • isLineWrap

      public boolean isLineWrap()
      Returns:
      Whether lines will be logically wrapped in the view if needed.
    • setLineWrap

      public void setLineWrap(boolean newLineWrap)
      Sets whether lines will be logically wrapped in the view if needed. This is a bound property of type Boolean.
      Parameters:
      newLineWrap - Whether lines should be logically wrapped in the view if needed.
      See Also:
    • isMultiline

      public boolean isMultiline()
      Returns:
      Whether the user is allowed to enter multiple physical lines if the control has multiple rows.
    • setMultiline

      public void setMultiline(boolean newMultiline)
      Sets whether the user is allowed to enter multiple physical lines if the control has multiple rows. This is a bound property of type Boolean.
      Parameters:
      newMultiline - Whether the user should be allowed to enter multiple physical lines if the control has multiple rows.
      See Also:
    • getRowCount

      public int getRowCount()
      Returns:
      The estimated number of rows requested to be visible, or -1 if no row count is specified.
    • setRowCount

      public void setRowCount(int newRowCount)
      Sets the estimated number of rows requested to be visible. This is a bound property of type Integer.
      Parameters:
      newRowCount - The new requested number of visible rows, or -1 if no row count is specified.
      See Also: