Class AbstractTextDataBinding<V>
java.lang.Object
com.amalgamasimulation.desktop.binding.widgets.AbstractTextDataBinding<V>
- Type Parameters:
V- The type of the model value being bound
- All Implemented Interfaces:
AbstractDataBinding<V>
- Direct Known Subclasses:
AbstractAutoCompleteTextDataBinding,ContainerTextDataBinding,TextDataBinding
Abstract base class for text-based data bindings between SWT
Text controls and model values.
Provides validation, formatting, and visual feedback capabilities for text input bindings.
Key features include:
- Two-way binding between text fields and model values
- Configurable validation strategy
- Null value handling
- Read-only mode support
- Dynamic background coloring
- Automatic validation feedback with error decorations
- Author:
- Ionov Ivan
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionFunction for determining background color based on current value.protected BooleanSupplierSupplier determining whether null values are allowed.protected org.eclipse.jface.fieldassist.ControlDecorationControl decoration for displaying validation errors.protected booleanFlag indicating if the text field is read-only.protected ValidationStrategy<V, String> Validation strategy for converting and validating text input.protected org.eclipse.swt.widgets.TextThe bound SWT Text control. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbackground(Function<V, org.eclipse.swt.graphics.Color> background) Sets the background color provider function.canBeNull(BooleanSupplier canBeNull) Sets whether null values are permitted.voidCreates and initializes the data binding.voidenable(boolean enable) Enables or disables the bound control.voidExecutes the binding to pull data from UI control to model.voidExecutes the binding to push data from model to UI control (target).protected booleanisSenseless(Object oldValue, Object newValue) readonly()Sets the binding to read-only mode.voidsetControl(Object control) Sets the UI control for this binding.strategy(ValidationStrategy<V, String> strategy) Sets the validation strategy for this binding.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.amalgamasimulation.desktop.binding.widgets.AbstractDataBinding
createControlDecoration, doAction, getValue
-
Field Details
-
text
protected org.eclipse.swt.widgets.Text textThe bound SWT Text control. -
strategy
Validation strategy for converting and validating text input. Defaults to an empty string strategy. -
canBeNull
Supplier determining whether null values are allowed. Defaults to false (null values not allowed). -
controlDecoration
protected org.eclipse.jface.fieldassist.ControlDecoration controlDecorationControl decoration for displaying validation errors. -
readonly
protected boolean readonlyFlag indicating if the text field is read-only. Defaults to false. -
background
Function for determining background color based on current value. Defaults to system white color.
-
-
Constructor Details
-
AbstractTextDataBinding
protected AbstractTextDataBinding()
-
-
Method Details
-
executeToTarget
public void executeToTarget()Description copied from interface:AbstractDataBindingExecutes the binding to push data from model to UI control (target).- Specified by:
executeToTargetin interfaceAbstractDataBinding<V>
-
executeToModel
public void executeToModel()Description copied from interface:AbstractDataBindingExecutes the binding to pull data from UI control to model.- Specified by:
executeToModelin interfaceAbstractDataBinding<V>
-
createBinding
public void createBinding()Description copied from interface:AbstractDataBindingCreates and initializes the data binding.- Specified by:
createBindingin interfaceAbstractDataBinding<V>
-
isSenseless
-
enable
public void enable(boolean enable) Description copied from interface:AbstractDataBindingEnables or disables the bound control.- Specified by:
enablein interfaceAbstractDataBinding<V>- Parameters:
enable- true to enable, false to disable
-
setControl
Description copied from interface:AbstractDataBindingSets the UI control for this binding.- Specified by:
setControlin interfaceAbstractDataBinding<V>- Parameters:
control- The control to bind to
-
canBeNull
Sets whether null values are permitted.- Parameters:
canBeNull- Supplier that returns true if null values are allowed- Returns:
- this binding instance for method chaining
-
readonly
Sets the binding to read-only mode.- Returns:
- this binding instance for method chaining
-
background
Sets the background color provider function.- Parameters:
background- Function that returns color based on current value- Returns:
- this binding instance for method chaining
-
strategy
Sets the validation strategy for this binding.- Parameters:
strategy- The validation strategy to use- Returns:
- this binding instance for method chaining
-