public class StringField extends AbstractField
IField implementation for String based values.
A validator may also be set with #setValidator(Predicate).
changeSupportPROP_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, setVerticalpublic StringField(FormToolkit toolkit,
Composite parent,
IFormFieldData model)
public void apply()
IFieldMay throw a runtime exception if the field value is not valid.
apply in interface IFieldapply in class AbstractFieldpublic Control createControl(FormToolkit toolkit,
Composite parent)
AbstractFieldcreateControl in class AbstractFieldtoolkit - the FormToolkitparent - the parent compositepublic java.lang.String getValidationError()
AbstractFieldShould be redefined if the implementation widget may contain invalid values.
getValidationError in interface IFieldgetValidationError in class AbstractFieldIField.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)