45 lines
1.2 KiB
Java
45 lines
1.2 KiB
Java
package envoy.client.ui.listcell;
|
|
|
|
import javafx.scene.control.Label;
|
|
import javafx.scene.layout.VBox;
|
|
|
|
import envoy.data.Contact;
|
|
import envoy.data.User;
|
|
|
|
/**
|
|
* Displays information about a contact in two rows. The first row contains the
|
|
* name. The second row contains the online status (user) or the member count
|
|
* (group).
|
|
* <p>
|
|
* Project: <strong>envoy-client</strong><br>
|
|
* File: <strong>ContactControl.java</strong><br>
|
|
* Created: <strong>13.07.2020</strong><br>
|
|
*
|
|
* @author Kai S. K. Engelbart
|
|
* @since Envoy Client v0.2-beta
|
|
*/
|
|
public class ContactControl extends VBox {
|
|
|
|
/**
|
|
* @param contact the contact to display
|
|
* @since Envoy Client v0.2-beta
|
|
*/
|
|
public ContactControl(Contact contact) {
|
|
|
|
// Name label
|
|
final var nameLabel = new Label(contact.getName());
|
|
getChildren().add(nameLabel);
|
|
|
|
// Online status (user) or member count (group)
|
|
if (contact instanceof User) {
|
|
final var status = ((User) contact).getStatus().toString();
|
|
final var statusLabel = new Label(status);
|
|
statusLabel.getStyleClass().add(status.toLowerCase());
|
|
getChildren().add(statusLabel);
|
|
} else {
|
|
getChildren().add(new Label(contact.getContacts().size() + " members"));
|
|
}
|
|
getStyleClass().add("listElement");
|
|
}
|
|
}
|