Added color display of user statuses
This commit is contained in:
parent
0661838c38
commit
d0d86fc0d4
@ -3,8 +3,10 @@ package envoy.client.ui;
|
|||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.ListCell;
|
import javafx.scene.control.ListCell;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
import envoy.data.Contact;
|
import envoy.data.Contact;
|
||||||
|
import envoy.data.Group;
|
||||||
import envoy.data.User;
|
import envoy.data.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,8 +29,32 @@ public class ContactListCell extends ListCell<Contact> {
|
|||||||
protected void updateItem(Contact contact, boolean empty) {
|
protected void updateItem(Contact contact, boolean empty) {
|
||||||
super.updateItem(contact, empty);
|
super.updateItem(contact, empty);
|
||||||
if (!empty && contact != null) {
|
if (!empty && contact != null) {
|
||||||
final var name = new Label(contact.getName());
|
// the infoLabel displays specific contact info, i.e. status of a user or amount
|
||||||
setGraphic(contact instanceof User ? new VBox(name, new Label(((User) contact).getStatus().toString())) : new VBox(name));
|
// 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user