40 lines
1.0 KiB
Java
40 lines
1.0 KiB
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)
|
|
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("list-element");
|
|
}
|
|
}
|