Rename UserListCell to ContactListCell
This commit is contained in:
parent
bc17203367
commit
0efd57f2ef
@ -1,11 +1,12 @@
|
|||||||
package envoy.client.ui;
|
package envoy.client.ui;
|
||||||
|
|
||||||
import envoy.data.Contact;
|
|
||||||
import envoy.data.User;
|
|
||||||
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 envoy.data.Contact;
|
||||||
|
import envoy.data.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: <strong>envoy-client</strong><br>
|
* Project: <strong>envoy-client</strong><br>
|
||||||
* File: <strong>UserListCell.java</strong><br>
|
* File: <strong>UserListCell.java</strong><br>
|
||||||
@ -14,20 +15,20 @@ import javafx.scene.layout.VBox;
|
|||||||
* @author Kai S. K. Engelbart
|
* @author Kai S. K. Engelbart
|
||||||
* @since Envoy Client v0.1-beta
|
* @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
|
@Override
|
||||||
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 Label name = new Label(contact.getName());
|
final var name = new Label(contact.getName());
|
||||||
if (contact instanceof User) {
|
setGraphic(contact instanceof User ? new VBox(name, new Label(((User) contact).getStatus().toString())) : new VBox(name));
|
||||||
final Label status = new Label(((User) contact).getStatus().toString());
|
|
||||||
setGraphic(new VBox(name, status));
|
|
||||||
} else setGraphic(new VBox(name));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,7 +21,7 @@ import envoy.client.net.Client;
|
|||||||
import envoy.client.net.WriteProxy;
|
import envoy.client.net.WriteProxy;
|
||||||
import envoy.client.ui.MessageListCell;
|
import envoy.client.ui.MessageListCell;
|
||||||
import envoy.client.ui.SceneContext;
|
import envoy.client.ui.SceneContext;
|
||||||
import envoy.client.ui.UserListCell;
|
import envoy.client.ui.ContactListCell;
|
||||||
import envoy.data.Contact;
|
import envoy.data.Contact;
|
||||||
import envoy.data.Message;
|
import envoy.data.Message;
|
||||||
import envoy.data.MessageBuilder;
|
import envoy.data.MessageBuilder;
|
||||||
@ -79,7 +79,7 @@ public final class ChatScene {
|
|||||||
|
|
||||||
// Initialize message and user rendering
|
// Initialize message and user rendering
|
||||||
messageList.setCellFactory(listView -> new MessageListCell());
|
messageList.setCellFactory(listView -> new MessageListCell());
|
||||||
userList.setCellFactory(listView -> new UserListCell());
|
userList.setCellFactory(listView -> new ContactListCell());
|
||||||
|
|
||||||
// Listen to received messages
|
// Listen to received messages
|
||||||
eventBus.register(MessageCreationEvent.class, e -> {
|
eventBus.register(MessageCreationEvent.class, e -> {
|
||||||
|
@ -10,7 +10,7 @@ import javafx.scene.control.Alert.AlertType;
|
|||||||
|
|
||||||
import envoy.client.event.SendEvent;
|
import envoy.client.event.SendEvent;
|
||||||
import envoy.client.ui.SceneContext;
|
import envoy.client.ui.SceneContext;
|
||||||
import envoy.client.ui.UserListCell;
|
import envoy.client.ui.ContactListCell;
|
||||||
import envoy.data.Contact;
|
import envoy.data.Contact;
|
||||||
import envoy.event.ElementOperation;
|
import envoy.event.ElementOperation;
|
||||||
import envoy.event.EventBus;
|
import envoy.event.EventBus;
|
||||||
@ -57,7 +57,7 @@ public class ContactSearchScene {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
contactList.setCellFactory(e -> new UserListCell());
|
contactList.setCellFactory(e -> new ContactListCell());
|
||||||
eventBus.register(ContactSearchResult.class, response -> Platform.runLater(() -> {
|
eventBus.register(ContactSearchResult.class, response -> Platform.runLater(() -> {
|
||||||
contactList.getItems().clear();
|
contactList.getItems().clear();
|
||||||
contactList.getItems().addAll(response.get());
|
contactList.getItems().addAll(response.get());
|
||||||
|
Reference in New Issue
Block a user