public class StringField extends AbstractField
IField
implementation for String based values.
A validator may also be set with #setValidator(Predicate)
.
changeSupport
PROP_VALUE
Constructor and Description |
---|
StringField(FormToolkit toolkit,
Composite parent,
IFormFieldData model) |
Modifier and Type | Method and Description |
---|---|
void |
apply()
Store the field value in the model.
|
Control |
createControl(FormToolkit toolkit,
Composite parent)
Create the edition control.
|
java.lang.String |
getValidationError()
Default implementation that always return null.
|
protected java.lang.String |
getValidationError(java.lang.String value) |
void |
refresh()
Refresh the value displayed by the field.
|
void |
setValidator(java.util.function.Function<java.lang.String,java.lang.String> validator)
Set a value validator.
|
addPropertyChangeListener, fireValueChanged, getComposite, getControl, getHelpText, getLabel, getModel, isVertical, layout, removePropertyChangeListener, setEditable, setHelpText, setModel, setVertical
public StringField(FormToolkit toolkit, Composite parent, IFormFieldData model)
public void apply()
IField
May throw a runtime exception if the field value is not valid.
apply
in interface IField
apply
in class AbstractField
public Control createControl(FormToolkit toolkit, Composite parent)
AbstractField
createControl
in class AbstractField
toolkit
- the FormToolkit
parent
- the parent compositepublic java.lang.String getValidationError()
AbstractField
Should be redefined if the implementation widget may contain invalid values.
getValidationError
in interface IField
getValidationError
in class AbstractField
IField.apply()
may be called safely, an error message in other cases.public void refresh()
IField
The field will typically query its IFormFieldData
model and refresh its contents.
public void setValidator(java.util.function.Function<java.lang.String,java.lang.String> validator)
validator
- the validator that will be called with the new value.protected java.lang.String getValidationError(java.lang.String value)