Top Description Fields Constructors Methods
com.dlsc.formsfx.model.structure

public Class MultiSelectionField<V>

extends SelectionField<V, MultiSelectionField<V>>
Class Inheritance
Imports
com.dlsc.formsfx.model.event.FieldEvent, com.dlsc.formsfx.model.util.BindingMode, com.dlsc.formsfx.model.validators.ValidationResult, .Validator, com.dlsc.formsfx.view.controls.SimpleListViewControl, java.util.ArrayList, .Collections, .List, java.util.stream.Collectors, javafx.beans.binding.Bindings, javafx.beans.property.ListProperty, .SimpleListProperty, javafx.collections.FXCollections, .ObservableList

This class provides an implementation of a MultiSelectionField allowing for multi-selection.
Authors
Sacha Schmid, Rinesch Murugathas

Field Summary

Modifier and TypeField and Description
protected final ListProperty<V>
persistentSelection

A MultiSelectionField can have multiple items selected.

protected final ListProperty<V>
protected final List<Validator<ObservableList<V>>>
validators

Every field contains a list of validators.

Inherited from com.dlsc.formsfx.model.structure.SelectionField:
items

Constructor Summary

AccessConstructor and Description
protected
MultiSelectionField(ListProperty<V>
The property that is used to store the items of the field.
items
,
List<Integer>
The list of indices of items that are to be selected.
selection
)

The constructor of MultiSelectionField.

Method Summary

Modifier and TypeMethod and Description
public MultiSelectionField<V>

Returns:

Returns the current field to allow for chaining.
bind
(ListProperty<V>
The items property to be bound with.
itemsBinding
,
ListProperty<V>
The selection property to be bound with.
selectionBinding
)

Binds the given items and selection property with the corresponding elements.

public MultiSelectionField<V>

Returns:

Returns the current field to allow for chaining.
deselect
(int
The index of the element to be removed.
index
)

Removes the element at the given index from the current selection.

public ObservableList<V>
public MultiSelectionField<V>

Returns:

Returns the current field to allow for chaining.
items
(List<V>
The new list of items.
newValue
,
List<Integer>
The new pre-defined selection.
newSelection
)

Updates the list of available items to a new list, along with a pre-defined selection.

public MultiSelectionField<V>

Returns:

Returns the current field to allow for chaining.
items
(List<V>
The new list of items.
newValue
)

Updates the list of available items to a new list, without a pre-defined selection.

public void
persist()

Implements com.dlsc.formsfx.model.structure.FormElement.persist.

Stores the field's current selection in its persistent selection.

public void
reset()

Implements com.dlsc.formsfx.model.structure.FormElement.reset.

Sets the field's current selection to its persistent selection, thus resetting any changes made by the user.

public MultiSelectionField<V>

Returns:

Returns the current field to allow for chaining.
select
(int
The index of the element to be selected.
index
)

Adds the element at the given index to the current selection.

public ListProperty<V>
public void
setBindingMode(BindingMode
The new binding mode for the current field.
newValue
)

Implements abstract com.dlsc.formsfx.model.structure.Field.setBindingMode.

Activates or deactivates the bindingModeListener based on the given BindingMode.

public MultiSelectionField<V>

Returns:

Returns the current field to allow for chaining.
unbind
(ListProperty<V>
The items property to be unbound with.
itemsBinding
,
ListProperty<V>
The selection property to be unbound with.
selectionBinding
)

Unbinds the given items and selection property with the corresponding elements.

public final MultiSelectionField<V>

Returns:

Returns the current field to allow for chaining.
validate
(Validator<ObservableList<V>>...
The validators that are to be used for validating this field.
newValue
)

Sets the list of validators for the current field.

public boolean

Returns:

Returns whether the user selection is a valid value or not.
validate
()

Implements abstract com.dlsc.formsfx.model.structure.Field.validate.

Validates a user input based on the field's selection and its validation rules.

protected boolean
validateRequired()

Implements abstract com.dlsc.formsfx.model.structure.SelectionField.validateRequired.

Validates that the new field input matches the required condition.

Inherited from com.dlsc.formsfx.model.structure.SelectionField:
getItemsitemsPropertyvalidate

Field Detail

persistentSelectionback to summary
protected final ListProperty<V> persistentSelection

A MultiSelectionField can have multiple items selected. These items are stored in a ListProperty.

selectionback to summary
protected final ListProperty<V> selection
validatorsback to summary
protected final List<Validator<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 Detail

MultiSelectionFieldback to summary
protected MultiSelectionField(ListProperty<V> items, List<Integer> selection)

The constructor of MultiSelectionField.

Parameters
items:ListProperty<V>

The property that is used to store the items of the field.

selection:List<Integer>

The list of indices of items that are to be selected.

Method Detail

bindback to summary
public MultiSelectionField<V> bind(ListProperty<V> itemsBinding, ListProperty<V> selectionBinding)

Binds the given items and selection property with the corresponding elements.

Parameters
itemsBinding:ListProperty<V>

The items property to be bound with.

selectionBinding:ListProperty<V>

The selection property to be bound with.

Returns:MultiSelectionField<V>

Returns the current field to allow for chaining.

deselectback to summary
public MultiSelectionField<V> deselect(int index)

Removes the element at the given index from the current selection.

Parameters
index:int

The index of the element to be removed.

Returns:MultiSelectionField<V>

Returns the current field to allow for chaining.

getSelectionback to summary
public ObservableList<V> getSelection()
itemsback to summary
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:List<V>

The new list of items.

newSelection:List<Integer>

The new pre-defined selection.

Returns:MultiSelectionField<V>

Returns the current field to allow for chaining.

itemsback to summary
public MultiSelectionField<V> items(List<V> newValue)

Updates the list of available items to a new list, without a pre-defined selection.

Parameters
newValue:List<V>

The new list of items.

Returns:MultiSelectionField<V>

Returns the current field to allow for chaining.

persistback to summary
public void persist()

Implements com.dlsc.formsfx.model.structure.FormElement.persist.

Stores the field's current selection in its persistent selection. This stores the user's changes in the model.

resetback to summary
public void reset()

Implements com.dlsc.formsfx.model.structure.FormElement.reset.

Sets the field's current selection to its persistent selection, thus resetting any changes made by the user.

selectback to summary
public MultiSelectionField<V> select(int index)

Adds the element at the given index to the current selection.

Parameters
index:int

The index of the element to be selected.

Returns:MultiSelectionField<V>

Returns the current field to allow for chaining.

selectionPropertyback to summary
public ListProperty<V> selectionProperty()
setBindingModeback to summary
public void setBindingMode(BindingMode newValue)

Implements abstract com.dlsc.formsfx.model.structure.Field.setBindingMode.

Doc from com.dlsc.formsfx.model.structure.Field.setBindingMode.

Activates or deactivates the bindingModeListener based on the given BindingMode.

Parameters
newValue:BindingMode

The new binding mode for the current field.

unbindback to summary
public MultiSelectionField<V> unbind(ListProperty<V> itemsBinding, ListProperty<V> selectionBinding)

Unbinds the given items and selection property with the corresponding elements.

Parameters
itemsBinding:ListProperty<V>

The items property to be unbound with.

selectionBinding:ListProperty<V>

The selection property to be unbound with.

Returns:MultiSelectionField<V>

Returns the current field to allow for chaining.

validateback to summary
public final MultiSelectionField<V> validate(Validator<ObservableList<V>>... newValue)

Sets the list of validators for the current field. This overrides all validators that have previously been added.

Parameters
newValue:Validator<ObservableList<V>>[]

The validators that are to be used for validating this field.

Returns:MultiSelectionField<V>

Returns the current field to allow for chaining.

Annotations
@SafeVarargs
validateback to summary
public boolean validate()

Implements abstract com.dlsc.formsfx.model.structure.Field.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.

Returns:boolean

Returns whether the user selection is a valid value or not.

validateRequiredback to summary
protected boolean validateRequired()

Implements abstract com.dlsc.formsfx.model.structure.SelectionField.validateRequired.

Doc from com.dlsc.formsfx.model.structure.SelectionField.validateRequired.

Validates that the new field input matches the required condition.

Returns:boolean

Returns whether the input matches the required condition.