mirror of
https://github.com/cryptomator/cryptomator.git
synced 2024-11-23 03:59:51 +00:00
removed FXML loader, elements created programmatically in NotificationBar
This commit is contained in:
parent
c5cfe4d1b3
commit
1e280f2c97
@ -37,7 +37,6 @@ public enum FxmlFile {
|
|||||||
MIGRATION_RUN("/fxml/migration_run.fxml"), //
|
MIGRATION_RUN("/fxml/migration_run.fxml"), //
|
||||||
MIGRATION_START("/fxml/migration_start.fxml"), //
|
MIGRATION_START("/fxml/migration_start.fxml"), //
|
||||||
MIGRATION_SUCCESS("/fxml/migration_success.fxml"), //
|
MIGRATION_SUCCESS("/fxml/migration_success.fxml"), //
|
||||||
NOTIFICATION("/fxml/notification.fxml"),
|
|
||||||
PREFERENCES("/fxml/preferences.fxml"), //
|
PREFERENCES("/fxml/preferences.fxml"), //
|
||||||
QUIT("/fxml/quit.fxml"), //
|
QUIT("/fxml/quit.fxml"), //
|
||||||
QUIT_FORCED("/fxml/quit_forced.fxml"), //
|
QUIT_FORCED("/fxml/quit_forced.fxml"), //
|
||||||
|
@ -6,9 +6,12 @@ import javafx.beans.property.BooleanProperty;
|
|||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.layout.Region;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class NotificationBar extends HBox {
|
public class NotificationBar extends HBox {
|
||||||
@ -24,11 +27,31 @@ public class NotificationBar extends HBox {
|
|||||||
|
|
||||||
|
|
||||||
public NotificationBar() {
|
public NotificationBar() {
|
||||||
loadFXML();
|
setAlignment(Pos.CENTER);
|
||||||
closeButton.visibleProperty().bind(dismissable);
|
setStyle("-fx-alignment: center;");
|
||||||
|
|
||||||
visibleProperty().bind(notifyProperty());
|
Region spacer = new Region();
|
||||||
managedProperty().bind(notifyProperty());
|
spacer.setMinWidth(40);
|
||||||
|
|
||||||
|
Region leftRegion = new Region();
|
||||||
|
HBox.setHgrow(leftRegion, javafx.scene.layout.Priority.ALWAYS);
|
||||||
|
|
||||||
|
Region rightRegion = new Region();
|
||||||
|
HBox.setHgrow(rightRegion, javafx.scene.layout.Priority.ALWAYS);
|
||||||
|
|
||||||
|
VBox vbox = new VBox();
|
||||||
|
vbox.setAlignment(Pos.CENTER);
|
||||||
|
HBox.setHgrow(vbox, javafx.scene.layout.Priority.ALWAYS);
|
||||||
|
|
||||||
|
notificationLabel = new Label();
|
||||||
|
notificationLabel.getStyleClass().add("notification-label");
|
||||||
|
notificationLabel.setStyle("-fx-alignment: center;");
|
||||||
|
vbox.getChildren().add(notificationLabel);
|
||||||
|
|
||||||
|
closeButton = new Button("X");
|
||||||
|
closeButton.setMinWidth(40);
|
||||||
|
closeButton.setStyle("-fx-background-color: transparent; -fx-text-fill: white; -fx-font-weight: bold;");
|
||||||
|
closeButton.visibleProperty().bind(dismissable);
|
||||||
|
|
||||||
closeButton.setOnAction(_ -> {
|
closeButton.setOnAction(_ -> {
|
||||||
visibleProperty().unbind();
|
visibleProperty().unbind();
|
||||||
@ -36,17 +59,19 @@ public class NotificationBar extends HBox {
|
|||||||
visibleProperty().set(false);
|
visibleProperty().set(false);
|
||||||
managedProperty().set(false);
|
managedProperty().set(false);
|
||||||
});
|
});
|
||||||
}
|
closeButton.visibleProperty().bind(dismissable);
|
||||||
|
|
||||||
private void loadFXML() {
|
closeButton.setOnAction(_ -> {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(FxmlFile.NOTIFICATION.getRessourcePathString()));
|
visibleProperty().unbind();
|
||||||
fxmlLoader.setController(this);
|
managedProperty().unbind();
|
||||||
try {
|
visibleProperty().set(false);
|
||||||
HBox content = fxmlLoader.load();
|
managedProperty().set(false);
|
||||||
this.getChildren().addAll(content.getChildren());
|
});
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
getChildren().addAll(spacer, leftRegion, vbox, rightRegion, closeButton);
|
||||||
}
|
|
||||||
|
visibleProperty().bind(notifyProperty());
|
||||||
|
managedProperty().bind(notifyProperty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.Region?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
<HBox xmlns:fx="http://javafx.com/fxml"
|
|
||||||
xmlns="http://javafx.com/javafx"
|
|
||||||
alignment="CENTER"
|
|
||||||
style="-fx-alignment: center;">
|
|
||||||
<Region minWidth="40"/>
|
|
||||||
<Region HBox.hgrow="ALWAYS"/>
|
|
||||||
<VBox alignment="CENTER" HBox.hgrow="ALWAYS">
|
|
||||||
<Label fx:id="notificationLabel" styleClass="notification-label" style="-fx-alignment: center;"/>
|
|
||||||
</VBox>
|
|
||||||
<Region HBox.hgrow="ALWAYS"/>
|
|
||||||
|
|
||||||
<Button fx:id="closeButton" minWidth="40" text="X" style="-fx-background-color: transparent; -fx-text-fill: white; -fx-font-weight: bold;"/>
|
|
||||||
</HBox>
|
|
Loading…
Reference in New Issue
Block a user