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

public abstract class AbstractTextDataBinding<V> extends Object implements AbstractDataBinding<V>
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 Details

    • text

      protected org.eclipse.swt.widgets.Text text
      The bound SWT Text control.
    • strategy

      protected ValidationStrategy<V,String> strategy
      Validation strategy for converting and validating text input. Defaults to an empty string strategy.
    • canBeNull

      protected BooleanSupplier canBeNull
      Supplier determining whether null values are allowed. Defaults to false (null values not allowed).
    • controlDecoration

      protected org.eclipse.jface.fieldassist.ControlDecoration controlDecoration
      Control decoration for displaying validation errors.
    • readonly

      protected boolean readonly
      Flag indicating if the text field is read-only. Defaults to false.
    • background

      protected Function<V,org.eclipse.swt.graphics.Color> 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: AbstractDataBinding
      Executes the binding to push data from model to UI control (target).
      Specified by:
      executeToTarget in interface AbstractDataBinding<V>
    • executeToModel

      public void executeToModel()
      Description copied from interface: AbstractDataBinding
      Executes the binding to pull data from UI control to model.
      Specified by:
      executeToModel in interface AbstractDataBinding<V>
    • createBinding

      public void createBinding()
      Description copied from interface: AbstractDataBinding
      Creates and initializes the data binding.
      Specified by:
      createBinding in interface AbstractDataBinding<V>
    • isSenseless

      protected boolean isSenseless(Object oldValue, Object newValue)
    • enable

      public void enable(boolean enable)
      Description copied from interface: AbstractDataBinding
      Enables or disables the bound control.
      Specified by:
      enable in interface AbstractDataBinding<V>
      Parameters:
      enable - true to enable, false to disable
    • setControl

      public void setControl(Object control)
      Description copied from interface: AbstractDataBinding
      Sets the UI control for this binding.
      Specified by:
      setControl in interface AbstractDataBinding<V>
      Parameters:
      control - The control to bind to
    • canBeNull

      public AbstractTextDataBinding<V> canBeNull(BooleanSupplier 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

      public AbstractTextDataBinding<V> readonly()
      Sets the binding to read-only mode.
      Returns:
      this binding instance for method chaining
    • background

      public AbstractTextDataBinding<V> background(Function<V,org.eclipse.swt.graphics.Color> 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

      public AbstractTextDataBinding<V> strategy(ValidationStrategy<V,String> strategy)
      Sets the validation strategy for this binding.
      Parameters:
      strategy - The validation strategy to use
      Returns:
      this binding instance for method chaining