Skip to content

Commit

Permalink
Merge pull request #4068 from jmacxx/fix_column_sort_range
Browse files Browse the repository at this point in the history
Sorting order of offers appropriately by min/max range
  • Loading branch information
ripcurlx authored Mar 18, 2020
2 parents fdc17e9 + d4dae4b commit d9b5422
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ public void initialize() {
Comparator.nullsFirst(Comparator.naturalOrder())
));
priceColumn.setComparator(Comparator.comparing(o -> o.getOffer().getPrice(), Comparator.nullsFirst(Comparator.naturalOrder())));
amountColumn.setComparator(Comparator.comparing(o -> o.getOffer().getAmount()));
volumeColumn.setComparator(Comparator.comparing(o -> o.getOffer().getVolume(), Comparator.nullsFirst(Comparator.naturalOrder())));
amountColumn.setComparator(Comparator.comparing(o -> o.getOffer().getMinAmount()));
volumeColumn.setComparator(Comparator.comparing(o -> o.getOffer().getMinVolume(), Comparator.nullsFirst(Comparator.naturalOrder())));
paymentMethodColumn.setComparator(Comparator.comparing(o -> o.getOffer().getPaymentMethod()));
avatarColumn.setComparator(Comparator.comparing(o -> o.getOffer().getOwnerNodeAddress().getFullAddress()));

Expand Down Expand Up @@ -293,6 +293,21 @@ protected void activate() {
model.priceSortTypeProperty.addListener((observable, oldValue, newValue) -> priceColumn.setSortType(newValue));
priceColumn.setSortType(model.priceSortTypeProperty.get());

amountColumn.sortTypeProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == TableColumn.SortType.DESCENDING) {
amountColumn.setComparator(Comparator.comparing(o -> o.getOffer().getAmount(), Comparator.nullsFirst(Comparator.naturalOrder())));
} else {
amountColumn.setComparator(Comparator.comparing(o -> o.getOffer().getMinAmount(), Comparator.nullsFirst(Comparator.naturalOrder())));
}
});
volumeColumn.sortTypeProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == TableColumn.SortType.DESCENDING) {
volumeColumn.setComparator(Comparator.comparing(o -> o.getOffer().getVolume(), Comparator.nullsFirst(Comparator.naturalOrder())));
} else {
volumeColumn.setComparator(Comparator.comparing(o -> o.getOffer().getMinVolume(), Comparator.nullsFirst(Comparator.naturalOrder())));
}
});

paymentMethodComboBox.setConverter(new PaymentMethodStringConverter(paymentMethodComboBox));
paymentMethodComboBox.getEditor().getStyleClass().add("combo-box-editor-bold");

Expand Down

0 comments on commit d9b5422

Please sign in to comment.