Add missing filtering on lists - introduce shared FilterBox

This commit is contained in:
xyzmaker123 2022-01-21 20:44:43 +01:00
parent 291ccef803
commit 75b9902e97
No known key found for this signature in database
GPG Key ID: 47689699B7B0AAFC
10 changed files with 89 additions and 130 deletions

View File

@ -0,0 +1,56 @@
package bisq.desktop.components.list;
import bisq.desktop.components.AutoTooltipLabel;
import bisq.desktop.components.InputTextField;
import bisq.desktop.util.filtering.FilterableListItem;
import bisq.core.locale.Res;
import javafx.scene.control.TableView;
import javafx.scene.layout.HBox;
import javafx.geometry.Insets;
import javafx.beans.value.ChangeListener;
import javafx.collections.transformation.FilteredList;
public class FilterBox extends HBox {
private final InputTextField textField;
private FilteredList<? extends FilterableListItem> filteredList;
private ChangeListener<String> listener;
public FilterBox() {
super();
setSpacing(5.0);
AutoTooltipLabel label = new AutoTooltipLabel(Res.get("shared.filter"));
HBox.setMargin(label, new Insets(5.0, 0, 0, 10.0));
textField = new InputTextField();
textField.setMinWidth(500);
getChildren().addAll(label, textField);
}
public void initialize(FilteredList<? extends FilterableListItem> filteredList,
TableView<? extends FilterableListItem> tableView) {
this.filteredList = filteredList;
listener = (observable, oldValue, newValue) -> {
tableView.getSelectionModel().clearSelection();
applyFilteredListPredicate(textField.getText());
};
}
public void activate() {
textField.textProperty().addListener(listener);
applyFilteredListPredicate(textField.getText());
}
public void deactivate() {
textField.textProperty().removeListener(listener);
}
private void applyFilteredListPredicate(String filterString) {
filteredList.setPredicate(item -> item.match(filterString));
}
}

View File

@ -23,22 +23,13 @@
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.HBox?>
<?import bisq.desktop.components.AutoTooltipLabel?>
<?import bisq.desktop.components.InputTextField?>
<?import bisq.desktop.components.list.FilterBox?>
<VBox fx:id="root" fx:controller="bisq.desktop.main.funds.deposit.DepositView"
spacing="10" xmlns:fx="http://javafx.com/fxml">
<padding>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0"/>
</padding>
<HBox spacing="5.0">
<AutoTooltipLabel fx:id="filterLabel">
<HBox.margin>
<Insets top="5.0" left="10.0" />
</HBox.margin>
</AutoTooltipLabel>
<InputTextField fx:id="filterTextField" minWidth="500"/>
</HBox>
<FilterBox fx:id="filterBox" />
<TableView fx:id="tableView" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="addressColumn" minWidth="320"/>

View File

