Skip to content

Commit

Permalink
Merge pull request #3651 from stejbac/ungenerify-popup-class
Browse files Browse the repository at this point in the history
Un-generify Popup class
  • Loading branch information
ripcurlx authored Nov 21, 2019
2 parents 871051f + a26366e commit 02d521a
Show file tree
Hide file tree
Showing 64 changed files with 309 additions and 311 deletions.
11 changes: 5 additions & 6 deletions desktop/src/main/java/bisq/desktop/app/BisqApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@

import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.StackPane;
Expand Down Expand Up @@ -149,7 +148,7 @@ public void startApplication(Runnable onUiReadyHandler) {
@Override
public void stop() {
if (!shutDownRequested) {
new Popup<>().headLine(Res.get("popup.shutDownInProgress.headline"))
new Popup().headLine(Res.get("popup.shutDownInProgress.headline"))
.backgroundInfo(Res.get("popup.shutDownInProgress.msg"))
.hideCloseButton()
.useAnimation(false)
Expand Down Expand Up @@ -182,7 +181,7 @@ public void handleUncaughtException(Throwable throwable, boolean doShutDown) {
try {
if (!popupOpened) {
popupOpened = true;
new Popup<>().error(Objects.requireNonNullElse(throwable.getMessage(), throwable.toString()))
new Popup().error(Objects.requireNonNullElse(throwable.getMessage(), throwable.toString()))
.onClose(() -> popupOpened = false)
.show();
}
Expand Down Expand Up @@ -296,12 +295,12 @@ private void addSceneKeyEventHandler(Scene scene, Injector injector) {
if (walletsManager.areWalletsAvailable())
new ShowWalletDataWindow(walletsManager).show();
else
new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show();
new Popup().warning(Res.get("popup.warning.walletNotInitialized")).show();
} else if (Utilities.isAltOrCtrlPressed(KeyCode.G, keyEvent)) {
if (injector.getInstance(BtcWalletService.class).isWalletReady())
injector.getInstance(ManualPayoutTxWindow.class).show();
else
new Popup<>().warning(Res.get("popup.warning.walletNotInitialized")).show();
new Popup().warning(Res.get("popup.warning.walletNotInitialized")).show();
} else if (DevEnv.isDevMode()) {
if (Utilities.isAltOrCtrlPressed(KeyCode.Z, keyEvent))
showDebugWindow(scene, injector);
Expand All @@ -327,7 +326,7 @@ private void shutDownByUser() {
// We show a popup to inform user that open offers will be removed if Bisq is not running.
String key = "showOpenOfferWarnPopupAtShutDown";
if (injector.getInstance(Preferences.class).showAgain(key) && !DevEnv.isDevMode()) {
new Popup<>().information(Res.get("popup.info.shutDownWithOpenOffers"))
new Popup().information(Res.get("popup.info.shutDownWithOpenOffers"))
.dontShowAgainId(key)
.useShutDownButton()
.closeButtonText(Res.get("shared.cancel"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void openWallet() {
Utilities.openURI(URI.create(getBitcoinURI()));
} catch (Exception e) {
log.warn(e.getMessage());
new Popup<>().warning(Res.get("addressTextField.openWallet.failed")).show();
new Popup().warning(Res.get("addressTextField.openWallet.failed")).show();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void addFormForAddAccount() {
tradeInstantCheckBox.setOnAction(e -> {
tradeInstant = tradeInstantCheckBox.isSelected();
if (tradeInstant)
new Popup<>().information(Res.get("payment.altcoin.tradeInstant.popup")).show();
new Popup().information(Res.get("payment.altcoin.tradeInstant.popup")).show();
});

gridPane.getChildren().remove(tradeInstantCheckBox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ else if (!paymentAccount.getTradeCurrencies().isEmpty())

void applyTradeCurrency(TradeCurrency tradeCurrency, FiatCurrency defaultCurrency) {
if (!defaultCurrency.equals(tradeCurrency)) {
new Popup<>().warning(Res.get("payment.foreign.currency"))
new Popup().warning(Res.get("payment.foreign.currency"))
.actionButtonText(Res.get("shared.yes"))
.onAction(() -> {
paymentAccount.setSingleTradeCurrency(tradeCurrency);
Expand Down
8 changes: 4 additions & 4 deletions desktop/src/main/java/bisq/desktop/main/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public static void removeEffect() {
private Label splashP2PNetworkLabel;
private ProgressBar btcSyncIndicator, p2pNetworkProgressBar;
private Label btcSplashInfo;
private Popup<?> p2PNetworkWarnMsgPopup, btcNetworkWarnMsgPopup;
private Popup p2PNetworkWarnMsgPopup, btcNetworkWarnMsgPopup;
private final DaoStateMonitoringService daoStateMonitoringService;

@Inject
Expand Down Expand Up @@ -427,7 +427,7 @@ public void onChangeAfterBatchProcessing() {

@Override
public void onCheckpointFail() {
new Popup<>().attention(Res.get("dao.monitor.daoState.checkpoint.popup"))
new Popup().attention(Res.get("dao.monitor.daoState.checkpoint.popup"))
.useShutDownButton()
.show();
}
Expand Down Expand Up @@ -715,7 +715,7 @@ private AnchorPane createFooter() {
btcInfoLabel.setId("splash-error-state-msg");
btcInfoLabel.getStyleClass().add("error-text");
if (btcNetworkWarnMsgPopup == null) {
btcNetworkWarnMsgPopup = new Popup<>().warning(newValue);
btcNetworkWarnMsgPopup = new Popup().warning(newValue);
btcNetworkWarnMsgPopup.show();
}
} else {
Expand Down Expand Up @@ -774,7 +774,7 @@ private AnchorPane createFooter() {
p2PNetworkLabel.idProperty().bind(model.getP2pNetworkLabelId());
model.getP2pNetworkWarnMsg().addListener((ov, oldValue, newValue) -> {
if (newValue != null) {
p2PNetworkWarnMsgPopup = new Popup<>().warning(newValue);
p2PNetworkWarnMsgPopup = new Popup().warning(newValue);
p2PNetworkWarnMsgPopup.show();
} else if (p2PNetworkWarnMsgPopup != null) {
p2PNetworkWarnMsgPopup.hide();
Expand Down
38 changes: 19 additions & 19 deletions desktop/src/main/java/bisq/desktop/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public void onSetupComplete() {
key = "displayHalfTradePeriodOver" + trade.getId();
if (DontShowAgainLookup.showAgain(key)) {
DontShowAgainLookup.dontShowAgain(key, true);
new Popup<>().warning(Res.get("popup.warning.tradePeriod.halfReached",
new Popup().warning(Res.get("popup.warning.tradePeriod.halfReached",
trade.getShortId(),
DisplayUtils.formatDateTime(maxTradePeriodDate)))
.show();
Expand All @@ -229,7 +229,7 @@ public void onSetupComplete() {
key = "displayTradePeriodOver" + trade.getId();
if (DontShowAgainLookup.showAgain(key)) {
DontShowAgainLookup.dontShowAgain(key, true);
new Popup<>().warning(Res.get("popup.warning.tradePeriod.ended",
new Popup().warning(Res.get("popup.warning.tradePeriod.ended",
trade.getShortId(),
DisplayUtils.formatDateTime(maxTradePeriodDate)))
.show();
Expand Down Expand Up @@ -292,7 +292,7 @@ private void setupHandlers() {
}, 1));

bisqSetup.setCryptoSetupFailedHandler(msg -> UserThread.execute(() ->
new Popup<>().warning(msg)
new Popup().warning(msg)
.useShutDownButton()
.useReportBugButton()
.show()));
Expand All @@ -302,16 +302,16 @@ private void setupHandlers() {
else
torNetworkSettingsWindow.hide();
});
bisqSetup.setSpvFileCorruptedHandler(msg -> new Popup<>().warning(msg)
bisqSetup.setSpvFileCorruptedHandler(msg -> new Popup().warning(msg)
.actionButtonText(Res.get("settings.net.reSyncSPVChainButton"))
.onAction(() -> GUIUtil.reSyncSPVChain(preferences))
.show());
bisqSetup.setVoteResultExceptionHandler(voteResultException -> log.warn(voteResultException.toString()));

bisqSetup.setChainFileLockedExceptionHandler(msg -> new Popup<>().warning(msg)
bisqSetup.setChainFileLockedExceptionHandler(msg -> new Popup().warning(msg)
.useShutDownButton()
.show());
bisqSetup.setLockedUpFundsHandler(msg -> new Popup<>().width(850).warning(msg).show());
bisqSetup.setLockedUpFundsHandler(msg -> new Popup().width(850).warning(msg).show());
bisqSetup.setShowFirstPopupIfResyncSPVRequestedHandler(this::showFirstPopupIfResyncSPVRequested);
bisqSetup.setRequestWalletPasswordHandler(aesKeyHandler -> walletPasswordWindow
.onAesKey(aesKeyHandler::accept)
Expand All @@ -334,22 +334,22 @@ private void setupHandlers() {
.onClose(() -> user.setDisplayedAlert(alert))
.show());
bisqSetup.setDisplayPrivateNotificationHandler(privateNotification ->
new Popup<>().headLine(Res.get("popup.privateNotification.headline"))
new Popup().headLine(Res.get("popup.privateNotification.headline"))
.attention(privateNotification.getMessage())
.setHeadlineStyle("-fx-text-fill: -bs-error-red; -fx-font-weight: bold; -fx-font-size: 16;")
.onClose(privateNotificationManager::removePrivateNotification)
.useIUnderstandButton()
.show());
bisqSetup.setDaoErrorMessageHandler(errorMessage -> new Popup<>().error(errorMessage).show());
bisqSetup.setDaoWarnMessageHandler(warnMessage -> new Popup<>().warning(warnMessage).show());
bisqSetup.setDaoErrorMessageHandler(errorMessage -> new Popup().error(errorMessage).show());
bisqSetup.setDaoWarnMessageHandler(warnMessage -> new Popup().warning(warnMessage).show());
bisqSetup.setDisplaySecurityRecommendationHandler(key ->
new Popup<>().headLine(Res.get("popup.securityRecommendation.headline"))
new Popup().headLine(Res.get("popup.securityRecommendation.headline"))
.information(Res.get("popup.securityRecommendation.msg"))
.dontShowAgainId(key)
.show());
bisqSetup.setDisplayLocalhostHandler(key -> {
if (!DevEnv.isDevMode()) {
Overlay popup = new Popup<>().backgroundInfo(Res.get("popup.bitcoinLocalhostNode.msg"))
Overlay popup = new Popup().backgroundInfo(Res.get("popup.bitcoinLocalhostNode.msg"))
.dontShowAgainId(key);
popup.setDisplayOrderPriority(5);
popupQueue.add(popup);
Expand All @@ -364,25 +364,25 @@ private void setupHandlers() {
bisqSetup.setDisplayPeerSignerHandler(key -> accountPresentation.showOneTimeAccountSigningPopup(
key, "popup.accountSigning.peerSigner"));

bisqSetup.setWrongOSArchitectureHandler(msg -> new Popup<>().warning(msg).show());
bisqSetup.setWrongOSArchitectureHandler(msg -> new Popup().warning(msg).show());

bisqSetup.setRejectedTxErrorMessageHandler(msg -> new Popup<>().width(850).warning(msg).show());
bisqSetup.setRejectedTxErrorMessageHandler(msg -> new Popup().width(850).warning(msg).show());

corruptedDatabaseFilesHandler.getCorruptedDatabaseFiles().ifPresent(files -> new Popup<>()
corruptedDatabaseFilesHandler.getCorruptedDatabaseFiles().ifPresent(files -> new Popup()
.warning(Res.get("popup.warning.incompatibleDB", files.toString(),
bisqEnvironment.getProperty(AppOptionKeys.APP_DATA_DIR_KEY)))
.useShutDownButton()
.show());

tradeManager.setTakeOfferRequestErrorMessageHandler(errorMessage -> new Popup<>()
tradeManager.setTakeOfferRequestErrorMessageHandler(errorMessage -> new Popup()
.warning(Res.get("popup.error.takeOfferRequestFailed", errorMessage))
.show());

tradeManager.getTradesWithoutDepositTx().addListener((ListChangeListener<Trade>) c -> {
c.next();
if (c.wasAdded()) {
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.moveToFailedTrades"))
.onAction(() -> tradeManager.addTradeToFailedTrades(trade))
.show();
Expand All @@ -393,7 +393,7 @@ private void setupHandlers() {
bisqSetup.getBtcSyncProgress().addListener((observable, oldValue, newValue) -> updateBtcSyncProgress());
daoPresentation.getBsqSyncProgress().addListener((observable, oldValue, newValue) -> updateBtcSyncProgress());

bisqSetup.setFilterWarningHandler(warning -> new Popup<>().warning(warning).show());
bisqSetup.setFilterWarningHandler(warning -> new Popup().warning(warning).show());
}

private void setupP2PNumPeersWatcher() {
Expand Down Expand Up @@ -451,7 +451,7 @@ private void setupBtcNumPeersWatcher() {
}

private void showFirstPopupIfResyncSPVRequested() {
Popup firstPopup = new Popup<>();
Popup firstPopup = new Popup();
firstPopup.information(Res.get("settings.net.reSyncSPVAfterRestart")).show();
if (bisqSetup.getBtcSyncProgress().get() == 1) {
showSecondPopupIfResyncSPVRequested(firstPopup);
Expand All @@ -466,7 +466,7 @@ private void showFirstPopupIfResyncSPVRequested() {
private void showSecondPopupIfResyncSPVRequested(Popup firstPopup) {
firstPopup.hide();
preferences.setResyncSpvRequested(false);
new Popup<>().information(Res.get("settings.net.reSyncSPVAfterRestartCompleted"))
new Popup().information(Res.get("settings.net.reSyncSPVAfterRestartCompleted"))
.hideCloseButton()
.useShutDownButton()
.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ else if (root.getSelectionModel().getSelectedItem() == backupTab)

String key = "accountPrivacyInfo";
if (!DevEnv.isDevMode())
new Popup<>()
new Popup()
.headLine(Res.get("account.info.headline"))
.backgroundInfo(Res.get("account.info.msg"))
.dontShowAgainId(key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ protected void deactivate() {
}

protected void onDeleteAccount(PaymentAccount paymentAccount) {
new Popup<>().warning(Res.get("shared.askConfirmDeleteAccount"))
new Popup().warning(Res.get("shared.askConfirmDeleteAccount"))
.actionButtonText(Res.get("shared.yes"))
.onAction(() -> {
boolean isPaymentAccountUsed = deleteAccountFromModel(paymentAccount);
if (!isPaymentAccountUsed)
removeSelectAccountForm();
else
UserThread.runAfter(() -> new Popup<>().warning(
UserThread.runAfter(() -> new Popup().warning(
Res.get("shared.cannotDeleteAccount"))
.show(), 100, TimeUnit.MILLISECONDS);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void onSaveNewAccount(PaymentAccount paymentAccount) {
if (selectedTradeCurrency != null) {
if (selectedTradeCurrency instanceof CryptoCurrency && ((CryptoCurrency) selectedTradeCurrency).isAsset()) {
String name = selectedTradeCurrency.getName();
new Popup<>().information(Res.get("account.altcoin.popup.wallet.msg",
new Popup().information(Res.get("account.altcoin.popup.wallet.msg",
selectedTradeCurrency.getCodeAndName(),
name,
name))
Expand All @@ -141,7 +141,7 @@ private void onSaveNewAccount(PaymentAccount paymentAccount) {
if (asset.isPresent()) {
final AltCoinAccountDisclaimer disclaimerAnnotation = asset.get().getClass().getAnnotation(AltCoinAccountDisclaimer.class);
if (disclaimerAnnotation != null) {
new Popup<>()
new Popup()
.width(asset.get() instanceof Monero ? 1000 : 669)
.maxMessageLength(2500)
.information(Res.get(disclaimerAnnotation.value()))
Expand All @@ -155,7 +155,7 @@ private void onSaveNewAccount(PaymentAccount paymentAccount) {
model.onSaveNewAccount(paymentAccount);
removeNewAccountForm();
} else {
new Popup<>().warning(Res.get("shared.accountNameAlreadyUsed")).show();
new Popup().warning(Res.get("shared.accountNameAlreadyUsed")).show();
}

preferences.dontShowAgain(INSTANT_TRADE_NEWS, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected void activate() {
String dateString = new SimpleDateFormat("yyyy-MM-dd-HHmmss").format(new Date());
String destination = Paths.get(backupDirectory, "bisq_backup_" + dateString).toString();
FileUtil.copyDirectory(dataDir, new File(destination));
new Popup<>().feedback(Res.get("account.backup.success", destination)).show();
new Popup().feedback(Res.get("account.backup.success", destination)).show();
} catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage());
Expand Down Expand Up @@ -181,7 +181,7 @@ private void updateButtons() {

private void showWrongPathWarningAndReset(@Nullable Throwable t) {
String error = t != null ? Res.get("shared.errorMessageInline", t.getMessage()) : "";
new Popup<>().warning(Res.get("account.backup.directoryNotAccessible", error)).show();
new Popup().warning(Res.get("account.backup.directoryNotAccessible", error)).show();
applyBackupDirectory(Utilities.getSystemHomeDirectory());
}

Expand Down
Loading

0 comments on commit 02d521a

Please sign in to comment.