|
|
@ -23,12 +23,16 @@ import java.util.List; |
|
|
|
public class SearchWalletDialog extends Dialog<Entry> { |
|
|
|
private static final Logger log = LoggerFactory.getLogger(SearchWalletDialog.class); |
|
|
|
|
|
|
|
private final WalletForm walletForm; |
|
|
|
private final List<WalletForm> walletForms; |
|
|
|
private final TextField search; |
|
|
|
private final CoinTreeTable results; |
|
|
|
|
|
|
|
public SearchWalletDialog(WalletForm walletForm) { |
|
|
|
this.walletForm = walletForm; |
|
|
|
public SearchWalletDialog(List<WalletForm> walletForms) { |
|
|
|
this.walletForms = walletForms; |
|
|
|
|
|
|
|
if(walletForms.isEmpty()) { |
|
|
|
throw new IllegalArgumentException("No wallets selected to search"); |
|
|
|
} |
|
|
|
|
|
|
|
final DialogPane dialogPane = getDialogPane(); |
|
|
|
dialogPane.getStylesheets().add(AppServices.class.getResource("general.css").toExternalForm()); |
|
|
@ -65,11 +69,19 @@ public class SearchWalletDialog extends Dialog<Entry> { |
|
|
|
|
|
|
|
results = new CoinTreeTable(); |
|
|
|
results.setShowRoot(false); |
|
|
|
results.setPrefWidth(850); |
|
|
|
results.setBitcoinUnit(walletForm.getWallet()); |
|
|
|
results.setPrefWidth(walletForms.size() > 1 ? 950 : 850); |
|
|
|
results.setBitcoinUnit(walletForms.iterator().next().getWallet()); |
|
|
|
results.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY); |
|
|
|
results.setPlaceholder(new Label("No results")); |
|
|
|
|
|
|
|
if(walletForms.size() > 1) { |
|
|
|
TreeTableColumn<Entry, String> walletColumn = new TreeTableColumn<>("Wallet"); |
|
|
|
walletColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<Entry, String> param) -> { |
|
|
|
return new ReadOnlyObjectWrapper<>(param.getValue().getValue().getWallet().getDisplayName()); |
|
|
|
}); |
|
|
|
results.getColumns().add(walletColumn); |
|
|
|
} |
|
|
|
|
|
|
|
TreeTableColumn<Entry, String> typeColumn = new TreeTableColumn<>("Type"); |
|
|
|
typeColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures<Entry, String> param) -> { |
|
|
|
return new ReadOnlyObjectWrapper<>(param.getValue().getValue().getEntryType()); |
|
|
@ -81,10 +93,8 @@ public class SearchWalletDialog extends Dialog<Entry> { |
|
|
|
return new ReadOnlyObjectWrapper<>(param.getValue().getValue()); |
|
|
|
}); |
|
|
|
entryCol.setCellFactory(p -> new SearchEntryCell()); |
|
|
|
String address = walletForm.getNodeEntry(KeyPurpose.RECEIVE).getAddress().toString(); |
|
|
|
if(address != null) { |
|
|
|
String address = walletForms.iterator().next().getNodeEntry(KeyPurpose.RECEIVE).getAddress().toString(); |
|
|
|
entryCol.setMinWidth(TextUtils.computeTextWidth(AppServices.getMonospaceFont(), address, 0.0)); |
|
|
|
} |
|
|
|
results.getColumns().add(entryCol); |
|
|
|
|
|
|
|
TreeTableColumn<Entry, String> labelCol = new TreeTableColumn<>("Label"); |
|
|
@ -138,6 +148,7 @@ public class SearchWalletDialog extends Dialog<Entry> { |
|
|
|
//ignore
|
|
|
|
} |
|
|
|
|
|
|
|
for(WalletForm walletForm : walletForms) { |
|
|
|
WalletTransactionsEntry walletTransactionsEntry = walletForm.getWalletTransactionsEntry(); |
|
|
|
for(Entry entry : walletTransactionsEntry.getChildren()) { |
|
|
|
if(entry instanceof TransactionEntry transactionEntry) { |
|
|
@ -173,8 +184,9 @@ public class SearchWalletDialog extends Dialog<Entry> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SearchWalletEntry rootEntry = new SearchWalletEntry(walletForm.getWallet(), matchingEntries); |
|
|
|
SearchWalletEntry rootEntry = new SearchWalletEntry(walletForms.iterator().next().getWallet(), matchingEntries); |
|
|
|
RecursiveTreeItem<Entry> rootItem = new RecursiveTreeItem<>(rootEntry, Entry::getChildren); |
|
|
|
results.setRoot(rootItem); |
|
|
|
} |
|
|
|