mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
utxo multiple selection, long confirmation indicator
This commit is contained in:
parent
5860a6e49f
commit
3305d0630a
6 changed files with 39 additions and 17 deletions
|
@ -6,6 +6,7 @@ import javafx.scene.chart.Axis;
|
|||
import javafx.scene.chart.LineChart;
|
||||
import javafx.scene.chart.XYChart;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class FeeRatesChart extends LineChart<String, Number> {
|
||||
|
@ -24,8 +25,10 @@ public class FeeRatesChart extends LineChart<String, Number> {
|
|||
public void update(Map<Integer, Double> targetBlocksFeeRates) {
|
||||
feeRateSeries.getData().clear();
|
||||
|
||||
for(Integer targetBlocks : targetBlocksFeeRates.keySet()) {
|
||||
XYChart.Data<String, Number> data = new XYChart.Data<>(Integer.toString(targetBlocks), targetBlocksFeeRates.get(targetBlocks));
|
||||
for(Iterator<Integer> targetBlocksIter = targetBlocksFeeRates.keySet().iterator(); targetBlocksIter.hasNext(); ) {
|
||||
Integer targetBlocks = targetBlocksIter.next();
|
||||
String category = targetBlocks + (targetBlocksIter.hasNext() ? "" : "+");
|
||||
XYChart.Data<String, Number> data = new XYChart.Data<>(category, targetBlocksFeeRates.get(targetBlocks));
|
||||
feeRateSeries.getData().add(data);
|
||||
}
|
||||
|
||||
|
@ -44,7 +47,7 @@ public class FeeRatesChart extends LineChart<String, Number> {
|
|||
XYChart.Data<String, Number> data = feeRateSeries.getData().get(i);
|
||||
Node symbol = lookup(".chart-line-symbol.data" + i);
|
||||
if(symbol != null) {
|
||||
if(data.getXValue().equals(targetBlocks.toString())) {
|
||||
if(data.getXValue().replace("+", "").equals(targetBlocks.toString())) {
|
||||
symbol.getStyleClass().add("selected");
|
||||
selectedTargetBlocks = targetBlocks;
|
||||
}
|
||||
|
|
|
@ -320,7 +320,7 @@ public class TransactionDiagram extends GridPane {
|
|||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return additionalInputs.size() + " more";
|
||||
return additionalInputs.size() + " more...";
|
||||
}
|
||||
|
||||
public List<BlockTransactionHashIndex> getAdditionalInputs() {
|
||||
|
|
|
@ -10,13 +10,15 @@ import javafx.scene.chart.BarChart;
|
|||
import javafx.scene.chart.XYChart;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class UtxosChart extends BarChart<String, Number> {
|
||||
private static final int MAX_BARS = 8;
|
||||
private static final String OTHER_CATEGORY = "Other";
|
||||
|
||||
private Entry selectedEntry;
|
||||
private List<Entry> selectedEntries;
|
||||
private int totalUtxos;
|
||||
|
||||
private XYChart.Series<String, Number> utxoSeries;
|
||||
|
||||
|
@ -36,6 +38,7 @@ public class UtxosChart extends BarChart<String, Number> {
|
|||
.sorted((o1, o2) -> (int) (o2.getYValue().longValue() - o1.getYValue().longValue()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
totalUtxos = utxoDataList.size();
|
||||
if(utxoDataList.size() > MAX_BARS) {
|
||||
Long otherTotal = utxoDataList.subList(MAX_BARS - 1, utxoDataList.size()).stream().mapToLong(data -> data.getYValue().longValue()).sum();
|
||||
utxoDataList = utxoDataList.subList(0, MAX_BARS - 1);
|
||||
|
@ -58,14 +61,14 @@ public class UtxosChart extends BarChart<String, Number> {
|
|||
utxoSeries.getData().remove(utxoDataList.size() - 1, utxoSeries.getData().size());
|
||||
}
|
||||
|
||||
if(selectedEntry != null) {
|
||||
select(selectedEntry);
|
||||
if(selectedEntries != null) {
|
||||
select(selectedEntries);
|
||||
}
|
||||
}
|
||||
|
||||
public void select(Entry entry) {
|
||||
Node selectedBar = lookup(".chart-bar.selected");
|
||||
if(selectedBar != null) {
|
||||
public void select(List<Entry> entries) {
|
||||
Set<Node> selectedBars = lookupAll(".chart-bar.selected");
|
||||
for(Node selectedBar : selectedBars) {
|
||||
selectedBar.getStyleClass().remove("selected");
|
||||
}
|
||||
|
||||
|
@ -73,11 +76,14 @@ public class UtxosChart extends BarChart<String, Number> {
|
|||
XYChart.Data<String, Number> data = utxoSeries.getData().get(i);
|
||||
Node bar = lookup(".data" + i);
|
||||
if(bar != null) {
|
||||
if(data.getExtraValue() != null && data.getExtraValue().equals(entry)) {
|
||||
if(data.getExtraValue() != null && entries.contains((Entry)data.getExtraValue())) {
|
||||
bar.getStyleClass().add("selected");
|
||||
} else if(data.getExtraValue() == null && entries.size() == totalUtxos) {
|
||||
bar.getStyleClass().add("selected");
|
||||
this.selectedEntry = entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.selectedEntries = entries;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.sparrowwallet.drongo.wallet.WalletNode;
|
|||
import com.sparrowwallet.sparrow.wallet.*;
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.SelectionMode;
|
||||
import javafx.scene.control.TreeTableColumn;
|
||||
import javafx.scene.control.TreeTableView;
|
||||
|
||||
|
@ -72,6 +73,8 @@ public class UtxosTreeTable extends TreeTableView<Entry> {
|
|||
setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
|
||||
amountCol.setSortType(TreeTableColumn.SortType.DESCENDING);
|
||||
getSortOrder().add(amountCol);
|
||||
|
||||
getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||
}
|
||||
|
||||
public void updateAll(WalletUtxosEntry rootEntry) {
|
||||
|
|
|
@ -76,6 +76,8 @@ public class SendController extends WalletFormController implements Initializabl
|
|||
|
||||
private final BooleanProperty userFeeSet = new SimpleBooleanProperty(false);
|
||||
|
||||
private final ObjectProperty<UtxoSelector> utxoSelectorProperty = new SimpleObjectProperty<>(null);
|
||||
|
||||
private final ObjectProperty<WalletTransaction> walletTransactionProperty = new SimpleObjectProperty<>(null);
|
||||
|
||||
private final BooleanProperty insufficientInputsProperty = new SimpleBooleanProperty(false);
|
||||
|
@ -163,12 +165,13 @@ public class SendController extends WalletFormController implements Initializabl
|
|||
targetBlocks.setLabelFormatter(new StringConverter<Double>() {
|
||||
@Override
|
||||
public String toString(Double object) {
|
||||
return Integer.toString(TARGET_BLOCKS_RANGE.get(object.intValue()));
|
||||
String blocks = Integer.toString(TARGET_BLOCKS_RANGE.get(object.intValue()));
|
||||
return (object.intValue() == TARGET_BLOCKS_RANGE.size() - 1) ? blocks + "+" : blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double fromString(String string) {
|
||||
return (double)TARGET_BLOCKS_RANGE.indexOf(Integer.valueOf(string));
|
||||
return (double)TARGET_BLOCKS_RANGE.indexOf(Integer.valueOf(string.replace("+", "")));
|
||||
}
|
||||
});
|
||||
targetBlocks.valueProperty().addListener(targetBlocksListener);
|
||||
|
@ -365,6 +368,10 @@ public class SendController extends WalletFormController implements Initializabl
|
|||
return targetBlocks.lookup(".thumb");
|
||||
}
|
||||
|
||||
public void setUtxoSelector(UtxoSelector utxoSelector) {
|
||||
utxoSelectorProperty.set(utxoSelector);
|
||||
}
|
||||
|
||||
public void setMaxInput(ActionEvent event) {
|
||||
|
||||
}
|
||||
|
|
|
@ -7,11 +7,14 @@ import com.sparrowwallet.sparrow.control.UtxosTreeTable;
|
|||
import com.sparrowwallet.sparrow.event.WalletEntryLabelChangedEvent;
|
||||
import com.sparrowwallet.sparrow.event.WalletHistoryChangedEvent;
|
||||
import com.sparrowwallet.sparrow.event.WalletNodesChangedEvent;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class UtxosController extends WalletFormController implements Initializable {
|
||||
|
||||
|
@ -31,9 +34,9 @@ public class UtxosController extends WalletFormController implements Initializab
|
|||
utxosTable.initialize(getWalletForm().getWalletUtxosEntry());
|
||||
utxosChart.initialize(getWalletForm().getWalletUtxosEntry());
|
||||
|
||||
utxosTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||
Entry entry = newValue.getValue();
|
||||
utxosChart.select(entry);
|
||||
utxosTable.getSelectionModel().getSelectedIndices().addListener((ListChangeListener<Integer>) c -> {
|
||||
List<Entry> selectedEntries = utxosTable.getSelectionModel().getSelectedCells().stream().map(tp -> tp.getTreeItem().getValue()).collect(Collectors.toList());
|
||||
utxosChart.select(selectedEntries);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue