mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 14:42:37 +01:00
Return CompletableFuture once applyData is completed with all
calls.
This commit is contained in:
parent
a00667bbc2
commit
8a4d1cb6db
4 changed files with 190 additions and 120 deletions
|
@ -73,6 +73,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
@ -226,11 +227,8 @@ public abstract class ChartView<T extends ChartViewModel<? extends ChartDataMode
|
||||||
findTimeIntervalToggleByTemporalAdjuster(temporalAdjuster).ifPresent(timeIntervalToggleGroup::selectToggle);
|
findTimeIntervalToggleByTemporalAdjuster(temporalAdjuster).ifPresent(timeIntervalToggleGroup::selectToggle);
|
||||||
|
|
||||||
defineAndAddActiveSeries();
|
defineAndAddActiveSeries();
|
||||||
applyData(); //todo
|
|
||||||
initBoundsForTimelineNavigation();
|
initBoundsForTimelineNavigation();
|
||||||
|
|
||||||
updateChartAfterDataChange(); //todo
|
|
||||||
|
|
||||||
// Apply listeners and handlers
|
// Apply listeners and handlers
|
||||||
root.widthProperty().addListener(widthListener);
|
root.widthProperty().addListener(widthListener);
|
||||||
xAxis.getChildrenUnmodifiable().addListener(nodeListChangeListener);
|
xAxis.getChildrenUnmodifiable().addListener(nodeListChangeListener);
|
||||||
|
@ -554,7 +552,7 @@ public abstract class ChartView<T extends ChartViewModel<? extends ChartDataMode
|
||||||
chart.getData().add(series);
|
chart.getData().add(series);
|
||||||
activeSeries.add(series);
|
activeSeries.add(series);
|
||||||
legendToggleBySeriesName.get(getSeriesId(series)).setSelected(true);
|
legendToggleBySeriesName.get(getSeriesId(series)).setSelected(true);
|
||||||
updateChartAfterDataChange();
|
applyDataAndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -562,7 +560,17 @@ public abstract class ChartView<T extends ChartViewModel<? extends ChartDataMode
|
||||||
// Data
|
// Data
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
protected abstract void applyData();
|
protected abstract CompletableFuture<Boolean> applyData();
|
||||||
|
|
||||||
|
private void applyDataAndUpdate() {
|
||||||
|
long ts = System.currentTimeMillis();
|
||||||
|
applyData().whenComplete((r, t) -> {
|
||||||
|
log.debug("applyData took {}", System.currentTimeMillis() - ts);
|
||||||
|
long ts2 = System.currentTimeMillis();
|
||||||
|
updateChartAfterDataChange();
|
||||||
|
log.debug("updateChartAfterDataChange took {}", System.currentTimeMillis() - ts2);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementations define which series will be used for setBoundsForTimelineNavigation
|
* Implementations define which series will be used for setBoundsForTimelineNavigation
|
||||||
|
@ -588,16 +596,14 @@ public abstract class ChartView<T extends ChartViewModel<? extends ChartDataMode
|
||||||
TemporalAdjusterModel.Interval interval = (TemporalAdjusterModel.Interval) newValue.getUserData();
|
TemporalAdjusterModel.Interval interval = (TemporalAdjusterModel.Interval) newValue.getUserData();
|
||||||
applyTemporalAdjuster(interval.getAdjuster());
|
applyTemporalAdjuster(interval.getAdjuster());
|
||||||
model.invalidateCache();
|
model.invalidateCache();
|
||||||
applyData();
|
applyDataAndUpdate();
|
||||||
updateChartAfterDataChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTimelineChanged() {
|
private void onTimelineChanged() {
|
||||||
updateTimeLinePositions();
|
updateTimeLinePositions();
|
||||||
|
|
||||||
model.invalidateCache();
|
model.invalidateCache();
|
||||||
applyData();
|
applyDataAndUpdate();//3
|
||||||
updateChartAfterDataChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTimeLinePositions() {
|
private void updateTimeLinePositions() {
|
||||||
|
@ -635,8 +641,7 @@ public abstract class ChartView<T extends ChartViewModel<? extends ChartDataMode
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
chart.getData().add(series);
|
chart.getData().add(series);
|
||||||
activeSeries.add(series);
|
activeSeries.add(series);
|
||||||
//model.invalidateCache();
|
applyDataAndUpdate();
|
||||||
applyData();
|
|
||||||
|
|
||||||
if (isRadioButtonBehaviour) {
|
if (isRadioButtonBehaviour) {
|
||||||
// We support different y-axis formats only if isRadioButtonBehaviour is set, otherwise we would get
|
// We support different y-axis formats only if isRadioButtonBehaviour is set, otherwise we would get
|
||||||
|
@ -646,9 +651,8 @@ public abstract class ChartView<T extends ChartViewModel<? extends ChartDataMode
|
||||||
} else if (!isRadioButtonBehaviour) { // if isRadioButtonBehaviour we have removed it already via the code above
|
} else if (!isRadioButtonBehaviour) { // if isRadioButtonBehaviour we have removed it already via the code above
|
||||||
chart.getData().remove(series);
|
chart.getData().remove(series);
|
||||||
activeSeries.remove(series);
|
activeSeries.remove(series);
|
||||||
|
updateChartAfterDataChange();
|
||||||
}
|
}
|
||||||
updateChartAfterDataChange();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -785,7 +789,7 @@ public abstract class ChartView<T extends ChartViewModel<? extends ChartDataMode
|
||||||
dataApplied = true;
|
dataApplied = true;
|
||||||
UserThread.execute(() -> {
|
UserThread.execute(() -> {
|
||||||
applyTimeLineNavigationLabels();
|
applyTimeLineNavigationLabels();
|
||||||
onTimelineChanged();
|
updateTimeLinePositions();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ import bisq.desktop.components.chart.ChartView;
|
||||||
|
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
|
|
||||||
|
import bisq.common.util.CompletableFutureUtils;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import javafx.scene.chart.XYChart;
|
import javafx.scene.chart.XYChart;
|
||||||
|
@ -29,8 +31,12 @@ import javafx.beans.property.DoubleProperty;
|
||||||
import javafx.beans.property.ReadOnlyDoubleProperty;
|
import javafx.beans.property.ReadOnlyDoubleProperty;
|
||||||
import javafx.beans.property.SimpleDoubleProperty;
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
|
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@ -121,64 +127,80 @@ public class PriceChartView extends ChartView<PriceChartViewModel> {
|
||||||
onSetYAxisFormatter(seriesBsqUsdPrice);
|
onSetYAxisFormatter(seriesBsqUsdPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void activateSeries(XYChart.Series<Number, Number> series) {
|
|
||||||
super.activateSeries(series);
|
|
||||||
String seriesId = getSeriesId(series);
|
|
||||||
if (seriesId.equals(getSeriesId(seriesBsqUsdPrice))) {
|
|
||||||
applyBsqUsdPriceChartDataAsync();
|
|
||||||
} else if (seriesId.equals(getSeriesId(seriesBsqBtcPrice))) {
|
|
||||||
applyBsqBtcPriceChartData();
|
|
||||||
} else if (seriesId.equals(getSeriesId(seriesBtcUsdPrice))) {
|
|
||||||
applyBtcUsdPriceChartData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Data
|
// Data
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyData() {
|
protected CompletableFuture<Boolean> applyData() {
|
||||||
|
List<CompletableFuture<Boolean>> allFutures = new ArrayList<>();
|
||||||
|
|
||||||
if (activeSeries.contains(seriesBsqUsdPrice)) {
|
if (activeSeries.contains(seriesBsqUsdPrice)) {
|
||||||
applyBsqUsdPriceChartDataAsync();
|
CompletableFuture<Boolean> task1Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task1Done);
|
||||||
|
applyBsqUsdPriceChartDataAsync(task1Done);
|
||||||
}
|
}
|
||||||
if (activeSeries.contains(seriesBsqBtcPrice)) {
|
if (activeSeries.contains(seriesBsqBtcPrice)) {
|
||||||
applyBsqBtcPriceChartData();
|
CompletableFuture<Boolean> task2Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task2Done);
|
||||||
|
applyBsqBtcPriceChartData(task2Done);
|
||||||
}
|
}
|
||||||
if (activeSeries.contains(seriesBtcUsdPrice)) {
|
if (activeSeries.contains(seriesBtcUsdPrice)) {
|
||||||
applyBtcUsdPriceChartData();
|
CompletableFuture<Boolean> task3Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task3Done);
|
||||||
|
applyBtcUsdPriceChartData(task3Done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompletableFuture<Boolean> task4Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task4Done);
|
||||||
model.averageBsqBtcPrice()
|
model.averageBsqBtcPrice()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
averageBsqBtcPriceProperty.set(data)));
|
averageBsqBtcPriceProperty.set(data);
|
||||||
|
task4Done.complete(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
CompletableFuture<Boolean> task5Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task5Done);
|
||||||
model.averageBsqUsdPrice()
|
model.averageBsqUsdPrice()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
averageBsqUsdPriceProperty.set(data)));
|
averageBsqUsdPriceProperty.set(data);
|
||||||
|
task5Done.complete(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
return CompletableFutureUtils.allOf(allFutures).thenApply(e -> {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyBsqUsdPriceChartDataAsync() {
|
private void applyBsqUsdPriceChartDataAsync(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getBsqUsdPriceChartData()
|
model.getBsqUsdPriceChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesBsqUsdPrice.getData().setAll(data)));
|
ObservableList<XYChart.Data<Number, Number>> data1 = seriesBsqUsdPrice.getData();
|
||||||
|
data1.setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyBtcUsdPriceChartData() {
|
private void applyBtcUsdPriceChartData(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getBtcUsdPriceChartData()
|
model.getBtcUsdPriceChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesBtcUsdPrice.getData().setAll(data)));
|
seriesBtcUsdPrice.getData().setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyBsqBtcPriceChartData() {
|
private void applyBsqBtcPriceChartData(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getBsqBtcPriceChartData()
|
model.getBsqBtcPriceChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesBsqBtcPrice.getData().setAll(data)));
|
seriesBsqBtcPrice.getData().setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ import bisq.desktop.components.chart.ChartView;
|
||||||
|
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
|
|
||||||
|
import bisq.common.util.CompletableFutureUtils;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import javafx.scene.chart.XYChart;
|
import javafx.scene.chart.XYChart;
|
||||||
|
@ -29,8 +31,10 @@ import javafx.beans.property.LongProperty;
|
||||||
import javafx.beans.property.ReadOnlyLongProperty;
|
import javafx.beans.property.ReadOnlyLongProperty;
|
||||||
import javafx.beans.property.SimpleLongProperty;
|
import javafx.beans.property.SimpleLongProperty;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@ -117,52 +121,61 @@ public class VolumeChartView extends ChartView<VolumeChartViewModel> {
|
||||||
onSetYAxisFormatter(seriesUsdVolume);
|
onSetYAxisFormatter(seriesUsdVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void activateSeries(XYChart.Series<Number, Number> series) {
|
|
||||||
super.activateSeries(series);
|
|
||||||
|
|
||||||
if (getSeriesId(series).equals(getSeriesId(seriesUsdVolume))) {
|
|
||||||
applyUsdVolumeChartData();
|
|
||||||
} else if (getSeriesId(series).equals(getSeriesId(seriesBtcVolume))) {
|
|
||||||
applyBtcVolumeChartData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Data
|
// Data
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyData() {
|
protected CompletableFuture<Boolean> applyData() {
|
||||||
|
List<CompletableFuture<Boolean>> allFutures = new ArrayList<>();
|
||||||
if (activeSeries.contains(seriesUsdVolume)) {
|
if (activeSeries.contains(seriesUsdVolume)) {
|
||||||
applyUsdVolumeChartData();
|
CompletableFuture<Boolean> task1Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task1Done);
|
||||||
|
applyUsdVolumeChartData(task1Done);
|
||||||
}
|
}
|
||||||
if (activeSeries.contains(seriesBtcVolume)) {
|
if (activeSeries.contains(seriesBtcVolume)) {
|
||||||
applyBtcVolumeChartData();
|
CompletableFuture<Boolean> task2Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task2Done);
|
||||||
|
applyBtcVolumeChartData(task2Done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompletableFuture<Boolean> task3Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task3Done);
|
||||||
model.getUsdVolume()
|
model.getUsdVolume()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
usdVolumeProperty.set(data)));
|
usdVolumeProperty.set(data);
|
||||||
|
task3Done.complete(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
CompletableFuture<Boolean> task4Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task4Done);
|
||||||
model.getBtcVolume()
|
model.getBtcVolume()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
btcVolumeProperty.set(data)));
|
btcVolumeProperty.set(data);
|
||||||
|
task4Done.complete(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
return CompletableFutureUtils.allOf(allFutures).thenApply(e -> true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyBtcVolumeChartData() {
|
private void applyBtcVolumeChartData(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getBtcVolumeChartData()
|
model.getBtcVolumeChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesBtcVolume.getData().setAll(data)));
|
seriesBtcVolume.getData().setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyUsdVolumeChartData() {
|
private void applyUsdVolumeChartData(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getUsdVolumeChartData()
|
model.getUsdVolumeChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesUsdVolume.getData().setAll(data)));
|
seriesUsdVolume.getData().setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ import bisq.desktop.components.chart.ChartView;
|
||||||
|
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
|
|
||||||
|
import bisq.common.util.CompletableFutureUtils;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import javafx.scene.chart.XYChart;
|
import javafx.scene.chart.XYChart;
|
||||||
|
@ -29,8 +31,10 @@ import javafx.beans.property.LongProperty;
|
||||||
import javafx.beans.property.ReadOnlyLongProperty;
|
import javafx.beans.property.ReadOnlyLongProperty;
|
||||||
import javafx.beans.property.SimpleLongProperty;
|
import javafx.beans.property.SimpleLongProperty;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@ -134,108 +138,135 @@ public class DaoChartView extends ChartView<DaoChartViewModel> {
|
||||||
activateSeries(seriesTotalBurned);
|
activateSeries(seriesTotalBurned);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void activateSeries(XYChart.Series<Number, Number> series) {
|
|
||||||
super.activateSeries(series);
|
|
||||||
|
|
||||||
if (getSeriesId(series).equals(getSeriesId(seriesTotalIssued))) {
|
|
||||||
applyTotalIssued();
|
|
||||||
} else if (getSeriesId(series).equals(getSeriesId(seriesCompensation))) {
|
|
||||||
applyCompensation();
|
|
||||||
} else if (getSeriesId(series).equals(getSeriesId(seriesReimbursement))) {
|
|
||||||
applyReimbursement();
|
|
||||||
} else if (getSeriesId(series).equals(getSeriesId(seriesTotalBurned))) {
|
|
||||||
applyTotalBurned();
|
|
||||||
} else if (getSeriesId(series).equals(getSeriesId(seriesBsqTradeFee))) {
|
|
||||||
applyBsqTradeFee();
|
|
||||||
} else if (getSeriesId(series).equals(getSeriesId(seriesProofOfBurn))) {
|
|
||||||
applyProofOfBurn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Data
|
// Data
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyData() {
|
protected CompletableFuture<Boolean> applyData() {
|
||||||
|
List<CompletableFuture<Boolean>> allFutures = new ArrayList<>();
|
||||||
if (activeSeries.contains(seriesTotalIssued)) {
|
if (activeSeries.contains(seriesTotalIssued)) {
|
||||||
applyTotalIssued();
|
CompletableFuture<Boolean> task1Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task1Done);
|
||||||
|
applyTotalIssued(task1Done);
|
||||||
}
|
}
|
||||||
if (activeSeries.contains(seriesCompensation)) {
|
if (activeSeries.contains(seriesCompensation)) {
|
||||||
applyCompensation();
|
CompletableFuture<Boolean> task2Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task2Done);
|
||||||
|
applyCompensation(task2Done);
|
||||||
}
|
}
|
||||||
if (activeSeries.contains(seriesReimbursement)) {
|
if (activeSeries.contains(seriesReimbursement)) {
|
||||||
applyReimbursement();
|
CompletableFuture<Boolean> task3Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task3Done);
|
||||||
|
applyReimbursement(task3Done);
|
||||||
}
|
}
|
||||||
if (activeSeries.contains(seriesTotalBurned)) {
|
if (activeSeries.contains(seriesTotalBurned)) {
|
||||||
applyTotalBurned();
|
CompletableFuture<Boolean> task4Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task4Done);
|
||||||
|
applyTotalBurned(task4Done);
|
||||||
}
|
}
|
||||||
if (activeSeries.contains(seriesBsqTradeFee)) {
|
if (activeSeries.contains(seriesBsqTradeFee)) {
|
||||||
applyBsqTradeFee();
|
CompletableFuture<Boolean> task5Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task5Done);
|
||||||
|
applyBsqTradeFee(task5Done);
|
||||||
}
|
}
|
||||||
if (activeSeries.contains(seriesProofOfBurn)) {
|
if (activeSeries.contains(seriesProofOfBurn)) {
|
||||||
applyProofOfBurn();
|
CompletableFuture<Boolean> task6Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task6Done);
|
||||||
|
applyProofOfBurn(task6Done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompletableFuture<Boolean> task7Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task7Done);
|
||||||
model.getCompensationAmount()
|
model.getCompensationAmount()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
compensationAmountProperty.set(data)));
|
compensationAmountProperty.set(data);
|
||||||
|
task7Done.complete(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
CompletableFuture<Boolean> task8Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task8Done);
|
||||||
model.getReimbursementAmount()
|
model.getReimbursementAmount()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
reimbursementAmountProperty.set(data)));
|
reimbursementAmountProperty.set(data);
|
||||||
|
task8Done.complete(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
CompletableFuture<Boolean> task9Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task9Done);
|
||||||
model.getBsqTradeFeeAmount()
|
model.getBsqTradeFeeAmount()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
bsqTradeFeeAmountProperty.set(data)));
|
bsqTradeFeeAmountProperty.set(data);
|
||||||
|
task9Done.complete(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
CompletableFuture<Boolean> task10Done = new CompletableFuture<>();
|
||||||
|
allFutures.add(task10Done);
|
||||||
model.getProofOfBurnAmount()
|
model.getProofOfBurnAmount()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
proofOfBurnAmountProperty.set(data)));
|
proofOfBurnAmountProperty.set(data);
|
||||||
|
task10Done.complete(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
return CompletableFutureUtils.allOf(allFutures).thenApply(e -> true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyTotalIssued() {
|
private void applyTotalIssued(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getTotalIssuedChartData()
|
model.getTotalIssuedChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesTotalIssued.getData().setAll(data)));
|
seriesTotalIssued.getData().setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyCompensation() {
|
private void applyCompensation(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getCompensationChartData()
|
model.getCompensationChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesCompensation.getData().setAll(data)));
|
seriesCompensation.getData().setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyReimbursement() {
|
private void applyReimbursement(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getReimbursementChartData()
|
model.getReimbursementChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesReimbursement.getData().setAll(data)));
|
seriesReimbursement.getData().setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyTotalBurned() {
|
private void applyTotalBurned(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getTotalBurnedChartData()
|
model.getTotalBurnedChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesTotalBurned.getData().setAll(data)));
|
seriesTotalBurned.getData().setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyBsqTradeFee() {
|
private void applyBsqTradeFee(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getBsqTradeFeeChartData()
|
model.getBsqTradeFeeChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesBsqTradeFee.getData().setAll(data)));
|
seriesBsqTradeFee.getData().setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyProofOfBurn() {
|
private void applyProofOfBurn(CompletableFuture<Boolean> completeFuture) {
|
||||||
model.getProofOfBurnChartData()
|
model.getProofOfBurnChartData()
|
||||||
.whenComplete((data, t) ->
|
.whenComplete((data, t) ->
|
||||||
mapToUserThread(() ->
|
mapToUserThread(() -> {
|
||||||
seriesProofOfBurn.getData().setAll(data)));
|
seriesProofOfBurn.getData().setAll(data);
|
||||||
|
completeFuture.complete(true);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue