diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index fa5811c65d0..8a3e4e280dc 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2324,6 +2324,7 @@ dao.burningman.daoBalanceTotalBurned=Total amount of burned BSQ dao.burningman.daoBalanceTotalDistributed=Total amount of distributed BTC / BSQ dao.burningman.selectedContributor=Selected contributor dao.burningman.selectedContributorName=Contributor name +dao.burningman.selectedContributorTotalReceived=Total received dao.burningman.selectedContributorTotalRevenue=Total revenue dao.burningman.selectedContributorAddress=Receiver address dao.burningman.shared.table.height=Block height diff --git a/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BalanceEntryItem.java b/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BalanceEntryItem.java index 96640d7dbdf..50c16eba851 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BalanceEntryItem.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BalanceEntryItem.java @@ -68,7 +68,7 @@ class BalanceEntryItem { @Getter private final Optional burnedBsq; @Getter - private final Optional revenue; + private final long revenue; // We create the strings on demand and cache them. For large data sets it would be a bit slow otherwise. private String monthAsString, dateAsString, receivedBtcAsString, receivedBtcAsBsqAsString, burnedBsqAsString, revenueAsString, @@ -111,11 +111,7 @@ class BalanceEntryItem { receivedBtcAsBsq = Optional.of(MathUtils.roundDoubleToLong(MathUtils.scaleDownByPowerOf10(volume, 6))); } - if (balanceEntry instanceof MonthlyBalanceEntry) { - revenue = Optional.of(receivedBtcAsBsq.orElse(0L) + burnedBsq.get()); - } else { - revenue = Optional.empty(); - } + revenue = receivedBtcAsBsq.orElse(0L) + burnedBsq.orElse(0L); } String getMonthAsString() { @@ -168,7 +164,8 @@ String getRevenueAsString() { return revenueAsString; } - revenueAsString = revenue.filter(e -> e != 0).map(bsqFormatter::formatCoin).orElse(""); + revenueAsString = balanceEntry instanceof MonthlyBalanceEntry ? + bsqFormatter.formatCoin(revenue) : ""; return revenueAsString; } @@ -214,6 +211,6 @@ String getTypeAsString() { receivedBtc = null; receivedBtcAsBsq = null; burnedBsq = null; - revenue = null; + revenue = 0L; } } diff --git a/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BurningManView.java b/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BurningManView.java index d95003b8088..8504f6453b0 100644 --- a/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BurningManView.java +++ b/desktop/src/main/java/bisq/desktop/main/dao/burnbsq/burningman/BurningManView.java @@ -138,11 +138,12 @@ public class BurningManView extends ActivatableView implements private TitledGroupBg burnOutputsTitledGroupBg, compensationsTitledGroupBg, selectedContributorTitledGroupBg; private AutoTooltipSlideToggleButton showOnlyActiveBurningmenToggle, showMonthlyBalanceEntryToggle; private TextField expectedRevenueField, daoBalanceTotalBurnedField, daoBalanceTotalDistributedField, - selectedContributorNameField, selectedContributorTotalRevenueField, selectedContributorAddressField, - burnTargetField; + selectedContributorNameField, selectedContributorTotalRevenueField, selectedContributorTotalReceivedField, + selectedContributorAddressField, burnTargetField; private ToggleGroup balanceEntryToggleGroup; private HBox balanceEntryHBox; - private VBox selectedContributorNameBox, selectedContributorTotalRevenueBox, selectedContributorAddressBox; + private VBox selectedContributorNameBox, selectedContributorTotalReceivedBox, selectedContributorTotalRevenueBox, + selectedContributorAddressBox; private TableView burningManTableView; private TableView balanceEntryTableView; private TableView burnOutputsTableView; @@ -227,6 +228,8 @@ private BurningManView(DaoFacade daoFacade, selectedContributorTitledGroupBg.setVisible(isValueSet); selectedContributorNameBox.setManaged(isValueSet); selectedContributorNameBox.setVisible(isValueSet); + selectedContributorTotalReceivedBox.setManaged(isValueSet); + selectedContributorTotalReceivedBox.setVisible(isValueSet); selectedContributorTotalRevenueBox.setManaged(isValueSet); selectedContributorTotalRevenueBox.setVisible(isValueSet); selectedContributorAddressBox.setManaged(isValueSet); @@ -353,11 +356,13 @@ public BurningManListItem fromString(String string) { Res.get("dao.burningman.selectedContributor"), Layout.COMPACT_GROUP_DISTANCE); selectedContributorTitledGroupBg.setManaged(false); selectedContributorTitledGroupBg.setVisible(false); - Tuple3 nameTuple = addCompactTopLabelTextField(gridPane, ++gridRow, - Res.get("dao.burningman.selectedContributorName"), "", - Layout.COMPACT_GROUP_DISTANCE + Layout.FLOATING_LABEL_DISTANCE); - selectedContributorNameField = nameTuple.second; - selectedContributorNameBox = nameTuple.third; + + // left box + selectedContributorNameField = new BisqTextField(); + selectedContributorNameField.setEditable(false); + selectedContributorNameField.setFocusTraversable(false); + selectedContributorNameBox = getTopLabelWithVBox(Res.get("dao.burningman.selectedContributorName"), + selectedContributorNameField).second; selectedContributorNameBox.setManaged(false); selectedContributorNameBox.setVisible(false); @@ -369,6 +374,23 @@ public BurningManListItem fromString(String string) { selectedContributorTotalRevenueBox.setManaged(false); selectedContributorTotalRevenueBox.setVisible(false); + HBox leftHBox = new HBox(5, selectedContributorNameBox, selectedContributorTotalRevenueBox); + HBox.setHgrow(selectedContributorNameBox, Priority.ALWAYS); + HBox.setHgrow(selectedContributorTotalRevenueBox, Priority.ALWAYS); + + GridPane.setRowIndex(leftHBox, ++gridRow); + GridPane.setMargin(leftHBox, new Insets(Layout.COMPACT_GROUP_DISTANCE + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0)); + gridPane.getChildren().add(leftHBox); + + // right box + selectedContributorTotalReceivedField = new BisqTextField(); + selectedContributorTotalReceivedField.setEditable(false); + selectedContributorTotalReceivedField.setFocusTraversable(false); + selectedContributorTotalReceivedBox = getTopLabelWithVBox(Res.get("dao.burningman.selectedContributorTotalReceived"), + selectedContributorTotalReceivedField).second; + selectedContributorTotalReceivedBox.setManaged(false); + selectedContributorTotalReceivedBox.setVisible(false); + selectedContributorAddressField = new BisqTextField(); selectedContributorAddressField.setEditable(false); selectedContributorAddressField.setFocusTraversable(false); @@ -377,15 +399,14 @@ public BurningManListItem fromString(String string) { selectedContributorAddressBox.setManaged(false); selectedContributorAddressBox.setVisible(false); - HBox rightHBox = new HBox(5, selectedContributorTotalRevenueBox, selectedContributorAddressBox); - HBox.setHgrow(selectedContributorTotalRevenueBox, Priority.ALWAYS); + HBox rightHBox = new HBox(5, selectedContributorTotalReceivedBox, selectedContributorAddressBox); + HBox.setHgrow(selectedContributorTotalReceivedBox, Priority.ALWAYS); HBox.setHgrow(selectedContributorAddressBox, Priority.ALWAYS); GridPane.setRowIndex(rightHBox, gridRow); GridPane.setColumnIndex(rightHBox, 1); GridPane.setMargin(rightHBox, new Insets(Layout.COMPACT_GROUP_DISTANCE + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0)); gridPane.getChildren().add(rightHBox); - GridPane.setColumnSpan(rightHBox, 2); // BalanceEntry TitledGroupBg balanceEntryTitledGroupBg = new TitledGroupBg(); @@ -726,15 +747,20 @@ private void onBurningManSelected(BurningManListItem burningManListItem) { .map(balanceEntry -> new BalanceEntryItem(balanceEntry, averageBsqPriceByMonth, bsqFormatter, btcFormatter)) .collect(Collectors.toList())); - long totalRevenue = balanceEntryObservableList.stream() - .filter(item -> item.getRevenue().isPresent()) - .mapToLong(item -> item.getRevenue().get()) + long totalRevenueAsBsq = balanceEntryObservableList.stream() + .mapToLong(item -> item.getRevenue()) + .sum(); + selectedContributorTotalRevenueField.setText(bsqFormatter.formatCoinWithCode(totalRevenueAsBsq)); + + long totalReceivedAsBtc = balanceEntryObservableList.stream() + .filter(item -> item.getReceivedBtc().isPresent()) + .mapToLong(item -> item.getReceivedBtc().get()) .sum(); - String totalRevenueAsBsq = bsqFormatter.formatCoinWithCode(totalRevenue); - selectedContributorTotalRevenueField.setText(totalRevenueAsBsq); + selectedContributorTotalReceivedField.setText(btcFormatter.formatCoinWithCode(totalReceivedAsBtc)); } else { balanceEntryObservableList.clear(); selectedContributorTotalRevenueField.clear(); + selectedContributorTotalReceivedField.clear(); } GUIUtil.setFitToRowsForTableView(balanceEntryTableView, 36, 28, 4, 6); @@ -1321,7 +1347,7 @@ public void updateItem(final BalanceEntryItem item, boolean empty) { } }); balanceEntryTableView.getColumns().add(column); - column.setComparator(Comparator.comparing(e -> e.getRevenue().orElse(null))); + column.setComparator(Comparator.comparing(BalanceEntryItem::getRevenue)); column.setSortType(TableColumn.SortType.DESCENDING); column = new AutoTooltipTableColumn<>(Res.get("dao.burningman.table.balanceEntry.type"));