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