Class CustomMultipleSelectionModel<T>
java.lang.Object
javafx.scene.control.SelectionModel<T>
javafx.scene.control.MultipleSelectionModel<T>
com.dlsc.gemsfx.util.CustomMultipleSelectionModel<T>
- Type Parameters:
T- the type of the items contained in the selection model.
public class CustomMultipleSelectionModel<T>
extends javafx.scene.control.MultipleSelectionModel<T>
CustomMultipleSelectionModel allows for managing the selection state of items in an ObservableList.
It extends from MultipleSelectionModel and adds functionality to maintain a weak reference to the
items list, facilitating the handling of list changes and ensuring selection consistency.
-
Property Summary
PropertiesTypePropertyDescriptionfinal javafx.beans.property.ListProperty<T> The items available for selection.Properties inherited from class javafx.scene.control.MultipleSelectionModel
selectionModeProperties inherited from class javafx.scene.control.SelectionModel
selectedIndex, selectedItem -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAndSelect(int index) Clears the current selection and selects the item at the given index.voidClears the current selection.voidclearSelection(int index) Clears the selection for the given index.final javafx.collections.ObservableList<T> getItems()Gets the value of theitemsproperty.javafx.collections.ObservableList<Integer> Returns the selected indices.javafx.collections.ObservableList<T> Returns the selected items.booleanisEmpty()Checks whether no items are currently selected.booleanisSelected(int index) Checks whether the given index is selected.final javafx.beans.property.ListProperty<T> The items available for selection.voidselect(int index) Selects the item at the given index.voidSelects the given item.voidSelects all items.voidSelects the first item.voidselectIndices(int index, int... indices) Selects the given indices.voidSelects the last item.voidSelects the next item.voidSelects the previous item.final voidSets the value of theitemsproperty.Methods inherited from class javafx.scene.control.MultipleSelectionModel
getSelectionMode, selectionModeProperty, selectRange, setSelectionModeMethods inherited from class javafx.scene.control.SelectionModel
getSelectedIndex, getSelectedItem, selectedIndexProperty, selectedItemProperty, setSelectedIndex, setSelectedItem
-
Property Details
-
items
The items available for selection.- See Also:
-
-
Constructor Details
-
CustomMultipleSelectionModel
public CustomMultipleSelectionModel()Creates a new selection model.
-
-
Method Details
-
getItems
Gets the value of theitemsproperty.- Property description:
- The items available for selection.
- Returns:
- the value of the
itemsproperty - See Also:
-
setItems
Sets the value of theitemsproperty.- Property description:
- The items available for selection.
- Parameters:
value- the value for theitemsproperty- See Also:
-
itemsProperty
The items available for selection.- Returns:
- the items property
- See Also:
-
getSelectedIndices
-
getSelectedItems
-
selectIndices
public void selectIndices(int index, int... indices) Selects the given indices.- Specified by:
selectIndicesin classjavafx.scene.control.MultipleSelectionModel<T>- Parameters:
index- the first index to selectindices- the additional indices to select
-
selectAll
public void selectAll()Selects all items.- Specified by:
selectAllin classjavafx.scene.control.MultipleSelectionModel<T>
-
clearAndSelect
public void clearAndSelect(int index) Clears the current selection and selects the item at the given index.- Specified by:
clearAndSelectin classjavafx.scene.control.SelectionModel<T>- Parameters:
index- the index to select
-
select
public void select(int index) Selects the item at the given index.- Specified by:
selectin classjavafx.scene.control.SelectionModel<T>- Parameters:
index- the index to select
-
select
-
clearSelection
public void clearSelection(int index) Clears the selection for the given index.- Specified by:
clearSelectionin classjavafx.scene.control.SelectionModel<T>- Parameters:
index- the index to clear
-
clearSelection
public void clearSelection()Clears the current selection.- Specified by:
clearSelectionin classjavafx.scene.control.SelectionModel<T>
-
isSelected
public boolean isSelected(int index) Checks whether the given index is selected.- Specified by:
isSelectedin classjavafx.scene.control.SelectionModel<T>- Parameters:
index- the index to check- Returns:
trueif the index is selected
-
isEmpty
public boolean isEmpty()Checks whether no items are currently selected.- Specified by:
isEmptyin classjavafx.scene.control.SelectionModel<T>- Returns:
trueif no items are selected
-
selectPrevious
public void selectPrevious()Selects the previous item.- Specified by:
selectPreviousin classjavafx.scene.control.SelectionModel<T>
-
selectNext
public void selectNext()Selects the next item.- Specified by:
selectNextin classjavafx.scene.control.SelectionModel<T>
-
selectFirst
public void selectFirst()Selects the first item.- Specified by:
selectFirstin classjavafx.scene.control.MultipleSelectionModel<T>
-
selectLast
public void selectLast()Selects the last item.- Specified by:
selectLastin classjavafx.scene.control.MultipleSelectionModel<T>
-