Avoid raw use of Overlay<T>

This commit is contained in:
Steven Barclay 2020-03-06 17:03:55 +08:00
parent 879c3f2eb2
commit 6ef6bf24d9
No known key found for this signature in database
GPG key ID: 9FED6BF1176D500B
3 changed files with 20 additions and 23 deletions

View file

@ -133,7 +133,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
private Timer checkNumberOfP2pNetworkPeersTimer; private Timer checkNumberOfP2pNetworkPeersTimer;
@SuppressWarnings("FieldCanBeLocal") @SuppressWarnings("FieldCanBeLocal")
private MonadicBinding<Boolean> tradesAndUIReady; private MonadicBinding<Boolean> tradesAndUIReady;
private Queue<Overlay> popupQueue = new PriorityQueue<>(Comparator.comparing(Overlay::getDisplayOrderPriority)); private Queue<Overlay<?>> popupQueue = new PriorityQueue<>(Comparator.comparing(Overlay::getDisplayOrderPriority));
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -362,7 +362,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
.show()); .show());
bisqSetup.setDisplayLocalhostHandler(key -> { bisqSetup.setDisplayLocalhostHandler(key -> {
if (!DevEnv.isDevMode()) { if (!DevEnv.isDevMode()) {
Overlay popup = new Popup().backgroundInfo(Res.get("popup.bitcoinLocalhostNode.msg") + Popup popup = new Popup().backgroundInfo(Res.get("popup.bitcoinLocalhostNode.msg") +
Res.get("popup.bitcoinLocalhostNode.additionalRequirements")) Res.get("popup.bitcoinLocalhostNode.additionalRequirements"))
.dontShowAgainId(key); .dontShowAgainId(key);
popup.setDisplayOrderPriority(5); popup.setDisplayOrderPriority(5);
@ -396,14 +396,14 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
tradeManager.getTradesWithoutDepositTx().addListener((ListChangeListener<Trade>) c -> { tradeManager.getTradesWithoutDepositTx().addListener((ListChangeListener<Trade>) c -> {
c.next(); c.next();
if (c.wasAdded()) { if (c.wasAdded()) {
c.getAddedSubList().forEach(trade -> { c.getAddedSubList().forEach(trade ->
new Popup().warning(Res.get("popup.warning.trade.depositTxNull", trade.getShortId())) new Popup().warning(Res.get("popup.warning.trade.depositTxNull", trade.getShortId()))
.actionButtonText(Res.get("popup.warning.trade.depositTxNull.shutDown")) .actionButtonText(Res.get("popup.warning.trade.depositTxNull.shutDown"))
.onAction(() -> BisqApp.getShutDownHandler().run()) .onAction(() -> BisqApp.getShutDownHandler().run())
.secondaryActionButtonText(Res.get("popup.warning.trade.depositTxNull.moveToFailedTrades")) .secondaryActionButtonText(Res.get("popup.warning.trade.depositTxNull.moveToFailedTrades"))
.onSecondaryAction(() -> tradeManager.addTradeToFailedTrades(trade)) .onSecondaryAction(() -> tradeManager.addTradeToFailedTrades(trade))
.show(); .show()
}); );
} }
}); });
@ -682,7 +682,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener {
private void maybeShowPopupsFromQueue() { private void maybeShowPopupsFromQueue() {
if (!popupQueue.isEmpty()) { if (!popupQueue.isEmpty()) {
Overlay overlay = popupQueue.poll(); Overlay<?> overlay = popupQueue.poll();
overlay.getIsHiddenProperty().addListener((observable, oldValue, newValue) -> { overlay.getIsHiddenProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) { if (newValue) {
UserThread.runAfter(this::maybeShowPopupsFromQueue, 2); UserThread.runAfter(this::maybeShowPopupsFromQueue, 2);

View file

@ -19,7 +19,6 @@ package bisq.desktop.main.dao.monitor.daostate;
import bisq.desktop.common.view.FxmlView; import bisq.desktop.common.view.FxmlView;
import bisq.desktop.main.dao.monitor.StateMonitorView; import bisq.desktop.main.dao.monitor.StateMonitorView;
import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.FormBuilder; import bisq.desktop.util.FormBuilder;
@ -53,7 +52,7 @@ public class DaoStateMonitorView extends StateMonitorView<DaoStateHash, DaoState
implements DaoStateMonitoringService.Listener { implements DaoStateMonitoringService.Listener {
private final DaoStateMonitoringService daoStateMonitoringService; private final DaoStateMonitoringService daoStateMonitoringService;
private ListChangeListener<UtxoMismatch> utxoMismatchListChangeListener; private ListChangeListener<UtxoMismatch> utxoMismatchListChangeListener;
private Overlay warningPopup; private Popup warningPopup;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -208,17 +207,16 @@ public class DaoStateMonitorView extends StateMonitorView<DaoStateHash, DaoState
private void updateUtxoMismatches() { private void updateUtxoMismatches() {
if (!daoStateMonitoringService.getUtxoMismatches().isEmpty()) { if (!daoStateMonitoringService.getUtxoMismatches().isEmpty()) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
daoStateMonitoringService.getUtxoMismatches().forEach(e -> { daoStateMonitoringService.getUtxoMismatches().forEach(e -> sb.append("\n")
sb.append("\n").append(Res.get("dao.monitor.daoState.utxoConflicts.blockHeight", e.getHeight())).append("\n") .append(Res.get("dao.monitor.daoState.utxoConflicts.blockHeight", e.getHeight())).append("\n")
.append(Res.get("dao.monitor.daoState.utxoConflicts.sumUtxo", e.getSumUtxo() / 100)).append("\n") .append(Res.get("dao.monitor.daoState.utxoConflicts.sumUtxo", e.getSumUtxo() / 100)).append("\n")
.append(Res.get("dao.monitor.daoState.utxoConflicts.sumBsq", e.getSumBsq() / 100)); .append(Res.get("dao.monitor.daoState.utxoConflicts.sumBsq", e.getSumBsq() / 100))
}); );
if (warningPopup == null) { if (warningPopup == null) {
warningPopup = new Popup().headLine(Res.get("dao.monitor.daoState.utxoConflicts")) warningPopup = new Popup().headLine(Res.get("dao.monitor.daoState.utxoConflicts"))
.warning(Utilities.toTruncatedString(sb.toString(), 500, false)).onClose(() -> { .warning(Utilities.toTruncatedString(sb.toString(), 500, false))
warningPopup = null; .onClose(() -> warningPopup = null);
});
warningPopup.show(); warningPopup.show();
} }
} }

View file

@ -20,7 +20,6 @@ package bisq.desktop.main.portfolio.pendingtrades.steps;
import bisq.desktop.components.InfoTextField; import bisq.desktop.components.InfoTextField;
import bisq.desktop.components.TitledGroupBg; import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.components.TxIdTextField; import bisq.desktop.components.TxIdTextField;
import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.portfolio.pendingtrades.PendingTradesViewModel; import bisq.desktop.main.portfolio.pendingtrades.PendingTradesViewModel;
import bisq.desktop.main.portfolio.pendingtrades.TradeStepInfo; import bisq.desktop.main.portfolio.pendingtrades.TradeStepInfo;
@ -93,7 +92,7 @@ public abstract class TradeStepView extends AnchorPane {
private ClockWatcher.Listener clockListener; private ClockWatcher.Listener clockListener;
private final ChangeListener<String> errorMessageListener; private final ChangeListener<String> errorMessageListener;
protected Label infoLabel; protected Label infoLabel;
private Overlay acceptMediationResultPopup; private Popup acceptMediationResultPopup;
private BootstrapListener bootstrapListener; private BootstrapListener bootstrapListener;