From b2c362d5a71b8c46f8990a6b6b9b96f81ee24c90 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 28 Jan 2025 12:52:52 +0200 Subject: [PATCH] store treetable column sort on adjustment, and restore on wallet load --- .../drongo/wallet/SortDirection.java | 5 ++++ .../drongo/wallet/WalletTable.java | 27 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/sparrowwallet/drongo/wallet/SortDirection.java diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/SortDirection.java b/src/main/java/com/sparrowwallet/drongo/wallet/SortDirection.java new file mode 100644 index 0000000..ecb054d --- /dev/null +++ b/src/main/java/com/sparrowwallet/drongo/wallet/SortDirection.java @@ -0,0 +1,5 @@ +package com.sparrowwallet.drongo.wallet; + +public enum SortDirection { + ASCENDING, DESCENDING +} diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/WalletTable.java b/src/main/java/com/sparrowwallet/drongo/wallet/WalletTable.java index 68afc2c..8c9098f 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/WalletTable.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/WalletTable.java @@ -3,10 +3,21 @@ package com.sparrowwallet.drongo.wallet; public class WalletTable extends Persistable { private final TableType tableType; private final Double[] widths; + private final int sortColumn; + private final SortDirection sortDirection; - public WalletTable(TableType tableType, Double[] widths) { + public WalletTable(TableType tableType, Double[] widths, int sortColumn, SortDirection sortDirection) { this.tableType = tableType; this.widths = widths; + this.sortColumn = sortColumn; + this.sortDirection = sortDirection; + } + + public WalletTable(TableType tableType, Double[] widths, Sort sort) { + this.tableType = tableType; + this.widths = widths; + this.sortColumn = sort.sortColumn; + this.sortDirection = sort.sortDirection; } public TableType getTableType() { @@ -17,6 +28,18 @@ public class WalletTable extends Persistable { return widths; } + public int getSortColumn() { + return sortColumn; + } + + public SortDirection getSortDirection() { + return sortDirection; + } + + public Sort getSort() { + return new Sort(sortColumn, sortDirection); + } + @Override public final boolean equals(Object o) { if(this == o) { @@ -33,4 +56,6 @@ public class WalletTable extends Persistable { public int hashCode() { return tableType.hashCode(); } + + public record Sort(int sortColumn, SortDirection sortDirection) {} }