Class IPAddressFormatter
java.lang.Object
org.eclipse.nebula.widgets.formattedtext.AbstractFormatter
org.eclipse.nebula.widgets.formattedtext.IPAddressFormatter
- All Implemented Interfaces:
java.util.EventListener,ITextFormatter,org.eclipse.swt.events.VerifyListener,org.eclipse.swt.internal.SWTEventListener
public class IPAddressFormatter extends AbstractFormatter
-
Field Summary
Fields Modifier and Type Field Description protected org.eclipse.swt.widgets.ListenerkeyListenerKey listenerFields inherited from class org.eclipse.nebula.widgets.formattedtext.AbstractFormatter
EMPTY, ignore, SPACE, text -
Constructor Summary
Constructors Constructor Description IPAddressFormatter()An empty constructer.
An ip address will have an unique format,so there is no necessary to offer an new format -
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 input.java.lang.ObjectgetValue()Returns the current value of the text control if it is a valid ip address.
If invalid, returnsnull.java.lang.Class<java.lang.String>getValueType()Returns the type of value thisITextFormatterhandles, i.e. returns inITextFormatter.getValue().booleanisEmpty()Returnstrueif current edited value is empty, else returnsfalse.booleanisValid()Returnstrueif current edited value is valid, else returnsfalse.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.voidverifyText(org.eclipse.swt.events.VerifyEvent e)Methods inherited from class org.eclipse.nebula.widgets.formattedtext.AbstractFormatter
beep, setIgnore, updateText, updateText
-
Field Details
-
keyListener
protected org.eclipse.swt.widgets.Listener keyListenerKey listener
-
-
Constructor Details
-
IPAddressFormatter
public IPAddressFormatter()An empty constructer.
An ip address will have an unique format,so there is no necessary to offer an new format
-
-
Method Details
-
detach
public void detach()Called when the formatter is replaced by an other one in theFormattedTextcontrol. Allow to release ressources like additionnal listeners.Removes the
KeyListeneron the text widget.- Specified by:
detachin interfaceITextFormatter- Overrides:
detachin classAbstractFormatter- See Also:
ITextFormatter.detach()
-
setText
public void setText(org.eclipse.swt.widgets.Text text)Sets theTextwidget that will be managed by this formatter.The ancestor is overrided to add a key listener on the text widget.
- Specified by:
setTextin interfaceITextFormatter- Overrides:
setTextin classAbstractFormatter- Parameters:
text- Text widget- See Also:
ITextFormatter.setText(Text)
-
getDisplayString
public java.lang.String getDisplayString()Returns the current value formatted for display. This method is called byFormattedTextwhen theTextwidget 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.- Returns:
- display string if valid, edit string else
- See Also:
ITextFormatter.getDisplayString()
-
getEditString
public java.lang.String getEditString()Returns the current value formatted for input. This method is called byFormattedTextwhen theTextwidget gains focus. The value returned is the content of the StringBuilder used as cache.- Returns:
- edit string
- See Also:
ITextFormatter.getEditString()
-
getValue
public java.lang.Object getValue()Returns the current value of the text control if it is a valid ip address.
If invalid, returnsnull.- Returns:
- current ip address if valid in which the spaces has been removed,
nullelse - See Also:
ITextFormatter.getValue()
-
isValid
public boolean isValid()Returnstrueif current edited value is valid, else returnsfalse.- Returns:
- true if valid, else false
- See Also:
ITextFormatter.isValid()
-
setValue
public void setValue(java.lang.Object value)Sets the value to edit. The value provided must be a valid ip address in String format.- Parameters:
value- new ip address- Throws:
java.lang.IllegalArgumentException- if not an invalid ip- See Also:
ITextFormatter.setValue(java.lang.Object)
-
verifyText
public void verifyText(org.eclipse.swt.events.VerifyEvent e) -
getValueType
public java.lang.Class<java.lang.String> getValueType()Description copied from interface:ITextFormatterReturns the type of value thisITextFormatterhandles, i.e. returns inITextFormatter.getValue().- Returns:
- The value type.
-
isEmpty
public boolean isEmpty()Description copied from interface:ITextFormatterReturnstrueif 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
-