Top Description Inners Fields Constructors Methods
com.dlsc.gemsfx

public Class HistoryButton<T>

extends Button
Class Inheritance
Type Parameters
<T>
the type of the objects that this button manages in its history
Imports
com.dlsc.gemsfx.util.HistoryManager, javafx.application.Platform, javafx.beans.binding.Bindings, javafx.beans.property.*, javafx.css.PseudoClass, javafx.scene.Node, javafx.scene.control.*, javafx.scene.input.KeyCode, .KeyEvent, .MouseButton, .MouseEvent, javafx.scene.layout.BorderPane, javafx.util.Callback, org.kordamp.ikonli.javafx.FontIcon, org.kordamp.ikonli.materialdesign.MaterialDesign, java.util.*, java.util.function.Consumer

A custom button that manages and displays a history of entries based on a generic type T. This button integrates directly with a HistoryManager to present a list of previously used items to the user. The user can then pick one of those items to set a value on an input field.

Usage scenarios include search fields, form inputs, or any other component where users might benefit from being able to see and interact with their previous entries. The generic type T allows for flexibility, making it suitable for various data types that can represent user input history.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
HistoryButton.HistoryPopup

The popup used by the HistoryButton to display a list view with the previously used items.

public class

Field Summary

Modifier and TypeField and Description
private ObjectProperty<Callback<ListView<T>, ListCell<T>>>
private static final String
private static final PseudoClass
private ObjectProperty<HistoryManager<T>>
private final ObjectProperty<Node>
private final ObjectProperty<Node>
private final ObjectProperty<Node>
private final ObjectProperty<Node>
private ObjectProperty<Consumer<T>>
private ObjectProperty<Node>
private final ObjectProperty<Node>
private HistoryButton<T>.HistoryPopup
private final ReadOnlyBooleanWrapper

Constructor Summary

AccessConstructor and Description
public
HistoryButton()

Creates a new instance of the history button.

public
HistoryButton(Node
the owner of the button, used for focus management.
owner
)

Creates a new instance of the history button where the button will be used in combination with the given node.

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<Callback<ListView<T>, ListCell<T>>>

Returns:

the cell factory
cellFactoryProperty
()

The cell factory for the history popup list view.

public final Callback<ListView<T>, ListCell<T>>
public final HistoryManager<T>
public final Node
public final Node
public final Node
public final Node
public final Consumer<T>
public final Node
public final Node
public void
hidePopup()

Hides the popup that is showing the history items.

public final ObjectProperty<HistoryManager<T>>

Returns:

the property representing the history manager
historyManagerProperty
()

The history manager that is used for persisting the history of the button.

public final boolean
public final ObjectProperty<Node>

Returns:

the node shown on the bottom of the list view
listDecorationBottomProperty
()

The list used by the popup to show previously used items can be easily decorated by specifying nodes for its left, right, top, and / or bottom sides.

public final ObjectProperty<Node>

Returns:

the node shown to the left of the list view
listDecorationLeftProperty
()

The list used by the popup to show previously used items can be easily decorated by specifying nodes for its left, right, top, and / or bottom sides.

public final ObjectProperty<Node>

Returns:

the node shown to the right of the list view
listDecorationRightProperty
()

The list used by the popup to show previously used items can be easily decorated by specifying nodes for its left, right, top, and / or bottom sides.

public final ObjectProperty<Node>

Returns:

the node shown at the top of the list view
listDecorationTopProperty
()

The list used by the popup to show previously used items can be easily decorated by specifying nodes for its left, right, top, and / or bottom sides.

public final ObjectProperty<Consumer<T>>

Returns:

the property storing the "on history item confirmed" callback function.
onItemSelectedProperty
()

Returns the property representing the callback function to be executed when a history item within the list view is either clicked directly or selected via the ENTER key press.

public final ObjectProperty<Node>

Returns:

the owning node, e.g. a text field.
ownerProperty
()

The (optional) "owner" of a history button can be a textfield where the button is shown inside the field.

public final ObjectProperty<Node>

Returns:

the property representing the history placeholder node
placeholderProperty
()

Returns the property representing the history placeholder node.

public final ReadOnlyBooleanProperty

Returns:

true if the history popup is showing, false otherwise
popupShowingProperty
()

Indicates whether the history popup is showing.

public final void
public final void
setHistoryManager(HistoryManager<T> historyManager)

public final void
setListDecorationBottom(Node listDecorationBottom)

public final void
setListDecorationLeft(Node listDecorationLeft)

public final void
setListDecorationRight(Node listDecorationRight)

public final void
setListDecorationTop(Node listDecorationTop)

public final void
setOnItemSelected(Consumer<T> onItemSelected)

public final void
setOwner(Node owner)

public final void
setPlaceholder(Node placeholder)

public void
showPopup()

