mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Merge branch 'show-past-comps' of https://github.com/sqrrm/exchange into sqrrm-show-past-comps
This commit is contained in:
commit
b706edd15a
@ -1014,9 +1014,9 @@ dao.phase.short.BREAK2=
|
||||
dao.phase.short.VOTE_CONFIRMATION=Result
|
||||
dao.phase.short.BREAK3=
|
||||
|
||||
dao.compensation.selectedRequest=Selected compensation request
|
||||
|
||||
dao.compensation.active.header=Active compensation request
|
||||
dao.compensation.active.selectedRequest=Selected compensation request
|
||||
dao.compensation.active.notOpenAnymore=This compensation request is not open anymore for funding. Please wait until the next funding period starts.
|
||||
dao.compensation.active.remove=Remove compensation request
|
||||
dao.compensation.active.remove.failed=Could not remove compensation request.
|
||||
@ -1024,6 +1024,8 @@ dao.compensation.active.vote=Vote on compensation request
|
||||
dao.compensation.active.fund=Fund compensation request
|
||||
dao.compensation.active.successfullyFunded=Compensation request successfully funded.
|
||||
|
||||
dao.compensation.past.header=Past compensation request
|
||||
|
||||
dao.compensation.create.createNew=Create new compensation request
|
||||
dao.compensation.create.create.button=Create compensation request
|
||||
dao.compensation.create.confirm=Confirm compensation request
|
||||
|
@ -876,7 +876,7 @@ dao.compensation.menuItem.activeRequests=Aktive Anfragen
|
||||
dao.compensation.menuItem.pastRequests=Erledigte Anfragen
|
||||
|
||||
dao.compensation.active.header=Aktive Entschädigungsanfrage
|
||||
dao.compensation.active.selectedRequest=Ausgewählte Entschädigungsanfrage
|
||||
dao.compensation.selectedRequest=Ausgewählte Entschädigungsanfrage
|
||||
dao.compensation.active.notOpenAnymore=Diese Entschädigung ist nicht zur Finanzierung verfügbar. Bitte warten Sie bis die nächste Finanzierungsperiode beginnt.
|
||||
dao.compensation.active.vote=Für Entschädigung stimmen
|
||||
dao.compensation.active.fund=Entschädigungsanfrage finanzieren
|
||||
|
@ -849,7 +849,7 @@ dao.compensation.menuItem.activeRequests=Ενεργά αιτήματα
|
||||
dao.compensation.menuItem.pastRequests=Προηγούμενα αιτήματα
|
||||
|
||||
dao.compensation.active.header=Ενεργό αίτημα αποζημίωσης
|
||||
dao.compensation.active.selectedRequest=Επιλεγμένο αίτημα αποζημίωσης
|
||||
dao.compensation.selectedRequest=Επιλεγμένο αίτημα αποζημίωσης
|
||||
dao.compensation.active.notOpenAnymore=Το αίτημα αποζημίωσης δεν είναι πλέον ανοιχτό προς χρηματοδότηση. Περίμενε μέχρι την έναρξη της επόμενης περιόδου χρηματοδότησης.
|
||||
dao.compensation.active.vote=Ψήφισμα περί αιτήματος αποζημίωσης
|
||||
dao.compensation.active.fund=Χρηματοδότηση αιτήματος αποζημίωσης
|
||||
|
@ -849,7 +849,7 @@ dao.compensation.menuItem.activeRequests=Activar solicitudes
|
||||
dao.compensation.menuItem.pastRequests=Solicitudes pasadas
|
||||
|
||||
dao.compensation.active.header=Activar solicitud de compensación
|
||||
dao.compensation.active.selectedRequest=Solicitud de compensación seleccionada
|
||||
dao.compensation.selectedRequest=Solicitud de compensación seleccionada
|
||||
dao.compensation.active.notOpenAnymore=Esta solicitud de compensación ya no está abierta para añadir fondos. Por favor, espere a que comience el siguiente periodo de financiación.
|
||||
dao.compensation.active.vote=Votar solicitud de compensación
|
||||
dao.compensation.active.fund=Financiar solicitud de compensación
|
||||
|
@ -915,7 +915,7 @@ dao.phase.short.BREAK3=
|
||||
|
||||
|
||||
dao.compensation.active.header=Aktív kártérítési kérelmek
|
||||
dao.compensation.active.selectedRequest=Kiválasztott kártérítési kérelmek
|
||||
dao.compensation.selectedRequest=Kiválasztott kártérítési kérelmek
|
||||
dao.compensation.active.notOpenAnymore=Ez a Kártérítési kérelem többé nem nyílt finanszírozáshoz. Kérjük várjon, amíg megkezdődik a következő finanszírozási időszak.
|
||||
dao.compensation.active.remove=Töröld a kártérítési kérelmet
|
||||
dao.compensation.active.remove.failed=A kártérítési kérelmet nem sikerült eltávolítani.
|
||||
|
@ -849,7 +849,7 @@ dao.compensation.menuItem.activeRequests=Solicitações ativas
|
||||
dao.compensation.menuItem.pastRequests=Solicitações anteriores
|
||||
|
||||
dao.compensation.active.header=Pedido de compensação ativo
|
||||
dao.compensation.active.selectedRequest=Pedido de compensação selecionado
|
||||
dao.compensation.selectedRequest=Pedido de compensação selecionado
|
||||
dao.compensation.active.notOpenAnymore=Este pedido de compensação não está mais aberto para financiamento. Favor aguardar até o próximo período de financiamento iniciar.
|
||||
dao.compensation.active.vote=Votar em pedido de compensação
|
||||
dao.compensation.active.fund=Financiar pedido de compensação
|
||||
|
@ -915,7 +915,7 @@ dao.phase.short.BREAK3=
|
||||
|
||||
|
||||
dao.compensation.active.header=Solicitare de despăgubire activă
|
||||
dao.compensation.active.selectedRequest=Solicitare de despăgubire selectată
|
||||
dao.compensation.selectedRequest=Solicitare de despăgubire selectată
|
||||
dao.compensation.active.notOpenAnymore=Această solicitare de despăgubire nu mai este deschisă spre finanțare. Așteaptă până începe următoarea perioadă de finanțare.
|
||||
dao.compensation.active.remove=Înlătură solicitarea de despăgubire
|
||||
dao.compensation.active.remove.failed=Solicitarea de despăgubire nu a putut fi înlăturată.
|
||||
|
@ -849,7 +849,7 @@ dao.compensation.menuItem.activeRequests=Текущие запросы
|
||||
dao.compensation.menuItem.pastRequests=Прошлые запросы
|
||||
|
||||
dao.compensation.active.header=Запрос активной компенсации
|
||||
dao.compensation.active.selectedRequest=Запрос выбранной компенсации
|
||||
dao.compensation.selectedRequest=Запрос выбранной компенсации
|
||||
dao.compensation.active.notOpenAnymore=Этот запрос компенсации более не открыт для оплаты. Пожалуйста подождите до начала следующего периода оплаты.
|
||||
dao.compensation.active.vote=Голосование по запросу компенсации
|
||||
dao.compensation.active.fund=Найти запрос компенсации
|
||||
|
@ -849,7 +849,7 @@ dao.compensation.menuItem.activeRequests=Aktivni zahtevi
|
||||
dao.compensation.menuItem.pastRequests=Raniji zahtevi
|
||||
|
||||
dao.compensation.active.header=Aktivni zahtevi za nadoknadu
|
||||
dao.compensation.active.selectedRequest=Izabrani zahtevi za nadoknadu
|
||||
dao.compensation.selectedRequest=Izabrani zahtevi za nadoknadu
|
||||
dao.compensation.active.notOpenAnymore=Ovaj zahtev za nadoknadu nije više otvoren za finansiranje. Molimo sačekajte do početka sledećeg perioda finansiranja.
|
||||
dao.compensation.active.vote=Glasaj na zahtev za nadoknadu
|
||||
dao.compensation.active.fund=Finansiraj zahtev za nadoknadu
|
||||
|
@ -849,7 +849,7 @@ dao.compensation.menuItem.activeRequests=活动要求
|
||||
dao.compensation.menuItem.pastRequests=过期要求
|
||||
|
||||
dao.compensation.active.header=活动赔偿要求
|
||||
dao.compensation.active.selectedRequest=选定赔偿要求
|
||||
dao.compensation.selectedRequest=选定赔偿要求
|
||||
dao.compensation.active.notOpenAnymore=这笔补偿申请不再对资金开放。 请等到下一个资助期开始。
|
||||
dao.compensation.active.vote=在赔偿要求上投票
|
||||
dao.compensation.active.fund=为赔偿要求充值
|
||||
|
@ -42,6 +42,7 @@ public class AppSetupWithP2P extends AppSetup {
|
||||
protected final FilterManager filterManager;
|
||||
protected BooleanProperty p2pNetWorkReady;
|
||||
protected final TradeStatisticsManager tradeStatisticsManager;
|
||||
protected ArrayList<PersistedDataHost> persistedDataHosts;
|
||||
|
||||
@Inject
|
||||
public AppSetupWithP2P(EncryptionService encryptionService,
|
||||
@ -50,16 +51,16 @@ public class AppSetupWithP2P extends AppSetup {
|
||||
TradeStatisticsManager tradeStatisticsManager,
|
||||
AccountAgeWitnessService accountAgeWitnessService,
|
||||
FilterManager filterManager) {
|
||||
super(encryptionService,keyRing);
|
||||
super(encryptionService, keyRing);
|
||||
this.p2PService = p2PService;
|
||||
this.tradeStatisticsManager = tradeStatisticsManager;
|
||||
this.accountAgeWitnessService = accountAgeWitnessService;
|
||||
this.filterManager = filterManager;
|
||||
this.persistedDataHosts = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPersistedDataHosts() {
|
||||
ArrayList<PersistedDataHost> persistedDataHosts = new ArrayList<>();
|
||||
persistedDataHosts.add(p2PService);
|
||||
|
||||
// we apply at startup the reading of persisted data but don't want to get it triggered in the constructor
|
||||
|
@ -18,6 +18,7 @@
|
||||
package io.bisq.core.app;
|
||||
|
||||
import io.bisq.common.crypto.KeyRing;
|
||||
import io.bisq.common.proto.persistable.PersistedDataHost;
|
||||
import io.bisq.core.dao.DaoManager;
|
||||
import io.bisq.core.filter.FilterManager;
|
||||
import io.bisq.core.payment.AccountAgeWitnessService;
|
||||
@ -47,6 +48,7 @@ public class AppSetupWithP2PAndDAO extends AppSetupWithP2P {
|
||||
accountAgeWitnessService,
|
||||
filterManager);
|
||||
this.daoManager = daoManager;
|
||||
this.persistedDataHosts.add(daoManager.getCompensationRequestManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,6 +24,7 @@ import io.bisq.core.dao.blockchain.BsqNode;
|
||||
import io.bisq.core.dao.blockchain.BsqNodeProvider;
|
||||
import io.bisq.core.dao.compensation.CompensationRequestManager;
|
||||
import io.bisq.core.dao.vote.VotingManager;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* High level entry point for Dao domain
|
||||
@ -31,6 +32,7 @@ import io.bisq.core.dao.vote.VotingManager;
|
||||
public class DaoManager {
|
||||
private final DaoPeriodService daoPeriodService;
|
||||
private final VotingManager voteManager;
|
||||
@Getter
|
||||
private final CompensationRequestManager compensationRequestManager;
|
||||
private final BsqNode bsqNode;
|
||||
|
||||
|
@ -22,16 +22,19 @@ import io.bisq.core.btc.wallet.BsqWalletService;
|
||||
import io.bisq.core.dao.compensation.CompensationRequestPayload;
|
||||
import io.bisq.core.dao.compensation.Restrictions;
|
||||
import io.bisq.core.provider.fee.FeeService;
|
||||
import io.bisq.gui.components.HyperlinkWithIcon;
|
||||
import io.bisq.gui.components.InputTextField;
|
||||
import io.bisq.gui.components.TxIdTextField;
|
||||
import io.bisq.gui.components.*;
|
||||
import io.bisq.gui.util.BsqFormatter;
|
||||
import io.bisq.gui.util.GUIUtil;
|
||||
import io.bisq.gui.util.Layout;
|
||||
import io.bisq.gui.util.validation.BsqAddressValidator;
|
||||
import io.bisq.gui.util.validation.BsqValidator;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.util.Callback;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
@ -150,4 +153,177 @@ public class CompensationRequestDisplay {
|
||||
public int incrementAndGetGridRow() {
|
||||
return ++gridRow;
|
||||
}
|
||||
|
||||
public GridPane createCompensationList(TableView<CompensationRequestListItem> tableView, String headerString) {
|
||||
GridPane compensationList = new GridPane();
|
||||
|
||||
TableGroupHeadline header = new TableGroupHeadline(headerString);
|
||||
GridPane.setMargin(header, new Insets(10, 0, 0, 0));
|
||||
GridPane.setRowIndex(header, 0);
|
||||
compensationList.getChildren().add(header);
|
||||
header.setMinHeight(20);
|
||||
header.setMaxHeight(20);
|
||||
|
||||
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
|
||||
tableView.setMinHeight(90);
|
||||
GridPane.setRowIndex(tableView, 1);
|
||||
GridPane.setColumnSpan(tableView, 1);
|
||||
GridPane.setMargin(tableView, new Insets(5, 10, -10, 10));
|
||||
GridPane.setVgrow(tableView, Priority.ALWAYS);
|
||||
GridPane.setHgrow(tableView, Priority.ALWAYS);
|
||||
compensationList.getChildren().add(tableView);
|
||||
|
||||
createColumns(tableView);
|
||||
|
||||
return compensationList;
|
||||
}
|
||||
|
||||
public ScrollPane createCompensationRequestDisplay() {
|
||||
ScrollPane scrollPane = new ScrollPane();
|
||||
scrollPane.setFitToWidth(true);
|
||||
scrollPane.setFitToHeight(true);
|
||||
scrollPane.setMinHeight(100);
|
||||
|
||||
AnchorPane bottomAnchorPane = new AnchorPane();
|
||||
scrollPane.setContent(bottomAnchorPane);
|
||||
|
||||
gridPane.setHgap(5);
|
||||
gridPane.setVgap(5);
|
||||
ColumnConstraints columnConstraints1 = new ColumnConstraints();
|
||||
columnConstraints1.setHalignment(HPos.RIGHT);
|
||||
columnConstraints1.setHgrow(Priority.SOMETIMES);
|
||||
columnConstraints1.setMinWidth(140);
|
||||
ColumnConstraints columnConstraints2 = new ColumnConstraints();
|
||||
columnConstraints2.setHgrow(Priority.ALWAYS);
|
||||
columnConstraints2.setMinWidth(300);
|
||||
|
||||
gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
|
||||
AnchorPane.setBottomAnchor(gridPane, 20d);
|
||||
AnchorPane.setRightAnchor(gridPane, 10d);
|
||||
AnchorPane.setLeftAnchor(gridPane, 10d);
|
||||
AnchorPane.setTopAnchor(gridPane, -20d);
|
||||
bottomAnchorPane.getChildren().add(gridPane);
|
||||
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
public SplitPane createCompensationRequestPane(TableView<CompensationRequestListItem> tableView, String headerString) {
|
||||
SplitPane compensationRequestPane = new SplitPane();
|
||||
compensationRequestPane.setOrientation(Orientation.VERTICAL);
|
||||
compensationRequestPane.setDividerPositions(0.2, 0.7);
|
||||
compensationRequestPane.setStyle("-fx-padding: 0; -fx-box-border: transparent;");
|
||||
|
||||
compensationRequestPane.getItems().add(createCompensationList(tableView, headerString));
|
||||
compensationRequestPane.getItems().add(createCompensationRequestDisplay());
|
||||
return compensationRequestPane;
|
||||
}
|
||||
|
||||
private void createColumns(TableView<CompensationRequestListItem> tableView) {
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> dateColumn = new AutoTooltipTableColumn<CompensationRequestListItem, CompensationRequestListItem>(Res.get("shared.dateTime")) {
|
||||
{
|
||||
setMinWidth(190);
|
||||
setMaxWidth(190);
|
||||
}
|
||||
};
|
||||
dateColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
|
||||
dateColumn.setCellFactory(
|
||||
new Callback<TableColumn<CompensationRequestListItem, CompensationRequestListItem>, TableCell<CompensationRequestListItem,
|
||||
CompensationRequestListItem>>() {
|
||||
@Override
|
||||
public TableCell<CompensationRequestListItem, CompensationRequestListItem> call(
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> column) {
|
||||
return new TableCell<CompensationRequestListItem, CompensationRequestListItem>() {
|
||||
@Override
|
||||
public void updateItem(final CompensationRequestListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(bsqFormatter.formatDateTime(item.getCompensationRequest().getPayload().getCreationDate()));
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
dateColumn.setComparator((o1, o2) -> o1.getCompensationRequest().getPayload().getCreationDate().compareTo(o2.getCompensationRequest().getPayload().getCreationDate()));
|
||||
dateColumn.setSortType(TableColumn.SortType.DESCENDING);
|
||||
tableView.getColumns().add(dateColumn);
|
||||
tableView.getSortOrder().add(dateColumn);
|
||||
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> nameColumn = new AutoTooltipTableColumn<>(Res.get("shared.name"));
|
||||
nameColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
|
||||
nameColumn.setCellFactory(
|
||||
new Callback<TableColumn<CompensationRequestListItem, CompensationRequestListItem>, TableCell<CompensationRequestListItem,
|
||||
CompensationRequestListItem>>() {
|
||||
@Override
|
||||
public TableCell<CompensationRequestListItem, CompensationRequestListItem> call(
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> column) {
|
||||
return new TableCell<CompensationRequestListItem, CompensationRequestListItem>() {
|
||||
@Override
|
||||
public void updateItem(final CompensationRequestListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getCompensationRequest().getPayload().getName());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
nameColumn.setComparator((o1, o2) -> o1.getCompensationRequest().getPayload().getName().compareTo(o2.getCompensationRequest().getPayload().getName()));
|
||||
tableView.getColumns().add(nameColumn);
|
||||
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> uidColumn = new AutoTooltipTableColumn<>(Res.get("shared.id"));
|
||||
uidColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
|
||||
uidColumn.setCellFactory(
|
||||
new Callback<TableColumn<CompensationRequestListItem, CompensationRequestListItem>, TableCell<CompensationRequestListItem,
|
||||
CompensationRequestListItem>>() {
|
||||
@Override
|
||||
public TableCell<CompensationRequestListItem, CompensationRequestListItem> call(
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> column) {
|
||||
return new TableCell<CompensationRequestListItem, CompensationRequestListItem>() {
|
||||
@Override
|
||||
public void updateItem(final CompensationRequestListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getCompensationRequest().getPayload().getUid());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
uidColumn.setComparator((o1, o2) -> o1.getCompensationRequest().getPayload().getUid().compareTo(o2.getCompensationRequest().getPayload().getUid()));
|
||||
tableView.getColumns().add(uidColumn);
|
||||
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> confidenceColumn = new TableColumn<>(Res.get("shared.confirmations"));
|
||||
confidenceColumn.setMinWidth(130);
|
||||
confidenceColumn.setMaxWidth(confidenceColumn.getMinWidth());
|
||||
|
||||
confidenceColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
|
||||
confidenceColumn.setCellFactory(new Callback<TableColumn<CompensationRequestListItem, CompensationRequestListItem>,
|
||||
TableCell<CompensationRequestListItem, CompensationRequestListItem>>() {
|
||||
|
||||
@Override
|
||||
public TableCell<CompensationRequestListItem, CompensationRequestListItem> call(TableColumn<CompensationRequestListItem,
|
||||
CompensationRequestListItem> column) {
|
||||
return new TableCell<CompensationRequestListItem, CompensationRequestListItem>() {
|
||||
|
||||
@Override
|
||||
public void updateItem(final CompensationRequestListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
setGraphic(item.getTxConfidenceIndicator());
|
||||
} else {
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
confidenceColumn.setComparator((o1, o2) -> o1.getConfirmations().compareTo(o2.getConfirmations()));
|
||||
tableView.getColumns().add(confidenceColumn);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.gui.main.dao.compensation.active;
|
||||
package io.bisq.gui.main.dao.compensation;
|
||||
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.core.btc.listeners.TxConfidenceListener;
|
||||
@ -42,7 +42,7 @@ import java.util.Optional;
|
||||
@ToString
|
||||
@Slf4j
|
||||
@EqualsAndHashCode
|
||||
class CompensationRequestListItem implements BsqBlockChainListener {
|
||||
public class CompensationRequestListItem implements BsqBlockChainListener {
|
||||
@Getter
|
||||
private final CompensationRequest compensationRequest;
|
||||
private final BsqWalletService bsqWalletService;
|
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bisq.gui.main.dao.compensation;
|
||||
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.core.btc.wallet.BsqWalletService;
|
||||
import io.bisq.core.dao.blockchain.BsqBlockChainChangeDispatcher;
|
||||
import io.bisq.core.dao.blockchain.BsqBlockChainListener;
|
||||
import io.bisq.core.dao.blockchain.parse.BsqBlockChain;
|
||||
import io.bisq.core.dao.compensation.CompensationRequest;
|
||||
import io.bisq.core.dao.compensation.CompensationRequestManager;
|
||||
import io.bisq.gui.common.view.ActivatableView;
|
||||
import io.bisq.gui.common.view.FxmlView;
|
||||
import io.bisq.gui.util.BsqFormatter;
|
||||
import io.bisq.gui.util.Layout;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import javafx.scene.control.SplitPane;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.Subscription;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@FxmlView
|
||||
public class CompensationRequestView extends ActivatableView<GridPane, Void> implements BsqBlockChainListener {
|
||||
|
||||
protected final CompensationRequestManager compensationRequestManger;
|
||||
protected final BsqBlockChain bsqBlockChain;
|
||||
protected final ObservableList<CompensationRequestListItem> observableList = FXCollections.observableArrayList();
|
||||
protected TableView<CompensationRequestListItem> tableView;
|
||||
protected final BsqWalletService bsqWalletService;
|
||||
protected final BsqBlockChainChangeDispatcher bsqBlockChainChangeDispatcher;
|
||||
protected final BsqFormatter bsqFormatter;
|
||||
protected SortedList<CompensationRequestListItem> sortedList = new SortedList<>(observableList);
|
||||
protected Subscription selectedCompensationRequestSubscription;
|
||||
protected CompensationRequestDisplay compensationRequestDisplay;
|
||||
protected int gridRow = 0;
|
||||
protected GridPane detailsGridPane, gridPane;
|
||||
protected SplitPane compensationRequestPane;
|
||||
protected CompensationRequestListItem selectedCompensationRequest;
|
||||
protected ChangeListener<Number> chainHeightChangeListener;
|
||||
protected ListChangeListener<CompensationRequest> compensationRequestListChangeListener;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
protected CompensationRequestView(CompensationRequestManager compensationRequestManger,
|
||||
BsqWalletService bsqWalletService,
|
||||
BsqBlockChain bsqBlockChain,
|
||||
BsqBlockChainChangeDispatcher bsqBlockChainChangeDispatcher,
|
||||
BsqFormatter bsqFormatter) {
|
||||
this.compensationRequestManger = compensationRequestManger;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.bsqBlockChain = bsqBlockChain;
|
||||
this.bsqBlockChainChangeDispatcher = bsqBlockChainChangeDispatcher;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
|
||||
selectedCompensationRequestSubscription = EasyBind.subscribe(tableView.getSelectionModel().selectedItemProperty(), this::onSelectCompensationRequest);
|
||||
|
||||
bsqWalletService.getChainHeightProperty().addListener(chainHeightChangeListener);
|
||||
bsqBlockChainChangeDispatcher.addBsqBlockChainListener(this);
|
||||
compensationRequestManger.getAllRequests().addListener(compensationRequestListChangeListener);
|
||||
updateList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
sortedList.comparatorProperty().unbind();
|
||||
|
||||
selectedCompensationRequestSubscription.unsubscribe();
|
||||
|
||||
bsqWalletService.getChainHeightProperty().removeListener(chainHeightChangeListener);
|
||||
bsqBlockChainChangeDispatcher.removeBsqBlockChainListener(this);
|
||||
compensationRequestManger.getAllRequests().removeListener(compensationRequestListChangeListener);
|
||||
|
||||
observableList.forEach(CompensationRequestListItem::cleanup);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void onBsqBlockChainChanged() {
|
||||
// Need delay otherwise we modify list while dispatching and cause a ConcurrentModificationException
|
||||
UserThread.execute(this::updateList);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Protected
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
protected void updateList() {
|
||||
}
|
||||
|
||||
protected void onSelectCompensationRequest(CompensationRequestListItem item) {
|
||||
selectedCompensationRequest = item;
|
||||
if (item != null) {
|
||||
final CompensationRequest compensationRequest = item.getCompensationRequest();
|
||||
compensationRequestDisplay.removeAllFields();
|
||||
compensationRequestDisplay.createAllFields(Res.get("dao.compensation.selectedRequest"), Layout.GROUP_DISTANCE);
|
||||
compensationRequestDisplay.setAllFieldsEditable(false);
|
||||
compensationRequestDisplay.fillWithData(compensationRequest.getPayload());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,10 @@
|
||||
-->
|
||||
|
||||
|
||||
<?import javafx.scene.control.SplitPane?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<SplitPane fx:id="root" fx:controller="io.bisq.gui.main.dao.compensation.active.ActiveCompensationRequestView"
|
||||
AnchorPane.bottomAnchor="-20.0" AnchorPane.leftAnchor="-10.0"
|
||||
AnchorPane.rightAnchor="-10.0" AnchorPane.topAnchor="-20.0"
|
||||
orientation="VERTICAL"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
</SplitPane>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<GridPane fx:id="root" fx:controller="io.bisq.gui.main.dao.compensation.active.ActiveCompensationRequestView"
|
||||
AnchorPane.bottomAnchor="-20.0" AnchorPane.leftAnchor="-10.0"
|
||||
AnchorPane.rightAnchor="-10.0" AnchorPane.topAnchor="-20.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
</GridPane>
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
package io.bisq.gui.main.dao.compensation.active;
|
||||
|
||||
import io.bisq.common.UserThread;
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.core.btc.wallet.BsqWalletService;
|
||||
import io.bisq.core.dao.DaoPeriodService;
|
||||
@ -28,35 +27,23 @@ import io.bisq.core.dao.compensation.CompensationRequest;
|
||||
import io.bisq.core.dao.compensation.CompensationRequestManager;
|
||||
import io.bisq.core.provider.fee.FeeService;
|
||||
import io.bisq.gui.Navigation;
|
||||
import io.bisq.gui.common.view.ActivatableView;
|
||||
import io.bisq.gui.common.view.FxmlView;
|
||||
import io.bisq.gui.components.AutoTooltipLabel;
|
||||
import io.bisq.gui.components.AutoTooltipTableColumn;
|
||||
import io.bisq.gui.components.SeparatedPhaseBars;
|
||||
import io.bisq.gui.components.TableGroupHeadline;
|
||||
import io.bisq.gui.main.MainView;
|
||||
import io.bisq.gui.main.dao.DaoView;
|
||||
import io.bisq.gui.main.dao.compensation.CompensationRequestDisplay;
|
||||
import io.bisq.gui.main.dao.compensation.CompensationRequestListItem;
|
||||
import io.bisq.gui.main.dao.compensation.CompensationRequestView;
|
||||
import io.bisq.gui.main.dao.voting.VotingView;
|
||||
import io.bisq.gui.main.dao.voting.vote.VoteView;
|
||||
import io.bisq.gui.main.overlays.popups.Popup;
|
||||
import io.bisq.gui.util.BsqFormatter;
|
||||
import io.bisq.gui.util.Layout;
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.ColumnConstraints;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.util.Callback;
|
||||
import javafx.scene.layout.*;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.Subscription;
|
||||
|
||||
@ -69,32 +56,15 @@ import static io.bisq.gui.util.FormBuilder.addButtonAfterGroup;
|
||||
import static io.bisq.gui.util.FormBuilder.addTitledGroupBg;
|
||||
|
||||
@FxmlView
|
||||
public class ActiveCompensationRequestView extends ActivatableView<SplitPane, Void> implements BsqBlockChainListener {
|
||||
public class ActiveCompensationRequestView extends CompensationRequestView implements BsqBlockChainListener {
|
||||
|
||||
TableView<CompensationRequestListItem> tableView;
|
||||
private final CompensationRequestManager compensationRequestManger;
|
||||
private final DaoPeriodService daoPeriodService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final BsqBlockChain bsqBlockChain;
|
||||
private final FeeService feeService;
|
||||
private final BsqBlockChainChangeDispatcher bsqBlockChainChangeDispatcher;
|
||||
private final Navigation navigation;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
private final ObservableList<CompensationRequestListItem> observableList = FXCollections.observableArrayList();
|
||||
private SortedList<CompensationRequestListItem> sortedList = new SortedList<>(observableList);
|
||||
private Subscription selectedCompensationRequestSubscription, phaseSubscription;
|
||||
private CompensationRequestDisplay compensationRequestDisplay;
|
||||
private int gridRow = 0;
|
||||
private GridPane detailsGridPane, gridPane;
|
||||
private DaoPeriodService.Phase currentPhase;
|
||||
private CompensationRequestListItem selectedCompensationRequest;
|
||||
private Button removeButton, voteButton;
|
||||
private TextField cycleTextField;
|
||||
private List<SeparatedPhaseBars.SeparatedPhaseBarsItem> phaseBarsItems;
|
||||
private ChangeListener<Number> chainHeightChangeListener;
|
||||
private ListChangeListener<CompensationRequest> compensationRequestListChangeListener;
|
||||
private Button removeButton, voteButton;
|
||||
private final Navigation navigation;
|
||||
private final DaoPeriodService daoPeriodService;
|
||||
private DaoPeriodService.Phase currentPhase;
|
||||
private ChangeListener<DaoPeriodService.Phase> phaseChangeListener;
|
||||
|
||||
private Subscription phaseSubscription;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
@ -109,22 +79,16 @@ public class ActiveCompensationRequestView extends ActivatableView<SplitPane, Vo
|
||||
BsqBlockChainChangeDispatcher bsqBlockChainChangeDispatcher,
|
||||
Navigation navigation,
|
||||
BsqFormatter bsqFormatter) {
|
||||
this.compensationRequestManger = compensationRequestManger;
|
||||
super(compensationRequestManger, bsqWalletService, bsqBlockChain, bsqBlockChainChangeDispatcher, bsqFormatter);
|
||||
this.daoPeriodService = daoPeriodService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.bsqBlockChain = bsqBlockChain;
|
||||
this.feeService = feeService;
|
||||
this.bsqBlockChainChangeDispatcher = bsqBlockChainChangeDispatcher;
|
||||
this.navigation = navigation;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
root.setDividerPositions(0.3, 0.7);
|
||||
root.getStyleClass().add("compensation-root");
|
||||
AnchorPane topAnchorPane = new AnchorPane();
|
||||
root.getItems().add(topAnchorPane);
|
||||
root.getChildren().add(topAnchorPane);
|
||||
|
||||
gridPane = new GridPane();
|
||||
gridPane.setHgap(5);
|
||||
@ -135,19 +99,13 @@ public class ActiveCompensationRequestView extends ActivatableView<SplitPane, Vo
|
||||
AnchorPane.setTopAnchor(gridPane, 10d);
|
||||
topAnchorPane.getChildren().add(gridPane);
|
||||
|
||||
// Add phase info
|
||||
addTitledGroupBg(gridPane, gridRow, 1, Res.get("dao.compensation.active.phase.header"));
|
||||
phaseBarsItems = Arrays.asList(
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.COMPENSATION_REQUESTS, true),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK1, false),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.OPEN_FOR_VOTING, true),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK2, false),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.VOTE_CONFIRMATION, true),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK3, false));
|
||||
SeparatedPhaseBars separatedPhaseBars = new SeparatedPhaseBars(phaseBarsItems);
|
||||
GridPane.setRowIndex(separatedPhaseBars, gridRow);
|
||||
SeparatedPhaseBars separatedPhaseBars = createSeparatedPhaseBars();
|
||||
GridPane.setColumnSpan(separatedPhaseBars, 2);
|
||||
GridPane.setColumnIndex(separatedPhaseBars, 0);
|
||||
GridPane.setMargin(separatedPhaseBars, new Insets(Layout.FIRST_ROW_DISTANCE - 6, 0, 0, 0));
|
||||
GridPane.setRowIndex(separatedPhaseBars, gridRow);
|
||||
gridPane.getChildren().add(separatedPhaseBars);
|
||||
|
||||
/* final Tuple2<Label, TextField> tuple2 = addLabelTextField(gridPane, ++gridRow, Res.get("dao.compensation.active.cycle"));
|
||||
@ -155,25 +113,15 @@ public class ActiveCompensationRequestView extends ActivatableView<SplitPane, Vo
|
||||
GridPane.setHalignment(label, HPos.RIGHT);
|
||||
cycleTextField = tuple2.second;*/
|
||||
|
||||
TableGroupHeadline header = new TableGroupHeadline(Res.get("dao.compensation.active.header"));
|
||||
GridPane.setRowIndex(header, ++gridRow);
|
||||
GridPane.setMargin(header, new Insets(Layout.GROUP_DISTANCE, -10, -10, -10));
|
||||
gridPane.getChildren().add(header);
|
||||
header.setMinHeight(20);
|
||||
header.setMaxHeight(20);
|
||||
|
||||
// Add compensationrequest pane
|
||||
tableView = new TableView<>();
|
||||
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
|
||||
tableView.setMinHeight(90);
|
||||
GridPane.setRowIndex(tableView, ++gridRow);
|
||||
GridPane.setColumnSpan(tableView, 2);
|
||||
GridPane.setMargin(tableView, new Insets(5, -15, -10, -10));
|
||||
GridPane.setVgrow(tableView, Priority.ALWAYS);
|
||||
GridPane.setHgrow(tableView, Priority.ALWAYS);
|
||||
gridPane.getChildren().add(tableView);
|
||||
|
||||
createColumns();
|
||||
detailsGridPane = new GridPane();
|
||||
compensationRequestDisplay = new CompensationRequestDisplay(detailsGridPane, bsqFormatter, bsqWalletService, null);
|
||||
compensationRequestPane = compensationRequestDisplay.createCompensationRequestPane(tableView, Res.get("dao.compensation.active.header"));
|
||||
GridPane.setColumnSpan(compensationRequestPane, 2);
|
||||
GridPane.setMargin(compensationRequestPane, new Insets(Layout.FIRST_ROW_DISTANCE - 6, -10, 0, -10));
|
||||
GridPane.setRowIndex(compensationRequestPane, ++gridRow);
|
||||
gridPane.getChildren().add(compensationRequestPane);
|
||||
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
tableView.setItems(sortedList);
|
||||
@ -186,17 +134,27 @@ public class ActiveCompensationRequestView extends ActivatableView<SplitPane, Vo
|
||||
phaseChangeListener = (observable, oldValue, newValue) -> onPhaseChanged(newValue);
|
||||
}
|
||||
|
||||
|
||||
private SeparatedPhaseBars createSeparatedPhaseBars() {
|
||||
phaseBarsItems = Arrays.asList(
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.COMPENSATION_REQUESTS, true),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK1, false),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.OPEN_FOR_VOTING, true),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK2, false),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.VOTE_CONFIRMATION, true),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK3, false));
|
||||
SeparatedPhaseBars separatedPhaseBars = new SeparatedPhaseBars(phaseBarsItems);
|
||||
return separatedPhaseBars;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
|
||||
selectedCompensationRequestSubscription = EasyBind.subscribe(tableView.getSelectionModel().selectedItemProperty(), this::onSelectCompensationRequest);
|
||||
super.activate();
|
||||
phaseSubscription = EasyBind.subscribe(daoPeriodService.getPhaseProperty(), phase -> {
|
||||
if (!phase.equals(this.currentPhase)) {
|
||||
this.currentPhase = phase;
|
||||
onSelectCompensationRequest(selectedCompensationRequest);
|
||||
}
|
||||
|
||||
phaseBarsItems.stream().forEach(item -> {
|
||||
if (item.getPhase() == phase) {
|
||||
item.setActive();
|
||||
@ -206,46 +164,19 @@ public class ActiveCompensationRequestView extends ActivatableView<SplitPane, Vo
|
||||
});
|
||||
});
|
||||
|
||||
bsqWalletService.getChainHeightProperty().addListener(chainHeightChangeListener);
|
||||
bsqBlockChainChangeDispatcher.addBsqBlockChainListener(this);
|
||||
compensationRequestManger.getAllRequests().addListener(compensationRequestListChangeListener);
|
||||
daoPeriodService.getPhaseProperty().addListener(phaseChangeListener);
|
||||
|
||||
onChainHeightChanged(bsqWalletService.getChainHeightProperty().get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
sortedList.comparatorProperty().unbind();
|
||||
|
||||
selectedCompensationRequestSubscription.unsubscribe();
|
||||
super.deactivate();
|
||||
phaseSubscription.unsubscribe();
|
||||
|
||||
bsqWalletService.getChainHeightProperty().removeListener(chainHeightChangeListener);
|
||||
bsqBlockChainChangeDispatcher.removeBsqBlockChainListener(this);
|
||||
compensationRequestManger.getAllRequests().removeListener(compensationRequestListChangeListener);
|
||||
daoPeriodService.getPhaseProperty().removeListener(phaseChangeListener);
|
||||
|
||||
observableList.forEach(CompensationRequestListItem::cleanup);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void onBsqBlockChainChanged() {
|
||||
// Need delay otherwise we modify list while dispatching and cause a ConcurrentModificationException
|
||||
UserThread.execute(this::updateList);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void updateList() {
|
||||
protected void updateList() {
|
||||
observableList.forEach(CompensationRequestListItem::cleanup);
|
||||
|
||||
final FilteredList<CompensationRequest> activeRequests = compensationRequestManger.getActiveRequests();
|
||||
@ -258,8 +189,6 @@ public class ActiveCompensationRequestView extends ActivatableView<SplitPane, Vo
|
||||
}
|
||||
|
||||
private void onChainHeightChanged(int height) {
|
||||
//cycleTextField.setText(String.valueOf(daoPeriodService.getNumOfStartedCycles(height)));
|
||||
|
||||
phaseBarsItems.stream().forEach(item -> {
|
||||
int startBlock = daoPeriodService.getAbsoluteStartBlockOfPhase(height, item.getPhase());
|
||||
int endBlock = daoPeriodService.getAbsoluteEndBlockOfPhase(height, item.getPhase());
|
||||
@ -274,48 +203,11 @@ public class ActiveCompensationRequestView extends ActivatableView<SplitPane, Vo
|
||||
}
|
||||
item.getProgressProperty().set(progress);
|
||||
});
|
||||
|
||||
updateList();
|
||||
}
|
||||
|
||||
private void onSelectCompensationRequest(CompensationRequestListItem item) {
|
||||
selectedCompensationRequest = item;
|
||||
protected void onSelectCompensationRequest(CompensationRequestListItem item) {
|
||||
super.onSelectCompensationRequest(item);
|
||||
if (item != null) {
|
||||
final CompensationRequest compensationRequest = item.getCompensationRequest();
|
||||
if (compensationRequestDisplay == null) {
|
||||
ScrollPane scrollPane = new ScrollPane();
|
||||
scrollPane.setFitToWidth(true);
|
||||
scrollPane.setFitToHeight(true);
|
||||
scrollPane.setMinHeight(100);
|
||||
root.getItems().add(scrollPane);
|
||||
|
||||
AnchorPane bottomAnchorPane = new AnchorPane();
|
||||
scrollPane.setContent(bottomAnchorPane);
|
||||
|
||||
detailsGridPane = new GridPane();
|
||||
detailsGridPane.setHgap(5);
|
||||
detailsGridPane.setVgap(5);
|
||||
ColumnConstraints columnConstraints1 = new ColumnConstraints();
|
||||
columnConstraints1.setHalignment(HPos.RIGHT);
|
||||
columnConstraints1.setHgrow(Priority.SOMETIMES);
|
||||
columnConstraints1.setMinWidth(140);
|
||||
ColumnConstraints columnConstraints2 = new ColumnConstraints();
|
||||
columnConstraints2.setHgrow(Priority.ALWAYS);
|
||||
columnConstraints2.setMinWidth(300);
|
||||
detailsGridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
|
||||
AnchorPane.setBottomAnchor(detailsGridPane, 20d);
|
||||
AnchorPane.setRightAnchor(detailsGridPane, 10d);
|
||||
AnchorPane.setLeftAnchor(detailsGridPane, 10d);
|
||||
AnchorPane.setTopAnchor(detailsGridPane, -20d);
|
||||
bottomAnchorPane.getChildren().add(detailsGridPane);
|
||||
|
||||
compensationRequestDisplay = new CompensationRequestDisplay(detailsGridPane, bsqFormatter, bsqWalletService, feeService);
|
||||
}
|
||||
compensationRequestDisplay.removeAllFields();
|
||||
compensationRequestDisplay.createAllFields(Res.get("dao.compensation.active.selectedRequest"), Layout.GROUP_DISTANCE);
|
||||
compensationRequestDisplay.setAllFieldsEditable(false);
|
||||
compensationRequestDisplay.fillWithData(compensationRequest.getPayload());
|
||||
|
||||
if (removeButton != null) {
|
||||
removeButton.setManaged(false);
|
||||
removeButton.setVisible(false);
|
||||
@ -330,7 +222,7 @@ public class ActiveCompensationRequestView extends ActivatableView<SplitPane, Vo
|
||||
}
|
||||
}
|
||||
|
||||
private void onPhaseChanged(DaoPeriodService.Phase phase) {
|
||||
protected void onPhaseChanged(DaoPeriodService.Phase phase) {
|
||||
if (removeButton != null) {
|
||||
removeButton.setManaged(false);
|
||||
removeButton.setVisible(false);
|
||||
@ -384,118 +276,5 @@ public class ActiveCompensationRequestView extends ActivatableView<SplitPane, Vo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Table
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void createColumns() {
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> dateColumn = new AutoTooltipTableColumn<CompensationRequestListItem, CompensationRequestListItem>(Res.get("shared.dateTime")) {
|
||||
{
|
||||
setMinWidth(190);
|
||||
setMaxWidth(190);
|
||||
}
|
||||
};
|
||||
dateColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
|
||||
dateColumn.setCellFactory(
|
||||
new Callback<TableColumn<CompensationRequestListItem, CompensationRequestListItem>, TableCell<CompensationRequestListItem,
|
||||
CompensationRequestListItem>>() {
|
||||
@Override
|
||||
public TableCell<CompensationRequestListItem, CompensationRequestListItem> call(
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> column) {
|
||||
return new TableCell<CompensationRequestListItem, CompensationRequestListItem>() {
|
||||
@Override
|
||||
public void updateItem(final CompensationRequestListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(bsqFormatter.formatDateTime(item.getCompensationRequest().getPayload().getCreationDate()));
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
dateColumn.setComparator((o1, o2) -> o1.getCompensationRequest().getPayload().getCreationDate().compareTo(o2.getCompensationRequest().getPayload().getCreationDate()));
|
||||
dateColumn.setSortType(TableColumn.SortType.DESCENDING);
|
||||
tableView.getColumns().add(dateColumn);
|
||||
tableView.getSortOrder().add(dateColumn);
|
||||
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> nameColumn = new AutoTooltipTableColumn<>(Res.get("shared.name"));
|
||||
nameColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
|
||||
nameColumn.setCellFactory(
|
||||
new Callback<TableColumn<CompensationRequestListItem, CompensationRequestListItem>, TableCell<CompensationRequestListItem,
|
||||
CompensationRequestListItem>>() {
|
||||
@Override
|
||||
public TableCell<CompensationRequestListItem, CompensationRequestListItem> call(
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> column) {
|
||||
return new TableCell<CompensationRequestListItem, CompensationRequestListItem>() {
|
||||
@Override
|
||||
public void updateItem(final CompensationRequestListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getCompensationRequest().getPayload().getName());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
nameColumn.setComparator((o1, o2) -> o1.getCompensationRequest().getPayload().getName().compareTo(o2.getCompensationRequest().getPayload().getName()));
|
||||
tableView.getColumns().add(nameColumn);
|
||||
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> uidColumn = new AutoTooltipTableColumn<>(Res.get("shared.id"));
|
||||
uidColumn.setCellValueFactory((tradeStatistics) -> new ReadOnlyObjectWrapper<>(tradeStatistics.getValue()));
|
||||
uidColumn.setCellFactory(
|
||||
new Callback<TableColumn<CompensationRequestListItem, CompensationRequestListItem>, TableCell<CompensationRequestListItem,
|
||||
CompensationRequestListItem>>() {
|
||||
@Override
|
||||
public TableCell<CompensationRequestListItem, CompensationRequestListItem> call(
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> column) {
|
||||
return new TableCell<CompensationRequestListItem, CompensationRequestListItem>() {
|
||||
@Override
|
||||
public void updateItem(final CompensationRequestListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(item.getCompensationRequest().getPayload().getUid());
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
uidColumn.setComparator((o1, o2) -> o1.getCompensationRequest().getPayload().getUid().compareTo(o2.getCompensationRequest().getPayload().getUid()));
|
||||
tableView.getColumns().add(uidColumn);
|
||||
|
||||
TableColumn<CompensationRequestListItem, CompensationRequestListItem> confidenceColumn = new TableColumn<>(Res.get("shared.confirmations"));
|
||||
confidenceColumn.setMinWidth(130);
|
||||
confidenceColumn.setMaxWidth(confidenceColumn.getMinWidth());
|
||||
|
||||
confidenceColumn.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
|
||||
confidenceColumn.setCellFactory(new Callback<TableColumn<CompensationRequestListItem, CompensationRequestListItem>,
|
||||
TableCell<CompensationRequestListItem, CompensationRequestListItem>>() {
|
||||
|
||||
@Override
|
||||
public TableCell<CompensationRequestListItem, CompensationRequestListItem> call(TableColumn<CompensationRequestListItem,
|
||||
CompensationRequestListItem> column) {
|
||||
return new TableCell<CompensationRequestListItem, CompensationRequestListItem>() {
|
||||
|
||||
@Override
|
||||
public void updateItem(final CompensationRequestListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
setGraphic(item.getTxConfidenceIndicator());
|
||||
} else {
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
confidenceColumn.setComparator((o1, o2) -> o1.getConfirmations().compareTo(o2.getConfirmations()));
|
||||
tableView.getColumns().add(confidenceColumn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,15 +17,10 @@
|
||||
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<GridPane fx:id="root" fx:controller="io.bisq.gui.main.dao.compensation.past.PastCompensationRequestView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-10.0"
|
||||
AnchorPane.bottomAnchor="-20.0" AnchorPane.leftAnchor="-10.0"
|
||||
AnchorPane.rightAnchor="-10.0" AnchorPane.topAnchor="-20.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0"/>
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
||||
|
@ -17,14 +17,34 @@
|
||||
|
||||
package io.bisq.gui.main.dao.compensation.past;
|
||||
|
||||
import io.bisq.gui.common.view.ActivatableView;
|
||||
import io.bisq.common.locale.Res;
|
||||
import io.bisq.core.btc.wallet.BsqWalletService;
|
||||
import io.bisq.core.dao.DaoPeriodService;
|
||||
import io.bisq.core.dao.blockchain.BsqBlockChainChangeDispatcher;
|
||||
import io.bisq.core.dao.blockchain.BsqBlockChainListener;
|
||||
import io.bisq.core.dao.blockchain.parse.BsqBlockChain;
|
||||
import io.bisq.core.dao.compensation.CompensationRequest;
|
||||
import io.bisq.core.dao.compensation.CompensationRequestManager;
|
||||
import io.bisq.gui.Navigation;
|
||||
import io.bisq.gui.common.view.FxmlView;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import io.bisq.gui.components.SeparatedPhaseBars;
|
||||
import io.bisq.gui.main.dao.compensation.CompensationRequestDisplay;
|
||||
import io.bisq.gui.main.dao.compensation.CompensationRequestListItem;
|
||||
import io.bisq.gui.main.dao.compensation.CompensationRequestView;
|
||||
import io.bisq.gui.util.BsqFormatter;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.*;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@FxmlView
|
||||
public class PastCompensationRequestView extends ActivatableView<GridPane, Void> {
|
||||
public class PastCompensationRequestView extends CompensationRequestView implements BsqBlockChainListener {
|
||||
|
||||
private List<SeparatedPhaseBars.SeparatedPhaseBarsItem> phaseBarsItems;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -32,19 +52,63 @@ public class PastCompensationRequestView extends ActivatableView<GridPane, Void>
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private PastCompensationRequestView() {
|
||||
private PastCompensationRequestView(CompensationRequestManager compensationRequestManger,
|
||||
DaoPeriodService daoPeriodService,
|
||||
BsqWalletService bsqWalletService,
|
||||
BsqBlockChain bsqBlockChain,
|
||||
BsqBlockChainChangeDispatcher bsqBlockChainChangeDispatcher,
|
||||
BsqFormatter bsqFormatter) {
|
||||
super(compensationRequestManger, bsqWalletService, bsqBlockChain, bsqBlockChainChangeDispatcher, bsqFormatter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
root.getStyleClass().add("compensation-root");
|
||||
AnchorPane topAnchorPane = new AnchorPane();
|
||||
root.getChildren().add(topAnchorPane);
|
||||
|
||||
gridPane = new GridPane();
|
||||
gridPane.setHgap(5);
|
||||
gridPane.setVgap(5);
|
||||
AnchorPane.setBottomAnchor(gridPane, 10d);
|
||||
AnchorPane.setRightAnchor(gridPane, 10d);
|
||||
AnchorPane.setLeftAnchor(gridPane, 10d);
|
||||
AnchorPane.setTopAnchor(gridPane, 0d);
|
||||
topAnchorPane.getChildren().add(gridPane);
|
||||
|
||||
// Add compensationrequest pane
|
||||
tableView = new TableView<>();
|
||||
detailsGridPane = new GridPane();
|
||||
compensationRequestDisplay = new CompensationRequestDisplay(detailsGridPane, bsqFormatter, bsqWalletService, null);
|
||||
compensationRequestPane = compensationRequestDisplay.createCompensationRequestPane(tableView, Res.get("dao.compensation.past.header"));
|
||||
compensationRequestPane.setMinWidth(800);
|
||||
GridPane.setColumnSpan(compensationRequestPane, 2);
|
||||
GridPane.setColumnIndex(compensationRequestPane, 0);
|
||||
GridPane.setMargin(compensationRequestPane, new Insets(0, -10, 0, -10));
|
||||
GridPane.setRowIndex(compensationRequestPane, gridRow);
|
||||
|
||||
gridPane.getChildren().add(compensationRequestPane);
|
||||
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
tableView.setItems(sortedList);
|
||||
|
||||
compensationRequestListChangeListener = c -> updateList();
|
||||
chainHeightChangeListener = (observable, oldValue, newValue) -> {
|
||||
updateList();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
}
|
||||
protected void updateList() {
|
||||
observableList.forEach(CompensationRequestListItem::cleanup);
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
final FilteredList<CompensationRequest> pastRequests = compensationRequestManger.getPastRequests();
|
||||
observableList.setAll(pastRequests.stream()
|
||||
.map(e -> new CompensationRequestListItem(e, bsqWalletService, bsqBlockChain, bsqBlockChainChangeDispatcher, bsqFormatter))
|
||||
.collect(Collectors.toSet()));
|
||||
|
||||
if (pastRequests.isEmpty() && compensationRequestDisplay != null)
|
||||
compensationRequestDisplay.removeAllFields();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user