Class StringFormatter

java.lang.Object
org.eclipse.nebula.widgets.formattedtext.AbstractFormatter
org.eclipse.nebula.widgets.formattedtext.StringFormatter
All Implemented Interfaces:
java.util.EventListener, ITextFormatter, org.eclipse.swt.events.VerifyListener, org.eclipse.swt.internal.SWTEventListener

public class StringFormatter
extends AbstractFormatter
Default formatter for the String class.
This formatter is a kind of NullFormatter and do no formatting, allowing the edit of simple String values, without constraints.
It is registered in the DefaultFormatterFactory as the default formatter for String values.
  • Field Summary

    Fields inherited from class org.eclipse.nebula.widgets.formattedtext.AbstractFormatter

    EMPTY, ignore, SPACE, text
  • Constructor Summary

    Constructors 
    Constructor Description
    StringFormatter()  
  • Method Summary

    Modifier and Type Method Description
    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.
    This formatter has no formatting features.
    java.lang.Class<java.lang.String> getValueType()
    Returns the type of value this ITextFormatter handles, i.e. returns in getValue().
    A StringFormatter always returns a String value.
    boolean isEmpty()
    Returns true if current edited value is empty, else returns false.
    A string is empty if its length is 0.
    boolean isValid()
    Returns true if current edited value is valid, else returns false.
    StringFormatter always return true.
    void setValue​(java.lang.Object value)
    Sets the value to edit.
    void verifyText​(org.eclipse.swt.events.VerifyEvent e)
    Handles a VerifyEvent sent when the text is about to be modified.

    Methods inherited from class org.eclipse.nebula.widgets.formattedtext.AbstractFormatter

    beep, detach, setIgnore, setText, updateText, updateText

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getDisplayString

      public java.lang.String getDisplayString()
      Returns the current value formatted for display.

      There is no difference in this formatter between edit and display values. So this method returns the edit string.

      Returns:
      display string
      See Also:
      ITextFormatter.getDisplayString()
    • getEditString

      public java.lang.String getEditString()
      Returns the current value formatted for editing. This method is called by FormattedText when the Text widget gains focus.
      This formatter has no formatting features. So it simply return the Text widget content.
      Returns:
      edit string
      See Also:
      ITextFormatter.getEditString()
    • getValue

      public java.lang.Object getValue()
      Returns the current value.
      This formatter has no formatting features. So it simply return the Text widget content.
      Returns:
      current string value
      See Also:
      ITextFormatter.getValue()
    • getValueType

      public java.lang.Class<java.lang.String> getValueType()
      Returns the type of value this ITextFormatter handles, i.e. returns in getValue().
      A StringFormatter always returns a String value.
      Returns:
      The value type.
    • isEmpty

      public boolean isEmpty()
      Returns true if current edited value is empty, else returns false.
      A string is empty if its length is 0.
      Returns:
      true if empty, else false
    • isValid

      public boolean isValid()
      Returns true if current edited value is valid, else returns false.
      StringFormatter always return true.
      Returns:
      true
      See Also:
      ITextFormatter.isValid()
    • setValue

      public void setValue​(java.lang.Object value)
      Sets the value to edit. The value provided must be a String. The Text widget is simply updated with the value.
      Parameters:
      value - string value
      Throws:
      java.lang.IllegalArgumentException - if not a string
      See Also:
      ITextFormatter.setValue(java.lang.Object)
    • verifyText

      public void verifyText​(org.eclipse.swt.events.VerifyEvent e)
      Handles a VerifyEvent sent when the text is about to be modified. This method is the entry point of all operations of formatting.
      This formatter has no formatting features. So this method do nothing.
      See Also:
      VerifyListener.verifyText(org.eclipse.swt.events.VerifyEvent)