Refactor FilterWindow - remove redundant interfaces

This commit is contained in:
lusarz 2019-11-15 15:56:21 +01:00 committed by lukasz
parent 95257b10f9
commit ba0437e6b0
No known key found for this signature in database
GPG Key ID: 7FFDB4B31012B93E
2 changed files with 3 additions and 31 deletions

View File

@ -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) {

View File

@ -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();