mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Refactor FilterWindow - remove redundant interfaces
This commit is contained in:
parent
95257b10f9
commit
ba0437e6b0
@ -349,10 +349,7 @@ public class BisqApp extends Application implements UncaughtExceptionHandler {
|
||||
private void showFilterPopup(Injector injector) {
|
||||
FilterManager filterManager = injector.getInstance(FilterManager.class);
|
||||
boolean useDevPrivilegeKeys = injector.getInstance(Key.get(Boolean.class, Names.named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS)));
|
||||
new FilterWindow(filterManager, useDevPrivilegeKeys)
|
||||
.onAddFilter(filterManager::addFilterMessageIfKeyIsValid)
|
||||
.onRemoveFilter(filterManager::removeFilterMessageIfKeyIsValid)
|
||||
.show();
|
||||
new FilterWindow(filterManager, useDevPrivilegeKeys).show();
|
||||
}
|
||||
|
||||
private void showBtcEmergencyWalletPopup(Injector injector) {
|
||||
|
@ -51,24 +51,9 @@ import static bisq.desktop.util.FormBuilder.addLabelCheckBox;
|
||||
import static bisq.desktop.util.FormBuilder.addTopLabelInputTextField;
|
||||
|
||||
public class FilterWindow extends Overlay<FilterWindow> {
|
||||
private SendFilterMessageHandler sendFilterMessageHandler;
|
||||
private RemoveFilterMessageHandler removeFilterMessageHandler;
|
||||
private final FilterManager filterManager;
|
||||
private final boolean useDevPrivilegeKeys;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
public interface SendFilterMessageHandler {
|
||||
boolean handle(Filter filter, String privKey);
|
||||
}
|
||||
|
||||
public interface RemoveFilterMessageHandler {
|
||||
boolean handle(String privKey);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -91,16 +76,6 @@ public class FilterWindow extends Overlay<FilterWindow> {
|
||||
display();
|
||||
}
|
||||
|
||||
public FilterWindow onAddFilter(SendFilterMessageHandler sendFilterMessageHandler) {
|
||||
this.sendFilterMessageHandler = sendFilterMessageHandler;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterWindow onRemoveFilter(RemoveFilterMessageHandler removeFilterMessageHandler) {
|
||||
this.removeFilterMessageHandler = removeFilterMessageHandler;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Protected
|
||||
@ -166,7 +141,7 @@ public class FilterWindow extends Overlay<FilterWindow> {
|
||||
}
|
||||
Button sendButton = new AutoTooltipButton(Res.get("filterWindow.add"));
|
||||
sendButton.setOnAction(e -> {
|
||||
if (sendFilterMessageHandler.handle(
|
||||
if (filterManager.addFilterMessageIfKeyIsValid(
|
||||
new Filter(
|
||||
readAsList(offerIdsInputTextField),
|
||||
readAsList(nodesInputTextField),
|
||||
@ -194,7 +169,7 @@ public class FilterWindow extends Overlay<FilterWindow> {
|
||||
Button removeFilterMessageButton = new AutoTooltipButton(Res.get("filterWindow.remove"));
|
||||
removeFilterMessageButton.setOnAction(e -> {
|
||||
if (keyInputTextField.getText().length() > 0) {
|
||||
if (removeFilterMessageHandler.handle(keyInputTextField.getText()))
|
||||
if (filterManager.removeFilterMessageIfKeyIsValid(keyInputTextField.getText()))
|
||||
hide();
|
||||
else
|
||||
new Popup<>().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
|
||||
|
Loading…
Reference in New Issue
Block a user