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 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.
|
javafx.beans.property.ReadOnlyListProperty<String> |
stringList
String list which can be used by the UI to present the data.
|
modelListProperty, targetListProperty
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() |
List<String> |
getStringList() |
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.
|
javafx.beans.property.ReadOnlyListProperty<String> |
stringListProperty()
String list which can be used by the UI to present the data.
|
getModelList, getTargetList, modelListProperty, setModelList, targetListProperty
public 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 SelectableStringList
getSelectedIndex()
public javafx.beans.property.ReadOnlyListProperty<String> stringListProperty
stringListProperty
in interface SelectableStringList
stringListProperty
in class ItemList<ListType>
getStringList()
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 SelectableStringList
getSelectedIndex()
public int getSelectedIndex()
getSelectedIndex
in interface SelectableStringList
SelectableStringList.selectedIndexProperty()
public javafx.beans.property.ReadOnlyListProperty<String> stringListProperty()
SelectableStringList
stringListProperty
in interface SelectableStringList
stringListProperty
in class ItemList<ListType>
getStringList()
public List<String> getStringList()
ListTransformation.modelListProperty()
as List.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)
item
- the item will be selected.selectedItemProperty()
public ListType getSelectedItem()
selectedItemProperty()
public void clearSelection()
SelectableStringList
clearSelection
in interface SelectableStringList
public void select(int index)
select
in interface SelectableStringList
index
- the id to be selectedSelectableStringList.selectedIndexProperty()
Copyright © 2015 Saxonia Systems AG. All rights reserved.