@ -25,6 +25,7 @@ import bisq.desktop.components.ExternalHyperlink;
import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.components.list.FilterBox;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.QRCodeWindow;
import bisq.desktop.util.GUIUtil;
@ -103,9 +104,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
@FXML
GridPane gridPane;
@FXML
AutoTooltipLabel filterLabel;
@FXML
InputTextField filterTextField;
FilterBox filterBox;
@FXML
TableView<DepositListItem> tableView;
@FXML
@ -128,7 +127,6 @@ public class DepositView extends ActivatableView<VBox, Void> {
private Subscription amountTextFieldSubscription;
private ChangeListener<DepositListItem> tableViewSelectionListener;
private int gridRow = 0;
private ChangeListener<String> filterTextFieldListener;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, lifecycle
@ -145,12 +143,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
@Override
public void initialize() {
filterTextFieldListener = (observable, oldValue, newValue) -> {
tableView.getSelectionModel().clearSelection();
applyFilteredListPredicate(filterTextField.getText());
};
filterLabel.setText(Res.get("shared.filter"));
filterBox.initialize(filteredList, tableView);
paymentLabelString = Res.get("funds.deposit.fundBisqWallet");
addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address")));
balanceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.balanceWithCur", Res.getBaseCurrencyCode())));
@ -253,8 +246,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
@Override
protected void activate() {
filterTextField.textProperty().addListener(filterTextFieldListener);
applyFilteredListPredicate(filterTextField.getText());
filterBox.activate();
tableView.getSelectionModel().selectedItemProperty().addListener(tableViewSelectionListener);
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
@ -273,7 +265,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
@Override
protected void deactivate() {
filterTextField.textProperty().removeListener(filterTextFieldListener);
filterBox.deactivate();
tableView.getSelectionModel().selectedItemProperty().removeListener(tableViewSelectionListener);
sortedList.comparatorProperty().unbind();
observableList.forEach(DepositListItem::cleanup);
@ -286,10 +278,6 @@ public class DepositView extends ActivatableView<VBox, Void> {
// UI handlers
///////////////////////////////////////////////////////////////////////////////////////////
private void applyFilteredListPredicate(String filterString) {
filteredList.setPredicate(item -> item.match(filterString));
}
private void fillForm(String address) {
titledGroupBg.setVisible(true);
titledGroupBg.setManaged(true);

View File

@ -25,21 +25,13 @@
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>
<?import javafx.geometry.Insets?>
<?import bisq.desktop.components.AutoTooltipLabel?>
<?import bisq.desktop.components.InputTextField?>
<?import bisq.desktop.components.list.FilterBox?>
<VBox fx:id="root" fx:controller="bisq.desktop.main.funds.locked.LockedView"
spacing="10" xmlns:fx="http://javafx.com/fxml">
<padding>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0"/>
</padding>
<HBox spacing="5.0">
<AutoTooltipLabel fx:id="filterLabel">
<HBox.margin>
<Insets top="5.0" left="10.0" />
</HBox.margin>
</AutoTooltipLabel>
<InputTextField fx:id="filterTextField" minWidth="500"/>
</HBox>
<FilterBox fx:id="filterBox" />
<TableView fx:id="tableView" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="dateColumn" minWidth="180" maxWidth="180"/>

View File

@ -23,7 +23,7 @@ import bisq.desktop.components.AutoTooltipButton;
import bisq.desktop.components.AutoTooltipLabel;
import bisq.desktop.components.ExternalHyperlink;
import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.list.FilterBox;
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
import bisq.desktop.util.GUIUtil;
@ -68,7 +68,6 @@ import javafx.scene.layout.VBox;
import javafx.geometry.Insets;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
@ -87,9 +86,7 @@ import java.util.stream.Collectors;
@FxmlView
public class LockedView extends ActivatableView<VBox, Void> {
@FXML
AutoTooltipLabel filterLabel;
@FXML
InputTextField filterTextField;
FilterBox filterBox;
@FXML
TableView<LockedListItem> tableView;
@FXML
@ -114,7 +111,6 @@ public class LockedView extends ActivatableView<VBox, Void> {
private BalanceListener balanceListener;
private ListChangeListener<OpenOffer> openOfferListChangeListener;
private ListChangeListener<Trade> tradeListChangeListener;
private ChangeListener<String> filterTextFieldListener;
///////////////////////////////////////////////////////////////////////////////////////////
@ -140,11 +136,7 @@ public class LockedView extends ActivatableView<VBox, Void> {
@Override
public void initialize() {
filterTextFieldListener = (observable, oldValue, newValue) -> {
tableView.getSelectionModel().clearSelection();
applyFilteredListPredicate(filterTextField.getText());
};
filterLabel.setText(Res.get("shared.filter"));
filterBox.initialize(filteredList, tableView);
dateColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.dateTime")));
detailsColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.details")));
addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address")));
@ -182,8 +174,7 @@ public class LockedView extends ActivatableView<VBox, Void> {
@Override
protected void activate() {
filterTextField.textProperty().addListener(filterTextFieldListener);
applyFilteredListPredicate(filterTextField.getText());
filterBox.activate();
openOfferManager.getObservableList().addListener(openOfferListChangeListener);
tradeManager.getObservableList().addListener(tradeListChangeListener);
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
@ -222,7 +213,7 @@ public class LockedView extends ActivatableView<VBox, Void> {
@Override
protected void deactivate() {
filterTextField.textProperty().removeListener(filterTextFieldListener);
filterBox.deactivate();
openOfferManager.getObservableList().removeListener(openOfferListChangeListener);
tradeManager.getObservableList().removeListener(tradeListChangeListener);
sortedList.comparatorProperty().unbind();
@ -236,10 +227,6 @@ public class LockedView extends ActivatableView<VBox, Void> {
// Private
///////////////////////////////////////////////////////////////////////////////////////////
private void applyFilteredListPredicate(String filterString) {
filteredList.setPredicate(item -> item.match(filterString));
}
private void updateList() {
observableList.forEach(LockedListItem::cleanup);
observableList.setAll(tradeManager.getTradesStreamWithFundsLockedIn()

View File

@ -25,21 +25,13 @@
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>
<?import javafx.geometry.Insets?>
<?import bisq.desktop.components.AutoTooltipLabel?>
<?import bisq.desktop.components.InputTextField?>
<?import bisq.desktop.components.list.FilterBox?>
<VBox fx:id="root" fx:controller="bisq.desktop.main.funds.reserved.ReservedView"
spacing="10" xmlns:fx="http://javafx.com/fxml">
<padding>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0"/>
</padding>
<HBox spacing="5.0">
<AutoTooltipLabel fx:id="filterLabel">
<HBox.margin>
<Insets top="5.0" left="10.0" />
</HBox.margin>
</AutoTooltipLabel>
<InputTextField fx:id="filterTextField" minWidth="500"/>
</HBox>
<FilterBox fx:id="filterBox" />
<TableView fx:id="tableView" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="dateColumn" minWidth="180" maxWidth="180"/>

View File

@ -23,7 +23,7 @@ import bisq.desktop.components.AutoTooltipButton;
import bisq.desktop.components.AutoTooltipLabel;
import bisq.desktop.components.ExternalHyperlink;
import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.list.FilterBox;
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
import bisq.desktop.util.GUIUtil;
@ -68,7 +68,6 @@ import javafx.scene.layout.VBox;
import javafx.geometry.Insets;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
@ -87,9 +86,7 @@ import java.util.stream.Collectors;
@FxmlView
public class ReservedView extends ActivatableView<VBox, Void> {
@FXML
AutoTooltipLabel filterLabel;
@FXML
InputTextField filterTextField;
FilterBox filterBox;
@FXML
TableView<ReservedListItem> tableView;
@FXML
@ -114,7 +111,6 @@ public class ReservedView extends ActivatableView<VBox, Void> {
private BalanceListener balanceListener;
private ListChangeListener<OpenOffer> openOfferListChangeListener;
private ListChangeListener<Trade> tradeListChangeListener;
private ChangeListener<String> filterTextFieldListener;
///////////////////////////////////////////////////////////////////////////////////////////
@ -140,11 +136,7 @@ public class ReservedView extends ActivatableView<VBox, Void> {
@Override
public void initialize() {
filterTextFieldListener = (observable, oldValue, newValue) -> {
tableView.getSelectionModel().clearSelection();
applyFilteredListPredicate(filterTextField.getText());
};
filterLabel.setText(Res.get("shared.filter"));
filterBox.initialize(filteredList, tableView);
dateColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.dateTime")));
detailsColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.details")));
addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address")));
@ -182,8 +174,7 @@ public class ReservedView extends ActivatableView<VBox, Void> {
@Override
protected void activate() {
filterTextField.textProperty().addListener(filterTextFieldListener);
applyFilteredListPredicate(filterTextField.getText());
filterBox.activate();
openOfferManager.getObservableList().addListener(openOfferListChangeListener);
tradeManager.getObservableList().addListener(tradeListChangeListener);
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
@ -222,7 +213,7 @@ public class ReservedView extends ActivatableView<VBox, Void> {
@Override
protected void deactivate() {
filterTextField.textProperty().removeListener(filterTextFieldListener);
filterBox.deactivate();
openOfferManager.getObservableList().removeListener(openOfferListChangeListener);
tradeManager.getObservableList().removeListener(tradeListChangeListener);
sortedList.comparatorProperty().unbind();
@ -236,10 +227,6 @@ public class ReservedView extends ActivatableView<VBox, Void> {
// Private
///////////////////////////////////////////////////////////////////////////////////////////
private void applyFilteredListPredicate(String filterString) {
filteredList.setPredicate(item -> item.match(filterString));
}
private void updateList() {
observableList.forEach(ReservedListItem::cleanup);
observableList.setAll(openOfferManager.getObservableList().stream()

View File

@ -25,21 +25,13 @@
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>
<?import javafx.geometry.Insets?>
<?import bisq.desktop.components.AutoTooltipLabel?>
<?import bisq.desktop.components.InputTextField?>
<?import bisq.desktop.components.list.FilterBox?>
<VBox fx:id="root" fx:controller="bisq.desktop.main.funds.transactions.TransactionsView"
spacing="10" alignment="CENTER_RIGHT" xmlns:fx="http://javafx.com/fxml">
<padding>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0"/>
</padding>
<HBox spacing="5.0">
<AutoTooltipLabel fx:id="filterLabel">
<HBox.margin>
<Insets top="5.0" left="10.0" />
</HBox.margin>
</AutoTooltipLabel>
<InputTextField fx:id="filterTextField" minWidth="500"/>
</HBox>
<FilterBox fx:id="filterBox" />
<TableView fx:id="tableView" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="dateColumn" minWidth="180" maxWidth="180"/>

View File

@ -24,7 +24,7 @@ import bisq.desktop.components.AutoTooltipButton;
import bisq.desktop.components.AutoTooltipLabel;
import bisq.desktop.components.ExternalHyperlink;
import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.list.FilterBox;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.BsqTradeDetailsWindow;
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
@ -83,7 +83,6 @@ import javafx.scene.layout.VBox;
import javafx.geometry.Insets;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ChangeListener;
import javafx.event.EventHandler;
@ -104,9 +103,7 @@ import javax.annotation.Nullable;
@FxmlView
public class TransactionsView extends ActivatableView<VBox, Void> {
@FXML
AutoTooltipLabel filterLabel;
@FXML
InputTextField filterTextField;
FilterBox filterBox;
@FXML
TableView<TransactionsListItem> tableView;
@FXML
@ -141,7 +138,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
private EventHandler<KeyEvent> keyEventEventHandler;
private Scene scene;
private ChangeListener<String> filterTextFieldListener;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, lifecycle
@ -180,11 +176,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
@Override
public void initialize() {
filterTextFieldListener = (observable, oldValue, newValue) -> {
tableView.getSelectionModel().clearSelection();
applyFilteredListPredicate(filterTextField.getText());
};
filterLabel.setText(Res.get("shared.filter"));
filterBox.initialize(filteredList, tableView);
dateColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.dateTime")));
detailsColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.details")));
addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address")));
@ -247,8 +239,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
@Override
protected void activate() {
filterTextField.textProperty().addListener(filterTextFieldListener);
applyFilteredListPredicate(filterTextField.getText());
filterBox.activate();
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
tableView.setItems(sortedList);
updateList();
@ -288,7 +279,7 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
@Override
protected void deactivate() {
filterTextField.textProperty().removeListener(filterTextFieldListener);
filterBox.deactivate();
sortedList.comparatorProperty().unbind();
observableList.forEach(TransactionsListItem::cleanup);
btcWalletService.removeChangeEventListener(walletChangeEventListener);
@ -341,10 +332,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
observableList.setAll(transactionsListItems);
}
private void applyFilteredListPredicate(String filterString) {
filteredList.setPredicate(item -> item.match(filterString));
}
private void openTxInBlockExplorer(TransactionsListItem item) {
if (item.getTxId() != null)
GUIUtil.openWebPage(preferences.getBlockChainExplorer().txUrl + item.getTxId(), false);

View File

@ -25,6 +25,7 @@ import bisq.desktop.components.ExternalHyperlink;
import bisq.desktop.components.HyperlinkWithIcon;
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.components.list.FilterBox;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.TxDetails;
import bisq.desktop.main.overlays.windows.WalletPasswordWindow;
@ -118,13 +119,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
@FxmlView
public class WithdrawalView extends ActivatableView<VBox, Void> {
@FXML
GridPane gridPane;
@FXML
AutoTooltipLabel filterLabel;
@FXML
InputTextField filterTextField;
FilterBox filterBox;
@FXML
TableView<WithdrawalListItem> tableView;
@FXML
@ -160,7 +158,6 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
private boolean feeExcluded;
private int rowIndex = 0;
private final FeeService feeService;
private ChangeListener<String> filterTextFieldListener;
///////////////////////////////////////////////////////////////////////////////////////////
@ -190,11 +187,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
@Override
public void initialize() {
filterTextFieldListener = (observable, oldValue, newValue) -> {
tableView.getSelectionModel().clearSelection();
applyFilteredListPredicate(filterTextField.getText());
};
filterLabel.setText(Res.get("shared.filter"));
filterBox.initialize(filteredList, tableView);
final TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, rowIndex, 4, Res.get("funds.deposit.withdrawFromWallet"));
titledGroupBg.getStyleClass().add("last");
@ -354,9 +347,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
@Override
protected void activate() {
filterTextField.textProperty().addListener(filterTextFieldListener);
applyFilteredListPredicate(filterTextField.getText());
filterBox.activate();
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
tableView.setItems(sortedList);
updateList();
@ -388,7 +379,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
@Override
protected void deactivate() {
filterTextField.textProperty().removeListener(filterTextFieldListener);
filterBox.deactivate();
sortedList.comparatorProperty().unbind();
observableList.forEach(WithdrawalListItem::cleanup);
btcWalletService.removeBalanceListener(balanceListener);
@ -407,10 +398,6 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
// UI handlers
///////////////////////////////////////////////////////////////////////////////////////////
private void applyFilteredListPredicate(String filterString) {
filteredList.setPredicate(item -> item.match(filterString));
}
private void onWithdraw() {
if (GUIUtil.isReadyForTxBroadcastOrShowPopup(p2PService, walletsSetup)) {
try {