SuggesterFX is a JavaFX lightweight library that provides a suggestion (autocompletion) system for text fields linked to data entries. This library integrates with mvciFX library to provide a clean, maintainable architecture for handling suggestions and autocompletion.
- Original MVCI framework concept by Dave Barrett (PragmaticoCoding).
- Built on ControlsFX components
- Autocompletion modifications based on Clément Grennerat's post and his PDF4Teachers application
SuggesterFX combines JavaFX's text fields with ControlsFX's autocompletion features, wrapped in an MVCI (Model-View-Controller-Interactor) architecture. This makes it easy to implement type-ahead suggestions while maintaining clean separation of concerns.
This library provides the following components:
SuggestionInteractor
: an abstract MVCI Interactor class specialized for suggestions handling- fetches entries based on user input
- retrieves text suggestions
- manages model updates after suggestion selection
Entry
: an interface representing data entities (such as POJOs) that can be used with the suggestion system.- Supports composite primary keys
- Provides description text for display
- Suggestion Components:
EntryConverter
: converts betweenEntry
objects and their string representations.EntrySelectionHandler
: handles the selection events from auto-completion textfield. It uses theSuggestionInteractor
to handle what should be done after the operation is completed.EntrySuggesterCallback
: a callback backed by theSuggestionInteractor.fetchEntries(String)
method, which retrieves entries based on a user's suggestion or partial input.StringSuggesterCallback
: a callback backed by toSuggestionInteractor.fetchNames(String)
method, which retrieves a list of names matching a user's suggestion or partial input
The classes in com.maemlab.suggesterfx.controlsfx.autocompletion
package are taken from ControlsFX.
They have been repackaged and modified following Clément Grennerat's post.
impl.textfield.AutoCompletionBinding
:- Removed EventTarget implementation
- Simplified
fireAutoCompletion
method: - Made
isCancelled
andgetUserText
methods public - Removed
invalidated
method
impl.textfield.TextFields
: removedcreateClearablePasswordField
methodimpl.textfield.AutoCompletionTextFieldBinding
: a little bit of code reviewimpl.skin.AutoCompletePopupSkin
: removed the default style
TODO
Contributions are welcome! Please feel free to submit a pull request or open an issue.