public class IPAddressFormatter extends AbstractFormatter
Modifier and Type | Field and Description |
---|---|
protected org.eclipse.swt.widgets.Listener |
keyListener
Key listener
|
EMPTY, ignore, SPACE, text
Constructor and Description |
---|
IPAddressFormatter()
An empty constructer.
An ip address will have an unique format,so there is no necessary to offer an new format |
Modifier and Type | Method and 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 input.
|
java.lang.Object |
getValue()
Returns the current value of the text control if it is a valid ip address.
If invalid, returns null . |
java.lang.Class<java.lang.String> |
getValueType()
Returns the type of value this
ITextFormatter handles,
i.e. |
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 |
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.
|
void |
verifyText(org.eclipse.swt.events.VerifyEvent e) |
beep, setIgnore, updateText, updateText
public IPAddressFormatter()
public void detach()
FormattedText
control. Allow to release ressources like additionnal listeners.
Removes the KeyListener
on the text widget.
detach
in interface ITextFormatter
detach
in class AbstractFormatter
ITextFormatter.detach()
public void setText(org.eclipse.swt.widgets.Text text)
Text
widget that will be managed by this formatter.
The ancestor is overrided to add a key listener on the text widget.
setText
in interface ITextFormatter
setText
in class AbstractFormatter
text
- Text widgetITextFormatter.setText(Text)
public java.lang.String getDisplayString()
FormattedText
when the Text
widget looses focus.
In case the input is invalid (eg. not an invalid ip address), the edit
string is returned in place of the display string.ITextFormatter.getDisplayString()
public java.lang.String getEditString()
FormattedText
when the Text
widget gains focus.
The value returned is the content of the StringBuilder used as cache.ITextFormatter.getEditString()
public java.lang.Object getValue()
null
.null
elseITextFormatter.getValue()
public boolean isValid()
true
if current edited value is valid, else returns
false
.ITextFormatter.isValid()
public void setValue(java.lang.Object value)
value
- new ip addressjava.lang.IllegalArgumentException
- if not an invalid ipITextFormatter.setValue(java.lang.Object)
public void verifyText(org.eclipse.swt.events.VerifyEvent e)
public java.lang.Class<java.lang.String> getValueType()
ITextFormatter
ITextFormatter
handles,
i.e. returns in ITextFormatter.getValue()
.public boolean isEmpty()
ITextFormatter
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.