Apply resources to BitsquareApp and MainView (WIP)

This commit is contained in:
Manfred Karrer 2017-03-04 18:58:27 -05:00
parent 01cd10c79b
commit f626509158
5 changed files with 242 additions and 128 deletions

View file

@ -10,6 +10,7 @@ import io.bitsquare.common.UserThread;
import io.bitsquare.common.handlers.FaultHandler;
import io.bitsquare.common.util.Tuple2;
import io.bitsquare.http.HttpClient;
import io.bitsquare.locale.BSResources;
import javafx.beans.property.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -36,9 +37,9 @@ public class PriceFeedService {
///////////////////////////////////////////////////////////////////////////////////////////
public enum Type {
ASK("Ask"),
BID("Bid"),
LAST("Last");
ASK(BSResources.get("marketPrice.ask")),
BID(BSResources.get("marketPrice.bid")),
LAST(BSResources.get("marketPrice.last"));
public final String name;

View file

@ -43,6 +43,7 @@ import io.bitsquare.gui.main.debug.DebugView;
import io.bitsquare.gui.main.overlays.popups.Popup;
import io.bitsquare.gui.main.overlays.windows.*;
import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.locale.BSResources;
import io.bitsquare.p2p.P2PService;
import io.bitsquare.storage.Storage;
import io.bitsquare.trade.TradeManager;
@ -215,16 +216,16 @@ public class BitsquareApp extends Application {
} else if (new KeyCodeCombination(KeyCode.J, KeyCombination.ALT_DOWN).match(keyEvent)) {
WalletsManager walletsManager = injector.getInstance(WalletsManager.class);
if (walletsManager.areWalletsAvailable())
new ShowWalletDataWindow(walletsManager).information("Wallet raw data").show();
new ShowWalletDataWindow(walletsManager).show();
else
new Popup<>().warning("The wallet is not initialized yet").show();
new Popup<>().warning(BSResources.get("popup.warning.walletNotInitialized")).show();
} else if (new KeyCodeCombination(KeyCode.G, KeyCombination.ALT_DOWN).match(keyEvent)) {
TradeWalletService tradeWalletService = injector.getInstance(TradeWalletService.class);
BtcWalletService walletService = injector.getInstance(BtcWalletService.class);
if (walletService.isWalletReady())
new SpendFromDepositTxWindow(tradeWalletService).information("Emergency wallet tool").show();
new SpendFromDepositTxWindow(tradeWalletService).show();
else
new Popup<>().warning("The wallet is not initialized yet").show();
new Popup<>().warning(BSResources.get("popup.warning.walletNotInitialized")).show();
} else if (DevFlags.DEV_MODE && new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN).match(keyEvent)) {
showDebugWindow();
}
@ -256,10 +257,7 @@ public class BitsquareApp extends Application {
String osArchitecture = Utilities.getOSArchitecture();
// We don't force a shutdown as the osArchitecture might in strange cases return a wrong value.
// Needs at least more testing on different machines...
new Popup<>().warning("You probably have the wrong Bitsquare version for this computer.\n" +
"Your computer's architecture is: " + osArchitecture + ".\n" +
"The Bitsquare binary you installed is: " + Utilities.getJVMArchitecture() + ".\n" +
"Please shut down and re-install the correct version (" + osArchitecture + ").")
new Popup<>().warning(BSResources.get("popup.warning.wrongVersion"))
.show();
}
@ -326,11 +324,12 @@ public class BitsquareApp extends Application {
stop();
} catch (Throwable throwable2) {
// If printStackTrace cause a further exception we don't pass the throwable to the Popup.
//TODO check if Dialogs is still wanted?
Dialogs.create()
.owner(primaryStage)
.title("Error")
.title(BSResources.get("popup.error.title"))
.message(throwable.toString())
.masthead("A fatal exception occurred at startup.")
.masthead(BSResources.get("popup.error.fatalStartupException"))
.showError();
if (doShutDown)
stop();
@ -345,7 +344,7 @@ public class BitsquareApp extends Application {
Parent parent = (Parent) debugView.getRoot();
Stage stage = new Stage();
stage.setScene(new Scene(parent));
stage.setTitle("Debug window");
stage.setTitle("Debug window"); // Don't translate, just for dev
stage.initModality(Modality.NONE);
stage.initStyle(StageStyle.UTILITY);
stage.initOwner(scene.getWindow());
@ -354,7 +353,6 @@ public class BitsquareApp extends Application {
stage.show();
}
private void showFPSWindow() {
Label label = new Label();
EventStreams.animationTicks()
@ -363,14 +361,14 @@ public class BitsquareApp extends Application {
int n = ticks.size() - 1;
return n * 1_000_000_000.0 / (ticks.get(n) - ticks.get(0));
})
.map(d -> String.format("FPS: %.3f", d))
.map(d -> String.format("FPS: %.3f", d)) // Don't translate, just for dev
.feedTo(label.textProperty());
Pane root = new StackPane();
root.getChildren().add(label);
Stage stage = new Stage();
stage.setScene(new Scene(root));
stage.setTitle("FPS");
stage.setTitle("FPS"); // Don't translate, just for dev
stage.initModality(Modality.NONE);
stage.initStyle(StageStyle.UTILITY);
stage.initOwner(scene.getWindow());
@ -384,9 +382,8 @@ public class BitsquareApp extends Application {
@Override
public void stop() {
if (!shutDownRequested) {
new Popup().headLine("Shut down in progress")
.backgroundInfo("Shutting down application can take a few seconds.\n" +
"Please don't interrupt this process.")
new Popup().headLine(BSResources.get("popup.shutDownInProgress.headline"))
.backgroundInfo(BSResources.get("popup.shutDownInProgress.message"))
.hideCloseButton()
.useAnimation(false)
.show();

View file

@ -40,6 +40,7 @@ import io.bitsquare.gui.main.settings.SettingsView;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.GUIUtil;
import io.bitsquare.gui.util.Transitions;
import io.bitsquare.locale.BSResources;
import javafx.beans.value.ChangeListener;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
@ -126,15 +127,15 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
protected void initialize() {
MainView.rootContainer = this.root;
ToggleButton marketButton = new NavButton(MarketView.class, "Market");
ToggleButton buyButton = new NavButton(BuyOfferView.class, "Buy BTC");
ToggleButton sellButton = new NavButton(SellOfferView.class, "Sell BTC");
ToggleButton portfolioButton = new NavButton(PortfolioView.class, "Portfolio");
ToggleButton fundsButton = new NavButton(FundsView.class, "Funds");
ToggleButton disputesButton = new NavButton(DisputesView.class, "Support");
ToggleButton settingsButton = new NavButton(SettingsView.class, "Settings");
ToggleButton accountButton = new NavButton(AccountView.class, "Account");
ToggleButton daoButton = new NavButton(DaoView.class, "DAO");
ToggleButton marketButton = new NavButton(MarketView.class, BSResources.get("mainView.menu.market"));
ToggleButton buyButton = new NavButton(BuyOfferView.class, BSResources.get("mainView.menu.buyBtc"));
ToggleButton sellButton = new NavButton(SellOfferView.class, BSResources.get("mainView.menu.sellBtc"));
ToggleButton portfolioButton = new NavButton(PortfolioView.class, BSResources.get("mainView.menu.portfolio"));
ToggleButton fundsButton = new NavButton(FundsView.class, BSResources.get("mainView.menu.funds"));
ToggleButton disputesButton = new NavButton(DisputesView.class, BSResources.get("mainView.menu.support"));
ToggleButton settingsButton = new NavButton(SettingsView.class, BSResources.get("mainView.menu.settings"));
ToggleButton accountButton = new NavButton(AccountView.class, BSResources.get("mainView.menu.account"));
ToggleButton daoButton = new NavButton(DaoView.class, BSResources.get("mainView.menu.dao"));
Pane portfolioButtonHolder = new Pane(portfolioButton);
Pane disputesButtonHolder = new Pane(disputesButton);
@ -144,7 +145,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
}};
Tuple3<ComboBox<PriceFeedComboBoxItem>, Label, VBox> marketPriceBox = getMarketPriceBox("Market price");
Tuple3<ComboBox<PriceFeedComboBoxItem>, Label, VBox> marketPriceBox = getMarketPriceBox();
ComboBox<PriceFeedComboBoxItem> priceComboBox = marketPriceBox.first;
priceComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
@ -161,19 +162,19 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
marketPriceBox.second.textProperty().bind(createStringBinding(
() -> {
PriceFeedService.Type type = model.typeProperty.get();
return type != null ? "Market price (" + type.name + ")" : "";
return type != null ? BSResources.get("mainView.marketPrice", type.name) : "";
},
model.marketPriceCurrencyCode, model.typeProperty));
HBox.setMargin(marketPriceBox.third, new Insets(0, 0, 0, 0));
Tuple2<TextField, VBox> availableBalanceBox = getBalanceBox("Available balance");
Tuple2<TextField, VBox> availableBalanceBox = getBalanceBox(BSResources.get("mainView.balance.available"));
availableBalanceBox.first.textProperty().bind(model.availableBalance);
Tuple2<TextField, VBox> reservedBalanceBox = getBalanceBox("Reserved in offers");
Tuple2<TextField, VBox> reservedBalanceBox = getBalanceBox(BSResources.get("mainView.balance.reserved"));
reservedBalanceBox.first.textProperty().bind(model.reservedBalance);
Tuple2<TextField, VBox> lockedBalanceBox = getBalanceBox("Locked in trades");
Tuple2<TextField, VBox> lockedBalanceBox = getBalanceBox(BSResources.get("mainView.balance.locked"));
lockedBalanceBox.first.textProperty().bind(model.lockedBalance);
HBox rightNavPane = new HBox(marketPriceBox.third, availableBalanceBox.second, reservedBalanceBox.second, lockedBalanceBox.second,
@ -247,7 +248,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
"Please check if you have the latest version of Bitsquare installed.\n" +
"You can download it at:\nhttps://github.com/bitsquare/bitsquare/releases\n\n" +
"Please restart the application.")
.closeButtonText("Shut down")
.closeButtonText(BSResources.get("shared.shutDown"))
.onClose(BitsquareApp.shutDownHandler::run)
.show();
} else {
@ -298,7 +299,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
};
}
private Tuple3<ComboBox<PriceFeedComboBoxItem>, Label, VBox> getMarketPriceBox(String text) {
private Tuple3<ComboBox<PriceFeedComboBoxItem>, Label, VBox> getMarketPriceBox() {
ComboBox<PriceFeedComboBoxItem> priceComboBox = new ComboBox<>();
priceComboBox.setVisibleRowCount(20);
priceComboBox.setMaxWidth(220);
@ -310,7 +311,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
buttonCell.setId("price-feed-combo");
priceComboBox.setButtonCell(buttonCell);
Label label = new Label(text);
Label label = new Label();
label.setId("nav-balance-label");
label.setPadding(new Insets(0, 0, 0, 2));

View file

@ -54,7 +54,7 @@ public class SpendFromDepositTxWindow extends Overlay<SpendFromDepositTxWindow>
public void show() {
if (headLine == null)
headLine = "Emergency MS payout tool";
headLine = "Emergency MultiSig payout tool";
width = 1000;
createGridPane();

View file

@ -1,98 +1,107 @@
# Used by gui/components/infoDisplay.java
# Keep display strings organized by domain
# Naming convention: We use camelCase and dot separated name spaces.
# Use as many sub spaces as required to make the structure clear, but as little as possible.
# E.g.: [main-view].[component].[description]
# Shared
shared.readMore=Read more
shared.openHelp=Open Help
shared.warning=Warning
shared.error=Error
shared.close=Close
shared.cancel=Cancel
shared.ok=OK
shared.yes=Yes
shared.no=No
shared.openSettings=Open settings for editing
shared.buyBitcoin=Buy bitcoin
shared.sellBitcoin=Sell bitcoin
shared.buy=buy
shared.sell=sell
shared.spend=spend
# App
####################################################################
# UI views
####################################################################
app.version=You probably have the wrong Bitsquare version for this computer.\nYour computer's architecture is: {0}.\nThe Bitsquare binary you installed is: {1}.\nPlease shut down and re-install the correct version ( {3} ).
app.shutdown.headline=Shutdown in progress ...
app.shutdown.text=Shutting down application can take a few seconds.\nPlease don't interrupt this process.
####################################################################
# Main view
####################################################################
# Payment methods
mainView.menu.market=Market
mainView.menu.buyBtc=Buy BTC
mainView.menu.sellBtc=Sell BTC
mainView.menu.portfolio=Portfolio
mainView.menu.funds=Funds
mainView.menu.support=Support
mainView.menu.settings=Settings
mainView.menu.account=Account
mainView.menu.dao=DAO
payment.account.no=Account no.:
payment.currency=Currency:
payment.account.name=Account name:
payment.payment.method=Payment method:
payment.account.owner=Account holder name:
payment.bank.country=Country of bank:
payment.account.name.email=Account holder name / email
payment.bank.name=Bank name:
payment.select.account=Select account type
payment.select.currency=Select currency
payment.select.region=Select region
payment.select.country=Select country
payment.select.bank.country=Select country of bank
payment.foreign.currency=Are you sure you want to choose a currency other than the country's default currency?
payment.restore.default=No, restore default currency
payment.email=Email:
payment.country=Country:
payment.owner.email=Account holder email:
payment.extras=Extra requirements:
payment.us.info=Bank transfer with WIRE or ACH is not supported for the US because WIRE is too expensive and ACH has a high chargeback risk.\n\nPlease use payment methods \"ClearXchange\", \"US Postal Money Order\" or \"Cash/ATM Deposit\" instead.
payment.email.mobile=Email or mobile no.:
payment.altcoin.address=Altcoin address:
payment.address=address:
payment.altcoin=Altcoin:
payment.select.altcoin=Select or search altcoin
payment.uk.sort=UK sort code:
payment.secret=Secret question:
payment.answer=Answer:
payment.wallet=Wallet ID:
payment.supported.okpay=Supported currencies:
payment.max.allowed=Max. allowed period / date:
payment.hours=hours
payment.days=days
payment.1hour=1 hour
payment.1day=1 day
payment.max.duration=Max. trade duration:
payment.max.limit=Max. trade limit:
payment.limitations=Limitations:
payment.iban=IBAN:
payment.bic=BIC:
payment.accept.euro=Accept trades from these Euro countries:
payment.accept.noneuro=Accept trades from these non-Euro countries:
payment.all.euro=All Euro countries
payment.accepted.countries=Accepted countries:
payment.accepted.banks=Accepted banks:
payment.mobile=Mobile no.:
payment.postal.address=Postal address:
mainView.marketPrice=Market price ({0})
mainView.balance.available=Available balance
mainView.balance.reserved=Reserved in offers
mainView.balance.locked=Locked in trades
# Validation
validation.empty=Empty input is not allowed.
validation.NaN=Input is not a valid number.
validation.zero=Input of 0 is not allowed.
validation.negative=A negative value is not allowed.
validation.fiat.toSmall=Input smaller than minimum possible amount is not allowed.
validation.fiat.toLarge=Input larger than maximum possible amount is not allowed.
validation.btc.toSmall=Input results in a bitcoin value with a fraction of the smallest unit (Satoshi).
validation.btc.toLarge=Input larger than {0} is not allowed.
validation.securityDeposit.toSmall=Input smaller than {0} is not allowed.
validation.passwordTooShort=The password you entered is too short. It needs to have min. 8 characters.
validation.passwordTooLong=The password you entered is too long. It cannot be longer than 50 characters.
validation.sortCodeNumber={0} must consist of {1} numbers.
validation.sortCodeChars={0} must consist of {1} characters.
validation.bankIdNumber={0} must consist of {1} numbers.
validation.accountNr=Account number must consist of {0} numbers.
validation.accountNrChars=Account number must consist of {0} characters.
mainView.footer.usingTor=(using Tor)
mainView.footer.btcInfo=Bitcoin network peers: {0} / synchronized with {1} {2}
mainView.footer.p2pInfo= P2P network peers: {0}
marketPrice.ask=Ask
marketPrice.bid=Bid
marketPrice.last=Last
####################################################################
# Market
####################################################################
market.tabs.offerBook=Offer boook
market.tabs.spread=Spread
market.tabs.trades=Trades
####################################################################
# Offerbook
####################################################################
####################################################################
# Portfolio
####################################################################
####################################################################
# Funds
####################################################################
####################################################################
# Support
####################################################################
####################################################################
# Settings
####################################################################
####################################################################
# Account
####################################################################
####################################################################
# DAO
####################################################################
####################################################################
# Popups
####################################################################
popup.error.title=Error
popup.error.fatalStartupException=A fatal exception occurred at startup.
popup.warning.walletNotInitialized=The wallet is not initialized yet
popup.warning.wrongVersion=You probably have the wrong Bitsquare version for this computer.\nYour computer's architecture is: {0}.\nThe Bitsquare binary you installed is: {1}.\nPlease shut down and re-install the correct version ({2}).
popup.shutDownInProgress.headline=Shut down in progress
popup.shutDownInProgress.message=Shutting down application can take a few seconds.\nPlease don't interrupt this process.
####################################################################
# Offerbook / Create offer
####################################################################
# Create offer
createOffer.amount.prompt=Enter amount in BTC
createOffer.price.prompt=Enter price
createOffer.volume.prompt=Enter amount in {0}
@ -148,7 +157,11 @@ createOffer.success.info=You can manage your open offers in the \"Portfolio\" sc
createOffer.error.message=An error occurred when placing the offer.\n\n{0}
# Take offer
####################################################################
# Offerbook / Take offer
####################################################################
takeOffer.amount.prompt=Enter amount in BTC
takeOffer.price.prompt=Enter price
takeOffer.volume.prompt=Enter amount in {0}
@ -207,7 +220,89 @@ takeOffer.success.headline=You have successfully taken an offer.
takeOffer.success.info=You can see the status of your trade at the \"Portfolio\" screen under \"Open trades\".
takeOffer.error.message=An error occurred when taking the offer.\n\n{0}
####################################################################
# Shared
####################################################################
shared.readMore=Read more
shared.openHelp=Open Help
shared.warning=Warning
shared.error=Error
shared.close=Close
shared.cancel=Cancel
shared.ok=OK
shared.yes=Yes
shared.no=No
shared.notAvailable=N/A
shared.shutDown=Shut down
shared.openSettings=Open settings for editing
shared.buyBitcoin=Buy bitcoin
shared.sellBitcoin=Sell bitcoin
shared.buy=buy
shared.sell=sell
shared.spend=spend
####################################################################
# Domain specific
####################################################################
####################################################################
# Payment methods
####################################################################
payment.account.no=Account no.:
payment.currency=Currency:
payment.account.name=Account name:
payment.payment.method=Payment method:
payment.account.owner=Account holder name:
payment.bank.country=Country of bank:
payment.account.name.email=Account holder name / email
payment.bank.name=Bank name:
payment.select.account=Select account type
payment.select.currency=Select currency
payment.select.region=Select region
payment.select.country=Select country
payment.select.bank.country=Select country of bank
payment.foreign.currency=Are you sure you want to choose a currency other than the country's default currency?
payment.restore.default=No, restore default currency
payment.email=Email:
payment.country=Country:
payment.owner.email=Account holder email:
payment.extras=Extra requirements:
payment.us.info=Bank transfer with WIRE or ACH is not supported for the US because WIRE is too expensive and ACH has a high chargeback risk.\n\nPlease use payment methods \"ClearXchange\", \"US Postal Money Order\" or \"Cash/ATM Deposit\" instead.
payment.email.mobile=Email or mobile no.:
payment.altcoin.address=Altcoin address:
payment.address=address:
payment.altcoin=Altcoin:
payment.select.altcoin=Select or search altcoin
payment.uk.sort=UK sort code:
payment.secret=Secret question:
payment.answer=Answer:
payment.wallet=Wallet ID:
payment.supported.okpay=Supported currencies:
payment.max.allowed=Max. allowed period / date:
payment.hours=hours
payment.days=days
payment.1hour=1 hour
payment.1day=1 day
payment.max.duration=Max. trade duration:
payment.max.limit=Max. trade limit:
payment.limitations=Limitations:
payment.iban=IBAN:
payment.bic=BIC:
payment.accept.euro=Accept trades from these Euro countries:
payment.accept.noneuro=Accept trades from these non-Euro countries:
payment.all.euro=All Euro countries
payment.accepted.countries=Accepted countries:
payment.accepted.banks=Accepted banks:
payment.mobile=Mobile no.:
payment.postal.address=Postal address:
# We use constants from the code so we don't use our normal naming convention
N/A=Not available
OK_PAY=OKPay
PERFECT_MONEY=Perfect Money
@ -223,7 +318,6 @@ CHASE_QUICK_PAY=Chase QuickPay
INTERAC_E_TRANSFER=Interac e-Transfer
US_POSTAL_MONEY_ORDER=US Postal Money Order
CASH_DEPOSIT=Cash Deposit
BLOCK_CHAINS=Altcoins
N/A_SHORT=N/A
@ -241,5 +335,26 @@ CHASE_QUICK_PAY_SHORT=Chase QuickPay
INTERAC_E_TRANSFER_SHORT=Interac e-Transfer
US_POSTAL_MONEY_ORDER_SHORT=US Money Order
CASH_DEPOSIT_SHORT=Cash Deposit
BLOCK_CHAINS_SHORT=Altcoins
BLOCK_CHAINS_SHORT=Altcoins
####################################################################
# Validation
####################################################################
validation.empty=Empty input is not allowed.
validation.NaN=Input is not a valid number.
validation.zero=Input of 0 is not allowed.
validation.negative=A negative value is not allowed.
validation.fiat.toSmall=Input smaller than minimum possible amount is not allowed.
validation.fiat.toLarge=Input larger than maximum possible amount is not allowed.
validation.btc.toSmall=Input results in a bitcoin value with a fraction of the smallest unit (Satoshi).
validation.btc.toLarge=Input larger than {0} is not allowed.
validation.securityDeposit.toSmall=Input smaller than {0} is not allowed.
validation.passwordTooShort=The password you entered is too short. It needs to have min. 8 characters.
validation.passwordTooLong=The password you entered is too long. It cannot be longer than 50 characters.
validation.sortCodeNumber={0} must consist of {1} numbers.
validation.sortCodeChars={0} must consist of {1} characters.
validation.bankIdNumber={0} must consist of {1} numbers.
validation.accountNr=Account number must consist of {0} numbers.
validation.accountNrChars=Account number must consist of {0} characters.