Shows the popup that includes the list view with the items stored by the history manager.

Inherited from javafx.scene.control.Button:
cancelButtonPropertycreateDefaultSkindefaultButtonPropertyfireisCancelButtonisDefaultButtonsetCancelButtonsetDefaultButton

Field Detail

cellFactoryback to summary
private ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactory
DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

Hides javafx.scene.control.Button.DEFAULT_STYLE_CLASS.

DISABLED_POPUP_PSEUDO_CLASSback to summary
private static final PseudoClass DISABLED_POPUP_PSEUDO_CLASS
historyManagerback to summary
private ObjectProperty<HistoryManager<T>> historyManager
listDecorationBottomback to summary
private final ObjectProperty<Node> listDecorationBottom
listDecorationLeftback to summary
private final ObjectProperty<Node> listDecorationLeft
listDecorationRightback to summary
private final ObjectProperty<Node> listDecorationRight
listDecorationTopback to summary
private final ObjectProperty<Node> listDecorationTop
onItemSelectedback to summary
private ObjectProperty<Consumer<T>> onItemSelected
ownerback to summary
private ObjectProperty<Node> owner
placeholderback to summary
private final ObjectProperty<Node> placeholder
popupShowingback to summary
private final ReadOnlyBooleanWrapper popupShowing

Constructor Detail

HistoryButtonback to summary
public HistoryButton()

Creates a new instance of the history button.

HistoryButtonback to summary
public HistoryButton(Node owner)

Creates a new instance of the history button where the button will be used in combination with the given node.

Parameters
owner:Node

the owner of the button, used for focus management.

Method Detail

cellFactoryPropertyback to summary
public final ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactoryProperty()

The cell factory for the history popup list view.

Returns:ObjectProperty<Callback<ListView<T>, ListCell<T>>>

the cell factory

getCellFactoryback to summary
public final Callback<ListView<T>, ListCell<T>> getCellFactory()
getHistoryManagerback to summary
public final HistoryManager<T> getHistoryManager()
getListDecorationBottomback to summary
public final Node getListDecorationBottom()
getListDecorationLeftback to summary
public final Node getListDecorationLeft()
getListDecorationRightback to summary
public final Node getListDecorationRight()
getListDecorationTopback to summary
public final Node getListDecorationTop()
getOnItemSelectedback to summary
public final Consumer<T> getOnItemSelected()
getOwnerback to summary
public final Node getOwner()
getPlaceholderback to summary
public final Node getPlaceholder()
hidePopupback to summary
public void hidePopup()

Hides the popup that is showing the history items.

historyManagerPropertyback to summary
public final ObjectProperty<HistoryManager<T>> historyManagerProperty()

The history manager that is used for persisting the history of the button.

If its value is null, clicking the button will not display the history popup.

If its value is not null, clicking the button will display a popup showing the items previously stored for this button.

Returns:ObjectProperty<HistoryManager<T>>

the property representing the history manager

isPopupShowingback to summary
public final boolean isPopupShowing()
listDecorationBottomPropertyback to summary
public final ObjectProperty<Node> listDecorationBottomProperty()

The list used by the popup to show previously used items can be easily decorated by specifying nodes for its left, right, top, and / or bottom sides. This property stores an optional node for the bottom side.

Returns:ObjectProperty<Node>

the node shown on the bottom of the list view

listDecorationLeftPropertyback to summary
public final ObjectProperty<Node> listDecorationLeftProperty()

The list used by the popup to show previously used items can be easily decorated by specifying nodes for its left, right, top, and / or bottom sides. This property stores an optional node for the left side.

Returns:ObjectProperty<Node>

the node shown to the left of the list view

listDecorationRightPropertyback to summary
public final ObjectProperty<Node> listDecorationRightProperty()

The list used by the popup to show previously used items can be easily decorated by specifying nodes for its left, right, top, and / or bottom sides. This property stores an optional node for the right side.

Returns:ObjectProperty<Node>

the node shown to the right of the list view

listDecorationTopPropertyback to summary
public final ObjectProperty<Node> listDecorationTopProperty()

The list used by the popup to show previously used items can be easily decorated by specifying nodes for its left, right, top, and / or bottom sides. This property stores an optional node for the top side.

Returns:ObjectProperty<Node>

the node shown at the top of the list view

onItemSelectedPropertyback to summary
public final ObjectProperty<Consumer<T>> onItemSelectedProperty()

Returns the property representing the callback function to be executed when a history item within the list view is either clicked directly or selected via the ENTER key press. This property enables setting a custom callback function that will be invoked with the text of the clicked or selected history item as the argument.

Returns:ObjectProperty<Consumer<T>>

the property storing the "on history item confirmed" callback function.

ownerPropertyback to summary
public final ObjectProperty<Node> ownerProperty()

