From 454ee1fbe043efa14545ee0f14f5caa4e37ddd98 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 11 Nov 2014 12:22:01 +0100 Subject: [PATCH] Introduce explicit title param in ViewCB Like previous commits, this change removes reliance on the global "appName" in favor of an explicit and configurable "view.title" parameter. It is still set by default to the value of appName, but this assignment is now done in BitsquareEnvironment, as are the other similar parameters that have been broken out in previous commits. --- .../java/io/bitsquare/app/BitsquareEnvironment.java | 3 +++ src/main/java/io/bitsquare/gui/GuiModule.java | 4 ++++ src/main/java/io/bitsquare/gui/ViewCB.java | 2 ++ .../bitsquare/gui/components/SystemNotification.java | 4 ++-- src/main/java/io/bitsquare/gui/main/MainViewCB.java | 10 +++++----- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/bitsquare/app/BitsquareEnvironment.java b/src/main/java/io/bitsquare/app/BitsquareEnvironment.java index e66520517d..83ffaccf03 100644 --- a/src/main/java/io/bitsquare/app/BitsquareEnvironment.java +++ b/src/main/java/io/bitsquare/app/BitsquareEnvironment.java @@ -20,6 +20,7 @@ package io.bitsquare.app; import io.bitsquare.BitsquareException; import io.bitsquare.btc.UserAgent; import io.bitsquare.btc.WalletFacade; +import io.bitsquare.gui.ViewCB; import io.bitsquare.persistence.Persistence; import com.google.common.base.Preconditions; @@ -81,6 +82,8 @@ public class BitsquareEnvironment extends StandardEnvironment { setProperty(Persistence.DIR_KEY, AppDirectory.dir(appName).toString()); setProperty(Persistence.PREFIX_KEY, appName + "_pref"); + + setProperty(ViewCB.TITLE_KEY, appName); }}); } diff --git a/src/main/java/io/bitsquare/gui/GuiModule.java b/src/main/java/io/bitsquare/gui/GuiModule.java index 48f06c1975..ce06522b0f 100644 --- a/src/main/java/io/bitsquare/gui/GuiModule.java +++ b/src/main/java/io/bitsquare/gui/GuiModule.java @@ -28,6 +28,8 @@ import io.bitsquare.gui.util.validation.FiatValidator; import io.bitsquare.gui.util.validation.InputValidator; import io.bitsquare.gui.util.validation.PasswordValidator; +import com.google.inject.name.Names; + import javafx.stage.Stage; import org.springframework.core.env.Environment; @@ -57,5 +59,7 @@ public class GuiModule extends BitsquareModule { bind(Stage.class).toInstance(primaryStage); Popups.primaryStage = primaryStage; Help.primaryStage = primaryStage; + + bindConstant().annotatedWith(Names.named(ViewCB.TITLE_KEY)).to(env.getRequiredProperty(ViewCB.TITLE_KEY)); } } diff --git a/src/main/java/io/bitsquare/gui/ViewCB.java b/src/main/java/io/bitsquare/gui/ViewCB.java index f31f4a8e39..65cccfa947 100644 --- a/src/main/java/io/bitsquare/gui/ViewCB.java +++ b/src/main/java/io/bitsquare/gui/ViewCB.java @@ -36,6 +36,8 @@ import org.slf4j.LoggerFactory; public class ViewCB implements Initializable { private static final Logger log = LoggerFactory.getLogger(ViewCB.class); + public static final String TITLE_KEY = "view.title"; + protected T presentationModel; //TODO Initializable has to be changed to CodeBehind when all UIs are updated protected Initializable childController; diff --git a/src/main/java/io/bitsquare/gui/components/SystemNotification.java b/src/main/java/io/bitsquare/gui/components/SystemNotification.java index 3b3712e7d0..d9d140dc6c 100644 --- a/src/main/java/io/bitsquare/gui/components/SystemNotification.java +++ b/src/main/java/io/bitsquare/gui/components/SystemNotification.java @@ -31,11 +31,11 @@ public class SystemNotification { private static final Logger log = LoggerFactory.getLogger(SystemNotification.class); private static final Notification.Notifier notifier = NotifierBuilder.create().build(); - public static void openInfoNotification(String headline, String message) { + public static void openInfoNotification(String title, String message) { // On windows it causes problems with the hidden stage used in the hansolo Notification implementation // Lets deactivate it for the moment and fix that with a more native-like or real native solution later. String os = System.getProperty("os.name").toLowerCase(); if (!os.contains("win")) - notifier.notify(NotificationBuilder.create().title(headline).message(message).build()); + notifier.notify(NotificationBuilder.create().title(title).message(message).build()); } } diff --git a/src/main/java/io/bitsquare/gui/main/MainViewCB.java b/src/main/java/io/bitsquare/gui/main/MainViewCB.java index a8dfd5a041..f79adf9cb2 100644 --- a/src/main/java/io/bitsquare/gui/main/MainViewCB.java +++ b/src/main/java/io/bitsquare/gui/main/MainViewCB.java @@ -59,7 +59,7 @@ public class MainViewCB extends ViewCB { private final OverlayManager overlayManager; private final ToggleGroup navButtonsGroup = new ToggleGroup(); private final Settings settings; - private final String appName; + private final String title; private BorderPane baseApplicationContainer; private VBox splashScreen; @@ -77,13 +77,13 @@ public class MainViewCB extends ViewCB { @Inject private MainViewCB(MainPM presentationModel, Navigation navigation, OverlayManager overlayManager, - TradeManager tradeManager, Settings settings, @Named("appName") String appName) { + TradeManager tradeManager, Settings settings, @Named(TITLE_KEY) String title) { super(presentationModel); this.navigation = navigation; this.overlayManager = overlayManager; this.settings = settings; - this.appName = appName; + this.title = title; tradeManager.featureNotImplementedWarningProperty().addListener((ov, oldValue, newValue) -> { if (oldValue == null && newValue != null) { @@ -207,8 +207,8 @@ public class MainViewCB extends ViewCB { numPendingTradesLabel.setText(String.valueOf(numPendingTrades)); } - log.trace("openInfoNotification " + appName); - SystemNotification.openInfoNotification(appName, "You got a new trade message."); + log.trace("openInfoNotification " + title); + SystemNotification.openInfoNotification(title, "You got a new trade message."); } else { if (portfolioButtonButtonPane.getChildren().size() > 1)