Rename UserListCell to ContactListCell

This commit is contained in:
Kai S. K. Engelbart 2020-06-09 15:49:11 +02:00
parent bc17203367
commit 0efd57f2ef
3 changed files with 14 additions and 13 deletions

View File

@ -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: <strong>envoy-client</strong><br>
* File: <strong>UserListCell.java</strong><br>
@ -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<Contact> {
public class ContactListCell extends ListCell<Contact> {
/**
* {@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));
}
}
}

View File

@ -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 -> {

View File

@ -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());