ListType - type of the list elements which should be transformed to a string
listpublic class SelectableItemList<ListType> extends ItemList<ListType> implements SelectableStringList
ChoiceBox or
ListView. You should only expose the ItemList.stringListProperty()
and/or the selectedIndexProperty() to the view, otherwise you create
a visibility of the view to the model. If you want to expose it more
convenient, use the SelectableStringList interface to hide all
dependencies to the model. Create something like this in your View Model:
public SelectableStringList stringListProperty(){
return selectableItemListInstance;
}
You have to provide a ModelToStringFunction to define how to map
from your model representation to a string. In addition you have properties
which represents the actual selection state of a list. You can set either the
selectedIndexProperty() or the selectedItemProperty() and
the other will change automatically.| Type | Property and Description |
|---|---|
javafx.beans.property.ReadOnlyIntegerProperty |
selectedIndex
Represents an
Integer which is the current selection index. |
javafx.beans.property.ObjectProperty<ListType> |
selectedItem
Represents the current selected item.
|
stringListPropertymodelListProperty, targetListPropertystringListProperty| Constructor and Description |
|---|
SelectableItemList(javafx.collections.ObservableList<ListType> itemList,
ModelToStringFunction<ListType> modelToStringMapper)
Creates a
SelectableItemList by a given list of items and a
ModelToStringFunction. |
| Modifier and Type | Method and Description |
|---|---|
void |
clearSelection()
Removes the selection.
|
int |
getSelectedIndex()
Gets the value of the property selectedIndex.
|
ListType |
getSelectedItem() |
void |
select(int index) |
void |
select(ListType item) |
javafx.beans.property.ReadOnlyIntegerProperty |
selectedIndexProperty()
Represents an
Integer which is the current selection index. |
javafx.beans.property.ObjectProperty<ListType> |
selectedItemProperty()
Represents the current selected item.
|
stringListPropertymodelListProperty, setModelList, targetListPropertyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitstringListPropertypublic javafx.beans.property.ReadOnlyIntegerProperty selectedIndexProperty
Integer which is the current selection index. If
you set another value to the property selectedItemProperty()
will change automatically. If the value was an invalid index, the change
will be rollbacked.selectedIndexProperty in interface SelectableStringListgetSelectedIndex()public javafx.beans.property.ObjectProperty<ListType> selectedItemProperty
selectedIndexProperty() will change automatically. If
the value was an invalid item which is not in the itemlist, the change
will be rollbacked.getSelectedItem()public SelectableItemList(javafx.collections.ObservableList<ListType> itemList, ModelToStringFunction<ListType> modelToStringMapper)
SelectableItemList by a given list of items and a
ModelToStringFunction.itemList - which should be transformed for the UImodelToStringMapper - which is used for transformationpublic javafx.beans.property.ReadOnlyIntegerProperty selectedIndexProperty()
Integer which is the current selection index. If
you set another value to the property selectedItemProperty()
will change automatically. If the value was an invalid index, the change
will be rollbacked.selectedIndexProperty in interface SelectableStringListgetSelectedIndex()public int getSelectedIndex()
getSelectedIndex in interface SelectableStringListSelectableStringList.selectedIndexProperty()public javafx.beans.property.ObjectProperty<ListType> selectedItemProperty()
selectedIndexProperty() will change automatically. If
the value was an invalid item which is not in the itemlist, the change
will be rollbacked.getSelectedItem()public void select(ListType item)
selectedItemProperty()public ListType getSelectedItem()
selectedItemProperty()public void clearSelection()
SelectableStringListclearSelection in interface SelectableStringListpublic void select(int index)
select in interface SelectableStringListSelectableStringList.selectedIndexProperty();Copyright © 2014 Saxonia Systems AG. All rights reserved.