Class AbstractFormatter

java.lang.Object
org.eclipse.nebula.widgets.formattedtext.AbstractFormatter
All Implemented Interfaces:
java.util.EventListener, ITextFormatter, org.eclipse.swt.events.VerifyListener, org.eclipse.swt.internal.SWTEventListener
Direct Known Subclasses:
DateTimeFormatter, IPAddressFormatter, MaskFormatter, NumberFormatter, StringFormatter

public abstract class AbstractFormatter
extends java.lang.Object
implements ITextFormatter
Base class of formatters. Formatters can directly implement ITextFormatter, or inherit this abstract class.

Provide several common functionalities and constants for the formatters.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected static java.lang.String EMPTY
    Empty String
    protected boolean ignore
    Flag indicating if VerifyEvent must be ignored (true) or not (false)
    protected static char SPACE
    Space character
    protected org.eclipse.swt.widgets.Text text
    Managed Text widget
  • Constructor Summary

    Constructors 
    Constructor Description
    AbstractFormatter()  
  • Method Summary

    Modifier and Type Method Description
    protected void beep()
    Emits an audio beep.
    void detach()
    Called when the formatter is replaced by an other one in the FormattedText control.
    void setIgnore​(boolean ignore)
    Sets the ignore flag.
    void setText​(org.eclipse.swt.widgets.Text text)
    Sets the Text widget that will be managed by this formatter.
    protected void updateText​(java.lang.String t)
    Updates the text in the Text widget.
    protected void updateText​(java.lang.String t, int pos)
    Updates the text in the Text widget.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.eclipse.nebula.widgets.formattedtext.ITextFormatter

    getDisplayString, getEditString, getValue, getValueType, isEmpty, isValid, setValue

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

    verifyText
  • Field Details

    • SPACE

      protected static final char SPACE
      Space character
      See Also:
      Constant Field Values
    • EMPTY

      protected static final java.lang.String EMPTY
      Empty String
      See Also:
      Constant Field Values
    • text

      protected org.eclipse.swt.widgets.Text text
      Managed Text widget
    • ignore

      protected boolean ignore
      Flag indicating if VerifyEvent must be ignored (true) or not (false)
  • Constructor Details

  • Method Details

    • beep

      protected void beep()
      Emits an audio beep.
    • detach

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

      By default, do nothing. Override if needed.

      Specified by:
      detach in interface ITextFormatter
      See Also:
      ITextFormatter.detach()
    • setIgnore

      public void setIgnore​(boolean ignore)
      Sets the ignore flag.
      Specified by:
      setIgnore in interface ITextFormatter
      Parameters:
      ignore - when true, VerifyEvent events are processed.
      See Also:
      ITextFormatter.setIgnore(boolean)
    • setText

      public void setText​(org.eclipse.swt.widgets.Text text)
      Sets the Text widget that will be managed by this formatter.
      Specified by:
      setText in interface ITextFormatter
      Parameters:
      text - Text widget
      See Also:
      ITextFormatter.setText(Text)
    • updateText

      protected void updateText​(java.lang.String t)
      Updates the text in the Text widget. The absolute position of the cursor in the widget is preserved.
      Parameters:
      t - new text
    • updateText

      protected void updateText​(java.lang.String t, int pos)
      Updates the text in the Text widget. The cursor is set to the given position.
      Parameters:
      t - new text
      pos - new cursor's position