From 06c0211f1fc6449c58d68bd9401bfa01a3546aff Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Wed, 2 Dec 2020 09:43:41 -0600 Subject: [PATCH 1/4] Prevent annoying popup errors for unhandled systray exception. --- common/src/main/java/bisq/common/setup/CommonSetup.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/src/main/java/bisq/common/setup/CommonSetup.java b/common/src/main/java/bisq/common/setup/CommonSetup.java index b56613bd56..f90424d617 100644 --- a/common/src/main/java/bisq/common/setup/CommonSetup.java +++ b/common/src/main/java/bisq/common/setup/CommonSetup.java @@ -74,6 +74,9 @@ public class CommonSetup { } else if (throwable instanceof ClassCastException && "sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData".equals(throwable.getMessage())) { log.warn(throwable.getMessage()); + } else if (throwable instanceof UnsupportedOperationException && + "The system tray is not supported on the current platform.".equals(throwable.getMessage())) { + log.warn(throwable.getMessage()); } else { log.error("Uncaught Exception from thread " + Thread.currentThread().getName()); log.error("throwableMessage= " + throwable.getMessage()); From c7290ee091d19f103f10d757023f8263af9772a8 Mon Sep 17 00:00:00 2001 From: Deus Max Date: Wed, 2 Dec 2020 18:09:03 +0200 Subject: [PATCH 2/4] Replace use of Collections to FXCollections in desktop. Replace use of java library java.util.Collections with javafx.collections.FXCollections instead. Bisq issue#4388. --- .../skin/StaticProgressIndicatorSkin.java | 18 +++---- .../market/offerbook/OfferBookChartView.java | 5 +- .../market/trades/TradesChartsViewModel.java | 14 ++--- .../main/overlays/windows/FilterWindow.java | 5 +- .../settings/preferences/PreferencesView.java | 5 +- .../bisq/desktop/util/AxisInlierUtils.java | 4 +- .../DisplayedTransactionsTest.java | 4 +- .../offerbook/OfferBookViewModelTest.java | 53 +++++++++---------- 8 files changed, 54 insertions(+), 54 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java b/desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java index d7cd410ca6..343bb0a567 100644 --- a/desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java +++ b/desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java @@ -75,8 +75,10 @@ import javafx.beans.property.BooleanProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; +import javafx.collections.ObservableList; +import javafx.collections.FXCollections; + import java.util.ArrayList; -import java.util.Collections; import java.util.List; // TODO Copied form OpenJFX, check license issues and way how we integrated it @@ -261,7 +263,7 @@ public class StaticProgressIndicatorSkin extends SkinBase * CssMetaData of its super classes. */ @SuppressWarnings("SameReturnValue") - public static List> getClassCssMetaData() { + public static ObservableList> getClassCssMetaData() { return StyleableProperties.STYLEABLES; } @@ -316,7 +318,7 @@ public class StaticProgressIndicatorSkin extends SkinBase * {@inheritDoc} */ @Override - public List> getCssMetaData() { + public ObservableList> getCssMetaData() { return getClassCssMetaData(); } @@ -691,7 +693,7 @@ public class StaticProgressIndicatorSkin extends SkinBase */ @SuppressWarnings({"deprecation", "unchecked", "ConstantConditions"}) private static class StyleableProperties { - static final List> STYLEABLES; + static final ObservableList> STYLEABLES; private static final CssMetaData PROGRESS_COLOR = new CssMetaData<>( @@ -746,7 +748,6 @@ public class StaticProgressIndicatorSkin extends SkinBase return skin.spinEnabled == null || !skin.spinEnabled.isBound(); } - @Override public StyleableProperty getStyleableProperty(TxConfidenceIndicator node) { final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) node.getSkin(); @@ -755,13 +756,12 @@ public class StaticProgressIndicatorSkin extends SkinBase }; static { - final List> styleables = - new ArrayList<>(SkinBase.getClassCssMetaData()); + final ObservableList> styleables = + FXCollections.observableArrayList(SkinBase.getClassCssMetaData()); styleables.add(PROGRESS_COLOR); styleables.add(INDETERMINATE_SEGMENT_COUNT); styleables.add(SPIN_ENABLED); - STYLEABLES = Collections.unmodifiableList(styleables); + STYLEABLES = FXCollections.unmodifiableObservableList(styleables); } } - } diff --git a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java index e79b701f32..29a87c9ac2 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java +++ b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java @@ -93,7 +93,6 @@ import java.text.DecimalFormat; import javafx.util.Callback; import javafx.util.StringConverter; -import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -668,12 +667,12 @@ public class OfferBookChartView extends ActivatableViewAndModel> columns = FXCollections.observableArrayList(buyOfferTableView.getColumns()); buyOfferTableView.getColumns().clear(); - Collections.reverse(columns); + FXCollections.reverse(columns); buyOfferTableView.getColumns().addAll(columns); columns = FXCollections.observableArrayList(sellOfferTableView.getColumns()); sellOfferTableView.getColumns().clear(); - Collections.reverse(columns); + FXCollections.reverse(columns); sellOfferTableView.getColumns().addAll(columns); } diff --git a/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java b/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java index 831f5551a6..0e67d26b02 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java @@ -65,7 +65,6 @@ import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashMap; @@ -292,7 +291,7 @@ class TradesChartsViewModel extends ActivatableViewModel { long accumulatedVolume = 0; long accumulatedAmount = 0; long numTrades = set.size(); - List tradePrices = new ArrayList<>(set.size()); + ObservableList tradePrices = FXCollections.observableArrayList(); for (TradeStatistics3 item : set) { long tradePriceAsLong = item.getTradePrice().getValue(); @@ -304,13 +303,14 @@ class TradesChartsViewModel extends ActivatableViewModel { accumulatedAmount += item.getTradeAmount().getValue(); tradePrices.add(item.getTradePrice().getValue()); } - Collections.sort(tradePrices); + FXCollections.sort(tradePrices); List list = new ArrayList<>(set); - list.sort(Comparator.comparingLong(TradeStatistics3::getDateAsLong)); - if (list.size() > 0) { - open = list.get(0).getTradePrice().getValue(); - close = list.get(list.size() - 1).getTradePrice().getValue(); + ObservableList obsList = FXCollections.observableArrayList(list); + obsList.sort(Comparator.comparingLong(TradeStatistics3::getDateAsLong)); + if (obsList.size() > 0) { + open = obsList.get(0).getTradePrice().getValue(); + close = obsList.get(obsList.size() - 1).getTradePrice().getValue(); } long averagePrice; diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java index 167c4e6bd9..a82f00d02b 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java @@ -37,6 +37,8 @@ import javax.inject.Named; import org.apache.commons.lang3.StringUtils; +import javafx.collections.FXCollections; + import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; @@ -50,7 +52,6 @@ import javafx.geometry.HPos; import javafx.geometry.Insets; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -294,7 +295,7 @@ public class FilterWindow extends Overlay { private List readAsList(InputTextField field) { if (field.getText().isEmpty()) { - return Collections.emptyList(); + return FXCollections.emptyObservableList(); } else { return Arrays.asList(StringUtils.deleteWhitespace(field.getText()).split(",")); } diff --git a/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java b/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java index ed2ac501d0..8d000b3139 100644 --- a/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java +++ b/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java @@ -99,7 +99,6 @@ import java.io.File; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; @@ -416,9 +415,9 @@ public class PreferencesView extends ActivatableViewAndModel, VBox> fiatTuple = addTopLabelListView(root, displayCurrenciesGridRowIndex, Res.get("setting.preferences.displayFiat")); diff --git a/desktop/src/main/java/bisq/desktop/util/AxisInlierUtils.java b/desktop/src/main/java/bisq/desktop/util/AxisInlierUtils.java index d80d79a009..66e1c6f2dc 100644 --- a/desktop/src/main/java/bisq/desktop/util/AxisInlierUtils.java +++ b/desktop/src/main/java/bisq/desktop/util/AxisInlierUtils.java @@ -25,8 +25,8 @@ import javafx.scene.chart.XYChart; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; +import javafx.collections.FXCollections; -import java.util.Collections; import java.util.DoubleSummaryStatistics; import java.util.List; import java.util.stream.Collectors; @@ -171,7 +171,7 @@ public class AxisInlierUtils { return numbers; } if (totalPercentTrim == 100) { - return Collections.emptyList(); + return FXCollections.emptyObservableList(); } if (numbers.isEmpty()) { diff --git a/desktop/src/test/java/bisq/desktop/main/funds/transactions/DisplayedTransactionsTest.java b/desktop/src/test/java/bisq/desktop/main/funds/transactions/DisplayedTransactionsTest.java index 1bc407f5c3..09c84516b7 100644 --- a/desktop/src/test/java/bisq/desktop/main/funds/transactions/DisplayedTransactionsTest.java +++ b/desktop/src/test/java/bisq/desktop/main/funds/transactions/DisplayedTransactionsTest.java @@ -23,6 +23,8 @@ import org.bitcoinj.core.Transaction; import com.google.common.collect.Sets; +import javafx.collections.FXCollections; + import java.util.Collections; import java.util.Set; @@ -61,7 +63,7 @@ public class DisplayedTransactionsTest { .thenReturn(Collections.singleton(mock(Transaction.class))); TradableRepository tradableRepository = mock(TradableRepository.class); - when(tradableRepository.getAll()).thenReturn(Collections.emptySet()); + when(tradableRepository.getAll()).thenReturn(FXCollections.emptyObservableSet()); TransactionListItemFactory transactionListItemFactory = mock(TransactionListItemFactory.class); diff --git a/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java index 9cd74e457f..3c75ba5f18 100644 --- a/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java @@ -57,7 +57,6 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -94,7 +93,7 @@ public class OfferBookViewModelTest { @Ignore("PaymentAccountPayload needs to be set (has been changed with PB changes)") public void testIsAnyPaymentAccountValidForOffer() { Collection paymentAccounts; - paymentAccounts = new ArrayList<>(Collections.singletonList(getSepaAccount("EUR", "DE", "1212324", + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSepaAccount("EUR", "DE", "1212324", new ArrayList<>(Arrays.asList("AT", "DE"))))); assertTrue(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getSEPAPaymentMethod("EUR", "AT", new ArrayList<>(Arrays.asList("AT", "DE")), "PSK"), paymentAccounts)); @@ -108,33 +107,33 @@ public class OfferBookViewModelTest { // simple cases: same payment methods // offer: alipay paymentAccount: alipay - same country, same currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getAliPayAccount("CNY"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getAliPayAccount("CNY"))); assertTrue(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getAliPayPaymentMethod("EUR"), paymentAccounts)); // offer: ether paymentAccount: ether - same country, same currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getCryptoAccount("ETH"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getCryptoAccount("ETH"))); assertTrue(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getBlockChainsPaymentMethod("ETH"), paymentAccounts)); // offer: sepa paymentAccount: sepa - same country, same currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getSepaAccount("EUR", "AT", "1212324", + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSepaAccount("EUR", "AT", "1212324", new ArrayList<>(Arrays.asList("AT", "DE"))))); assertTrue(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getSEPAPaymentMethod("EUR", "AT", new ArrayList<>(Arrays.asList("AT", "DE")), "PSK"), paymentAccounts)); // offer: nationalBank paymentAccount: nationalBank - same country, same currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getNationalBankAccount("EUR", "AT", "PSK"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getNationalBankAccount("EUR", "AT", "PSK"))); assertTrue(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // offer: SameBank paymentAccount: SameBank - same country, same currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getSameBankAccount("EUR", "AT", "PSK"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSameBankAccount("EUR", "AT", "PSK"))); assertTrue(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getSameBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // offer: sepa paymentAccount: sepa - diff. country, same currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getSepaAccount("EUR", "DE", "1212324", new ArrayList<>(Arrays.asList("AT", "DE"))))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSepaAccount("EUR", "DE", "1212324", new ArrayList<>(Arrays.asList("AT", "DE"))))); assertTrue(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getSEPAPaymentMethod("EUR", "AT", new ArrayList<>(Arrays.asList("AT", "DE")), "PSK"), paymentAccounts)); @@ -142,78 +141,78 @@ public class OfferBookViewModelTest { ////// // offer: sepa paymentAccount: sepa - same country, same currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getSepaAccount("EUR", "AT", "1212324", new ArrayList<>(Arrays.asList("AT", "DE"))))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSepaAccount("EUR", "AT", "1212324", new ArrayList<>(Arrays.asList("AT", "DE"))))); assertTrue(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getSEPAPaymentMethod("EUR", "AT", new ArrayList<>(Arrays.asList("AT", "DE")), "PSK"), paymentAccounts)); // offer: sepa paymentAccount: nationalBank - same country, same currency // wrong method - paymentAccounts = new ArrayList<>(Collections.singletonList(getNationalBankAccount("EUR", "AT", "PSK"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getNationalBankAccount("EUR", "AT", "PSK"))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getSEPAPaymentMethod("EUR", "AT", new ArrayList<>(Arrays.asList("AT", "DE")), "PSK"), paymentAccounts)); // wrong currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getNationalBankAccount("USD", "US", "XXX"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getNationalBankAccount("USD", "US", "XXX"))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // wrong country - paymentAccounts = new ArrayList<>(Collections.singletonList(getNationalBankAccount("EUR", "FR", "PSK"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getNationalBankAccount("EUR", "FR", "PSK"))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // sepa wrong country - paymentAccounts = new ArrayList<>(Collections.singletonList(getNationalBankAccount("EUR", "CH", "PSK"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getNationalBankAccount("EUR", "CH", "PSK"))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getSEPAPaymentMethod("EUR", "AT", new ArrayList<>(Arrays.asList("AT", "DE")), "PSK"), paymentAccounts)); // sepa wrong currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getNationalBankAccount("CHF", "DE", "PSK"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getNationalBankAccount("CHF", "DE", "PSK"))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getSEPAPaymentMethod("EUR", "AT", new ArrayList<>(Arrays.asList("AT", "DE")), "PSK"), paymentAccounts)); // same bank - paymentAccounts = new ArrayList<>(Collections.singletonList(getSameBankAccount("EUR", "AT", "PSK"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSameBankAccount("EUR", "AT", "PSK"))); assertTrue(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // not same bank - paymentAccounts = new ArrayList<>(Collections.singletonList(getSameBankAccount("EUR", "AT", "Raika"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSameBankAccount("EUR", "AT", "Raika"))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // same bank, wrong country - paymentAccounts = new ArrayList<>(Collections.singletonList(getSameBankAccount("EUR", "DE", "PSK"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSameBankAccount("EUR", "DE", "PSK"))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // same bank, wrong currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getSameBankAccount("USD", "AT", "PSK"))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSameBankAccount("USD", "AT", "PSK"))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // spec. bank - paymentAccounts = new ArrayList<>(Collections.singletonList(getSpecificBanksAccount("EUR", "AT", "PSK", + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSpecificBanksAccount("EUR", "AT", "PSK", new ArrayList<>(Arrays.asList("PSK", "Raika"))))); assertTrue(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // spec. bank, missing bank - paymentAccounts = new ArrayList<>(Collections.singletonList(getSpecificBanksAccount("EUR", "AT", "PSK", - new ArrayList<>(Collections.singletonList("Raika"))))); + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSpecificBanksAccount("EUR", "AT", "PSK", + new ArrayList<>(FXCollections.singletonObservableList("Raika"))))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // spec. bank, wrong country - paymentAccounts = new ArrayList<>(Collections.singletonList(getSpecificBanksAccount("EUR", "FR", "PSK", + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSpecificBanksAccount("EUR", "FR", "PSK", new ArrayList<>(Arrays.asList("PSK", "Raika"))))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); // spec. bank, wrong currency - paymentAccounts = new ArrayList<>(Collections.singletonList(getSpecificBanksAccount("USD", "AT", "PSK", + paymentAccounts = new ArrayList<>(FXCollections.singletonObservableList(getSpecificBanksAccount("USD", "AT", "PSK", new ArrayList<>(Arrays.asList("PSK", "Raika"))))); assertFalse(PaymentAccountUtil.isAnyTakerPaymentAccountValidForOffer( getNationalBankPaymentMethod("EUR", "AT", "PSK"), paymentAccounts)); @@ -526,7 +525,7 @@ public class OfferBookViewModelTest { return getPaymentMethod(currencyCode, PaymentMethod.NATIONAL_BANK_ID, countryCode, - new ArrayList<>(Collections.singletonList(countryCode)), + new ArrayList<>(FXCollections.singletonObservableList(countryCode)), bankId, null); } @@ -535,9 +534,9 @@ public class OfferBookViewModelTest { return getPaymentMethod(currencyCode, PaymentMethod.SAME_BANK_ID, countryCode, - new ArrayList<>(Collections.singletonList(countryCode)), + new ArrayList<>(FXCollections.singletonObservableList(countryCode)), bankId, - new ArrayList<>(Collections.singletonList(bankId))); + new ArrayList<>(FXCollections.singletonObservableList(bankId))); } private Offer getSpecificBanksPaymentMethod(String currencyCode, @@ -547,7 +546,7 @@ public class OfferBookViewModelTest { return getPaymentMethod(currencyCode, PaymentMethod.SPECIFIC_BANKS_ID, countryCode, - new ArrayList<>(Collections.singletonList(countryCode)), + new ArrayList<>(FXCollections.singletonObservableList(countryCode)), bankId, bankIds); } From b8bdbbc55140ed287296f3e31188e96c75483d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Louck=C3=BD?= Date: Tue, 1 Dec 2020 23:35:18 +0100 Subject: [PATCH 3/4] Fix warning for rejected transaction --- core/src/main/resources/i18n/displayStrings.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index b454a9fc3d..e8d414ecd2 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2803,7 +2803,7 @@ popup.warning.openOffer.makerFeeTxRejected=The maker fee transaction for offer w popup.warning.trade.txRejected.tradeFee=trade fee popup.warning.trade.txRejected.deposit=deposit popup.warning.trade.txRejected=The {0} transaction for trade with ID {1} was rejected by the Bitcoin network.\n\ - Transaction ID={2}}\n\ + Transaction ID={2}\n\ The trade has been moved to failed trades.\n\ Please go to \"Settings/Network info\" and do a SPV resync.\n\ For further help please contact the Bisq support channel at the Bisq Keybase team. From d60030e2f2eedc16e77ea8b154678ca05a318286 Mon Sep 17 00:00:00 2001 From: Deus Max Date: Thu, 3 Dec 2020 21:06:34 +0200 Subject: [PATCH 4/4] Offer Book chart outlier filter improved. Outlier data filter used for the Market Offer Book chart, now accounts for the switching display position of Buy, Sell data depending on currency type (Crypto or Fiat). --- .../market/offerbook/OfferBookChartView.java | 94 ++++++++++++------- 1 file changed, 62 insertions(+), 32 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java index e79b701f32..3cfb832cfc 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java +++ b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java @@ -127,7 +127,7 @@ public class OfferBookChartView extends ActivatableViewAndModel changeListener; private ListChangeListener currencyListItemsListener; - private final double chartDataFactor = 3; + private final double dataLimitFactor = 3; private final double initialOfferTableViewHeight = 121; private final double pixelsPerOfferTableRow = (initialOfferTableViewHeight - 30) / 5.0; // initial visible row count=5, header height=30 private final Function offerTableViewHeight = (screenSize) -> { @@ -387,48 +387,78 @@ public class OfferBookChartView extends ActivatableViewAndModel o.getXValue().doubleValue()) - .min() - .orElse(Double.MAX_VALUE); + List leftMnMx, rightMnMx; + boolean isCrypto = CurrencyUtil.isCryptoCurrency(model.getCurrencyCode()); + if (isCrypto) { // crypto: left-sell, right-buy, + leftMnMx = minMaxFilterLeft(model.getSellData()); + rightMnMx = minMaxFilterRight(model.getBuyData()); + } else { // fiat: left-buy, right-sell + leftMnMx = minMaxFilterLeft(model.getBuyData()); + rightMnMx = minMaxFilterRight(model.getSellData()); + } - // Hide buy offers that are more than a factor of chartDataFactor higher than the lowest buy offer - double buyMaxValue = model.getBuyData().stream() - .mapToDouble(o -> o.getXValue().doubleValue()) - .filter(o -> o < buyMinValue * chartDataFactor) - .max() - .orElse(Double.MIN_VALUE); - - double sellMaxValue = model.getSellData().stream() - .mapToDouble(o -> o.getXValue().doubleValue()) - .max() - .orElse(Double.MIN_VALUE); - - // Hide sell offers that are less than a factor of chartDataFactor lower than the highest sell offer - double sellMinValue = model.getSellData().stream() - .mapToDouble(o -> o.getXValue().doubleValue()) - .filter(o -> o > sellMaxValue / chartDataFactor) - .min() - .orElse(Double.MAX_VALUE); - - double minValue = Double.min(buyMinValue, sellMinValue); - double maxValue = Double.max(buyMaxValue, sellMaxValue); + double minValue = Double.min(leftMnMx.get(0).doubleValue(), rightMnMx.get(0).doubleValue()); + double maxValue = Double.max(leftMnMx.get(1).doubleValue(), rightMnMx.get(1).doubleValue()); if (minValue == Double.MAX_VALUE || maxValue == Double.MIN_VALUE) { // no filtering seriesBuy.getData().addAll(model.getBuyData()); seriesSell.getData().addAll(model.getSellData()); } else { // apply filtering - seriesBuy.getData().addAll(model.getBuyData().stream() - .filter(o -> o.getXValue().doubleValue() < buyMinValue * 3) - .collect(Collectors.toList())); - seriesSell.getData().addAll(model.getSellData().stream() - .filter(o -> o.getXValue().doubleValue() > sellMaxValue / 3) - .collect(Collectors.toList())); + if (isCrypto) { // crypto: left-sell, right-buy + seriesBuy.getData().addAll(filterRight(model.getBuyData(), rightMnMx.get(0))); + seriesSell.getData().addAll(filterLeft(model.getSellData(), leftMnMx.get(1))); + } else { // fiat: left-buy, right-sell + seriesBuy.getData().addAll(filterLeft(model.getBuyData(), leftMnMx.get(1))); + seriesSell.getData().addAll(filterRight(model.getSellData(), rightMnMx.get(0))); + } } areaChart.getData().addAll(List.of(seriesBuy, seriesSell)); } + private List minMaxFilterLeft(List> data) { + double maxValue = data.stream() + .mapToDouble(o -> o.getXValue().doubleValue()) + .max() + .orElse(Double.MIN_VALUE); + // Hide sell offers that are less than a div-factor of dataLimitFactor + // lower than the highest sell offer. + double minValue = data.stream() + .mapToDouble(o -> o.getXValue().doubleValue()) + .filter(o -> o > maxValue / dataLimitFactor) + .min() + .orElse(Double.MAX_VALUE); + return List.of(minValue, maxValue); + } + + private List minMaxFilterRight(List> data) { + double minValue = data.stream() + .mapToDouble(o -> o.getXValue().doubleValue()) + .min() + .orElse(Double.MAX_VALUE); + + // Hide sell offers that are more than dataLimitFactor factor higher + // than the lowest sell offer + double maxValue = data.stream() + .mapToDouble(o -> o.getXValue().doubleValue()) + .filter(o -> o < minValue * dataLimitFactor) + .max() + .orElse(Double.MIN_VALUE); + return List.of(minValue, maxValue); + } + + private List> filterLeft(List> data, double maxValue) { + return data.stream() + .filter(o -> o.getXValue().doubleValue() > maxValue / dataLimitFactor) + .collect(Collectors.toList()); + } + + private List> filterRight(List> data, double minValue) { + return data.stream() + .filter(o -> o.getXValue().doubleValue() < minValue * dataLimitFactor) + .collect(Collectors.toList()); + } + private Tuple4, VBox, Button, Label> getOfferTable(OfferPayload.Direction direction) { TableView tableView = new TableView<>(); tableView.setMinHeight(initialOfferTableViewHeight);