mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 10:22:18 +01:00
Complete bonds view
This commit is contained in:
parent
6218da0623
commit
8e3864589a
@ -522,11 +522,11 @@ public class DaoFacade implements DaoSetupService {
|
||||
return bondedRolesService.getActiveBonds();
|
||||
}
|
||||
|
||||
public List<Bond> getAllActiveBonds() {
|
||||
List<BondedReputation> activeReputations = bondedReputationService.getActiveBonds();
|
||||
List<BondedRole> activeRoles = bondedRolesService.getActiveBonds();
|
||||
List<Bond> bonds = new ArrayList<>(activeReputations);
|
||||
bonds.addAll(activeRoles);
|
||||
public List<Bond> getAllBonds() {
|
||||
List<BondedReputation> bondedReputations = bondedReputationService.getAllBonds();
|
||||
List<BondedRole> bondedRoles = bondedRolesService.getAllBonds();
|
||||
List<Bond> bonds = new ArrayList<>(bondedReputations);
|
||||
bonds.addAll(bondedRoles);
|
||||
return bonds;
|
||||
}
|
||||
|
||||
|
@ -182,6 +182,10 @@ public abstract class BondService<T extends Bond, R extends BondedAsset> impleme
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<T> getAllBonds() {
|
||||
return new ArrayList<>(bondByUidMap.values());
|
||||
}
|
||||
|
||||
public Optional<T> findBondByLockupTxId(String lockupTxId) {
|
||||
return bondByUidMap.values().stream()
|
||||
.filter(bond -> lockupTxId.equals(bond.getLockupTxId()))
|
||||
|
@ -21,15 +21,15 @@ import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.dao.governance.bond.Bond;
|
||||
import bisq.core.dao.governance.bond.BondConsensus;
|
||||
import bisq.core.dao.governance.bond.BondService;
|
||||
import bisq.core.dao.governance.bond.role.BondedRolesService;
|
||||
import bisq.core.dao.state.DaoStateService;
|
||||
import bisq.core.dao.state.model.blockchain.TxOutput;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -37,40 +37,18 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class BondedReputationService extends BondService<BondedReputation, Reputation> {
|
||||
private final BondedRolesService bondedRolesService;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public BondedReputationService(DaoStateService daoStateService, BsqWalletService bsqWalletService) {
|
||||
public BondedReputationService(DaoStateService daoStateService, BsqWalletService bsqWalletService,
|
||||
BondedRolesService bondedRolesService) {
|
||||
super(daoStateService, bsqWalletService);
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public List<BondedReputation> getActiveBondedReputations() {
|
||||
return bondByUidMap.values().stream()
|
||||
.filter(e -> e.isActive())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<BondedReputation> getAllBondedReputations() {
|
||||
return new ArrayList<>(bondByUidMap.values());
|
||||
}
|
||||
|
||||
public List<BondedReputation> getUnconfirmedBondedReputations() {
|
||||
//TODO
|
||||
/* Set<String> myWalletTransactionIds = bsqWalletService.getWalletTransactions().stream()
|
||||
.map(Transaction::getHashAsString)
|
||||
.collect(Collectors.toSet());
|
||||
*/
|
||||
return bondByUidMap.values().stream()
|
||||
.filter(e -> e.isActive())
|
||||
.collect(Collectors.toList());
|
||||
this.bondedRolesService = bondedRolesService;
|
||||
}
|
||||
|
||||
|
||||
@ -90,15 +68,14 @@ public class BondedReputationService extends BondService<BondedReputation, Reput
|
||||
|
||||
@Override
|
||||
protected void updateMap() {
|
||||
//TODO
|
||||
/* bondByUidMap.clear();
|
||||
bondByUidMap.clear();
|
||||
getBondedReputationStream().forEach(bondedReputation -> {
|
||||
bondByUidMap.put(bondedReputation.getBondedAsset().getUid(), bondedReputation);
|
||||
});*/
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private Stream<BondedReputation> getBondedReputationStream() {
|
||||
Set<String> bondedRolesLockupTxIdSet = bondedRolesService.getAllBonds().stream().map(e -> e.getLockupTxId()).collect(Collectors.toSet());
|
||||
return daoStateService.getLockupTxOutputs().stream()
|
||||
.map(lockupTxOutput -> {
|
||||
String lockupTxId = lockupTxOutput.getTxId();
|
||||
@ -110,14 +87,23 @@ public class BondedReputationService extends BondService<BondedReputation, Reput
|
||||
byte[] hash = BondConsensus.getHashFromOpReturnData(opReturnTxOutput.getOpReturnData());
|
||||
Reputation reputation = new Reputation(hash);
|
||||
BondedReputation bondedReputation = new BondedReputation(reputation);
|
||||
//TODO
|
||||
//updateBond(bondedReputation, reputation, lockupTxOutput);
|
||||
updateBond(bondedReputation, reputation, lockupTxOutput);
|
||||
return bondedReputation;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
})
|
||||
.filter(Objects::nonNull);
|
||||
.filter(Objects::nonNull)
|
||||
.filter(e -> !bondedRolesLockupTxIdSet.contains(e.getLockupTxId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBond(BondedReputation bond, Reputation bondedAsset, TxOutput lockupTxOutput) {
|
||||
// Lets see if we have a lock up tx.
|
||||
String lockupTxId = lockupTxOutput.getTxId();
|
||||
daoStateService.getTx(lockupTxId).ifPresent(lockupTx -> {
|
||||
applyBondState(daoStateService, bond, lockupTx, lockupTxOutput);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1333,6 +1333,7 @@ dao.bonding.dashboard.bondsHeadline=Bonded BSQ
|
||||
dao.bonding.dashboard.lockupAmount=Lockup funds
|
||||
dao.bonding.dashboard.unlockingAmount=Unlocking funds (wait until lock time is over)
|
||||
dao.bonding.bonds.table.lockupTxId=Lockup tx ID
|
||||
dao.bonding.bonds.table.header=All bonds
|
||||
|
||||
dao.bonding.info=Lockup Tx ID: {0} / {1}
|
||||
dao.bonding.reputation.salt.info=Salt: {0}
|
||||
@ -1386,11 +1387,12 @@ dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holder
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.bondedReputation=Bonded Reputation
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.table.column.header.name=Name
|
||||
dao.bond.table.column.header.link=Link
|
||||
dao.bond.table.column.header.bondedRoleType=Role
|
||||
dao.bond.table.column.header.bondType=Bond type
|
||||
dao.bond.table.column.header.details=Details
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link zur Rollenbeschreibung
|
||||
dao.bond.bondedRoleType.details.isSingleton=Kann von mehreren Rollenhalter genommen werden
|
||||
dao.bond.bondedRoleType.details.blocks={0} Blöcke
|
||||
|
||||
dao.bond.table.header=Gekoppelte Rollen
|
||||
dao.bond.bondedRoles=Gekoppelte Rollen
|
||||
dao.bond.table.column.header.name=Name
|
||||
dao.bond.table.column.header.link=Konto
|
||||
dao.bond.table.column.header.bondedRoleType=Rolle
|
||||
dao.bond.table.column.header.bondType=Rolle
|
||||
dao.bond.table.column.header.startDate=Gestartet
|
||||
dao.bond.table.column.header.lockupTxId=Sperrung Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Widerrufen
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link to role description
|
||||
dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holders
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
dao.bond.table.column.header.name=Όνομα
|
||||
dao.bond.table.column.header.link=Λογαριασμός
|
||||
dao.bond.table.column.header.bondedRoleType=Ρόλος
|
||||
dao.bond.table.column.header.bondType=Ρόλος
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link to role description
|
||||
dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holders
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
dao.bond.table.column.header.name=Nombre
|
||||
dao.bond.table.column.header.link=Cuenta
|
||||
dao.bond.table.column.header.bondedRoleType=Rol
|
||||
dao.bond.table.column.header.bondType=Rol
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link to role description
|
||||
dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holders
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
dao.bond.table.column.header.name=نام
|
||||
dao.bond.table.column.header.link=حساب
|
||||
dao.bond.table.column.header.bondedRoleType=نقش
|
||||
dao.bond.table.column.header.bondType=نقش
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link to role description
|
||||
dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holders
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
dao.bond.table.column.header.name=Név
|
||||
dao.bond.table.column.header.link=Fiók
|
||||
dao.bond.table.column.header.bondedRoleType=Szerep
|
||||
dao.bond.table.column.header.bondType=Szerep
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link to role description
|
||||
dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holders
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
dao.bond.table.column.header.name=Nome
|
||||
dao.bond.table.column.header.link=Conta
|
||||
dao.bond.table.column.header.bondedRoleType=Função
|
||||
dao.bond.table.column.header.bondType=Função
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link to role description
|
||||
dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holders
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
dao.bond.table.column.header.name=Nume
|
||||
dao.bond.table.column.header.link=Cont
|
||||
dao.bond.table.column.header.bondedRoleType=Rol
|
||||
dao.bond.table.column.header.bondType=Rol
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Ссылка на подробности р
|
||||
dao.bond.bondedRoleType.details.isSingleton=Может быть принято несколькими держателями роли
|
||||
dao.bond.bondedRoleType.details.blocks={0} блоков
|
||||
|
||||
dao.bond.table.header=Обеспеченные роли
|
||||
dao.bond.bondedRoles=Обеспеченные роли
|
||||
dao.bond.table.column.header.name=Имя
|
||||
dao.bond.table.column.header.link=Счёт
|
||||
dao.bond.table.column.header.bondedRoleType=Роль
|
||||
dao.bond.table.column.header.bondType=Роль
|
||||
dao.bond.table.column.header.startDate=Начато
|
||||
dao.bond.table.column.header.lockupTxId=Транз. идент. блокировки
|
||||
dao.bond.table.column.header.revokeDate=Аннулировано
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link to role description
|
||||
dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holders
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
dao.bond.table.column.header.name=Ime
|
||||
dao.bond.table.column.header.link=Nalog
|
||||
dao.bond.table.column.header.bondedRoleType=Uloga
|
||||
dao.bond.table.column.header.bondType=Uloga
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link to role description
|
||||
dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holders
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
dao.bond.table.column.header.name=ชื่อ
|
||||
dao.bond.table.column.header.link=บัญชี
|
||||
dao.bond.table.column.header.bondedRoleType=บทบาท
|
||||
dao.bond.table.column.header.bondType=บทบาท
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link to role description
|
||||
dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holders
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
dao.bond.table.column.header.name=Tên
|
||||
dao.bond.table.column.header.link=Tài khoản
|
||||
dao.bond.table.column.header.bondedRoleType=Vai trò
|
||||
dao.bond.table.column.header.bondType=Vai trò
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -1161,10 +1161,10 @@ dao.bond.bondedRoleType.details.link=Link to role description
|
||||
dao.bond.bondedRoleType.details.isSingleton=Can be taken by multiple role holders
|
||||
dao.bond.bondedRoleType.details.blocks={0} blocks
|
||||
|
||||
dao.bond.table.header=Bonded roles
|
||||
dao.bond.bondedRoles=Bonded roles
|
||||
dao.bond.table.column.header.name=名称
|
||||
dao.bond.table.column.header.link=账户
|
||||
dao.bond.table.column.header.bondedRoleType=角色
|
||||
dao.bond.table.column.header.bondType=角色
|
||||
dao.bond.table.column.header.startDate=Started
|
||||
dao.bond.table.column.header.lockupTxId=Lockup Tx ID
|
||||
dao.bond.table.column.header.revokeDate=Revoked
|
||||
|
@ -17,19 +17,23 @@
|
||||
|
||||
package bisq.desktop.main.dao.bonding.bonds;
|
||||
|
||||
import bisq.desktop.components.AutoTooltipButton;
|
||||
import bisq.desktop.main.dao.bonding.BondingViewUtils;
|
||||
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.governance.bond.Bond;
|
||||
import bisq.core.dao.governance.bond.role.BondedRole;
|
||||
import bisq.core.dao.governance.bond.role.BondedRolesService;
|
||||
import bisq.core.dao.state.DaoStateListener;
|
||||
import bisq.core.dao.state.model.blockchain.Block;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.util.Utilities;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -47,10 +51,13 @@ class BondListItem implements DaoStateListener {
|
||||
private final BondedRolesService bondedRolesService;
|
||||
private final BondingViewUtils bondingViewUtils;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
private final String info;
|
||||
private final String bondType;
|
||||
private final String txId;
|
||||
private final String amount;
|
||||
private final String lockupDate;
|
||||
private final String lockTime;
|
||||
private final Label stateLabel;
|
||||
private final String bondDetails;
|
||||
|
||||
@Getter
|
||||
private Button button;
|
||||
@ -67,56 +74,30 @@ class BondListItem implements DaoStateListener {
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
|
||||
|
||||
info = bond.getBondedAsset().getDisplayString();
|
||||
txId = bond.getLockupTxId();
|
||||
amount = bsqFormatter.formatCoin(Coin.valueOf(bond.getAmount()));
|
||||
lockTime = bsqFormatter.formatDateTime(new Date(bond.getLockupDate()));
|
||||
|
||||
button = new AutoTooltipButton();
|
||||
button.setMinWidth(70);
|
||||
// label = new Label();
|
||||
/*
|
||||
daoFacade.addBsqStateListener(this);
|
||||
button.setOnAction(e -> {
|
||||
if (bondedRole.getBondState() == BondState.READY_FOR_LOCKUP) {
|
||||
bondingViewUtils.lockupBondForBondedRole(role,
|
||||
txId -> {
|
||||
bondedRole.setLockupTxId(txId);
|
||||
bondedRole.setBondState(BondState.LOCKUP_TX_PENDING);
|
||||
update();
|
||||
button.setDisable(true);
|
||||
});
|
||||
} else if (bondedRole.getBondState() == BondState.LOCKUP_TX_CONFIRMED) {
|
||||
bondingViewUtils.unLock(bondedRole.getLockupTxId(),
|
||||
txId -> {
|
||||
bondedRole.setUnlockTxId(txId);
|
||||
bondedRole.setBondState(BondState.UNLOCK_TX_PENDING);
|
||||
update();
|
||||
button.setDisable(true);
|
||||
});
|
||||
lockTime = Integer.toString(bond.getLockTime());
|
||||
if (bond instanceof BondedRole) {
|
||||
bondType = Res.get("dao.bond.bondedRoles");
|
||||
bondDetails = bond.getBondedAsset().getDisplayString();
|
||||
} else {
|
||||
bondType = Res.get("dao.bond.bondedReputation");
|
||||
bondDetails = Utilities.bytesAsHexString(bond.getBondedAsset().getHash());
|
||||
}
|
||||
});*/
|
||||
lockupDate = bsqFormatter.formatDateTime(new Date(bond.getLockupDate()));
|
||||
txId = bond.getLockupTxId();
|
||||
|
||||
stateLabel = new Label();
|
||||
|
||||
daoFacade.addBsqStateListener(this);
|
||||
update();
|
||||
}
|
||||
|
||||
private void update() {
|
||||
/* label.setText(Res.get("dao.bond.bondState." + bondedRole.getBondState().name()));
|
||||
|
||||
boolean showLockup = bondedRole.getBondState() == BondState.READY_FOR_LOCKUP;
|
||||
boolean showRevoke = bondedRole.getBondState() == BondState.LOCKUP_TX_CONFIRMED;
|
||||
if (showLockup)
|
||||
button.updateText(Res.get("dao.bond.table.button.lockup"));
|
||||
else if (showRevoke)
|
||||
button.updateText(Res.get("dao.bond.table.button.revoke"));
|
||||
|
||||
|
||||
boolean showButton = isMyRole && (showLockup || showRevoke);
|
||||
button.setVisible(showButton);
|
||||
button.setManaged(showButton);*/
|
||||
stateLabel.setText(Res.get("dao.bond.bondState." + bond.getBondState().name()));
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
// daoFacade.removeBsqStateListener(this);
|
||||
// button.setOnAction(null);
|
||||
daoFacade.removeBsqStateListener(this);
|
||||
}
|
||||
|
||||
// DaoStateListener
|
||||
|
@ -27,9 +27,7 @@
|
||||
AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="20.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints percentWidth="50"/>
|
||||
<ColumnConstraints minWidth="10" maxWidth="5"/>
|
||||
<ColumnConstraints percentWidth="50"/>
|
||||
<ColumnConstraints percentWidth="100"/>
|
||||
</columnConstraints>
|
||||
</GridPane>
|
||||
|
||||
|
@ -22,7 +22,6 @@ import bisq.desktop.common.view.FxmlView;
|
||||
import bisq.desktop.components.AutoTooltipTableColumn;
|
||||
import bisq.desktop.components.HyperlinkWithIcon;
|
||||
import bisq.desktop.main.dao.bonding.BondingViewUtils;
|
||||
import bisq.desktop.main.dao.wallet.BsqBalanceUtil;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.validation.BsqValidator;
|
||||
|
||||
@ -43,13 +42,12 @@ import javax.inject.Inject;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
|
||||
@ -59,19 +57,22 @@ import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
|
||||
import javafx.util.Callback;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
|
||||
|
||||
@FxmlView
|
||||
public class BondsView extends ActivatableView<GridPane, Void> implements BsqBalanceListener, DaoStateListener {
|
||||
private TableView<BondListItem> tableView;
|
||||
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
private final BsqBalanceUtil bsqBalanceUtil;
|
||||
private final BsqValidator bsqValidator;
|
||||
private final BondingViewUtils bondingViewUtils;
|
||||
private final BondedRolesService bondedRolesService;
|
||||
@ -81,6 +82,7 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
private int gridRow = 0;
|
||||
|
||||
private final ObservableList<BondListItem> observableList = FXCollections.observableArrayList();
|
||||
private final SortedList<BondListItem> sortedList = new SortedList<>(observableList);
|
||||
|
||||
private ListChangeListener<Transaction> walletBsqTransactionsListener;
|
||||
private ChangeListener<Number> walletChainHeightListener;
|
||||
@ -93,7 +95,6 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
@Inject
|
||||
private BondsView(BsqWalletService bsqWalletService,
|
||||
BsqFormatter bsqFormatter,
|
||||
BsqBalanceUtil bsqBalanceUtil,
|
||||
BsqValidator bsqValidator,
|
||||
BondingViewUtils bondingViewUtils,
|
||||
BondedRolesService bondedRolesService,
|
||||
@ -101,7 +102,6 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
Preferences preferences) {
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
this.bsqBalanceUtil = bsqBalanceUtil;
|
||||
this.bsqValidator = bsqValidator;
|
||||
this.bondingViewUtils = bondingViewUtils;
|
||||
this.bondedRolesService = bondedRolesService;
|
||||
@ -111,27 +111,21 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
gridRow = bsqBalanceUtil.addGroup(root, gridRow);
|
||||
addTitledGroupBg(root, gridRow, 2, Res.get("dao.bonding.bonds.table.header"));
|
||||
|
||||
tableView = new TableView<>();
|
||||
GridPane.setRowIndex(tableView, ++gridRow);
|
||||
GridPane.setMargin(tableView, new Insets(30, -10, 5, -10));
|
||||
root.getChildren().add(tableView);
|
||||
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
addColumns();
|
||||
|
||||
walletBsqTransactionsListener = change -> updateList();
|
||||
walletChainHeightListener = (observable, oldValue, newValue) -> updateList();
|
||||
|
||||
VBox vBox = new VBox();
|
||||
vBox.setSpacing(10);
|
||||
GridPane.setRowIndex(vBox, ++gridRow);
|
||||
GridPane.setColumnSpan(vBox, 3);
|
||||
GridPane.setMargin(vBox, new Insets(40, -10, 5, -10));
|
||||
vBox.getChildren().addAll(tableView);
|
||||
root.getChildren().add(vBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
bsqBalanceUtil.activate();
|
||||
bsqWalletService.addBsqBalanceListener(this);
|
||||
onUpdateBalances(bsqWalletService.getAvailableBalance(),
|
||||
bsqWalletService.getAvailableNonBsqBalance(),
|
||||
@ -144,7 +138,8 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
bsqWalletService.addBsqBalanceListener(this);
|
||||
bsqWalletService.getChainHeightProperty().addListener(walletChainHeightListener);
|
||||
|
||||
tableView.setItems(observableList);
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
tableView.setItems(sortedList);
|
||||
|
||||
daoFacade.addBsqStateListener(this);
|
||||
|
||||
@ -153,7 +148,6 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
bsqBalanceUtil.deactivate();
|
||||
bsqWalletService.removeBsqBalanceListener(this);
|
||||
|
||||
bsqWalletService.getWalletTransactions().removeListener(walletBsqTransactionsListener);
|
||||
@ -161,7 +155,9 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
bsqWalletService.getChainHeightProperty().removeListener(walletChainHeightListener);
|
||||
daoFacade.removeBsqStateListener(this);
|
||||
|
||||
// observableList.forEach(BondListItem::cleanup);
|
||||
sortedList.comparatorProperty().unbind();
|
||||
|
||||
observableList.forEach(BondListItem::cleanup);
|
||||
}
|
||||
|
||||
|
||||
@ -208,7 +204,7 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
List<BondListItem> items = daoFacade.getAllActiveBonds().stream()
|
||||
List<BondListItem> items = daoFacade.getAllBonds().stream()
|
||||
.map(bond -> {
|
||||
return new BondListItem(bond,
|
||||
daoFacade,
|
||||
@ -216,6 +212,7 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
bondingViewUtils,
|
||||
bsqFormatter);
|
||||
})
|
||||
.sorted(Comparator.comparing(BondListItem::getLockupDate).reversed())
|
||||
.collect(Collectors.toList());
|
||||
observableList.setAll(items);
|
||||
GUIUtil.setFitToRowsForTableView(tableView, 37, 28, 2, 10);
|
||||
@ -229,43 +226,13 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
private void addColumns() {
|
||||
TableColumn<BondListItem, BondListItem> column;
|
||||
|
||||
column = new AutoTooltipTableColumn<>(Res.get("dao.bonding.unlock.hash"));
|
||||
column.setMinWidth(160);
|
||||
column.setMaxWidth(column.getMinWidth());
|
||||
|
||||
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
column.setCellFactory(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public TableCell<BondListItem, BondListItem> call(TableColumn<BondListItem,
|
||||
BondListItem> column) {
|
||||
return new TableCell<>() {
|
||||
|
||||
@Override
|
||||
public void updateItem(final BondListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
setText(item.getInfo());
|
||||
} else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
|
||||
column = new AutoTooltipTableColumn<>(Res.get("shared.amountWithCur", "BSQ"));
|
||||
column.setMinWidth(120);
|
||||
column.setMaxWidth(column.getMinWidth());
|
||||
|
||||
column.setMinWidth(80);
|
||||
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
column.setCellFactory(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public TableCell<BondListItem, BondListItem> call(TableColumn<BondListItem,
|
||||
BondListItem> column) {
|
||||
public TableCell<BondListItem, BondListItem> call(TableColumn<BondListItem, BondListItem> column) {
|
||||
return new TableCell<>() {
|
||||
|
||||
@Override
|
||||
public void updateItem(final BondListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
@ -277,25 +244,115 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
tableView.getColumns().add(column);
|
||||
|
||||
column = new AutoTooltipTableColumn<>(Res.get("dao.bonding.unlock.time"));
|
||||
column.setMinWidth(140);
|
||||
column.setMaxWidth(column.getMinWidth());
|
||||
|
||||
column = new AutoTooltipTableColumn<>(Res.get("dao.bond.table.column.header.lockTime"));
|
||||
column.setMinWidth(40);
|
||||
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
column.setCellFactory(new Callback<>() {
|
||||
@Override
|
||||
public TableCell<BondListItem, BondListItem> call(TableColumn<BondListItem, BondListItem> column) {
|
||||
return new TableCell<>() {
|
||||
@Override
|
||||
public void updateItem(final BondListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
setText(item.getLockTime());
|
||||
} else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
|
||||
column = new AutoTooltipTableColumn<>(Res.get("dao.bond.table.column.header.bondState"));
|
||||
column.setCellValueFactory(item -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
column.setMinWidth(80);
|
||||
column.setCellFactory(
|
||||
new Callback<>() {
|
||||
@Override
|
||||
public TableCell<BondListItem, BondListItem> call(TableColumn<BondListItem,
|
||||
BondListItem> column) {
|
||||
return new TableCell<>() {
|
||||
Label label;
|
||||
|
||||
@Override
|
||||
public void updateItem(final BondListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
if (label == null) {
|
||||
label = item.getStateLabel();
|
||||
setGraphic(label);
|
||||
}
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (label != null)
|
||||
label = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
|
||||
column = new AutoTooltipTableColumn<>(Res.get("dao.bond.table.column.header.bondType"));
|
||||
column.setMinWidth(100);
|
||||
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
column.setCellFactory(new Callback<>() {
|
||||
@Override
|
||||
public TableCell<BondListItem, BondListItem> call(TableColumn<BondListItem, BondListItem> column) {
|
||||
return new TableCell<>() {
|
||||
|
||||
@Override
|
||||
public void updateItem(final BondListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
setText(item.getLockTime());
|
||||
setText(item.getBondType());
|
||||
} else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
|
||||
column = new AutoTooltipTableColumn<>(Res.get("dao.bond.table.column.header.details"));
|
||||
column.setMinWidth(100);
|
||||
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
column.setCellFactory(new Callback<>() {
|
||||
@Override
|
||||
public TableCell<BondListItem, BondListItem> call(TableColumn<BondListItem, BondListItem> column) {
|
||||
return new TableCell<>() {
|
||||
|
||||
@Override
|
||||
public void updateItem(final BondListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
setText(item.getBondDetails());
|
||||
} else
|
||||
setText("");
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
|
||||
column = new AutoTooltipTableColumn<>(Res.get("dao.bond.table.column.header.lockupDate"));
|
||||
column.setMinWidth(140);
|
||||
|
||||
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
column.setCellFactory(new Callback<>() {
|
||||
|
||||
@Override
|
||||
public TableCell<BondListItem, BondListItem> call(TableColumn<BondListItem, BondListItem> column) {
|
||||
return new TableCell<>() {
|
||||
@Override
|
||||
public void updateItem(final BondListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
setText(item.getLockupDate());
|
||||
} else
|
||||
setText("");
|
||||
}
|
||||
@ -337,36 +394,5 @@ public class BondsView extends ActivatableView<GridPane, Void> implements BsqBal
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
|
||||
column = new TableColumn<>();
|
||||
column.setCellValueFactory(item -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
column.setMinWidth(80);
|
||||
column.setCellFactory(
|
||||
new Callback<>() {
|
||||
@Override
|
||||
public TableCell<BondListItem, BondListItem> call(TableColumn<BondListItem,
|
||||
BondListItem> column) {
|
||||
return new TableCell<>() {
|
||||
Button button;
|
||||
|
||||
@Override
|
||||
public void updateItem(final BondListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
if (button == null) {
|
||||
button = item.getButton();
|
||||
setGraphic(button);
|
||||
}
|
||||
} else {
|
||||
setGraphic(null);
|
||||
if (button != null)
|
||||
button = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ import javafx.beans.value.ChangeListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
|
||||
import javafx.util.Callback;
|
||||
|
||||
@ -100,6 +101,7 @@ public class MyBondedReputationView extends ActivatableView<GridPane, Void> impl
|
||||
private ChangeListener<Boolean> amountFocusOutListener, timeFocusOutListener, saltFocusOutListener;
|
||||
private ChangeListener<String> amountInputTextFieldListener, timeInputTextFieldListener, saltInputTextFieldListener;
|
||||
private final ObservableList<MyBondedReputationListItem> observableList = FXCollections.observableArrayList();
|
||||
private final SortedList<MyBondedReputationListItem> sortedList = new SortedList<>(observableList);
|
||||
private ListChangeListener<Transaction> walletBsqTransactionsListener;
|
||||
private ChangeListener<Number> walletChainHeightListener;
|
||||
|
||||
@ -190,7 +192,8 @@ public class MyBondedReputationView extends ActivatableView<GridPane, Void> impl
|
||||
timeInputTextField.resetValidation();
|
||||
setNewRandomSalt();
|
||||
|
||||
tableView.setItems(observableList);
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
tableView.setItems(sortedList);
|
||||
|
||||
onUpdateBalances();
|
||||
updateList();
|
||||
@ -215,6 +218,8 @@ public class MyBondedReputationView extends ActivatableView<GridPane, Void> impl
|
||||
|
||||
lockupButton.setOnAction(null);
|
||||
|
||||
sortedList.comparatorProperty().unbind();
|
||||
|
||||
daoFacade.removeBsqStateListener(this);
|
||||
}
|
||||
|
||||
@ -291,6 +296,7 @@ public class MyBondedReputationView extends ActivatableView<GridPane, Void> impl
|
||||
|
||||
tableView = new TableView<>();
|
||||
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
createColumns();
|
||||
|
||||
VBox vBox = new VBox();
|
||||
|
@ -22,9 +22,7 @@ import bisq.desktop.common.view.FxmlView;
|
||||
import bisq.desktop.components.AutoTooltipLabel;
|
||||
import bisq.desktop.components.AutoTooltipTableColumn;
|
||||
import bisq.desktop.components.HyperlinkWithIcon;
|
||||
import bisq.desktop.components.TableGroupHeadline;
|
||||
import bisq.desktop.main.dao.bonding.BondingViewUtils;
|
||||
import bisq.desktop.main.dao.wallet.BsqBalanceUtil;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.dao.DaoFacade;
|
||||
@ -60,6 +58,8 @@ import javafx.util.Callback;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
|
||||
|
||||
@FxmlView
|
||||
public class BondedRolesView extends ActivatableView<GridPane, Void> implements DaoStateListener {
|
||||
private TableView<BondedRolesListItem> tableView;
|
||||
@ -79,7 +79,6 @@ public class BondedRolesView extends ActivatableView<GridPane, Void> implements
|
||||
|
||||
@Inject
|
||||
private BondedRolesView(BsqFormatter bsqFormatter,
|
||||
BsqBalanceUtil bsqBalanceUtil,
|
||||
BondingViewUtils bondingViewUtils,
|
||||
DaoFacade daoFacade,
|
||||
Preferences preferences) {
|
||||
@ -91,31 +90,23 @@ public class BondedRolesView extends ActivatableView<GridPane, Void> implements
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
TableGroupHeadline headline = new TableGroupHeadline(Res.get("dao.bond.table.header"));
|
||||
int gridRow = 0;
|
||||
GridPane.setRowIndex(headline, gridRow);
|
||||
GridPane.setMargin(headline, new Insets(0, -10, -10, -10));
|
||||
GridPane.setColumnSpan(headline, 2);
|
||||
root.getChildren().add(headline);
|
||||
addTitledGroupBg(root, gridRow, 2, Res.get("dao.bond.bondedRoles"));
|
||||
|
||||
tableView = new TableView<>();
|
||||
GridPane.setRowIndex(tableView, ++gridRow);
|
||||
GridPane.setMargin(tableView, new Insets(30, -10, 5, -10));
|
||||
root.getChildren().add(tableView);
|
||||
tableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
|
||||
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
|
||||
createColumns();
|
||||
|
||||
GridPane.setRowIndex(tableView, gridRow);
|
||||
GridPane.setMargin(tableView, new Insets(20, -10, 5, -10));
|
||||
GridPane.setColumnSpan(tableView, 2);
|
||||
root.getChildren().add(tableView);
|
||||
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
tableView.setItems(sortedList);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void activate() {
|
||||
daoFacade.addBsqStateListener(this);
|
||||
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
|
||||
|
||||
updateList();
|
||||
}
|
||||
@ -123,6 +114,7 @@ public class BondedRolesView extends ActivatableView<GridPane, Void> implements
|
||||
@Override
|
||||
protected void deactivate() {
|
||||
daoFacade.removeBsqStateListener(this);
|
||||
sortedList.comparatorProperty().unbind();
|
||||
|
||||
observableList.forEach(BondedRolesListItem::cleanup);
|
||||
}
|
||||
@ -226,7 +218,7 @@ public class BondedRolesView extends ActivatableView<GridPane, Void> implements
|
||||
});
|
||||
tableView.getColumns().add(column);
|
||||
|
||||
column = new AutoTooltipTableColumn<>(Res.get("dao.bond.table.column.header.bondedRoleType"));
|
||||
column = new AutoTooltipTableColumn<>(Res.get("dao.bond.table.column.header.bondType"));
|
||||
column.setCellValueFactory(item -> new ReadOnlyObjectWrapper<>(item.getValue()));
|
||||
column.setMinWidth(80);
|
||||
column.setCellFactory(
|
||||
|
@ -305,7 +305,7 @@ public class ProposalDisplay {
|
||||
comboBoxValueTextFieldIndex = gridRow;
|
||||
checkNotNull(confiscateBondComboBox, "confiscateBondComboBox must not be null");
|
||||
|
||||
confiscateBondComboBox.setItems(FXCollections.observableArrayList(daoFacade.getAllActiveBonds()));
|
||||
confiscateBondComboBox.setItems(FXCollections.observableArrayList(daoFacade.getAllBonds()));
|
||||
confiscateBondComboBox.setConverter(new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(Bond bond) {
|
||||
|
Loading…
Reference in New Issue
Block a user