java.lang.Object
com.dlsc.formsfx.model.structure.Element<F>
com.dlsc.formsfx.model.structure.Field<F>
com.dlsc.formsfx.model.structure.SelectionField<V,SingleSelectionField<V>>
com.dlsc.formsfx.model.structure.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 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.ObjectProperty<V>persistentSelectionASingleSelectionFieldcan only ever have one item selected.protected javafx.beans.property.ObjectProperty<V>selectionprotected List<Validator<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 protectedSingleSelectionField(javafx.beans.property.ListProperty<V> items, int selection)The constructor ofSingleSelectionField. -
Method Summary
Modifier and Type Method Description 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.SingleSelectionField<V>deselect()Removes the selection on the current field.VgetSelection()Gets the value of the property selection.SingleSelectionField<V>items(List<V> newValue)Updates the list of available items to a new list, without a pre-defined selection.SingleSelectionField<V>items(List<V> newValue, int newSelection)Updates the list of available items to a new list, along with a pre-defined selection.voidpersist()Stores the field's current value in its persistent value.voidreset()Sets the field's current value to its persistent value, thus resetting any changes made by the user.SingleSelectionField<V>select(int index)Sets the selection to the element at the given index.javafx.beans.property.ObjectProperty<V>selectionProperty()voidsetBindingMode(BindingMode newValue)Activates or deactivates thebindingModeListenerbased on the givenBindingMode.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.booleanvalidate()Validates a user input based on the field's selection and its validation rules.SingleSelectionField<V>validate(Validator<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
ASingleSelectionFieldcan only ever have one item selected. This item is stored in anObjectProperty. -
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
-
SingleSelectionField
The constructor ofSingleSelectionField.- 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
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
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
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
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
Activates or deactivates thebindingModeListenerbased on the givenBindingMode.- Specified by:
setBindingModein classField<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:
validateRequiredin classSelectionField<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 therequiredflag. This method directly updates thevalidproperty.- Specified by:
validatein classField<SingleSelectionField<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()
-