The (optional) "owner" of a history button can be a textfield where the button is shown inside the field.

Returns:ObjectProperty<Node>

the owning node, e.g. a text field.

placeholderPropertyback to summary
public final ObjectProperty<Node> placeholderProperty()

Returns the property representing the history placeholder node.

Returns:ObjectProperty<Node>

the property representing the history placeholder node

popupShowingPropertyback to summary
public final ReadOnlyBooleanProperty popupShowingProperty()

Indicates whether the history popup is showing. This is a read-only property.

Returns:ReadOnlyBooleanProperty

true if the history popup is showing, false otherwise

setCellFactoryback to summary
public final void setCellFactory(Callback<ListView<T>, ListCell<T>> cellFactory)
setHistoryManagerback to summary
public final void setHistoryManager(HistoryManager<T> historyManager)
setListDecorationBottomback to summary
public final void setListDecorationBottom(Node listDecorationBottom)
setListDecorationLeftback to summary
public final void setListDecorationLeft(Node listDecorationLeft)
setListDecorationRightback to summary
public final void setListDecorationRight(Node listDecorationRight)
setListDecorationTopback to summary
public final void setListDecorationTop(Node listDecorationTop)
setOnItemSelectedback to summary
public final void setOnItemSelected(Consumer<T> onItemSelected)
setOwnerback to summary
public final void setOwner(Node owner)
setPlaceholderback to summary
public final void setPlaceholder(Node placeholder)
showPopupback to summary
public void showPopup()

Shows the popup that includes the list view with the items stored by the history manager.

com.dlsc.gemsfx back to summary

public Class HistoryButton.HistoryPopup

extends CustomPopupControl
Class Inheritance

The popup used by the HistoryButton to display a list view with the previously used items.

Field Summary

Modifier and TypeField and Description
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.PopupControl.createDefaultSkin.

Create a new instance of the default skin for this control.

Inherited from com.dlsc.gemsfx.CustomPopupControl:
show

Field Detail

DEFAULT_STYLE_CLASSback to summary
public static final String DEFAULT_STYLE_CLASS

Constructor Detail

HistoryPopupback to summary
public HistoryPopup()

Method Detail

createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.PopupControl.createDefaultSkin.

Doc from javafx.scene.control.PopupControl.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Annotations
@Override
com.dlsc.gemsfx back to summary

public Class HistoryButton.HistoryPopupSkin

extends Object
implements Skin<HistoryButton<T>.HistoryPopup>
Class Inheritance
All Implemented Interfaces
javafx.scene.control.Skin

The skin used for the HistoryPopup.

Field Summary

Modifier and TypeField and Description
private final HistoryButton<T>.HistoryPopup
private final BorderPane

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private ListView<T>
public void
dispose()

Implements javafx.scene.control.Skin.dispose.

Called when a previously installed skin is about to be removed from its associated control.

public Node
getNode()

Implements javafx.scene.control.Skin.getNode.

Gets the Node which represents this Skin.

public HistoryButton<T>.HistoryPopup
getSkinnable()

Implements javafx.scene.control.Skin.getSkinnable.

Gets the Skinnable to which this Skin is assigned.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

popupback to summary
private final HistoryButton<T>.HistoryPopup popup
rootback to summary
private final BorderPane root

Constructor Detail

HistoryPopupSkinback to summary
public HistoryPopupSkin(HistoryButton<T>.HistoryPopup popup)

Method Detail

createListViewback to summary
private ListView<T> createListView()
disposeback to summary
public void dispose()

Implements javafx.scene.control.Skin.dispose.

Doc from javafx.scene.control.Skin.dispose.

Called when a previously installed skin is about to be removed from its associated control. This allows the skin to do clean up, like removing listeners and bindings, and undo any changes to the control's properties. After this method completes, getSkinnable() and getNode() should return null.

Calling dispose() more than once has no effect.

Annotations
@Override
getNodeback to summary
public Node getNode()

Implements javafx.scene.control.Skin.getNode.

Doc from javafx.scene.control.Skin.getNode.

Gets the Node which represents this Skin. This must never be null, except after a call to dispose(), and must never change except when changing to null.

Annotations
@Override
getSkinnableback to summary
public HistoryButton<T>.HistoryPopup getSkinnable()

Implements javafx.scene.control.Skin.getSkinnable.

Doc from javafx.scene.control.Skin.getSkinnable.

Gets the Skinnable to which this Skin is assigned. A Skin must be created for one and only one Skinnable. This value will only ever go from a non-null to null value when the Skin is removed from the Skinnable, and only as a consequence of a call to dispose().

The caller who constructs a Skinnable must also construct a Skin and properly establish the relationship between the Control and its Skin.

Annotations
@Override
handleItemSelectionback to summary
private void handleItemSelection(ListView<T> listView)