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.
This commit is contained in:
Chris Beams 2014-11-11 12:22:01 +01:00
parent 8f8866da6a
commit 454ee1fbe0
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
5 changed files with 16 additions and 7 deletions

View file

@ -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);
}});
}

View file

@ -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));
}
}

View file

@ -36,6 +36,8 @@ import org.slf4j.LoggerFactory;
public class ViewCB<T extends PresentationModel> 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<? extends PresentationModel> when all UIs are updated
protected Initializable childController;

View file

@ -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());
}
}

View file

@ -59,7 +59,7 @@ public class MainViewCB extends ViewCB<MainPM> {
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<MainPM> {
@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<MainPM> {
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)