mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Add missing filtering on lists - introduce FilterableListItem
This commit is contained in:
parent
1b571e9575
commit
06b73a6231
11 changed files with 118 additions and 103 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.desktop.main.funds.deposit;
|
||||
|
||||
import bisq.desktop.util.filtering.FilterableListItem;
|
||||
import bisq.desktop.components.indicator.TxConfidenceIndicator;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
|
@ -44,7 +45,7 @@ import java.util.function.Supplier;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
class DepositListItem {
|
||||
class DepositListItem implements FilterableListItem {
|
||||
private final StringProperty balance = new SimpleStringProperty();
|
||||
private final BtcWalletService walletService;
|
||||
private Coin balanceAsCoin;
|
||||
|
@ -149,4 +150,18 @@ class DepositListItem {
|
|||
public int getNumTxOutputs() {
|
||||
return numTxOutputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String filterString) {
|
||||
if (filterString.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (getAddressString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
if (getUsage().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
return getBalance().contains(filterString);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,20 +287,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void applyFilteredListPredicate(String filterString) {
|
||||
filteredList.setPredicate(item -> {
|
||||
if (filterString.isEmpty())
|
||||
return true;
|
||||
|
||||
if (item.getAddressString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getUsage().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return item.getBalance().contains(filterString);
|
||||
});
|
||||
filteredList.setPredicate(item -> item.match(filterString));
|
||||
}
|
||||
|
||||
private void fillForm(String address) {
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
|
||||
package bisq.desktop.main.funds.locked;
|
||||
|
||||
import bisq.desktop.util.filtering.FilterableListItem;
|
||||
import bisq.desktop.components.AutoTooltipLabel;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.filtering.FilteringUtils;
|
||||
|
||||
import bisq.core.btc.listeners.BalanceListener;
|
||||
import bisq.core.btc.model.AddressEntry;
|
||||
|
@ -38,7 +40,7 @@ import lombok.Getter;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
class LockedListItem {
|
||||
class LockedListItem implements FilterableListItem {
|
||||
private final BalanceListener balanceListener;
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final CoinFormatter formatter;
|
||||
|
@ -117,4 +119,28 @@ class LockedListItem {
|
|||
DisplayUtils.formatDateTime(trade.getDate()) :
|
||||
Res.get("shared.noDateAvailable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String filterString) {
|
||||
if (filterString.isEmpty())
|
||||
return true;
|
||||
|
||||
if (getDetails().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getDateString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getAddressString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getBalanceString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return FilteringUtils.match(getTrade(), filterString);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,28 +239,7 @@ public class LockedView extends ActivatableView<VBox, Void> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void applyFilteredListPredicate(String filterString) {
|
||||
filteredList.setPredicate(item -> {
|
||||
if (filterString.isEmpty())
|
||||
return true;
|
||||
|
||||
if (item.getDetails().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getDateString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getAddressString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getBalanceString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return FilteringUtils.match(item.getTrade(), filterString);
|
||||
});
|
||||
filteredList.setPredicate(item -> item.match(filterString));
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
|
||||
package bisq.desktop.main.funds.reserved;
|
||||
|
||||
import bisq.desktop.util.filtering.FilterableListItem;
|
||||
import bisq.desktop.components.AutoTooltipLabel;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.filtering.FilteringUtils;
|
||||
|
||||
import bisq.core.btc.listeners.BalanceListener;
|
||||
import bisq.core.btc.model.AddressEntry;
|
||||
|
@ -37,7 +39,7 @@ import java.util.Optional;
|
|||
|
||||
import lombok.Getter;
|
||||
|
||||
class ReservedListItem {
|
||||
class ReservedListItem implements FilterableListItem {
|
||||
private final BalanceListener balanceListener;
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final CoinFormatter formatter;
|
||||
|
@ -114,4 +116,24 @@ class ReservedListItem {
|
|||
Res.get("funds.reserved.reserved", openOffer.getShortId()) :
|
||||
Res.get("shared.noDetailsAvailable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String filterString) {
|
||||
if (filterString.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (getDetails().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
if (getAddressString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
if (getDateAsString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
if (getBalanceString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
return FilteringUtils.match(getOpenOffer().getOffer(), filterString);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,28 +239,7 @@ public class ReservedView extends ActivatableView<VBox, Void> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void applyFilteredListPredicate(String filterString) {
|
||||
filteredList.setPredicate(item -> {
|
||||
if (filterString.isEmpty())
|
||||
return true;
|
||||
|
||||
if (item.getDetails().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getAddressString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getDateAsString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getBalanceString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return FilteringUtils.match(item.getOpenOffer().getOffer(), filterString);
|
||||
});
|
||||
filteredList.setPredicate(item -> item.match(filterString));
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.desktop.main.funds.transactions;
|
||||
|
||||
import bisq.desktop.util.filtering.FilterableListItem;
|
||||
import bisq.desktop.components.indicator.TxConfidenceIndicator;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
@ -55,7 +56,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
@Slf4j
|
||||
class TransactionsListItem {
|
||||
class TransactionsListItem implements FilterableListItem {
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final CoinFormatter formatter;
|
||||
private String dateString;
|
||||
|
@ -377,4 +378,30 @@ class TransactionsListItem {
|
|||
public String getMemo() {
|
||||
return memo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String filterString) {
|
||||
if (filterString.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (getTxId().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
if (getDetails().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
if (getMemo() != null && getMemo().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
if (getDirection().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
if (getDateString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
if (getAmount().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
return getAddressString().contains(filterString);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -342,36 +342,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
|
|||
}
|
||||
|
||||
private void applyFilteredListPredicate(String filterString) {
|
||||
filteredList.setPredicate(item -> {
|
||||
if (filterString.isEmpty())
|
||||
return true;
|
||||
|
||||
if (item.getTxId().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getDetails().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getMemo() != null && item.getMemo().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getDirection().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getDateString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getAmount().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return item.getAddressString().contains(filterString);
|
||||
});
|
||||
filteredList.setPredicate(item -> item.match(filterString));
|
||||
}
|
||||
|
||||
private void openTxInBlockExplorer(TransactionsListItem item) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.desktop.main.funds.withdrawal;
|
||||
|
||||
import bisq.desktop.util.filtering.FilterableListItem;
|
||||
import bisq.desktop.components.AutoTooltipLabel;
|
||||
|
||||
import bisq.core.btc.listeners.BalanceListener;
|
||||
|
@ -34,7 +35,7 @@ import javafx.scene.control.Label;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
class WithdrawalListItem {
|
||||
class WithdrawalListItem implements FilterableListItem {
|
||||
private final BalanceListener balanceListener;
|
||||
private final Label balanceLabel;
|
||||
private final AddressEntry addressEntry;
|
||||
|
@ -125,4 +126,16 @@ class WithdrawalListItem {
|
|||
public String getAddressString() {
|
||||
return addressString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String filterString) {
|
||||
if (filterString.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (getBalanceAsString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
return getAddressString().contains(filterString);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -408,16 +408,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void applyFilteredListPredicate(String filterString) {
|
||||
filteredList.setPredicate(item -> {
|
||||
if (filterString.isEmpty())
|
||||
return true;
|
||||
|
||||
if (item.getBalanceAsString().contains(filterString)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return item.getAddressString().contains(filterString);
|
||||
});
|
||||
filteredList.setPredicate(item -> item.match(filterString));
|
||||
}
|
||||
|
||||
private void onWithdraw() {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package bisq.desktop.util.filtering;
|
||||
|
||||
public interface FilterableListItem {
|
||||
boolean match(String filterString);
|
||||
}
|
Loading…
Add table
Reference in a new issue