listView) { return new ContactListCell<>(listView); }
-}
diff --git a/client/src/main/java/envoy/client/ui/listcell/ListCellFactory.java b/client/src/main/java/envoy/client/ui/listcell/ListCellFactory.java
new file mode 100644
index 0000000..86270ce
--- /dev/null
+++ b/client/src/main/java/envoy/client/ui/listcell/ListCellFactory.java
@@ -0,0 +1,54 @@
+package envoy.client.ui.listcell;
+
+import java.util.function.Function;
+
+import javafx.scene.Node;
+import javafx.scene.control.ListCell;
+import javafx.scene.control.ListView;
+import javafx.util.Callback;
+
+/**
+ * Provides a creation mechanism for generic list cells given a list view and a
+ * conversion function.
+ *
+ * Project: envoy-client
+ * File: ListCellFactory.java
+ * Created: 13.07.2020
+ *
+ * @author Kai S. K. Engelbart
+ * @param the type of object to display
+ * @since Envoy Client v0.1-beta
+ */
+public final class ListCellFactory implements Callback, ListCell> {
+
+ private final class GenericListCell extends ListCell {
+
+ private ListView extends T> listView;
+
+ private GenericListCell(ListView extends T> listView) { this.listView = listView; }
+
+ @Override
+ protected void updateItem(T item, boolean empty) {
+ super.updateItem(item, empty);
+ if (empty || item == null) {
+ setText(null);
+ setGraphic(null);
+ } else {
+ final var control = converter.apply(item);
+ prefWidthProperty().bind(listView.widthProperty().subtract(40));
+ setGraphic(control);
+ }
+ }
+ }
+
+ private final Function super T, ? extends Node> converter;
+
+ /**
+ * @param converter a function converting the type to display into a node
+ * @since Envoy Client v0.1-beta
+ */
+ public ListCellFactory(Function super T, ? extends Node> converter) { this.converter = converter; }
+
+ @Override
+ public ListCell call(ListView listView) { return new GenericListCell(listView); }
+}
diff --git a/client/src/main/java/envoy/client/ui/listcell/MessageListCellFactory.java b/client/src/main/java/envoy/client/ui/listcell/MessageListCellFactory.java
deleted file mode 100644
index f8e4fa2..0000000
--- a/client/src/main/java/envoy/client/ui/listcell/MessageListCellFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package envoy.client.ui.listcell;
-
-import javafx.scene.control.ListCell;
-import javafx.scene.control.ListView;
-import javafx.scene.control.Tooltip;
-import javafx.stage.PopupWindow.AnchorLocation;
-
-import envoy.data.Message;
-
-/**
- * Displays a single message inside the message list.
- *
- * Project: envoy-client
- * File: MessageListCellFactory.java
- * Created: 28.03.2020
- *
- * @author Kai S. K. Engelbart
- * @since Envoy Client v0.1-beta
- */
-public class MessageListCellFactory extends ListCell {
-
- private final ListView listView;
-
- /**
- * @param listView the list view inside which this cell is contained
- * @since Envoy Client v0.1-beta
- */
- public MessageListCellFactory(ListView listView) { this.listView = listView; }
-
- /**
- * Displays the text, the data of creation and the status of a message.
- *
- * @since Envoy v0.1-beta
- */
- @Override
- protected void updateItem(Message message, boolean empty) {
- super.updateItem(message, empty);
- if (empty || message == null) {
- setText(null);
- setGraphic(null);
- } else {
- final var control = new MessageControl(message);
- control.prefWidthProperty().bind(listView.widthProperty().subtract(40));
- // Creating the Tooltip to deselect a message
- final var tooltip = new Tooltip("You can select a message by clicking on it \nand deselect it by pressing \"ctrl\" and clicking on it");
- tooltip.setWrapText(true);
- tooltip.setAnchorLocation(AnchorLocation.WINDOW_TOP_LEFT);
- setTooltip(tooltip);
- setGraphic(control);
- }
- }
-}