Class SingleSelectionField<V>

All Implemented Interfaces:
FormElement

public class SingleSelectionField<V>
extends SelectionField<V,​SingleSelectionField<V>>
This class provides an implementation of a SelectionField allowing only for single selection.
Author:
Sacha Schmid, Rinesch Murugathas
  • Property Details

  • Field Details

    • persistentSelection

      protected final javafx.beans.property.ObjectProperty<V> persistentSelection
      A SingleSelectionField can only ever have one item selected. This item is stored in an ObjectProperty.
    • selection

      protected final javafx.beans.property.ObjectProperty<V> selection
    • validators

      protected final List<Validator<V>> validators
      Every field contains a list of validators. The validators are limited to the ones that correspond to the field's type.
  • Constructor Details

    • SingleSelectionField

      protected SingleSelectionField​(javafx.beans.property.ListProperty<V> items, int selection)
      The constructor of SingleSelectionField.
      Parameters:
      items - The property that is used to store the items of the field.
      selection - The index of the item that is to be selected.
  • Method Details

    • items

      public SingleSelectionField<V> items​(List<V> newValue, int newSelection)
      Updates the list of available items to a new list, along with a pre-defined selection.
      Parameters:
      newValue - The new list of items.
      newSelection - The new pre-defined selection.
      Returns:
      Returns the current field to allow for chaining.
    • items

      public SingleSelectionField<V> items​(List<V> newValue)
      Updates the list of available items to a new list, without a pre-defined selection.
      Parameters:
      newValue - The new list of items.
      Returns:
      Returns the current field to allow for chaining.
    • validate

      @SafeVarargs public final SingleSelectionField<V> validate​(Validator<V>... newValue)
      Sets the list of validators for the current field. This overrides all validators that have previously been added.
      Parameters:
      newValue - The validators that are to be used for validating this field.
      Returns:
      Returns the current field to allow for chaining.
    • select

      public SingleSelectionField<V> select​(int index)
      Sets the selection to the element at the given index.
      Parameters:
      index - The index of the element to be selected.
      Returns:
      Returns the current field to allow for chaining.
    • deselect

      public SingleSelectionField<V> deselect()
      Removes the selection on the current field.
      Returns:
      Returns the current field to allow for chaining.
    • bind

      public SingleSelectionField<V> bind​(javafx.beans.property.ListProperty<V> itemsBinding, javafx.beans.property.ObjectProperty<V> selectionBinding)
      Binds the given items and selection property with the corresponding elements.
      Parameters:
      itemsBinding - The items property to be bound with.
      selectionBinding - The selection property to be bound with.
      Returns:
      Returns the current field to allow for chaining.
    • unbind

      public SingleSelectionField<V> unbind​(javafx.beans.property.ListProperty<V> itemsBinding, javafx.beans.property.ObjectProperty<V> selectionBinding)
      Unbinds the given items and selection property with the corresponding elements.
      Parameters:
      itemsBinding - The items property to be unbound with.
      selectionBinding - The selection property to be unbound with.
      Returns:
      Returns the current field to allow for chaining.
    • setBindingMode

      public void setBindingMode​(BindingMode newValue)
      Activates or deactivates the bindingModeListener based on the given BindingMode.
      Specified by:
      setBindingMode in class Field<SingleSelectionField<V>>
      Parameters:
      newValue - The new binding mode for the current field.
    • persist

      public void persist()
      Stores the field's current value in its persistent value. This stores the user's changes in the model.
    • reset

      public void reset()
      Sets the field's current value to its persistent value, thus resetting any changes made by the user.
    • validateRequired

      protected boolean validateRequired()
      Validates that the new field input matches the required condition.
      Specified by:
      validateRequired in class SelectionField<V,​SingleSelectionField<V>>
      Returns:
      Returns whether the input matches the required condition.
    • validate

      public boolean validate()
      Validates a user input based on the field's selection and its validation rules. Also considers the required flag. This method directly updates the valid property.
      Specified by:
      validate in class Field<SingleSelectionField<V>>
      Returns:
      Returns whether the user selection is a valid value or not.
    • getSelection

      public V getSelection()
      Gets the value of the property selection.
      Property description:
    • selectionProperty

      public javafx.beans.property.ObjectProperty<V> selectionProperty()
      See Also:
      getSelection()