50 lines
1.6 KiB
Java
50 lines
1.6 KiB
Java
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.
|
|
* <p>
|
|
* Project: <strong>client</strong><br>
|
|
* File: <strong>OnlyIfOnlineSettingsPane.java</strong><br>
|
|
* Created: <strong>04.08.2020</strong><br>
|
|
*
|
|
* @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 account.");
|
|
|
|
/**
|
|
* @param title
|
|
* @since Envoy Client v0.2-beta
|
|
*/
|
|
protected OnlyIfOnlineSettingsPane(String title, boolean online) {
|
|
super(title);
|
|
|
|
setDisable(!online);
|
|
|
|
if (!online) {
|
|
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); }
|
|
}
|