mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Refactor SendAlertMessageWindow - remove redundant interfaces
This commit is contained in:
parent
ba0437e6b0
commit
2f6589b5e5
@ -340,10 +340,7 @@ public class BisqApp extends Application implements UncaughtExceptionHandler {
|
||||
private void showSendAlertMessagePopup(Injector injector) {
|
||||
AlertManager alertManager = injector.getInstance(AlertManager.class);
|
||||
boolean useDevPrivilegeKeys = injector.getInstance(Key.get(Boolean.class, Names.named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS)));
|
||||
new SendAlertMessageWindow(useDevPrivilegeKeys)
|
||||
.onAddAlertMessage(alertManager::addAlertMessageIfKeyIsValid)
|
||||
.onRemoveAlertMessage(alertManager::removeAlertMessageIfKeyIsValid)
|
||||
.show();
|
||||
new SendAlertMessageWindow(alertManager, useDevPrivilegeKeys).show();
|
||||
}
|
||||
|
||||
private void showFilterPopup(Injector injector) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package bisq.desktop.main.overlays.windows;
|
||||
|
||||
import bisq.core.alert.AlertManager;
|
||||
import bisq.desktop.components.AutoTooltipButton;
|
||||
import bisq.desktop.components.InputTextField;
|
||||
import bisq.desktop.main.overlays.Overlay;
|
||||
@ -46,28 +47,15 @@ import static bisq.desktop.util.FormBuilder.addLabelCheckBox;
|
||||
import static bisq.desktop.util.FormBuilder.addTopLabelTextArea;
|
||||
|
||||
public class SendAlertMessageWindow extends Overlay<SendAlertMessageWindow> {
|
||||
private final AlertManager alertManager;
|
||||
private final boolean useDevPrivilegeKeys;
|
||||
private SendAlertMessageHandler sendAlertMessageHandler;
|
||||
private RemoveAlertMessageHandler removeAlertMessageHandler;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
public interface SendAlertMessageHandler {
|
||||
boolean handle(Alert alert, String privKey);
|
||||
}
|
||||
|
||||
public interface RemoveAlertMessageHandler {
|
||||
boolean handle(String privKey);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public SendAlertMessageWindow(boolean useDevPrivilegeKeys) {
|
||||
public SendAlertMessageWindow(AlertManager alertManager, boolean useDevPrivilegeKeys) {
|
||||
this.alertManager = alertManager;
|
||||
this.useDevPrivilegeKeys = useDevPrivilegeKeys;
|
||||
type = Type.Attention;
|
||||
}
|
||||
@ -84,16 +72,6 @@ public class SendAlertMessageWindow extends Overlay<SendAlertMessageWindow> {
|
||||
display();
|
||||
}
|
||||
|
||||
public SendAlertMessageWindow onAddAlertMessage(SendAlertMessageHandler sendAlertMessageHandler) {
|
||||
this.sendAlertMessageHandler = sendAlertMessageHandler;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SendAlertMessageWindow onRemoveAlertMessage(RemoveAlertMessageHandler removeAlertMessageHandler) {
|
||||
this.removeAlertMessageHandler = removeAlertMessageHandler;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Protected
|
||||
@ -151,11 +129,10 @@ public class SendAlertMessageWindow extends Overlay<SendAlertMessageWindow> {
|
||||
}
|
||||
if (!isUpdate || versionOK) {
|
||||
if (alertMessageTextArea.getText().length() > 0 && keyInputTextField.getText().length() > 0) {
|
||||
if (sendAlertMessageHandler.handle(
|
||||
new Alert(alertMessageTextArea.getText(),
|
||||
isUpdate,
|
||||
version),
|
||||
keyInputTextField.getText()))
|
||||
if (alertManager.addAlertMessageIfKeyIsValid(
|
||||
new Alert(alertMessageTextArea.getText(), isUpdate, version),
|
||||
keyInputTextField.getText())
|
||||
)
|
||||
hide();
|
||||
else
|
||||
new Popup<>().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
|
||||
@ -166,7 +143,7 @@ public class SendAlertMessageWindow extends Overlay<SendAlertMessageWindow> {
|
||||
Button removeAlertMessageButton = new AutoTooltipButton(Res.get("sendAlertMessageWindow.remove"));
|
||||
removeAlertMessageButton.setOnAction(e -> {
|
||||
if (keyInputTextField.getText().length() > 0) {
|
||||
if (removeAlertMessageHandler.handle(keyInputTextField.getText()))
|
||||
if (alertManager.removeAlertMessageIfKeyIsValid(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