mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-23 20:36:44 +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 javafx.animation.*;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
|
@ -99,6 +100,9 @@ public class AppController implements Initializable {
|
|||
@FXML
|
||||
private CheckMenuItem showTxHex;
|
||||
|
||||
@FXML
|
||||
private MenuItem refreshWallet;
|
||||
|
||||
@FXML
|
||||
private StackPane rootStack;
|
||||
|
||||
|
@ -223,6 +227,7 @@ public class AppController implements Initializable {
|
|||
hideEmptyUsedAddresses.setSelected(Config.get().isHideEmptyUsedAddresses());
|
||||
showTxHex.setSelected(Config.get().isShowTransactionHex());
|
||||
exportWallet.setDisable(true);
|
||||
refreshWallet.disableProperty().bind(Bindings.or(exportWallet.disableProperty(), Bindings.or(serverToggle.disableProperty(), AppServices.onlineProperty().not())));
|
||||
|
||||
setServerType(Config.get().getServerType());
|
||||
serverToggle.setSelected(isConnected());
|
||||
|
@ -828,6 +833,18 @@ public class AppController implements Initializable {
|
|||
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) {
|
||||
Window existingWalletWindow = AppServices.get().getWindowForWallet(storage);
|
||||
if(existingWalletWindow instanceof Stage) {
|
||||
|
|
|
@ -10,8 +10,10 @@ import com.sparrowwallet.sparrow.AppServices;
|
|||
import com.sparrowwallet.sparrow.EventManager;
|
||||
import com.sparrowwallet.sparrow.WalletTabData;
|
||||
import com.sparrowwallet.sparrow.event.*;
|
||||
import com.sparrowwallet.sparrow.io.Config;
|
||||
import com.sparrowwallet.sparrow.net.ElectrumServer;
|
||||
import com.sparrowwallet.sparrow.io.Storage;
|
||||
import com.sparrowwallet.sparrow.net.ServerType;
|
||||
import javafx.application.Platform;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -25,6 +27,7 @@ public class WalletForm {
|
|||
|
||||
private final Storage storage;
|
||||
protected Wallet wallet;
|
||||
private Wallet savedPastWallet;
|
||||
|
||||
private WalletTransactionsEntry walletTransactionsEntry;
|
||||
private WalletUtxosEntry walletUtxosEntry;
|
||||
|
@ -245,6 +248,13 @@ public class WalletForm {
|
|||
walletUtxosEntry = null;
|
||||
accountEntries.clear();
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +269,8 @@ public class WalletForm {
|
|||
|
||||
@Subscribe
|
||||
public void connected(ConnectionEvent event) {
|
||||
refreshHistory(event.getBlockHeight(), null);
|
||||
refreshHistory(event.getBlockHeight(), savedPastWallet);
|
||||
savedPastWallet = null;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<MenuItem text="File..." onAction="#openTransactionFromFile" accelerator="Shortcut+F"/>
|
||||
<MenuItem fx:id="openTransactionIdItem" text="From ID..." onAction="#openTransactionFromId" accelerator="Shortcut+I"/>
|
||||
<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"/> -->
|
||||
</items>
|
||||
</Menu>
|
||||
|
@ -82,6 +82,8 @@
|
|||
<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="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>
|
||||
</Menu>
|
||||
<Menu fx:id="toolsMenu" mnemonicParsing="false" text="Tools">
|
||||
|
|
Loading…
Reference in a new issue