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

public Class SingleSelectionField<V>

extends SelectionField<V, SingleSelectionField<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.SimpleComboBoxControl, java.util.ArrayList, .Collections, .List, java.util.stream.Collectors, javafx.beans.binding.Bindings, javafx.beans.property.ListProperty, .ObjectProperty, .SimpleObjectProperty

This class provides an implementation of a SelectionField allowing only for single selection.
Authors
Sacha Schmid, Rinesch Murugathas

Field Summary

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

A SingleSelectionField can only ever have one item selected.

protected final ObjectProperty<V>
protected final List<Validator<V>>
validators

Every field contains a list of validators.

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

Constructor Summary

AccessConstructor and Description
protected
SingleSelectionField(ListProperty<V>
The property that is used to store the items of the field.
items
,
int
The index of the item that is to be selected.
selection
)

The constructor of SingleSelectionField.

Method Summary

Modifier and TypeMethod and Description
public SingleSelectionField<V>

Returns:

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

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

public SingleSelectionField<V>

Returns:

Returns the current field to allow for chaining.
deselect
()

Removes the selection on the current field.

public V
public SingleSelectionField<V>

Returns:

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

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

public SingleSelectionField<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 value in its persistent value.

public void
reset()

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

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

public SingleSelectionField<V>

Returns:

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

Sets the selection to the element at the given index.

public ObjectProperty<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 SingleSelectionField<V>

Returns:

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

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

public final SingleSelectionField<V>

Returns:

Returns the current field to allow for chaining.
validate
(Validator<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 ObjectProperty<V> persistentSelection

A SingleSelectionField can only ever have one item selected. This item is stored in an ObjectProperty.

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

SingleSelectionFieldback to summary
protected SingleSelectionField(ListProperty<V> items, int selection)

The constructor of SingleSelectionField.

Parameters
items:ListProperty<V>

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

selection:int

The index of the item that is to be selected.

Method Detail

bindback to summary
public SingleSelectionField<V> bind(ListProperty<V> itemsBinding, ObjectProperty<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:ObjectProperty<V>

The selection property to be bound with.

Returns:SingleSelectionField<V>

Returns the current field to allow for chaining.

deselectback to summary
public SingleSelectionField<V> deselect()

Removes the selection on the current field.

Returns:SingleSelectionField<V>

Returns the current field to allow for chaining.

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

The new list of items.

newSelection:int

The new pre-defined selection.

Returns:SingleSelectionField<V>

Returns the current field to allow for chaining.

itemsback to summary
public SingleSelectionField<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:SingleSelectionField<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 value in its persistent value. 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 value to its persistent value, thus resetting any changes made by the user.

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

Sets the selection to the element at the given index.

Parameters
index:int

The index of the element to be selected.

Returns:SingleSelectionField<V>

Returns the current field to allow for chaining.

selectionPropertyback to summary
public ObjectProperty<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 SingleSelectionField<V> unbind(ListProperty<V> itemsBinding, ObjectProperty<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:ObjectProperty<V>

The selection property to be unbound with.

Returns:SingleSelectionField<V>

Returns the current field to allow for chaining.

validateback to summary
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:Validator<V>[]

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

Returns:SingleSelectionField<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.