refactor and rename launch and application classes

This commit is contained in:
Craig Raw 2022-10-11 11:41:49 +02:00
parent 1e4c8c3837
commit 778564a954
18 changed files with 94 additions and 83 deletions

View file

@ -110,7 +110,7 @@ dependencies {
application {
mainModule = 'com.sparrowwallet.sparrow'
mainClass = 'com.sparrowwallet.sparrow.MainApp'
mainClass = 'com.sparrowwallet.sparrow.SparrowWallet'
}
compileJava {

View file

@ -12,7 +12,7 @@ public class AboutController {
private Label title;
public void initializeView() {
title.setText(MainApp.APP_NAME + " " + MainApp.APP_VERSION + MainApp.APP_VERSION_SUFFIX);
title.setText(SparrowWallet.APP_NAME + " " + SparrowWallet.APP_VERSION + SparrowWallet.APP_VERSION_SUFFIX);
}
public void setStage(Stage stage) {

View file

@ -35,7 +35,6 @@ import com.sparrowwallet.sparrow.transaction.TransactionView;
import com.sparrowwallet.sparrow.wallet.Entry;
import com.sparrowwallet.sparrow.wallet.WalletController;
import com.sparrowwallet.sparrow.wallet.WalletForm;
import com.sparrowwallet.sparrow.whirlpool.Whirlpool;
import de.codecentric.centerdevice.MenuToolkit;
import javafx.animation.*;
import javafx.application.Platform;
@ -402,10 +401,10 @@ public class AppController implements Initializable {
MenuItem preferences = new MenuItem("Preferences...");
preferences.setOnAction(this::openPreferences);
preferences.setAccelerator(new KeyCodeCombination(KeyCode.COMMA, KeyCombination.META_DOWN));
Menu defaultApplicationMenu = new Menu("Apple", null, tk.createAboutMenuItem(MainApp.APP_NAME, getAboutStage()), new SeparatorMenuItem(),
Menu defaultApplicationMenu = new Menu("Apple", null, tk.createAboutMenuItem(SparrowWallet.APP_NAME, getAboutStage()), new SeparatorMenuItem(),
preferences, new SeparatorMenuItem(),
tk.createHideMenuItem(MainApp.APP_NAME), tk.createHideOthersMenuItem(), tk.createUnhideAllMenuItem(), new SeparatorMenuItem(),
tk.createQuitMenuItem(MainApp.APP_NAME));
tk.createHideMenuItem(SparrowWallet.APP_NAME), tk.createHideOthersMenuItem(), tk.createUnhideAllMenuItem(), new SeparatorMenuItem(),
tk.createQuitMenuItem(SparrowWallet.APP_NAME));
tk.setApplicationMenu(defaultApplicationMenu);
fileMenu.getItems().removeIf(item -> item.getStyleClass().contains("osxHide"));
@ -465,7 +464,7 @@ public class AppController implements Initializable {
}
Stage stage = new Stage(StageStyle.UNDECORATED);
stage.setTitle("About " + MainApp.APP_NAME);
stage.setTitle("About " + SparrowWallet.APP_NAME);
stage.initOwner(tabs.getScene().getWindow());
stage.initModality(Modality.WINDOW_MODAL);
stage.setResizable(false);
@ -1018,7 +1017,7 @@ public class AppController implements Initializable {
} catch(Exception e) {
if(e instanceof IOException && e.getMessage().startsWith("The process cannot access the file because another process has locked")) {
log.error("Error opening wallet", e);
showErrorDialog("Error Opening Wallet", "The wallet file is locked. Is another instance of " + MainApp.APP_NAME + " already running?");
showErrorDialog("Error Opening Wallet", "The wallet file is locked. Is another instance of " + SparrowWallet.APP_NAME + " already running?");
} else if(!attemptImportWallet(file, null)) {
log.error("Error opening wallet", e);
showErrorDialog("Error Opening Wallet", e.getMessage() == null ? "Unsupported file format" : e.getMessage());

View file

@ -20,7 +20,6 @@ import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.drongo.protocol.Transaction;
import com.sparrowwallet.drongo.psbt.PSBT;
import com.sparrowwallet.drongo.uri.BitcoinURI;
import com.sparrowwallet.sparrow.control.TextUtils;
import com.sparrowwallet.sparrow.control.TrayManager;
import com.sparrowwallet.sparrow.event.*;
import com.sparrowwallet.sparrow.io.*;
@ -43,7 +42,6 @@ import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.Dialog;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
@ -53,7 +51,6 @@ import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;
import org.berndpruenster.netlayer.tor.Tor;
import org.controlsfx.control.HyperlinkLabel;
import org.controlsfx.glyphfont.Glyph;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -70,8 +67,6 @@ import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class AppServices {
@ -573,7 +568,7 @@ public class AppServices {
private static Image getWindowIcon() {
if(windowIcon == null) {
windowIcon = new Image(MainApp.class.getResourceAsStream("/image/sparrow-icon.png"));
windowIcon = new Image(SparrowWallet.class.getResourceAsStream("/image/sparrow-icon.png"));
}
return windowIcon;

View file

@ -21,16 +21,16 @@ import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
public class Sparrow extends Application {
public class SparrowDesktop extends Application {
private Stage mainStage;
@Override
public void init() throws Exception {
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
if(e instanceof IndexOutOfBoundsException && Arrays.stream(e.getStackTrace()).anyMatch(element -> element.getClassName().equals("javafx.scene.chart.BarChart"))) {
LoggerFactory.getLogger(MainApp.class).debug("Exception in thread \"" + t.getName() + "\"", e);;
LoggerFactory.getLogger(SparrowWallet.class).debug("Exception in thread \"" + t.getName() + "\"", e);;
} else {
LoggerFactory.getLogger(MainApp.class).error("Exception in thread \"" + t.getName() + "\"", e);
LoggerFactory.getLogger(SparrowWallet.class).error("Exception in thread \"" + t.getName() + "\"", e);
}
});
super.init();
@ -114,9 +114,9 @@ public class Sparrow extends Application {
Config.get().setAppWidth(mainStage.getWidth());
Config.get().setAppHeight(mainStage.getHeight());
mainStage.close();
MainApp.SparrowInstance sparrowInstance = MainApp.getSparrowInstance();
if(sparrowInstance != null) {
sparrowInstance.freeLock();
SparrowWallet.Instance instance = SparrowWallet.getSparrowInstance();
if(instance != null) {
instance.freeLock();
}
}
}

View file

@ -7,9 +7,7 @@ import com.sparrowwallet.sparrow.io.Storage;
import com.sparrowwallet.sparrow.instance.InstanceException;
import com.sparrowwallet.sparrow.instance.InstanceList;
import com.sparrowwallet.sparrow.terminal.SparrowTerminal;
import com.sparrowwallet.sparrow.terminal.TerminalInteractionServices;
import com.sun.javafx.application.PlatformImpl;
import javafx.application.Application;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;
@ -17,7 +15,7 @@ import org.slf4j.bridge.SLF4JBridgeHandler;
import java.io.File;
import java.util.*;
public class MainApp {
public class SparrowWallet {
public static final String APP_ID = "com.sparrowwallet.sparrow";
public static final String APP_NAME = "Sparrow";
public static final String APP_VERSION = "1.6.6";
@ -25,7 +23,7 @@ public class MainApp {
public static final String APP_HOME_PROPERTY = "sparrow.home";
public static final String NETWORK_ENV_PROPERTY = "SPARROW_NETWORK";
private static SparrowInstance sparrowInstance;
private static Instance instance;
public static void main(String[] argv) {
Args args = new Args();
@ -72,17 +70,11 @@ public class MainApp {
getLogger().info("Using " + Network.get() + " configuration");
}
if(args.terminal) {
PlatformImpl.setTaskbarApplication(false);
Application.launch(SparrowTerminal.class, argv);
return;
}
List<String> fileUriArguments = jCommander.getUnknownOptions();
try {
sparrowInstance = new SparrowInstance(fileUriArguments);
sparrowInstance.acquireLock(); //If fileUriArguments is not empty, will exit app after sending fileUriArguments if lock cannot be acquired
instance = new Instance(fileUriArguments);
instance.acquireLock(); //If fileUriArguments is not empty, will exit app after sending fileUriArguments if lock cannot be acquired
} catch(InstanceException e) {
getLogger().error("Could not access application lock", e);
}
@ -93,22 +85,28 @@ public class MainApp {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
com.sun.javafx.application.LauncherImpl.launchApplication(Sparrow.class, MainAppPreloader.class, argv);
if(args.terminal) {
PlatformImpl.setTaskbarApplication(false);
com.sun.javafx.application.LauncherImpl.launchApplication(SparrowTerminal.class, SparrowWalletPreloader.class, argv);
} else {
com.sun.javafx.application.LauncherImpl.launchApplication(SparrowDesktop.class, SparrowWalletPreloader.class, argv);
}
}
public static SparrowInstance getSparrowInstance() {
return sparrowInstance;
public static Instance getSparrowInstance() {
return instance;
}
private static Logger getLogger() {
return LoggerFactory.getLogger(MainApp.class);
return LoggerFactory.getLogger(SparrowWallet.class);
}
public static class SparrowInstance extends InstanceList {
public static class Instance extends InstanceList {
private final List<String> fileUriArguments;
public SparrowInstance(List<String> fileUriArguments) {
super(MainApp.APP_ID + "." + Network.get(), !fileUriArguments.isEmpty());
public Instance(List<String> fileUriArguments) {
super(SparrowWallet.APP_ID + "." + Network.get(), !fileUriArguments.isEmpty());
this.fileUriArguments = fileUriArguments;
}

View file

@ -3,7 +3,7 @@ package com.sparrowwallet.sparrow;
import javafx.application.Preloader;
import javafx.stage.Stage;
public class MainAppPreloader extends Preloader {
public class SparrowWalletPreloader extends Preloader {
@Override
public void start(Stage stage) {
com.sun.glass.ui.Application.GetApplication().setName("Sparrow");

View file

@ -7,7 +7,7 @@ import com.sparrowwallet.drongo.wallet.MnemonicException;
import com.sparrowwallet.drongo.wallet.StandardAccount;
import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.MainApp;
import com.sparrowwallet.sparrow.SparrowWallet;
import com.sparrowwallet.sparrow.soroban.Soroban;
import com.sparrowwallet.sparrow.whirlpool.Whirlpool;
import javafx.concurrent.Service;
@ -547,8 +547,8 @@ public class Storage {
}
public static File getSparrowHome() {
if(System.getProperty(MainApp.APP_HOME_PROPERTY) != null) {
return new File(System.getProperty(MainApp.APP_HOME_PROPERTY));
if(System.getProperty(SparrowWallet.APP_HOME_PROPERTY) != null) {
return new File(System.getProperty(SparrowWallet.APP_HOME_PROPERTY));
}
if(Platform.getCurrent() == Platform.WINDOWS) {

View file

@ -6,7 +6,7 @@ import com.sparrowwallet.drongo.address.InvalidAddressException;
import com.sparrowwallet.drongo.crypto.ECKey;
import com.sparrowwallet.drongo.protocol.ScriptType;
import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.MainApp;
import com.sparrowwallet.sparrow.SparrowWallet;
import com.sparrowwallet.sparrow.event.VersionUpdatedEvent;
import javafx.concurrent.ScheduledService;
import javafx.concurrent.Task;
@ -91,10 +91,10 @@ public class VersionCheckService extends ScheduledService<VersionUpdatedEvent> {
private boolean isNewer(VersionCheck versionCheck) {
try {
Version versionCheckVersion = new Version(versionCheck.version);
Version currentVersion = new Version(MainApp.APP_VERSION);
Version currentVersion = new Version(SparrowWallet.APP_VERSION);
return versionCheckVersion.compareTo(currentVersion) > 0;
} catch(IllegalArgumentException e) {
log.error("Invalid versions to compare: " + versionCheck.version + " to " + MainApp.APP_VERSION, e);
log.error("Invalid versions to compare: " + versionCheck.version + " to " + SparrowWallet.APP_VERSION, e);
}
return false;

View file

@ -12,6 +12,7 @@ import com.sparrowwallet.sparrow.terminal.preferences.GeneralDialog;
import com.sparrowwallet.sparrow.terminal.preferences.ServerStatusDialog;
import com.sparrowwallet.sparrow.terminal.preferences.ServerTypeDialog;
import com.sparrowwallet.sparrow.terminal.wallet.LoadWallet;
import javafx.application.Platform;
import java.io.File;
import java.util.Map;
@ -46,7 +47,7 @@ public class MasterActionListBox extends ActionListBox {
File file = openBuilder.build().showDialog(SparrowTerminal.get().getGui());
if(file != null) {
LoadWallet loadWallet = new LoadWallet(new Storage(file));
SparrowTerminal.get().getGui().getGUIThread().invokeLater(loadWallet);
SparrowTerminal.get().getGuiThread().invokeLater(loadWallet);
}
});
builder.build().showDialog(SparrowTerminal.get().getGui());
@ -72,6 +73,6 @@ public class MasterActionListBox extends ActionListBox {
.showDialog(sparrowTerminal.getGui());
});
addItem("Quit", sparrowTerminal::stop);
addItem("Quit", () -> sparrowTerminal.getGui().getMainWindow().close());
}
}

View file

@ -3,6 +3,7 @@ package com.sparrowwallet.sparrow.terminal;
import com.googlecode.lanterna.TextColor;
import com.googlecode.lanterna.gui2.DefaultWindowManager;
import com.googlecode.lanterna.gui2.EmptySpace;
import com.googlecode.lanterna.gui2.TextGUIThread;
import com.googlecode.lanterna.screen.Screen;
import com.googlecode.lanterna.screen.TerminalScreen;
import com.googlecode.lanterna.terminal.DefaultTerminalFactory;
@ -10,6 +11,7 @@ import com.googlecode.lanterna.terminal.Terminal;
import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.SparrowWallet;
import com.sparrowwallet.sparrow.terminal.wallet.WalletData;
import javafx.application.Application;
import javafx.application.Platform;
@ -17,7 +19,6 @@ import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@ -43,8 +44,12 @@ public class SparrowTerminal extends Application {
sparrowTerminal = this;
try {
getScreen().startScreen();
getGui().getMainWindow().waitUntilClosed();
} finally {
exit();
}
}
@Override
@ -52,6 +57,19 @@ public class SparrowTerminal extends Application {
}
@Override
public void stop() throws Exception {
try {
AppServices.get().stop();
SparrowWallet.Instance instance = SparrowWallet.getSparrowInstance();
if(instance != null) {
instance.freeLock();
}
} catch(Exception e) {
log.error("Could not stop application", e);
}
}
public Screen getScreen() {
return screen;
}
@ -60,20 +78,20 @@ public class SparrowTerminal extends Application {
return gui;
}
public TextGUIThread getGuiThread() {
return gui.getGUIThread();
}
public Map<Wallet, WalletData> getWalletData() {
return walletData;
}
public void stop() {
public void exit() {
try {
screen.stopScreen();
terminal.exitPrivateMode();
Platform.runLater(() -> {
AppServices.get().stop();
Platform.exit();
});
Platform.runLater(Platform::exit);
} catch(Exception e) {
log.error("Could not stop terminal", e);
log.error("Could not stop terminal screen", e);
}
}

View file

@ -23,7 +23,7 @@ public class TerminalInteractionServices implements InteractionServices {
@SuppressWarnings("unchecked")
public Optional<ButtonType> showAlert(String title, String content, Alert.AlertType alertType, Node graphic, ButtonType... buttons) {
if(Platform.isFxApplicationThread()) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
Optional<ButtonType> optButtonType = showMessageDialog(title, content, buttons);
Platform.runLater(() -> Platform.exitNestedEventLoop(alertShowing, optButtonType));
});
@ -92,7 +92,7 @@ public class TerminalInteractionServices implements InteractionServices {
@SuppressWarnings("unchecked")
public Optional<String> requestPassphrase(String walletName, Keystore keystore) {
if(Platform.isFxApplicationThread()) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
Optional<String> optPassphrase = showPassphraseDialog(walletName, keystore);
Platform.runLater(() -> Platform.exitNestedEventLoop(passphraseShowing, optPassphrase));
});

View file

@ -78,7 +78,7 @@ public class AddressesDialog extends WalletDialog {
}
private void updateAddressesLater() {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(this::updateAddresses);
SparrowTerminal.get().getGuiThread().invokeLater(this::updateAddresses);
}
private void updateAddresses() {

View file

@ -7,7 +7,7 @@ import com.sparrowwallet.drongo.SecureString;
import com.sparrowwallet.drongo.crypto.InvalidPasswordException;
import com.sparrowwallet.drongo.wallet.Wallet;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.MainApp;
import com.sparrowwallet.sparrow.SparrowWallet;
import com.sparrowwallet.sparrow.TabData;
import com.sparrowwallet.sparrow.WalletTabData;
import com.sparrowwallet.sparrow.event.*;
@ -52,7 +52,7 @@ public class LoadWallet implements Runnable {
loadWalletService.setExecutor(Storage.LoadWalletService.getSingleThreadedExecutor());
loadWalletService.setOnSucceeded(workerStateEvent -> {
WalletAndKey walletAndKey = loadWalletService.getValue();
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> openWallet(storage, walletAndKey));
SparrowTerminal.get().getGuiThread().invokeLater(() -> openWallet(storage, walletAndKey));
});
loadWalletService.setOnFailed(workerStateEvent -> {
Throwable exception = workerStateEvent.getSource().getException();
@ -77,7 +77,7 @@ public class LoadWallet implements Runnable {
loadWalletService.setOnSucceeded(workerStateEvent -> {
EventManager.get().post(new StorageEvent(storage.getWalletId(null), TimedEvent.Action.END, "Done"));
WalletAndKey walletAndKey = loadWalletService.getValue();
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> openWallet(storage, walletAndKey));
SparrowTerminal.get().getGuiThread().invokeLater(() -> openWallet(storage, walletAndKey));
});
loadWalletService.setOnFailed(workerStateEvent -> {
EventManager.get().post(new StorageEvent(storage.getWalletId(null), TimedEvent.Action.END, "Failed"));
@ -99,7 +99,7 @@ public class LoadWallet implements Runnable {
}
} catch(Exception e) {
if(e instanceof IOException && e.getMessage().startsWith("The process cannot access the file because another process has locked")) {
showErrorDialog("Error Opening Wallet", "The wallet file is locked. Is another instance of " + MainApp.APP_NAME + " already running?");
showErrorDialog("Error Opening Wallet", "The wallet file is locked. Is another instance of " + SparrowWallet.APP_NAME + " already running?");
} else {
log.error("Error opening wallet", e);
showErrorDialog("Error Opening Wallet", e.getMessage() == null ? "Unsupported file format" : e.getMessage());

View file

@ -59,7 +59,7 @@ public class ReceiveDialog extends WalletDialog {
}
public void refreshAddress() {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
NodeEntry freshEntry = getWalletForm().getFreshNodeEntry(KeyPurpose.RECEIVE, currentEntry);
setNodeEntry(freshEntry);
});
@ -93,7 +93,7 @@ public class ReceiveDialog extends WalletDialog {
}
private void updateLastUsed() {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
Set<BlockTransactionHashIndex> currentOutputs = currentEntry.getNode().getTransactionOutputs();
if(AppServices.onlineProperty().get() && currentOutputs.isEmpty()) {
lastUsed.setText("Never");

View file

@ -73,7 +73,7 @@ public class TransactionsDialog extends WalletDialog {
}
private void updateHistory(WalletTransactionsEntry walletTransactionsEntry) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
TableModel<TableCell> tableModel = getTableModel(walletTransactionsEntry);
transactions.setTableModel(tableModel);
});
@ -89,7 +89,7 @@ public class TransactionsDialog extends WalletDialog {
}
private void updateLabels(WalletTransactionsEntry walletTransactionsEntry) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
balance.setText(formatBitcoinValue(walletTransactionsEntry.getBalance(), true));
mempoolBalance.setText(formatBitcoinValue(walletTransactionsEntry.getMempoolBalance(), true));
@ -137,7 +137,7 @@ public class TransactionsDialog extends WalletDialog {
@Subscribe
public void fiatCurrencySelected(FiatCurrencySelectedEvent event) {
if(event.getExchangeSource() == ExchangeSource.NONE) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
fiatBalance.setText("");
fiatMempoolBalance.setText("");
});
@ -146,7 +146,7 @@ public class TransactionsDialog extends WalletDialog {
@Subscribe
public void exchangeRatesUpdated(ExchangeRatesUpdatedEvent event) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
WalletTransactionsEntry walletTransactionsEntry = getWalletForm().getWalletTransactionsEntry();
fiatBalance.setText(formatFiatValue(getFiatValue(walletTransactionsEntry.getBalance(), event.getBtcRate())));
fiatMempoolBalance.setText(formatFiatValue(getFiatValue(walletTransactionsEntry.getMempoolBalance(), event.getBtcRate())));

View file

@ -36,12 +36,12 @@ public class UtxosDialog extends WalletDialog {
private Button mixTo;
private final ChangeListener<Boolean> mixingOnlineListener = (observable, oldValue, newValue) -> {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> startMix.setEnabled(newValue));
SparrowTerminal.get().getGuiThread().invokeLater(() -> startMix.setEnabled(newValue));
};
private final ChangeListener<Boolean> mixingStartingListener = (observable, oldValue, newValue) -> {
try {
SparrowTerminal.get().getGui().getGUIThread().invokeAndWait(() -> {
SparrowTerminal.get().getGuiThread().invokeAndWait(() -> {
startMix.setEnabled(!newValue && AppServices.onlineProperty().get());
startMix.setLabel(newValue && AppServices.onlineProperty().get() ? "Starting Mixing..." : isMixing() ? "Stop Mixing" : "Start Mixing");
mixTo.setEnabled(!newValue);
@ -53,7 +53,7 @@ public class UtxosDialog extends WalletDialog {
private final ChangeListener<Boolean> mixingStoppingListener = (observable, oldValue, newValue) -> {
try {
SparrowTerminal.get().getGui().getGUIThread().invokeAndWait(() -> {
SparrowTerminal.get().getGuiThread().invokeAndWait(() -> {
startMix.setEnabled(!newValue && AppServices.onlineProperty().get());
startMix.setLabel(newValue ? "Stopping Mixing..." : isMixing() ? "Stop Mixing" : "Start Mixing");
mixTo.setEnabled(!newValue);
@ -161,7 +161,7 @@ public class UtxosDialog extends WalletDialog {
}
private void updateHistory(WalletUtxosEntry walletUtxosEntry) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
TableModel<TableCell> tableModel = getTableModel(walletUtxosEntry);
utxos.setTableModel(tableModel);
});
@ -184,7 +184,7 @@ public class UtxosDialog extends WalletDialog {
}
private void updateLabels(WalletUtxosEntry walletUtxosEntry) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
balance.setText(formatBitcoinValue(walletUtxosEntry.getBalance(), true));
mempoolBalance.setText(formatBitcoinValue(walletUtxosEntry.getMempoolBalance(), true));
@ -275,7 +275,7 @@ public class UtxosDialog extends WalletDialog {
whirlpool.setMixToWallet(null, null);
}
SparrowTerminal.get().getGui().getGUIThread().invokeLater(this::updateMixToButton);
SparrowTerminal.get().getGuiThread().invokeLater(this::updateMixToButton);
if(whirlpool.isStarted()) {
//Will automatically restart
AppServices.getWhirlpoolServices().stopWhirlpool(whirlpool, false);
@ -343,7 +343,7 @@ public class UtxosDialog extends WalletDialog {
UtxoEntry tableEntry = (UtxoEntry)tableModel.getRow(row).get(0).getEntry();
if(tableEntry.getHashIndex().equals(event.getUtxo())) {
final int utxoRow = row;
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
tableModel.setCell(2, utxoRow, new MixTableCell(utxoEntry));
});
}
@ -369,12 +369,12 @@ public class UtxosDialog extends WalletDialog {
@Subscribe
public void openWallets(OpenWalletsEvent event) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(this::updateMixToButton);
SparrowTerminal.get().getGuiThread().invokeLater(this::updateMixToButton);
}
@Subscribe
public void walletLabelChanged(WalletLabelChangedEvent event) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(this::updateMixToButton);
SparrowTerminal.get().getGuiThread().invokeLater(this::updateMixToButton);
}
@Subscribe
@ -392,7 +392,7 @@ public class UtxosDialog extends WalletDialog {
@Subscribe
public void fiatCurrencySelected(FiatCurrencySelectedEvent event) {
if(event.getExchangeSource() == ExchangeSource.NONE) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
fiatBalance.setText("");
fiatMempoolBalance.setText("");
});
@ -401,7 +401,7 @@ public class UtxosDialog extends WalletDialog {
@Subscribe
public void exchangeRatesUpdated(ExchangeRatesUpdatedEvent event) {
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
WalletUtxosEntry walletUtxosEntry = getWalletForm().getWalletUtxosEntry();
fiatBalance.setText(formatFiatValue(getFiatValue(walletUtxosEntry.getBalance(), event.getBtcRate())));
fiatMempoolBalance.setText(formatFiatValue(getFiatValue(walletUtxosEntry.getMempoolBalance(), event.getBtcRate())));

View file

@ -24,7 +24,7 @@ public class WalletAccountsDialog extends DialogWindow {
for(Wallet wallet : masterWallet.getAllWallets()) {
actions.addItem(wallet.getDisplayName(), () -> {
close();
SparrowTerminal.get().getGui().getGUIThread().invokeLater(() -> {
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
WalletActionsDialog walletActionsDialog = new WalletActionsDialog(wallet);
walletActionsDialog.showDialog(SparrowTerminal.get().getGui());
});