package envoy.client.ui.listcell; import javafx.scene.*; import javafx.scene.control.*; /** * Provides a convenience frame for list cell creation. * * @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("list-element"); } @Override protected final void updateItem(T item, boolean empty) { super.updateItem(item, empty); if (!(empty || item == null)) { setCursor(Cursor.HAND); setGraphic(renderItem(item)); } else { setGraphic(null); setCursor(Cursor.DEFAULT); } } /** * 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); }