Interface ITextFormatter

All Superinterfaces:
java.util.EventListener, org.eclipse.swt.internal.SWTEventListener, org.eclipse.swt.events.VerifyListener
All Known Implementing Classes:
AbstractFormatter, BigDecimalFormatter, BigIntegerFormatter, DateFormatter, DateTimeFormatter, DoubleFormatter, FloatFormatter, IntegerFormatter, IPAddressFormatter, LongFormatter, MaskFormatter, NumberFormatter, PercentFormatter, ShortFormatter, StringFormatter, TimeFormatter

public interface ITextFormatter
extends org.eclipse.swt.events.VerifyListener
Interface defining all the text formatters.

Each formatter is associated with a Text control and can not be shared. Formatters have and edit mask applied when the associated Text has the focus, and a display mask for when the Text looses the focus. The formatter must control editing keystroke by keystroke. For this is it declared as a VerifyListener of the Text widget.

  • Method Summary

    Modifier and Type Method Description
    void detach()
    Called when the formatter is replaced by an other one in the FormattedText control.
    java.lang.String getDisplayString()
    Returns the current value formatted for display.
    java.lang.String getEditString()
    Returns the current value formatted for editing.
    java.lang.Object getValue()
    Returns the current value of the text control.
    java.lang.Class<?> getValueType()
    Returns the type of value this ITextFormatter handles, i.e. returns in getValue().
    boolean isEmpty()
    Returns true if current edited value is empty, else returns false.
    boolean isValid()
    Returns true if current edited value is valid, else returns false.
    void setIgnore​(boolean ignore)
    Specify whether or not VerifyEvent events must be processed.
    void setText​(org.eclipse.swt.widgets.Text text)
    Sets the Text widget that will be managed by this formatter.
    void setValue​(java.lang.Object value)
    Sets the value to edit.

    Methods inherited from interface org.eclipse.swt.events.VerifyListener

    verifyText
  • Method Details

    • detach

      void detach()
      Called when the formatter is replaced by an other one in the FormattedText control. Allow to release resources like additional listeners.
    • getDisplayString

      java.lang.String getDisplayString()
      Returns the current value formatted for display. This method is called by FormattedText when the Text widget looses focus.
      Returns:
      display string
    • getEditString

      java.lang.String getEditString()
      Returns the current value formatted for editing. This method is called by FormattedText when the Text widget gains focus.
      Returns:
      edit string
    • getValue

      java.lang.Object getValue()
      Returns the current value of the text control. If the current value is invalid for its type (ex. Date missing parts), returns null.
      Returns:
      current value
    • getValueType

      java.lang.Class<?> getValueType()
      Returns the type of value this ITextFormatter handles, i.e. returns in getValue().
      Returns:
      The value type.
    • isEmpty

      boolean isEmpty()
      Returns true if current edited value is empty, else returns false. An empty value depends of the formatter and is not just an empty string in the Text widget.
      Returns:
      true if empty, else false
    • isValid

      boolean isValid()
      Returns true if current edited value is valid, else returns false.
      Returns:
      true if valid, else false
    • setIgnore

      void setIgnore​(boolean ignore)
      Specify whether or not VerifyEvent events must be processed. Those events are the base of all formatters, allowing on-the-fly processing of each text change in the Text widget. In some situations (e.g. when focus change), the FormattedText must change the text in the widget without formatting.
      Parameters:
      ignore - when true, VerifyEvent events are processed.
    • setText

      void setText​(org.eclipse.swt.widgets.Text text)
      Sets the Text widget that will be managed by this formatter.
      Parameters:
      text - Text widget
    • setValue

      void setValue​(java.lang.Object value)
      Sets the value to edit.
      Parameters:
      value - value