From b4af3586dcc5c61282de44e05a108475082ec2c9 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 28 Jul 2022 16:09:10 +0200 Subject: [PATCH] explicitly name functions in strings --- .../com/sparrowwallet/sparrow/wallet/Function.java | 12 +++++++++++- .../sparrow/wallet/WalletController.java | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/Function.java b/src/main/java/com/sparrowwallet/sparrow/wallet/Function.java index 9fc2af35..c97b9cdc 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/Function.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/Function.java @@ -1,5 +1,15 @@ package com.sparrowwallet.sparrow.wallet; public enum Function { - TRANSACTIONS, SEND, RECEIVE, ADDRESSES, UTXOS, SETTINGS, LOCK; + TRANSACTIONS("transactions"), SEND("send"), RECEIVE("receive"), ADDRESSES("addresses"), UTXOS("utxos"), SETTINGS("settings"), LOCK("lock"); + + private final String name; + + Function(String name) { + this.name = name; + } + + public String getName() { + return name; + } } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletController.java index c201d214..9e7c7984 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/WalletController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/WalletController.java @@ -90,9 +90,9 @@ public class WalletController extends WalletFormController implements Initializa try { if(!existing) { - URL url = AppServices.class.getResource("wallet/" + function.toString().toLowerCase() + ".fxml"); + URL url = AppServices.class.getResource("wallet/" + function.getName() + ".fxml"); if(url == null) { - url = AppServices.class.getResource("wallet" + File.separator + function.toString().toLowerCase() + ".fxml"); + url = AppServices.class.getResource("wallet" + File.separator + function.getName() + ".fxml"); } if(url == null) { throw new IllegalStateException("Cannot find wallet/" + function.toString().toLowerCase() + ".fxml");