mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Use FXCollections instead of not existing ObservableListWrapper
This commit is contained in:
parent
8ed7f4218f
commit
13266b26da
@ -204,7 +204,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
||||
}
|
||||
});
|
||||
|
||||
model.currencyListItems.addListener(currencyListItemsListener);
|
||||
model.currencyListItems.getObservableList().addListener(currencyListItemsListener);
|
||||
|
||||
model.getOfferBookListItems().addListener(changeListener);
|
||||
tradeCurrencySubscriber = EasyBind.subscribe(model.selectedTradeCurrencyProperty,
|
||||
@ -295,7 +295,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
|
||||
protected void deactivate() {
|
||||
model.getOfferBookListItems().removeListener(changeListener);
|
||||
tabPaneSelectionModel.selectedIndexProperty().removeListener(selectedTabIndexListener);
|
||||
model.currencyListItems.removeListener(currencyListItemsListener);
|
||||
model.currencyListItems.getObservableList().removeListener(currencyListItemsListener);
|
||||
tradeCurrencySubscriber.unsubscribe();
|
||||
currencyComboBox.setOnAction(null);
|
||||
buyOfferTableView.getSelectionModel().selectedItemProperty().removeListener(buyTableRowSelectionListener);
|
||||
|
@ -234,11 +234,11 @@ class OfferBookChartViewModel extends ActivatableViewModel {
|
||||
}
|
||||
|
||||
public ObservableList<CurrencyListItem> getCurrencyListItems() {
|
||||
return currencyListItems;
|
||||
return currencyListItems.getObservableList();
|
||||
}
|
||||
|
||||
public Optional<CurrencyListItem> getSelectedCurrencyListItem() {
|
||||
return currencyListItems.stream().filter(e -> e.tradeCurrency.equals(selectedTradeCurrencyProperty.get())).findAny();
|
||||
return currencyListItems.getObservableList().stream().filter(e -> e.tradeCurrency.equals(selectedTradeCurrencyProperty.get())).findAny();
|
||||
}
|
||||
|
||||
public int getMaxNumberOfPriceZeroDecimalsToColorize(Offer offer) {
|
||||
|
@ -220,11 +220,11 @@ class TradesChartsViewModel extends ActivatableViewModel {
|
||||
}
|
||||
|
||||
public ObservableList<CurrencyListItem> getCurrencyListItems() {
|
||||
return currencyListItems;
|
||||
return currencyListItems.getObservableList();
|
||||
}
|
||||
|
||||
public Optional<CurrencyListItem> getSelectedCurrencyListItem() {
|
||||
return currencyListItems.stream().filter(e -> e.tradeCurrency.equals(selectedTradeCurrencyProperty.get())).findAny();
|
||||
return currencyListItems.getObservableList().stream().filter(e -> e.tradeCurrency.equals(selectedTradeCurrencyProperty.get())).findAny();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -22,7 +22,8 @@ import bisq.core.user.Preferences;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import com.sun.javafx.collections.ObservableListWrapper;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
@ -36,25 +37,30 @@ import java.util.function.BiFunction;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CurrencyList extends ObservableListWrapper<CurrencyListItem> {
|
||||
public class CurrencyList {
|
||||
private final CurrencyPredicates predicates;
|
||||
private final Preferences preferences;
|
||||
private final List<CurrencyListItem> delegate;
|
||||
|
||||
public CurrencyList(Preferences preferences) {
|
||||
this(new ArrayList<>(), preferences, new CurrencyPredicates());
|
||||
}
|
||||
|
||||
CurrencyList(List<CurrencyListItem> delegate, Preferences preferences, CurrencyPredicates predicates) {
|
||||
super(delegate);
|
||||
public CurrencyList(List<CurrencyListItem> delegate, Preferences preferences, CurrencyPredicates predicates) {
|
||||
this.delegate = delegate;
|
||||
this.predicates = predicates;
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
public ObservableList<CurrencyListItem> getObservableList() {
|
||||
return FXCollections.observableList(delegate);
|
||||
}
|
||||
|
||||
public void updateWithCurrencies(List<TradeCurrency> currencies, @Nullable CurrencyListItem first) {
|
||||
List<CurrencyListItem> result = Lists.newLinkedList();
|
||||
Optional.ofNullable(first).ifPresent(result::add);
|
||||
result.addAll(getPartitionedSortedItems(currencies));
|
||||
setAll(result);
|
||||
delegate.addAll(result);
|
||||
}
|
||||
|
||||
private List<CurrencyListItem> getPartitionedSortedItems(List<TradeCurrency> currencies) {
|
||||
|
Loading…
Reference in New Issue
Block a user