java.lang.Object
com.dlsc.formsfx.model.structure.Element<F>
com.dlsc.formsfx.model.structure.Field<F>
com.dlsc.formsfx.model.structure.SelectionField<V,MultiSelectionField<V>>
com.dlsc.formsfx.model.structure.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 Summary
Properties inherited from class com.dlsc.formsfx.model.structure.Field
changed, editable, errorMessages, label, placeholder, required, tooltip, valid -
Field Summary
Fields Modifier and Type Field Description protected javafx.beans.property.ListProperty<V>persistentSelectionAMultiSelectionFieldcan have multiple items selected.protected javafx.beans.property.ListProperty<V>selectionprotected List<Validator<javafx.collections.ObservableList<V>>>validatorsEvery field contains a list of validators.Fields inherited from class com.dlsc.formsfx.model.structure.Field
bindingModeListener, changed, editable, errorMessageKeys, errorMessages, eventHandlers, id, label, labelKey, placeholder, placeholderKey, renderer, rendererSupplier, required, requiredError, requiredErrorKey, span, styleClass, tooltip, tooltipKey, translationService, valid -
Constructor Summary
Constructors Modifier Constructor Description protectedMultiSelectionField(javafx.beans.property.ListProperty<V> items, List<Integer> selection)The constructor ofMultiSelectionField. -
Method Summary
Modifier and Type Method Description 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.MultiSelectionField<V>deselect(int index)Removes the element at the given index from the current selection.javafx.collections.ObservableList<V>getSelection()Gets the value of the property selection.MultiSelectionField<V>items(List<V> newValue)Updates the list of available items to a new list, without a pre-defined selection.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.voidpersist()Stores the field's current selection in its persistent selection.voidreset()Sets the field's current selection to its persistent selection, thus resetting any changes made by the user.MultiSelectionField<V>select(int index)Adds the element at the given index to the current selection.javafx.beans.property.ListProperty<V>selectionProperty()voidsetBindingMode(BindingMode newValue)Activates or deactivates thebindingModeListenerbased on the givenBindingMode.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.booleanvalidate()Validates a user input based on the field's selection and its validation rules.MultiSelectionField<V>validate(Validator<javafx.collections.ObservableList<V>>... newValue)Sets the list of validators for the current field.protected booleanvalidateRequired()Validates that the new field input matches the required condition.Methods inherited from class com.dlsc.formsfx.model.structure.SelectionField
getItems, itemsProperty, validateMethods inherited from class com.dlsc.formsfx.model.structure.Field
addEventHandler, changedProperty, editable, editableProperty, errorMessagesProperty, fireEvent, getErrorMessages, getLabel, getLabelDescription, getPlaceholder, getRenderer, getTooltip, getValueDescription, hasChanged, isEditable, isI18N, isRequired, isValid, label, labelDescription, labelDescription, labelProperty, ofBooleanType, ofBooleanType, ofDate, ofDate, ofDoubleType, ofDoubleType, ofIntegerType, ofIntegerType, ofMultiSelectionType, ofMultiSelectionType, ofMultiSelectionType, ofPasswordType, ofPasswordType, ofSingleSelectionType, ofSingleSelectionType, ofSingleSelectionType, ofStringType, ofStringType, placeholder, placeholderProperty, removeEventHandler, render, render, required, required, requiredProperty, tooltip, tooltipProperty, translate, updateElement, validProperty, valueDescription, valueDescriptionMethods inherited from class com.dlsc.formsfx.model.structure.Element
getID, getSpan, getStyleClass, id, idProperty, span, span, spanProperty, styleClass, styleClassProperty
-
Property Details
-
selection
- See Also:
getSelection()
-
-
Field Details
-
persistentSelection
AMultiSelectionFieldcan have multiple items selected. These items are stored in aListProperty. -
selection
-
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 ofMultiSelectionField.- 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
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
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
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
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
Activates or deactivates thebindingModeListenerbased on the givenBindingMode.- Specified by:
setBindingModein classField<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:
validateRequiredin classSelectionField<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 therequiredflag. This method directly updates thevalidproperty.- Specified by:
validatein classField<MultiSelectionField<V>>- Returns:
- Returns whether the user selection is a valid value or not.
-
getSelection
Gets the value of the property selection.- Property description:
-
selectionProperty
- See Also:
getSelection()
-