Module org.tentackle.fx
Class PrefixSelectionFeature<T extends javafx.scene.control.Control>
- java.lang.Object
-
- org.tentackle.fx.component.config.PrefixSelectionFeature<T>
-
- Type Parameters:
T- the control type
public class PrefixSelectionFeature<T extends javafx.scene.control.Control> extends java.lang.ObjectSelect items according to a prefix.
Useful for ComboBox and ChoiceBox but can be applied to any control providing a list of items that can be selected.- Author:
- harald
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.BooleanSupplierasYouTypeConditionprotected Tcontrolstatic java.lang.StringENABLEDTo disable this feature, invoke:protected java.util.function.Supplier<javafx.util.StringConverter>itemConverterprotected java.util.function.Supplier<java.util.Collection>itemProviderprotected java.lang.StringBuilderprefixBufprotected java.util.function.Consumer<java.lang.Integer>selector
-
Constructor Summary
Constructors Constructor Description PrefixSelectionFeature(T control, java.util.function.BooleanSupplier asYouTypeCondition, java.util.function.Supplier<java.util.Collection> itemProvider, java.util.function.Supplier<javafx.util.StringConverter> itemConverter, java.util.function.Consumer<java.lang.Integer> selector)Creates a prefix selection feature.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure()Configures the control to support this feature.protected javafx.event.EventHandler<javafx.scene.input.KeyEvent>createHandler()Creates the handler to catch the key events.protected java.lang.StringgetPrefix()Gets the prefix string to be used forisItemMatching(java.lang.String, java.lang.Object).protected booleanisEnabled()Returns whether this feature is enabled for the control.protected booleanisItemMatching(java.lang.String prefix, java.lang.Object item)Returns whether item is matching prefix string.protected booleanisSelectionByKeyEnabled()Returns whether selection by key is enabled.protected voidscrollToIndexInDropDown()Scrolls to the selected index in the dropdown.protected voidselect()Select an item according to the current prefix.
-
-
-
Field Detail
-
ENABLED
public static final java.lang.String ENABLED
To disable this feature, invoke:
control.getProperties().remove(PrefixSelectionFeature.ENABLED);
- See Also:
- Constant Field Values
-
control
protected final T extends javafx.scene.control.Control control
-
asYouTypeCondition
protected final java.util.function.BooleanSupplier asYouTypeCondition
-
itemProvider
protected final java.util.function.Supplier<java.util.Collection> itemProvider
-
itemConverter
protected final java.util.function.Supplier<javafx.util.StringConverter> itemConverter
-
selector
protected final java.util.function.Consumer<java.lang.Integer> selector
-
prefixBuf
protected final java.lang.StringBuilder prefixBuf
-
-
Constructor Detail
-
PrefixSelectionFeature
public PrefixSelectionFeature(T control, java.util.function.BooleanSupplier asYouTypeCondition, java.util.function.Supplier<java.util.Collection> itemProvider, java.util.function.Supplier<javafx.util.StringConverter> itemConverter, java.util.function.Consumer<java.lang.Integer> selector)
Creates a prefix selection feature.- Parameters:
control- the control to add this feature toasYouTypeCondition- the condition to activate preselection by keystrokesitemProvider- the items that can be selecteditemConverter- the item to string converterselector- the selector to select an item by its index
-
-
Method Detail
-
configure
public void configure()
Configures the control to support this feature.
-
scrollToIndexInDropDown
protected void scrollToIndexInDropDown()
Scrolls to the selected index in the dropdown.
-
createHandler
protected javafx.event.EventHandler<javafx.scene.input.KeyEvent> createHandler()
Creates the handler to catch the key events.- Returns:
- the handler
-
isEnabled
protected boolean isEnabled()
Returns whether this feature is enabled for the control.- Returns:
- true if enabled
-
isSelectionByKeyEnabled
protected boolean isSelectionByKeyEnabled()
Returns whether selection by key is enabled.- Returns:
- true if enabled
-
select
protected void select()
Select an item according to the current prefix.
-
getPrefix
protected java.lang.String getPrefix()
Gets the prefix string to be used forisItemMatching(java.lang.String, java.lang.Object).- Returns:
- the prefix string
-
isItemMatching
protected boolean isItemMatching(java.lang.String prefix, java.lang.Object item)Returns whether item is matching prefix string.- Parameters:
prefix- the prefix stringitem- the item- Returns:
- true if matching
-
-