package envoy.client.ui.settings; import javafx.geometry.Insets; import javafx.scene.control.Label; import javafx.scene.control.Tooltip; import javafx.scene.layout.Background; import javafx.scene.layout.BackgroundFill; import javafx.scene.layout.CornerRadii; import javafx.scene.paint.Color; /** * Inheriting from this class signifies that options should only be available if * the {@link envoy.data.User} is currently online. If the user is currently * offline, all {@link javafx.scene.Node} variables will be disabled and a * {@link Tooltip} will be displayed for the whole node. *
* Project: client
* File: OnlyIfOnlineSettingsPane.java
* Created: Aug 4, 2020
*
* @author Leon Hofmeister
* @since Envoy Client v0.2-beta
*/
public abstract class OnlyIfOnlineSettingsPane extends SettingsPane {
private final Tooltip beOnlineReminder = new Tooltip("You need to be online to modify your acount.");
/**
* @param title
* @since Envoy Client v0.2-beta
*/
protected OnlyIfOnlineSettingsPane(String title, boolean online) {
super(title);
final var offline = !online;
setDisable(offline);
if (offline) {
final var infoLabel = new Label("You shall not pass!\n(... Unless you would happen to be online)");
infoLabel.setId("infoLabel-warning");
infoLabel.setWrapText(true);
getChildren().add(infoLabel);
setBackground(new Background(new BackgroundFill(Color.grayRgb(100, 0.3), CornerRadii.EMPTY, Insets.EMPTY)));
Tooltip.install(this, beOnlineReminder);
} else Tooltip.uninstall(this, beOnlineReminder);
}
protected void setToolTipText(String text) { beOnlineReminder.setText(text); }
}