mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-24 23:46:00 -04:00
Add edit field in currency list
This commit is contained in:
parent
2f0f58c478
commit
61eee8f445
5 changed files with 28 additions and 107 deletions
|
@ -39,6 +39,7 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
class MarketsChartsViewModel extends ActivatableViewModel {
|
||||
final static String EDIT_FLAG = "EDIT_FLAG";
|
||||
|
||||
private final OfferBook offerBook;
|
||||
private final Preferences preferences;
|
||||
|
|
|
@ -93,10 +93,13 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
currencyComboBox.setConverter(new StringConverter<TradeCurrency>() {
|
||||
@Override
|
||||
public String toString(TradeCurrency tradeCurrency) {
|
||||
if (!tradeCurrency.getCode().equals(OfferBookViewModel.SHOW_ALL_FLAG))
|
||||
return tradeCurrency.getNameAndCode();
|
||||
String code = tradeCurrency.getCode();
|
||||
if (code.equals(OfferBookViewModel.SHOW_ALL_FLAG))
|
||||
return ">> Show all";
|
||||
else if (code.equals(OfferBookViewModel.EDIT_FLAG))
|
||||
return ">> Edit currency list";
|
||||
else
|
||||
return "Show all";
|
||||
return tradeCurrency.getNameAndCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,7 +114,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
@Override
|
||||
public String toString(PaymentMethod paymentMethod) {
|
||||
String id = paymentMethod.getId();
|
||||
return BSResources.get(!id.equals(OfferBookViewModel.SHOW_ALL_FLAG) ? id : "Show all");
|
||||
return BSResources.get(!id.equals(OfferBookViewModel.SHOW_ALL_FLAG) ? id : ">> Show all");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,11 @@ import io.bitsquare.app.Version;
|
|||
import io.bitsquare.btc.pricefeed.PriceFeed;
|
||||
import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.common.model.ActivatableViewModel;
|
||||
import io.bitsquare.gui.main.MainView;
|
||||
import io.bitsquare.gui.main.settings.SettingsView;
|
||||
import io.bitsquare.gui.main.settings.preferences.PreferencesView;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.locale.*;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
|
@ -49,7 +53,8 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
|
||||
class OfferBookViewModel extends ActivatableViewModel {
|
||||
final static String SHOW_ALL_FLAG = "XXX";
|
||||
final static String SHOW_ALL_FLAG = "SHOW_ALL_FLAG";
|
||||
final static String EDIT_FLAG = "EDIT_FLAG";
|
||||
|
||||
private final OpenOfferManager openOfferManager;
|
||||
private final User user;
|
||||
|
@ -57,6 +62,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
private final Preferences preferences;
|
||||
private final P2PService p2PService;
|
||||
private final PriceFeed priceFeed;
|
||||
private Navigation navigation;
|
||||
final BSFormatter formatter;
|
||||
|
||||
private final FilteredList<OfferBookListItem> filteredItems;
|
||||
|
@ -88,7 +94,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
@Inject
|
||||
public OfferBookViewModel(User user, OpenOfferManager openOfferManager, OfferBook offerBook,
|
||||
Preferences preferences, P2PService p2PService, PriceFeed priceFeed,
|
||||
BSFormatter formatter) {
|
||||
Navigation navigation, BSFormatter formatter) {
|
||||
super();
|
||||
|
||||
this.openOfferManager = openOfferManager;
|
||||
|
@ -97,6 +103,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
this.preferences = preferences;
|
||||
this.p2PService = p2PService;
|
||||
this.priceFeed = priceFeed;
|
||||
this.navigation = navigation;
|
||||
this.formatter = formatter;
|
||||
|
||||
offerBookListItems = offerBook.getOfferBookListItems();
|
||||
|
@ -133,9 +140,9 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
private void fillAllTradeCurrencies() {
|
||||
allTradeCurrencies.clear();
|
||||
// Used for ignoring filter (show all)
|
||||
TradeCurrency dummy = new FiatCurrency(SHOW_ALL_FLAG);
|
||||
allTradeCurrencies.add(dummy);
|
||||
allTradeCurrencies.add(new CryptoCurrency(SHOW_ALL_FLAG, SHOW_ALL_FLAG));
|
||||
allTradeCurrencies.addAll(preferences.getTradeCurrenciesAsObservable());
|
||||
allTradeCurrencies.add(new CryptoCurrency(EDIT_FLAG, EDIT_FLAG));
|
||||
}
|
||||
|
||||
private void setMarketPriceFeedCurrency() {
|
||||
|
@ -168,7 +175,9 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
public void onSetTradeCurrency(TradeCurrency tradeCurrency) {
|
||||
String code = tradeCurrency.getCode();
|
||||
showAllTradeCurrenciesProperty.set(isShowAllEntry(code));
|
||||
if (!showAllTradeCurrenciesProperty.get()) {
|
||||
if (isEditEntry(code))
|
||||
navigation.navigateTo(MainView.class, SettingsView.class, PreferencesView.class);
|
||||
else if (!showAllTradeCurrenciesProperty.get()) {
|
||||
this.selectedTradeCurrency = tradeCurrency;
|
||||
tradeCurrencyCode.set(code);
|
||||
}
|
||||
|
@ -366,4 +375,8 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
private boolean isShowAllEntry(String id) {
|
||||
return id.equals(SHOW_ALL_FLAG);
|
||||
}
|
||||
|
||||
private boolean isEditEntry(String id) {
|
||||
return id.equals(EDIT_FLAG);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -313,6 +313,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Activatab
|
|||
private void activateDisplayCurrencies() {
|
||||
preferredTradeCurrencyComboBox.setItems(tradeCurrencies);
|
||||
preferredTradeCurrencyComboBox.getSelectionModel().select(preferences.getPreferredTradeCurrency());
|
||||
preferredTradeCurrencyComboBox.setVisibleRowCount(Math.min(preferredTradeCurrencyComboBox.getItems().size(), 25));
|
||||
preferredTradeCurrencyComboBox.setOnAction(e -> {
|
||||
TradeCurrency selectedItem = preferredTradeCurrencyComboBox.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem != null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue