diff --git a/client/src/main/java/ctbrec/ui/CamrecApplication.java b/client/src/main/java/ctbrec/ui/CamrecApplication.java index 08f07836..7e59df7e 100644 --- a/client/src/main/java/ctbrec/ui/CamrecApplication.java +++ b/client/src/main/java/ctbrec/ui/CamrecApplication.java @@ -48,7 +48,6 @@ import javafx.scene.control.Alert; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import javafx.scene.image.Image; -import javafx.scene.media.AudioClip; import javafx.scene.paint.Color; import javafx.stage.Stage; import okhttp3.Request; @@ -66,7 +65,7 @@ public class CamrecApplication extends Application { private TabPane rootPane = new TabPane(); private List sites = new ArrayList<>(); public static HttpClient httpClient; - private Notification.Notifier notifier; + private Notification.Notifier notifier = Notification.Notifier.INSTANCE; @Override public void start(Stage primaryStage) throws Exception { @@ -93,6 +92,7 @@ public class CamrecApplication extends Application { } createGui(primaryStage); checkForUpdates(); + new Thread(() -> { try { Thread.sleep(TimeUnit.SECONDS.toMillis(10)); @@ -212,7 +212,6 @@ public class CamrecApplication extends Application { private void registerAlertSystem() { Notification.Notifier.setNotificationOwner(primaryStage); - notifier = Notification.Notifier.INSTANCE; EventBusHolder.BUS.register(new Object() { @Subscribe public void modelEvent(Map e) { @@ -223,10 +222,9 @@ public class CamrecApplication extends Application { LOG.debug("Alert: {} is {}", model.getName(), status); if (Objects.equals("online", status)) { Platform.runLater(() -> { - AudioClip clip = new AudioClip("file:///tmp/Oxygen-Im-Highlight-Msg.mp3"); - clip.play(); - Notification notification = new Notification("Model Online", model.getName() + " is now online"); - notifier.notify(notification); + notifier.notifyInfo("Model Online", model.getName() + " is now online"); + //AudioClip clip = new AudioClip("file:///tmp/Oxygen-Im-Highlight-Msg.mp3"); + //clip.play(); }); } } diff --git a/client/src/main/java/eu/hansolo/enzo/notification/Notification.java b/client/src/main/java/eu/hansolo/enzo/notification/Notification.java index 074fc295..567beaaa 100644 --- a/client/src/main/java/eu/hansolo/enzo/notification/Notification.java +++ b/client/src/main/java/eu/hansolo/enzo/notification/Notification.java @@ -79,7 +79,7 @@ public class Notification { private static double offsetX = 0; private static double offsetY = 25; private static double spacingY = 5; - private static Pos popupLocation = Pos.TOP_RIGHT; + private static Pos popupLocation = Pos.BOTTOM_RIGHT; private static Stage stageRef = null; private Duration popupLifetime; private Stage stage; @@ -101,7 +101,10 @@ public class Notification { } private void initGraphics() { - scene = new Scene(new Region()); + Region region = new Region(); + region.resize(0, 0); + region.setVisible(false); + scene = new Scene(region); scene.setFill(null); scene.getStylesheets().add(getClass().getResource("notifier.css").toExternalForm()); @@ -134,6 +137,7 @@ public class Notification { */ public static void setNotificationOwner(final Stage OWNER) { INSTANCE.stage.initOwner(OWNER); + INSTANCE.stage.getScene().getStylesheets().addAll(OWNER.getScene().getStylesheets()); } /** @@ -306,7 +310,6 @@ public class Notification { final Popup POPUP = new Popup(); POPUP.setX( getX() ); POPUP.setY( getY() ); - System.out.println(POPUP.getX() + "," + POPUP.getY()); POPUP.getContent().add(popupContent); popups.add(POPUP); @@ -323,6 +326,7 @@ public class Notification { timeline.setOnFinished(actionEvent -> Platform.runLater(() -> { POPUP.hide(); popups.remove(POPUP); + stage.hide(); })); // Move popup to the right during fade out diff --git a/client/src/main/resources/eu/hansolo/enzo/notification/notifier.css b/client/src/main/resources/eu/hansolo/enzo/notification/notifier.css index 723117bc..ded966ed 100644 --- a/client/src/main/resources/eu/hansolo/enzo/notification/notifier.css +++ b/client/src/main/resources/eu/hansolo/enzo/notification/notifier.css @@ -19,11 +19,11 @@ -fx-fill : transparent; } .notification { - -fx-background-color : -fx-background; + -fx-background-color : -fx-base; -fx-background-radius: 5; - -fx-effect : innershadow(two-pass-box, rgba(255, 255, 255, 0.6), 5.0, 0.25, 0, 0); - -foreground-color : -fx-base; - -icon-color : -fx-base; + -fx-effect : dropshadow(gaussian, rgba(0, 0, 0, 0.8), 20, 0, 0, 0); + -foreground-color : -fx-text-background-color; + -icon-color : -fx-text-background-color; } .notification .title {