60 lines
1.7 KiB
Java
60 lines
1.7 KiB
Java
package envoy.client.ui.settings;
|
|
|
|
import javafx.geometry.Insets;
|
|
import javafx.scene.control.*;
|
|
import javafx.scene.layout.*;
|
|
import javafx.scene.paint.Color;
|
|
|
|
import envoy.client.net.Client;
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* @author Leon Hofmeister
|
|
* @author Kai S. K. Engelbart
|
|
* @since Envoy Client v0.2-beta
|
|
*/
|
|
public abstract class OnlineOnlySettingsPane extends SettingsPane {
|
|
|
|
protected final Client client = context.getClient();
|
|
|
|
private final Tooltip beOnlineReminder =
|
|
new Tooltip("You need to be online to modify your account.");
|
|
|
|
/**
|
|
* @param title the title of this pane
|
|
* @since Envoy Client v0.2-beta
|
|
*/
|
|
protected OnlineOnlySettingsPane(String title) {
|
|
super(title);
|
|
|
|
setDisable(!client.isOnline());
|
|
|
|
if (!client.isOnline()) {
|
|
final var infoLabel =
|
|
new Label("You shall not pass!\n(... Unless you would happen to be online)");
|
|
infoLabel.setId("info-label-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);
|
|
}
|
|
|
|
/**
|
|
* Sets the text of the tooltip displayed for this pane.
|
|
*
|
|
* @param text the text to display
|
|
* @since Envoy Client v0.2-beta
|
|
*/
|
|
protected void setToolTipText(String text) {
|
|
beOnlineReminder.setText(text);
|
|
}
|
|
}
|