mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
Merge pull request #3364 from lusarz/refactor-filter-window
Refactor FilterWindow
This commit is contained in:
commit
cc2df91353
1 changed files with 29 additions and 78 deletions
|
@ -41,8 +41,8 @@ import javafx.scene.layout.HBox;
|
||||||
import javafx.geometry.HPos;
|
import javafx.geometry.HPos;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -197,90 +197,33 @@ public class FilterWindow extends Overlay<FilterWindow> {
|
||||||
}
|
}
|
||||||
Button sendButton = new AutoTooltipButton(Res.get("filterWindow.add"));
|
Button sendButton = new AutoTooltipButton(Res.get("filterWindow.add"));
|
||||||
sendButton.setOnAction(e -> {
|
sendButton.setOnAction(e -> {
|
||||||
List<String> offerIds = new ArrayList<>();
|
List<PaymentAccountFilter> paymentAccountFilters = readAsList(paymentAccountFilterInputTextField)
|
||||||
List<String> nodes = new ArrayList<>();
|
.stream().map(item -> {
|
||||||
List<PaymentAccountFilter> paymentAccountFilters = new ArrayList<>();
|
String[] list = item.split("\\|");
|
||||||
List<String> bannedCurrencies = new ArrayList<>();
|
if (list.length == 3)
|
||||||
List<String> bannedPaymentMethods = new ArrayList<>();
|
return new PaymentAccountFilter(list[0], list[1], list[2]);
|
||||||
List<String> arbitrators = new ArrayList<>();
|
else
|
||||||
List<String> mediators = new ArrayList<>();
|
return new PaymentAccountFilter("", "", "");
|
||||||
List<String> refundAgents = new ArrayList<>();
|
})
|
||||||
List<String> seedNodes = new ArrayList<>();
|
.collect(Collectors.toList());
|
||||||
List<String> priceRelayNodes = new ArrayList<>();
|
|
||||||
List<String> btcNodes = new ArrayList<>();
|
|
||||||
|
|
||||||
if (!offerIdsInputTextField.getText().isEmpty()) {
|
|
||||||
offerIds = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(offerIdsInputTextField.getText())
|
|
||||||
.split(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!nodesInputTextField.getText().isEmpty()) {
|
if (sendFilterMessageHandler.handle(new Filter(
|
||||||
nodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(nodesInputTextField.getText()).split(",")));
|
readAsList(offerIdsInputTextField),
|
||||||
}
|
readAsList(nodesInputTextField),
|
||||||
|
|
||||||
if (!paymentAccountFilterInputTextField.getText().isEmpty()) {
|
|
||||||
paymentAccountFilters = new ArrayList<>(Arrays.asList(paymentAccountFilterInputTextField.getText()
|
|
||||||
.replace(", ", ",")
|
|
||||||
.split(","))
|
|
||||||
.stream().map(item -> {
|
|
||||||
String[] list = item.split("\\|");
|
|
||||||
if (list.length == 3)
|
|
||||||
return new PaymentAccountFilter(list[0], list[1], list[2]);
|
|
||||||
else
|
|
||||||
return new PaymentAccountFilter("", "", "");
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bannedCurrenciesInputTextField.getText().isEmpty()) {
|
|
||||||
bannedCurrencies = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(bannedCurrenciesInputTextField.getText())
|
|
||||||
.split(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bannedPaymentMethodsInputTextField.getText().isEmpty()) {
|
|
||||||
bannedPaymentMethods = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(bannedPaymentMethodsInputTextField.getText())
|
|
||||||
.split(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!arbitratorsInputTextField.getText().isEmpty()) {
|
|
||||||
arbitrators = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(arbitratorsInputTextField.getText()).split(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mediatorsInputTextField.getText().isEmpty()) {
|
|
||||||
mediators = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(mediatorsInputTextField.getText()).split(",")));
|
|
||||||
}
|
|
||||||
if (!refundAgentsInputTextField.getText().isEmpty()) {
|
|
||||||
refundAgents = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(refundAgentsInputTextField.getText()).split(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!seedNodesInputTextField.getText().isEmpty()) {
|
|
||||||
seedNodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(seedNodesInputTextField.getText()).split(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!priceRelayNodesInputTextField.getText().isEmpty()) {
|
|
||||||
priceRelayNodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(priceRelayNodesInputTextField.getText()).split(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!btcNodesInputTextField.getText().isEmpty()) {
|
|
||||||
btcNodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(btcNodesInputTextField.getText())
|
|
||||||
.split(",")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sendFilterMessageHandler.handle(new Filter(offerIds,
|
|
||||||
nodes,
|
|
||||||
paymentAccountFilters,
|
paymentAccountFilters,
|
||||||
bannedCurrencies,
|
readAsList(bannedCurrenciesInputTextField),
|
||||||
bannedPaymentMethods,
|
readAsList(bannedPaymentMethodsInputTextField),
|
||||||
arbitrators,
|
readAsList(arbitratorsInputTextField),
|
||||||
seedNodes,
|
readAsList(seedNodesInputTextField),
|
||||||
priceRelayNodes,
|
readAsList(priceRelayNodesInputTextField),
|
||||||
preventPublicBtcNetworkCheckBox.isSelected(),
|
preventPublicBtcNetworkCheckBox.isSelected(),
|
||||||
btcNodes,
|
readAsList(btcNodesInputTextField),
|
||||||
disableDaoCheckBox.isSelected(),
|
disableDaoCheckBox.isSelected(),
|
||||||
disableDaoBelowVersionInputTextField.getText(),
|
disableDaoBelowVersionInputTextField.getText(),
|
||||||
disableTradeBelowVersionInputTextField.getText(),
|
disableTradeBelowVersionInputTextField.getText(),
|
||||||
mediators,
|
readAsList(mediatorsInputTextField),
|
||||||
refundAgents),
|
readAsList(refundAgentsInputTextField)),
|
||||||
keyInputTextField.getText()))
|
keyInputTextField.getText()))
|
||||||
hide();
|
hide();
|
||||||
else
|
else
|
||||||
|
@ -310,4 +253,12 @@ public class FilterWindow extends Overlay<FilterWindow> {
|
||||||
gridPane.getChildren().add(hBox);
|
gridPane.getChildren().add(hBox);
|
||||||
GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
|
GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<String> readAsList(InputTextField field) {
|
||||||
|
if (field.getText().isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
|
return Arrays.asList(StringUtils.deleteWhitespace(field.getText()).split(","));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue