mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
add refresh wallet menu item
This commit is contained in:
parent
11a0e3765b
commit
890b4098d7
3 changed files with 32 additions and 2 deletions
|
@ -33,6 +33,7 @@ import com.sparrowwallet.sparrow.wallet.WalletForm;
|
||||||
import de.codecentric.centerdevice.MenuToolkit;
|
import de.codecentric.centerdevice.MenuToolkit;
|
||||||
import javafx.animation.*;
|
import javafx.animation.*;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -99,6 +100,9 @@ public class AppController implements Initializable {
|
||||||
@FXML
|
@FXML
|
||||||
private CheckMenuItem showTxHex;
|
private CheckMenuItem showTxHex;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private MenuItem refreshWallet;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private StackPane rootStack;
|
private StackPane rootStack;
|
||||||
|
|
||||||
|
@ -223,6 +227,7 @@ public class AppController implements Initializable {
|
||||||
hideEmptyUsedAddresses.setSelected(Config.get().isHideEmptyUsedAddresses());
|
hideEmptyUsedAddresses.setSelected(Config.get().isHideEmptyUsedAddresses());
|
||||||
showTxHex.setSelected(Config.get().isShowTransactionHex());
|
showTxHex.setSelected(Config.get().isShowTransactionHex());
|
||||||
exportWallet.setDisable(true);
|
exportWallet.setDisable(true);
|
||||||
|
refreshWallet.disableProperty().bind(Bindings.or(exportWallet.disableProperty(), Bindings.or(serverToggle.disableProperty(), AppServices.onlineProperty().not())));
|
||||||
|
|
||||||
setServerType(Config.get().getServerType());
|
setServerType(Config.get().getServerType());
|
||||||
serverToggle.setSelected(isConnected());
|
serverToggle.setSelected(isConnected());
|
||||||
|
@ -828,6 +833,18 @@ public class AppController implements Initializable {
|
||||||
messageSignDialog.showAndWait();
|
messageSignDialog.showAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refreshWallet(ActionEvent event) {
|
||||||
|
Tab selectedTab = tabs.getSelectionModel().getSelectedItem();
|
||||||
|
TabData tabData = (TabData)selectedTab.getUserData();
|
||||||
|
if(tabData.getType() == TabData.TabType.WALLET) {
|
||||||
|
WalletTabData walletTabData = (WalletTabData) tabData;
|
||||||
|
Wallet wallet = walletTabData.getWallet();
|
||||||
|
Wallet pastWallet = wallet.copy();
|
||||||
|
wallet.clearHistory();
|
||||||
|
EventManager.get().post(new WalletSettingsChangedEvent(wallet, pastWallet, walletTabData.getStorage().getWalletFile()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addWalletTabOrWindow(Storage storage, Wallet wallet, boolean forceSameWindow) {
|
public void addWalletTabOrWindow(Storage storage, Wallet wallet, boolean forceSameWindow) {
|
||||||
Window existingWalletWindow = AppServices.get().getWindowForWallet(storage);
|
Window existingWalletWindow = AppServices.get().getWindowForWallet(storage);
|
||||||
if(existingWalletWindow instanceof Stage) {
|
if(existingWalletWindow instanceof Stage) {
|
||||||
|
|
|
@ -10,8 +10,10 @@ import com.sparrowwallet.sparrow.AppServices;
|
||||||
import com.sparrowwallet.sparrow.EventManager;
|
import com.sparrowwallet.sparrow.EventManager;
|
||||||
import com.sparrowwallet.sparrow.WalletTabData;
|
import com.sparrowwallet.sparrow.WalletTabData;
|
||||||
import com.sparrowwallet.sparrow.event.*;
|
import com.sparrowwallet.sparrow.event.*;
|
||||||
|
import com.sparrowwallet.sparrow.io.Config;
|
||||||
import com.sparrowwallet.sparrow.net.ElectrumServer;
|
import com.sparrowwallet.sparrow.net.ElectrumServer;
|
||||||
import com.sparrowwallet.sparrow.io.Storage;
|
import com.sparrowwallet.sparrow.io.Storage;
|
||||||
|
import com.sparrowwallet.sparrow.net.ServerType;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -25,6 +27,7 @@ public class WalletForm {
|
||||||
|
|
||||||
private final Storage storage;
|
private final Storage storage;
|
||||||
protected Wallet wallet;
|
protected Wallet wallet;
|
||||||
|
private Wallet savedPastWallet;
|
||||||
|
|
||||||
private WalletTransactionsEntry walletTransactionsEntry;
|
private WalletTransactionsEntry walletTransactionsEntry;
|
||||||
private WalletUtxosEntry walletUtxosEntry;
|
private WalletUtxosEntry walletUtxosEntry;
|
||||||
|
@ -245,6 +248,13 @@ public class WalletForm {
|
||||||
walletUtxosEntry = null;
|
walletUtxosEntry = null;
|
||||||
accountEntries.clear();
|
accountEntries.clear();
|
||||||
EventManager.get().post(new WalletNodesChangedEvent(wallet));
|
EventManager.get().post(new WalletNodesChangedEvent(wallet));
|
||||||
|
|
||||||
|
//It is necessary to save the past wallet because the actual copying of the past labels only occurs on a later ConnectionEvent with bwt
|
||||||
|
//The savedPastWallet variable can be removed once bwt supports dynamic loading of wallets without needing to disconnect/reconnect
|
||||||
|
if(Config.get().getServerType() == ServerType.BITCOIN_CORE) {
|
||||||
|
savedPastWallet = event.getPastWallet();
|
||||||
|
}
|
||||||
|
|
||||||
refreshHistory(AppServices.getCurrentBlockHeight(), event.getPastWallet());
|
refreshHistory(AppServices.getCurrentBlockHeight(), event.getPastWallet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +269,8 @@ public class WalletForm {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void connected(ConnectionEvent event) {
|
public void connected(ConnectionEvent event) {
|
||||||
refreshHistory(event.getBlockHeight(), null);
|
refreshHistory(event.getBlockHeight(), savedPastWallet);
|
||||||
|
savedPastWallet = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<MenuItem text="File..." onAction="#openTransactionFromFile" accelerator="Shortcut+F"/>
|
<MenuItem text="File..." onAction="#openTransactionFromFile" accelerator="Shortcut+F"/>
|
||||||
<MenuItem fx:id="openTransactionIdItem" text="From ID..." onAction="#openTransactionFromId" accelerator="Shortcut+I"/>
|
<MenuItem fx:id="openTransactionIdItem" text="From ID..." onAction="#openTransactionFromId" accelerator="Shortcut+I"/>
|
||||||
<MenuItem text="From Text..." onAction="#openTransactionFromText" accelerator="Shortcut+T"/>
|
<MenuItem text="From Text..." onAction="#openTransactionFromText" accelerator="Shortcut+T"/>
|
||||||
<MenuItem text="From QR..." onAction="#openTransactionFromQR" accelerator="Shortcut+R"/>
|
<MenuItem text="From QR..." onAction="#openTransactionFromQR" accelerator="Shortcut+U"/>
|
||||||
<!-- <MenuItem text="Examples" onAction="#openExamples"/> -->
|
<!-- <MenuItem text="Examples" onAction="#openExamples"/> -->
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
@ -82,6 +82,8 @@
|
||||||
<CheckMenuItem fx:id="openWalletsInNewWindows" mnemonicParsing="false" text="Open Wallets in New Windows" onAction="#openWalletsInNewWindows"/>
|
<CheckMenuItem fx:id="openWalletsInNewWindows" mnemonicParsing="false" text="Open Wallets in New Windows" onAction="#openWalletsInNewWindows"/>
|
||||||
<CheckMenuItem fx:id="hideEmptyUsedAddresses" mnemonicParsing="false" text="Hide Empty Used Addresses" onAction="#hideEmptyUsedAddresses"/>
|
<CheckMenuItem fx:id="hideEmptyUsedAddresses" mnemonicParsing="false" text="Hide Empty Used Addresses" onAction="#hideEmptyUsedAddresses"/>
|
||||||
<CheckMenuItem fx:id="showTxHex" mnemonicParsing="false" text="Show Transaction Hex" onAction="#showTxHex"/>
|
<CheckMenuItem fx:id="showTxHex" mnemonicParsing="false" text="Show Transaction Hex" onAction="#showTxHex"/>
|
||||||
|
<SeparatorMenuItem />
|
||||||
|
<MenuItem fx:id="refreshWallet" mnemonicParsing="false" text="Refresh Wallet" accelerator="Shortcut+R" onAction="#refreshWallet"/>
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu fx:id="toolsMenu" mnemonicParsing="false" text="Tools">
|
<Menu fx:id="toolsMenu" mnemonicParsing="false" text="Tools">
|
||||||
|
|
Loading…
Reference in a new issue