From d8bd91f959d8d14a46106b4ba536964134f0fe8c Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 5 Jul 2025 10:56:25 -0400 Subject: [PATCH] always use 'currency name (code)' format --- .../main/offer/offerbook/OfferBookView.java | 2 +- .../settings/preferences/PreferencesView.java | 2 +- .../haveno/desktop/util/CurrencyListItem.java | 2 +- .../java/haveno/desktop/util/GUIUtil.java | 30 +------------------ .../java/haveno/desktop/util/GUIUtilTest.java | 22 -------------- 5 files changed, 4 insertions(+), 54 deletions(-) diff --git a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookView.java b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookView.java index 6be82a1c81..d10e6b6562 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookView.java @@ -511,7 +511,7 @@ abstract public class OfferBookView() { @Override public String toString(TradeCurrency object) { - return object.getCode() + " - " + object.getName(); + return object.getName() + " (" + object.getCode() + ")"; } @Override diff --git a/desktop/src/main/java/haveno/desktop/util/CurrencyListItem.java b/desktop/src/main/java/haveno/desktop/util/CurrencyListItem.java index 5a85a80d08..3aea50a638 100644 --- a/desktop/src/main/java/haveno/desktop/util/CurrencyListItem.java +++ b/desktop/src/main/java/haveno/desktop/util/CurrencyListItem.java @@ -61,7 +61,7 @@ public class CurrencyListItem { if (isSpecialShowAllItem()) return Res.get(GUIUtil.SHOW_ALL_FLAG); else - return tradeCurrency.getCode() + " - " + tradeCurrency.getName(); + return tradeCurrency.getName() + " (" + tradeCurrency.getCode() + ")"; } private boolean isSpecialShowAllItem() { diff --git a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java index 2193cec831..2710c00f6a 100644 --- a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java @@ -387,7 +387,7 @@ public class GUIUtil { String code = item.getCode(); AnchorPane pane = new AnchorPane(); - Label currency = new AutoTooltipLabel(code + " - " + item.getName()); + Label currency = new AutoTooltipLabel(item.getName() + " (" + item.getCode() + ")"); currency.getStyleClass().add("currency-label-selected"); AnchorPane.setLeftAnchor(currency, 0.0); pane.getChildren().add(currency); @@ -422,34 +422,6 @@ public class GUIUtil { }; } - public static StringConverter getTradeCurrencyConverter(String postFixSingle, - String postFixMulti, - Map offerCounts) { - return new StringConverter<>() { - @Override - public String toString(TradeCurrency tradeCurrency) { - String code = tradeCurrency.getCode(); - Optional offerCountOptional = Optional.ofNullable(offerCounts.get(code)); - final String displayString; - displayString = offerCountOptional - .map(offerCount -> CurrencyUtil.getNameAndCode(code) - + " - " + offerCount + " " + (offerCount == 1 ? postFixSingle : postFixMulti)) - .orElseGet(() -> CurrencyUtil.getNameAndCode(code)); - // http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618 - if (code.equals(GUIUtil.SHOW_ALL_FLAG)) - return "▶ " + Res.get("list.currency.showAll"); - else if (code.equals(GUIUtil.EDIT_FLAG)) - return "▼ " + Res.get("list.currency.editList"); - return tradeCurrency.getDisplayPrefix() + displayString; - } - - @Override - public TradeCurrency fromString(String s) { - return null; - } - }; - } - public static Callback, ListCell> getTradeCurrencyCellFactory(String postFixSingle, String postFixMulti, Map offerCounts) { diff --git a/desktop/src/test/java/haveno/desktop/util/GUIUtilTest.java b/desktop/src/test/java/haveno/desktop/util/GUIUtilTest.java index dc7d68c873..f5b00a7fb6 100644 --- a/desktop/src/test/java/haveno/desktop/util/GUIUtilTest.java +++ b/desktop/src/test/java/haveno/desktop/util/GUIUtilTest.java @@ -19,21 +19,15 @@ package haveno.desktop.util; import haveno.core.locale.GlobalSettings; import haveno.core.locale.Res; -import haveno.core.locale.TradeCurrency; import haveno.core.trade.HavenoUtils; import haveno.core.user.DontShowAgainLookup; import haveno.core.user.Preferences; -import javafx.util.StringConverter; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.math.BigInteger; -import java.util.HashMap; import java.util.Locale; -import java.util.Map; -import static haveno.desktop.maker.TradeCurrencyMakers.euro; -import static haveno.desktop.maker.TradeCurrencyMakers.monero; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -49,22 +43,6 @@ public class GUIUtilTest { Res.setBaseCurrencyName("Bitcoin"); } - @Test - public void testTradeCurrencyConverter() { - Map offerCounts = new HashMap<>() {{ - put("XMR", 11); - put("EUR", 10); - }}; - StringConverter tradeCurrencyConverter = GUIUtil.getTradeCurrencyConverter( - Res.get("shared.oneOffer"), - Res.get("shared.multipleOffers"), - offerCounts - ); - - assertEquals("✦ Monero (XMR) - 11 offers", tradeCurrencyConverter.toString(monero)); - assertEquals("★ Euro (EUR) - 10 offers", tradeCurrencyConverter.toString(euro)); - } - @Test public void testOpenURLWithCampaignParameters() { Preferences preferences = mock(Preferences.class);