java.lang.Object
javafx.util.StringConverter<T>
org.tentackle.fx.NavigationLetterStringConverter<T>
- Type Parameters:
T- the type to convert
public abstract class NavigationLetterStringConverter<T>
extends javafx.util.StringConverter<T>
A
Provides navigation with keystrokes that do not correspond to the text displayed in the UI.
StringConverter to navigate within a collection of objects.Provides navigation with keystrokes that do not correspond to the text displayed in the UI.
Example:
converter = new NavigationLetterStringConverter<SomeType>(someCollection) {
@Override
public String getNavigationLetters(SomeType object) {
return StringHelper.filterUpperCase(object.getName());
}
@Override
public String getName(SomeType object) {
return object.getName();
}
};
sortedObjects = converter.getSortedObjects(); // for ComboBox.getItems().setAll(sortedObjects)
comboBox.setConverter(converter);
Notice that the ComboBox needs a cell-factory to show the object name, otherwise
the navigation-letters will be shown instead of the object's name.
Notice further, that enhanced camelcase navigation is also available via the
PrefixSelectionFeature.CAMEL_CASE property,
which is usually much simpler and does not need a NavigationLetterStringConverter at all.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfromString(String string) abstract StringExtracts the name from an object.abstract StringgetNavigationLetters(T object) Extracts the navigation letters from an object.Gets the objects sorted by navigation letters + name.
-
Constructor Details
-
NavigationLetterStringConverter
Creates a converter.- Parameters:
objects- the objects to navigate within
-
-
Method Details
-
getName
Extracts the name from an object.- Parameters:
object- the object- Returns:
- the object's name
-
getSortedObjects
Gets the objects sorted by navigation letters + name.- Returns:
- the sorted objects
-
toString
- Specified by:
toStringin classjavafx.util.StringConverter<T>
-
fromString
- Specified by:
fromStringin classjavafx.util.StringConverter<T>