diff --git a/src/main/java/envoy/client/ui/ContactListCell.java b/src/main/java/envoy/client/ui/ContactListCell.java index eb6e3c1..c3c51d4 100644 --- a/src/main/java/envoy/client/ui/ContactListCell.java +++ b/src/main/java/envoy/client/ui/ContactListCell.java @@ -3,8 +3,10 @@ package envoy.client.ui; import javafx.scene.control.Label; import javafx.scene.control.ListCell; import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; import envoy.data.Contact; +import envoy.data.Group; import envoy.data.User; /** @@ -20,15 +22,39 @@ public class ContactListCell extends ListCell { /** * 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 var name = new Label(contact.getName()); - setGraphic(contact instanceof User ? new VBox(name, new Label(((User) contact).getStatus().toString())) : new VBox(name)); + // the infoLabel displays specific contact info, i.e. status of a user or amount + // of members in a group + Label infoLabel = null; + if (contact instanceof User) { + // user specific info + infoLabel = new Label(((User) contact).getStatus().toString()); + Color textColor = null; + switch (((User) contact).getStatus()) { + case ONLINE: + textColor = Color.LIMEGREEN; + break; + case AWAY: + textColor = Color.ORANGERED; + break; + case BUSY: + textColor = Color.RED; + break; + case OFFLINE: + textColor = Color.GRAY; + break; + } + infoLabel.setTextFill(textColor); + } else + // group specific infos + infoLabel = new Label(String.valueOf(((Group) contact).getContacts().size()) + " members"); + setGraphic(new VBox(new Label(contact.getName()), infoLabel)); } } }