34 lines
869 B
Java
34 lines
869 B
Java
package envoy.client.ui.control;
|
|
|
|
import javafx.scene.control.Label;
|
|
import javafx.scene.layout.VBox;
|
|
|
|
import envoy.data.*;
|
|
|
|
/**
|
|
* 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).
|
|
*
|
|
* @author Kai S. K. Engelbart
|
|
* @since Envoy Client v0.2-beta
|
|
*/
|
|
public final 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)
|
|
getChildren().add(contact instanceof User ? new UserStatusLabel((User) contact) : new GroupSizeLabel((Group) contact));
|
|
|
|
getStyleClass().add("list-element");
|
|
}
|
|
}
|