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 voiddetach()Called when the formatter is replaced by an other one in theFormattedTextcontrol.java.lang.StringgetDisplayString()Returns the current value formatted for display.java.lang.StringgetEditString()Returns the current value formatted for editing.java.lang.ObjectgetValue()Returns the current value of the text control.java.lang.Class<?>getValueType()Returns the type of value thisITextFormatterhandles, i.e. returns ingetValue().booleanisEmpty()Returnstrueif current edited value is empty, else returnsfalse.booleanisValid()Returnstrueif current edited value is valid, else returnsfalse.voidsetIgnore(boolean ignore)Specify whether or notVerifyEventevents must be processed.voidsetText(org.eclipse.swt.widgets.Text text)Sets theTextwidget that will be managed by this formatter.voidsetValue(java.lang.Object value)Sets the value to edit.
-
Method Details
-
detach
void detach()Called when the formatter is replaced by an other one in theFormattedTextcontrol. Allow to release resources like additional listeners. -
getDisplayString
java.lang.String getDisplayString()Returns the current value formatted for display. This method is called byFormattedTextwhen theTextwidget looses focus.- Returns:
- display string
-
getEditString
java.lang.String getEditString()Returns the current value formatted for editing. This method is called byFormattedTextwhen theTextwidget 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), returnsnull.- Returns:
- current value
-
getValueType
java.lang.Class<?> getValueType()Returns the type of value thisITextFormatterhandles, i.e. returns ingetValue().- Returns:
- The value type.
-
isEmpty
boolean isEmpty()Returnstrueif current edited value is empty, else returnsfalse. 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()Returnstrueif current edited value is valid, else returnsfalse.- Returns:
- true if valid, else false
-
setIgnore
void setIgnore(boolean ignore)Specify whether or notVerifyEventevents 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), theFormattedTextmust 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 theTextwidget 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
-