package envoy.client.ui.listcell; import javafx.scene.Cursor; import javafx.scene.Node; import javafx.scene.control.ContentDisplay; import javafx.scene.control.ListCell; import javafx.scene.control.ListView; /** * Provides a convenience frame for list cell creation. *

* Project: envoy-client
* File: AbstractListCell.java
* Created: 18.07.2020
* * @author Kai S. K. Engelbart * @param the type of element displayed by the list cell * @param the type of node as which the list element will be displayed * @since Envoy Client v0.1-beta */ public abstract class AbstractListCell extends ListCell { protected ListView listView; /** * @param listView the list view inside of which the cell will be displayed * @since Envoy Client v0.1-beta */ public AbstractListCell(ListView listView) { this.listView = listView; setContentDisplay(ContentDisplay.GRAPHIC_ONLY); getStyleClass().add("listElement"); } @Override protected final void updateItem(T item, boolean empty) { super.updateItem(item, empty); if (!(empty || item == null)) { setCursor(Cursor.HAND); setGraphic(renderItem(item)); } } /** * Converts a list item to a node. This can have side effects on the list cell. * * @param item the item to render * @return a node representing the item * @since Envoy Client v0.1-beta */ protected abstract U renderItem(T item); }