Spec-Zone .ru
спецификации, руководства, описания, API
|
T
- The type of the item contained in the control that can be selected.public abstract class SelectionModel<T>
extends java.lang.Object
Type | Property and Description |
---|---|
ReadOnlyIntegerProperty |
selectedIndex
Refers to the selected index property, which is used to indicate
the currently selected index value in the selection model.
|
ReadOnlyObjectProperty<T> |
selectedItem
Refers to the selected item property, which is used to indicate
the currently selected item in the selection model.
|
Constructor and Description |
---|
SelectionModel()
Creates a default SelectionModel instance.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
clearAndSelect(int index)
A method that clears any selection prior to setting the selection to the
given index.
|
abstract void |
clearSelection()
Clears the selection model of all selected indices.
|
abstract void |
clearSelection(int index)
This method will clear the selection of the item in the given index.
|
int |
getSelectedIndex()
Returns the integer value indicating the currently selected index in
this model.
|
T |
getSelectedItem()
Returns the currently selected object (which resides in the selected index
position).
|
abstract boolean |
isEmpty()
This method is available to test whether there are any selected
indices/items.
|
abstract boolean |
isSelected(int index)
Convenience method to inform if the given index is currently selected
in this SelectionModel.
|
abstract void |
select(int index)
This will select the given index in the selection model, assuming the
index is within the valid range (i.e.
|
abstract void |
select(T obj)
This method will attempt to select the index that contains the given
object.
|
ReadOnlyIntegerProperty |
selectedIndexProperty()
Refers to the selected index property, which is used to indicate
the currently selected index value in the selection model.
|
ReadOnlyObjectProperty<T> |
selectedItemProperty()
Refers to the selected item property, which is used to indicate
the currently selected item in the selection model.
|
abstract void |
selectFirst()
This method will attempt to select the first index in the control.
|
abstract void |
selectLast()
This method will attempt to select the last index in the control.
|
abstract void |
selectNext()
This method will attempt to select the index directly after the current
focused index.
|
abstract void |
selectPrevious()
This method will attempt to select the index directly before the current
focused index.
|
protected void |
setSelectedIndex(int value)
Sets the value of the property selectedIndex.
|
protected void |
setSelectedItem(T value)
Sets the value of the property selectedItem.
|
public final ReadOnlyIntegerProperty selectedIndexProperty
Refers to the selected index property, which is used to indicate the currently selected index value in the selection model. The selected index is either -1, to represent that there is no selection, or an integer value that is within the range of the underlying data model size.
The selected index property is most commonly used when the selection model only allows single selection, but is equally applicable when in multiple selection mode. When in this mode, the selected index will always represent the last selection made.
Note that in the case of multiple selection, it is possible to add
a ListChangeListener
to the collection returned by
MultipleSelectionModel.getSelectedIndices()
to be informed whenever
the selection changes, and this will also work in the case of single selection.
getSelectedIndex()
,
setSelectedIndex(int)
public final ReadOnlyObjectProperty<T> selectedItemProperty
Refers to the selected item property, which is used to indicate the currently selected item in the selection model. The selected item is either null, to represent that there is no selection, or an Object that is retrieved from the underlying data model of the control the selection model is associated with.
The selected item property is most commonly used when the selection model is set to be single selection, but is equally applicable when in multiple selection mode. When in this mode, the selected item will always represent the last selection made.
getSelectedItem()
,
setSelectedItem(T)
public SelectionModel()
public final ReadOnlyIntegerProperty selectedIndexProperty()
Refers to the selected index property, which is used to indicate the currently selected index value in the selection model. The selected index is either -1, to represent that there is no selection, or an integer value that is within the range of the underlying data model size.
The selected index property is most commonly used when the selection model only allows single selection, but is equally applicable when in multiple selection mode. When in this mode, the selected index will always represent the last selection made.
Note that in the case of multiple selection, it is possible to add
a ListChangeListener
to the collection returned by
MultipleSelectionModel.getSelectedIndices()
to be informed whenever
the selection changes, and this will also work in the case of single selection.
getSelectedIndex()
,
setSelectedIndex(int)
protected final void setSelectedIndex(int value)
Refers to the selected index property, which is used to indicate the currently selected index value in the selection model. The selected index is either -1, to represent that there is no selection, or an integer value that is within the range of the underlying data model size.
The selected index property is most commonly used when the selection model only allows single selection, but is equally applicable when in multiple selection mode. When in this mode, the selected index will always represent the last selection made.
Note that in the case of multiple selection, it is possible to add
a ListChangeListener
to the collection returned by
MultipleSelectionModel.getSelectedIndices()
to be informed whenever
the selection changes, and this will also work in the case of single selection.
public final int getSelectedIndex()
Returns the integer value indicating the currently selected index in this model. If there are multiple items selected, this will return the most recent selection made.
Note that the returned value is a snapshot in time - if you wish to observe the selection model for changes to the selected index, you can add a ChangeListener as such:
SelectionModel sm = ...;
InvalidationListener listener = ...;
sm.selectedIndexProperty().addListener(listener);
public final ReadOnlyObjectProperty<T> selectedItemProperty()
Refers to the selected item property, which is used to indicate the currently selected item in the selection model. The selected item is either null, to represent that there is no selection, or an Object that is retrieved from the underlying data model of the control the selection model is associated with.
The selected item property is most commonly used when the selection model is set to be single selection, but is equally applicable when in multiple selection mode. When in this mode, the selected item will always represent the last selection made.
getSelectedItem()
,
setSelectedItem(T)
protected final void setSelectedItem(T value)
Refers to the selected item property, which is used to indicate the currently selected item in the selection model. The selected item is either null, to represent that there is no selection, or an Object that is retrieved from the underlying data model of the control the selection model is associated with.
The selected item property is most commonly used when the selection model is set to be single selection, but is equally applicable when in multiple selection mode. When in this mode, the selected item will always represent the last selection made.
public final T getSelectedItem()
Note that the returned value is a snapshot in time - if you wish to observe the selection model for changes to the selected item, you can add a ChangeListener as such:
SelectionModel sm = ...;
InvalidationListener listener = ...;
sm.selectedItemProperty().addListener(listener);
public abstract void clearAndSelect(int index)
clearSelection()
first, meaning that observers that are listening to
the selected index
property will not
see the selected index being temporarily set to -1.index
- The index that should be the only selected index in this
selection model.public abstract void select(int index)
This will select the given index in the selection model, assuming the index is within the valid range (i.e. greater than or equal to zero, and less than the total number of items in the underlying data model).
If there is already one or more indices selected in this model, calling
this method will not clear these selections - to do so it is
necessary to first call clearSelection()
.
If the index is already selected, it will not be selected again, or
unselected. However, if multiple selection is implemented, then calling
select on an already selected index will have the effect of making the index
the new selected index (as returned by getSelectedIndex()
.
index
- The position of the item to select in the selection model.public abstract void select(T obj)
This method will attempt to select the index that contains the given object. It will iterate through the underlying data model until it finds an item whose value is equal to the given object. At this point it will stop iterating - this means that this method will not select multiple indices.
obj
- The object to attempt to select in the underlying data model.public abstract void clearSelection(int index)
This method will clear the selection of the item in the given index. If the given index is not selected, nothing will happen.
index
- The selected item to deselect.public abstract void clearSelection()
Clears the selection model of all selected indices.
public abstract boolean isSelected(int index)
Convenience method to inform if the given index is currently selected
in this SelectionModel. Is functionally equivalent to calling
getSelectedIndices().contains(index)
.
index
- The index to check as to whether it is currently selected
or not.public abstract boolean isEmpty()
public abstract void selectPrevious()
This method will attempt to select the index directly before the current focused index. If clearSelection is not called first, this method will have the result of selecting the previous index, whilst retaining the selection of any other currently selected indices.
Calling this method will only succeed if:
If any of these conditions is false, no selection event will take place.
public abstract void selectNext()
This method will attempt to select the index directly after the current focused index. If clearSelection is not called first, this method will have the result of selecting the next index, whilst retaining the selection of any other currently selected indices.
Calling this method will only succeed if:
If any of these conditions is false, no selection event will take place.
public abstract void selectFirst()
This method will attempt to select the first index in the control. If clearSelection is not called first, this method will have the result of selecting the first index, whilst retaining the selection of any other currently selected indices.
If the first index is already selected, calling this method will have no result, and no selection event will take place.
public abstract void selectLast()
This method will attempt to select the last index in the control. If clearSelection is not called first, this method will have the result of selecting the last index, whilst retaining the selection of any other currently selected indices.
If the last index is already selected, calling this method will have no result, and no selection event will take place.
Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. Use is subject to