diff --git a/src/main/java/envoy/client/ui/UserListCell.java b/src/main/java/envoy/client/ui/ContactListCell.java
similarity index 59%
rename from src/main/java/envoy/client/ui/UserListCell.java
rename to src/main/java/envoy/client/ui/ContactListCell.java
index cfc1fdf..eb6e3c1 100644
--- a/src/main/java/envoy/client/ui/UserListCell.java
+++ b/src/main/java/envoy/client/ui/ContactListCell.java
@@ -1,11 +1,12 @@
package envoy.client.ui;
-import envoy.data.Contact;
-import envoy.data.User;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.layout.VBox;
+import envoy.data.Contact;
+import envoy.data.User;
+
/**
* Project: envoy-client
* File: UserListCell.java
@@ -14,20 +15,20 @@ import javafx.scene.layout.VBox;
* @author Kai S. K. Engelbart
* @since Envoy Client v0.1-beta
*/
-public class UserListCell extends ListCell {
+public class ContactListCell extends ListCell {
/**
- * {@inheritDoc}
+ * Displays the name of a contact. If the contact is a user, their online status
+ * is displayed as well.
+ *
+ * @since Envoy Client v0.1-beta
*/
@Override
protected void updateItem(Contact contact, boolean empty) {
super.updateItem(contact, empty);
if (!empty && contact != null) {
- final Label name = new Label(contact.getName());
- if (contact instanceof User) {
- final Label status = new Label(((User) contact).getStatus().toString());
- setGraphic(new VBox(name, status));
- } else setGraphic(new VBox(name));
+ final var name = new Label(contact.getName());
+ setGraphic(contact instanceof User ? new VBox(name, new Label(((User) contact).getStatus().toString())) : new VBox(name));
}
}
}
diff --git a/src/main/java/envoy/client/ui/controller/ChatScene.java b/src/main/java/envoy/client/ui/controller/ChatScene.java
index 76c0c3b..4c3fe05 100644
--- a/src/main/java/envoy/client/ui/controller/ChatScene.java
+++ b/src/main/java/envoy/client/ui/controller/ChatScene.java
@@ -21,7 +21,7 @@ import envoy.client.net.Client;
import envoy.client.net.WriteProxy;
import envoy.client.ui.MessageListCell;
import envoy.client.ui.SceneContext;
-import envoy.client.ui.UserListCell;
+import envoy.client.ui.ContactListCell;
import envoy.data.Contact;
import envoy.data.Message;
import envoy.data.MessageBuilder;
@@ -79,7 +79,7 @@ public final class ChatScene {
// Initialize message and user rendering
messageList.setCellFactory(listView -> new MessageListCell());
- userList.setCellFactory(listView -> new UserListCell());
+ userList.setCellFactory(listView -> new ContactListCell());
// Listen to received messages
eventBus.register(MessageCreationEvent.class, e -> {
diff --git a/src/main/java/envoy/client/ui/controller/ContactSearchScene.java b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java
index f98b016..9fc495d 100644
--- a/src/main/java/envoy/client/ui/controller/ContactSearchScene.java
+++ b/src/main/java/envoy/client/ui/controller/ContactSearchScene.java
@@ -10,7 +10,7 @@ import javafx.scene.control.Alert.AlertType;
import envoy.client.event.SendEvent;
import envoy.client.ui.SceneContext;
-import envoy.client.ui.UserListCell;
+import envoy.client.ui.ContactListCell;
import envoy.data.Contact;
import envoy.event.ElementOperation;
import envoy.event.EventBus;
@@ -57,7 +57,7 @@ public class ContactSearchScene {
@FXML
private void initialize() {
- contactList.setCellFactory(e -> new UserListCell());
+ contactList.setCellFactory(e -> new ContactListCell());
eventBus.register(ContactSearchResult.class, response -> Platform.runLater(() -> {
contactList.getItems().clear();
contactList.getItems().addAll(response.get());