Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dependency injection in FilterWindow and SendAlertMessageWindow #3654

Merged
merged 1 commit into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions desktop/src/main/java/bisq/desktop/app/BisqApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ private void addSceneKeyEventHandler(Scene scene, Injector injector) {
} else if (Utilities.isAltOrCtrlPressed(KeyCode.B, keyEvent)) {
showBsqEmergencyWalletPopup(injector);
} else if (Utilities.isAltOrCtrlPressed(KeyCode.M, keyEvent)) {
showSendAlertMessagePopup(injector);
injector.getInstance(SendAlertMessageWindow.class).show();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.F, keyEvent)) {
showFilterPopup(injector);
injector.getInstance(FilterWindow.class).show();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.UP, keyEvent)) {
log.warn("We re-published all proposalPayloads and blindVotePayloads to the P2P network.");
injector.getInstance(MissingDataRequestService.class).reRepublishAllGovernanceData();
Expand Down Expand Up @@ -336,18 +336,6 @@ private void shutDownByUser() {
}
}

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(alertManager, useDevPrivilegeKeys).show();
}

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).show();
}

private void showBtcEmergencyWalletPopup(Injector injector) {
EmptyWalletWindow emptyWalletWindow = injector.getInstance(EmptyWalletWindow.class);
emptyWalletWindow.setIsBtc(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@
import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.main.overlays.popups.Popup;

import bisq.core.app.AppOptionKeys;
import bisq.core.filter.Filter;
import bisq.core.filter.FilterManager;
import bisq.core.filter.PaymentAccountFilter;
import bisq.core.locale.Res;

import bisq.common.app.DevEnv;

import com.google.inject.Inject;

import javax.inject.Named;

import org.apache.commons.lang3.StringUtils;

import javafx.scene.Scene;
Expand All @@ -54,11 +59,9 @@ public class FilterWindow extends Overlay<FilterWindow> {
private final FilterManager filterManager;
private final boolean useDevPrivilegeKeys;

///////////////////////////////////////////////////////////////////////////////////////////
// Public API
///////////////////////////////////////////////////////////////////////////////////////////

public FilterWindow(FilterManager filterManager, boolean useDevPrivilegeKeys) {
@Inject
public FilterWindow(FilterManager filterManager,
@Named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) {
this.filterManager = filterManager;
this.useDevPrivilegeKeys = useDevPrivilegeKeys;
type = Type.Attention;
Expand All @@ -76,11 +79,6 @@ public void show() {
display();
}


///////////////////////////////////////////////////////////////////////////////////////////
// Protected
///////////////////////////////////////////////////////////////////////////////////////////

@Override
protected void setupKeyHandler(Scene scene) {
if (!hideCloseButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@
import bisq.desktop.util.FormBuilder;

import bisq.core.alert.Alert;
import bisq.core.app.AppOptionKeys;
import bisq.core.locale.Res;

import bisq.common.app.DevEnv;
import bisq.common.util.Tuple2;

import com.google.inject.Inject;

import javax.inject.Named;

import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
Expand All @@ -50,11 +55,9 @@ public class SendAlertMessageWindow extends Overlay<SendAlertMessageWindow> {
private final AlertManager alertManager;
private final boolean useDevPrivilegeKeys;

///////////////////////////////////////////////////////////////////////////////////////////
// Public API
///////////////////////////////////////////////////////////////////////////////////////////

public SendAlertMessageWindow(AlertManager alertManager, boolean useDevPrivilegeKeys) {
@Inject
public SendAlertMessageWindow(AlertManager alertManager,
@Named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) {
this.alertManager = alertManager;
this.useDevPrivilegeKeys = useDevPrivilegeKeys;
type = Type.Attention;
Expand Down