Class MultiSelectionField<V>

All Implemented Interfaces:
FormElement

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

  • Field Details

    • persistentSelection

      protected final javafx.beans.property.ListProperty<V> persistentSelection
      A MultiSelectionField can have multiple items selected. These items are stored in a ListProperty.
    • selection

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

      protected final List<Validator<javafx.collections.ObservableList<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

    • MultiSelectionField

      protected MultiSelectionField​(javafx.beans.property.ListProperty<V> items, List<Integer> selection)
      The constructor of MultiSelectionField.
      Parameters:
      items - The property that is used to store the items of the field.
      selection - The list of indices of items that are to be selected.
  • Method Details

    • items

      public MultiSelectionField<V> items​(List<V> newValue, List<Integer> 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 MultiSelectionField<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 MultiSelectionField<V> validate​(Validator<javafx.collections.ObservableList<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 MultiSelectionField<V> select​(int index)
      Adds the element at the given index to the current selection.
      Parameters:
      index - The index of the element to be selected.
      Returns:
      Returns the current field to allow for chaining.
    • deselect

      public MultiSelectionField<V> deselect​(int index)
      Removes the element at the given index from the current selection.
      Parameters:
      index - The index of the element to be removed.
      Returns:
      Returns the current field to allow for chaining.
    • bind

      public MultiSelectionField<V> bind​(javafx.beans.property.ListProperty<V> itemsBinding, javafx.beans.property.ListProperty<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 MultiSelectionField<V> unbind​(javafx.beans.property.ListProperty<V> itemsBinding, javafx.beans.property.ListProperty<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<MultiSelectionField<V>>
      Parameters:
      newValue - The new binding mode for the current field.
    • persist

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

      public void reset()
      Sets the field's current selection to its persistent selection, 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,​MultiSelectionField<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<MultiSelectionField<V>>
      Returns:
      Returns whether the user selection is a valid value or not.
    • getSelection

      public javafx.collections.ObservableList<V> getSelection()
      Gets the value of the property selection.
      Property description:
    • selectionProperty

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