mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 13:26:44 +00:00
add optional transaction count column on address table with table header context menu to show
This commit is contained in:
parent
03e9d23fa8
commit
f30da06aaf
7 changed files with 89 additions and 1 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
|||
Subproject commit 40dab5933702c5b12913337dc618a68652c445e4
|
||||
Subproject commit b2f5f5ffebfc0ce9f0d992f3ac3b59965661491b
|
|
@ -5,6 +5,7 @@ import com.sparrowwallet.sparrow.AppServices;
|
|||
import com.sparrowwallet.sparrow.EventManager;
|
||||
import com.sparrowwallet.sparrow.event.ReceiveActionEvent;
|
||||
import com.sparrowwallet.sparrow.event.ReceiveToEvent;
|
||||
import com.sparrowwallet.sparrow.event.ShowTransactionsCountEvent;
|
||||
import com.sparrowwallet.sparrow.io.Config;
|
||||
import com.sparrowwallet.sparrow.wallet.Entry;
|
||||
import com.sparrowwallet.sparrow.wallet.NodeEntry;
|
||||
|
@ -45,6 +46,15 @@ public class AddressTreeTable extends CoinTreeTable {
|
|||
labelCol.setSortable(false);
|
||||
getColumns().add(labelCol);
|
||||
|
||||
TreeTableColumn<Entry, Number> countCol = new TreeTableColumn<>("Transactions");
|
||||
countCol.setCellValueFactory((TreeTableColumn.CellDataFeatures<Entry, Number> param) -> {
|
||||
return new ReadOnlyObjectWrapper<>(param.getValue().getValue().getChildren().size());
|
||||
});
|
||||
countCol.setCellFactory(p -> new NumberCell());
|
||||
countCol.setSortable(false);
|
||||
countCol.setVisible(Config.get().isShowAddressTransactionCount());
|
||||
getColumns().add(countCol);
|
||||
|
||||
TreeTableColumn<Entry, Number> amountCol = new TreeTableColumn<>("Value");
|
||||
amountCol.setCellValueFactory((TreeTableColumn.CellDataFeatures<Entry, Number> param) -> {
|
||||
return new ReadOnlyObjectWrapper<>(param.getValue().getValue().getValue());
|
||||
|
@ -53,6 +63,19 @@ public class AddressTreeTable extends CoinTreeTable {
|
|||
amountCol.setSortable(false);
|
||||
getColumns().add(amountCol);
|
||||
|
||||
ContextMenu contextMenu = new ContextMenu();
|
||||
CheckMenuItem showCountItem = new CheckMenuItem("Show Transaction Count");
|
||||
contextMenu.setOnShowing(event -> {
|
||||
showCountItem.setSelected(Config.get().isShowAddressTransactionCount());
|
||||
});
|
||||
showCountItem.setOnAction(event -> {
|
||||
boolean show = !Config.get().isShowAddressTransactionCount();
|
||||
Config.get().setShowAddressTransactionCount(show);
|
||||
EventManager.get().post(new ShowTransactionsCountEvent(show));
|
||||
});
|
||||
contextMenu.getItems().add(showCountItem);
|
||||
getColumns().forEach(col -> col.setContextMenu(contextMenu));
|
||||
|
||||
setEditable(true);
|
||||
setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
|
||||
|
||||
|
@ -147,4 +170,8 @@ public class AddressTreeTable extends CoinTreeTable {
|
|||
Entry rootEntry = getRoot().getValue();
|
||||
rootEntry.updateLabel(entry);
|
||||
}
|
||||
|
||||
public void showTransactionsCount(boolean show) {
|
||||
getColumns().stream().filter(col -> col.getText().equals("Transactions")).forEach(col -> col.setVisible(show));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.sparrowwallet.sparrow.control;
|
||||
|
||||
import com.sparrowwallet.sparrow.wallet.Entry;
|
||||
import javafx.scene.control.TreeTableCell;
|
||||
import org.controlsfx.tools.Platform;
|
||||
|
||||
public class NumberCell extends TreeTableCell<Entry, Number> {
|
||||
public NumberCell() {
|
||||
super();
|
||||
getStyleClass().add("number-cell");
|
||||
if(Platform.getCurrent() == Platform.OSX) {
|
||||
getStyleClass().add("number-field");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateItem(Number amount, boolean empty) {
|
||||
super.updateItem(amount, empty);
|
||||
|
||||
if(empty || amount == null) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
setText(amount.toString());
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.sparrowwallet.sparrow.event;
|
||||
|
||||
public class ShowTransactionsCountEvent {
|
||||
private final boolean showCount;
|
||||
|
||||
public ShowTransactionsCountEvent(boolean showCount) {
|
||||
this.showCount = showCount;
|
||||
}
|
||||
|
||||
public boolean isShowCount() {
|
||||
return showCount;
|
||||
}
|
||||
}
|
|
@ -43,6 +43,7 @@ public class Config {
|
|||
private boolean hideEmptyUsedAddresses = false;
|
||||
private boolean showTransactionHex = true;
|
||||
private boolean showLoadingLog = true;
|
||||
private boolean showAddressTransactionCount = false;
|
||||
private boolean preventSleep = false;
|
||||
private List<File> recentWalletFiles;
|
||||
private Integer keyDerivationPeriod;
|
||||
|
@ -278,6 +279,15 @@ public class Config {
|
|||
flush();
|
||||
}
|
||||
|
||||
public boolean isShowAddressTransactionCount() {
|
||||
return showAddressTransactionCount;
|
||||
}
|
||||
|
||||
public void setShowAddressTransactionCount(boolean showAddressTransactionCount) {
|
||||
this.showAddressTransactionCount = showAddressTransactionCount;
|
||||
flush();
|
||||
}
|
||||
|
||||
public boolean isPreventSleep() {
|
||||
return preventSleep;
|
||||
}
|
||||
|
|
|
@ -125,6 +125,12 @@ public class AddressesController extends WalletFormController implements Initial
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void showTransactionsCount(ShowTransactionsCountEvent event) {
|
||||
receiveTable.showTransactionsCount(event.isShowCount());
|
||||
changeTable.showTransactionsCount(event.isShowCount());
|
||||
}
|
||||
|
||||
public void exportReceiveAddresses(ActionEvent event) {
|
||||
exportAddresses(KeyPurpose.RECEIVE);
|
||||
}
|
||||
|
|
|
@ -58,6 +58,10 @@
|
|||
-fx-text-fill: derive(white, -15%);
|
||||
}
|
||||
|
||||
.number-cell {
|
||||
-fx-alignment: center-right;
|
||||
}
|
||||
|
||||
.label-cell .text-field {
|
||||
-fx-padding: 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue