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 theFormattedText
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 thisITextFormatter
handles, i.e. returns ingetValue()
.boolean
isEmpty()
Returnstrue
if current edited value is empty, else returnsfalse
.boolean
isValid()
Returnstrue
if current edited value is valid, else returnsfalse
.void
setIgnore(boolean ignore)
Specify whether or notVerifyEvent
events must be processed.void
setText(org.eclipse.swt.widgets.Text text)
Sets theText
widget that will be managed by this formatter.void
setValue(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 theFormattedText
control. Allow to release resources like additional listeners. -
getDisplayString
java.lang.String getDisplayString()Returns the current value formatted for display. This method is called byFormattedText
when theText
widget looses focus.- Returns:
- display string
-
getEditString
java.lang.String getEditString()Returns the current value formatted for editing. This method is called byFormattedText
when theText
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), returnsnull
.- Returns:
- current value
-
getValueType
java.lang.Class<?> getValueType()Returns the type of value thisITextFormatter
handles, i.e. returns ingetValue()
.- Returns:
- The value type.
-
isEmpty
boolean isEmpty()Returnstrue
if 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()Returnstrue
if current edited value is valid, else returnsfalse
.- Returns:
- true if valid, else false
-
setIgnore
void setIgnore(boolean ignore)Specify whether or notVerifyEvent
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), theFormattedText
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 theText
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
-