mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-10 00:39:32 -04:00
always use 'currency name (code)' format
This commit is contained in:
parent
da17bcc76d
commit
d8bd91f959
5 changed files with 4 additions and 54 deletions
|
@ -511,7 +511,7 @@ abstract public class OfferBookView<R extends GridPane, M extends OfferBookViewM
|
|||
return Res.get(GUIUtil.SHOW_ALL_FLAG);
|
||||
if (isSpecialEditItem(item))
|
||||
return Res.get(GUIUtil.EDIT_FLAG);
|
||||
return item.getCode() + " - " + item.getName();
|
||||
return item.getName() + " (" + item.getCode() + ")";
|
||||
}
|
||||
|
||||
private boolean isSpecialShowAllItem(TradeCurrency item) {
|
||||
|
|
|
@ -315,7 +315,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
preferredTradeCurrencyComboBox.setConverter(new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(TradeCurrency object) {
|
||||
return object.getCode() + " - " + object.getName();
|
||||
return object.getName() + " (" + object.getCode() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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<TradeCurrency> getTradeCurrencyConverter(String postFixSingle,
|
||||
String postFixMulti,
|
||||
Map<String, Integer> offerCounts) {
|
||||
return new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(TradeCurrency tradeCurrency) {
|
||||
String code = tradeCurrency.getCode();
|
||||
Optional<Integer> 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<ListView<TradeCurrency>, ListCell<TradeCurrency>> getTradeCurrencyCellFactory(String postFixSingle,
|
||||
String postFixMulti,
|
||||
Map<String, Integer> offerCounts) {
|
||||
|
|
|
@ -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<String, Integer> offerCounts = new HashMap<>() {{
|
||||
put("XMR", 11);
|
||||
put("EUR", 10);
|
||||
}};
|
||||
StringConverter<TradeCurrency> 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue