X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Ftechtype%2Ftable%2FTechTypeTableSortModel.java;fp=org.simantics.district.network.ui%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2Fui%2Ftechtype%2Ftable%2FTechTypeTableSortModel.java;h=95c9008e48336d2b8320acbc3c674279be07e529;hb=3424ba8b4dd8e368badce8515bca96a99be518f4;hp=f6a02f4a6c8990e5ac3eed2673f548905b73546e;hpb=b84a03e5c4452c82c718644423373c0d7e2a1e62;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTableSortModel.java b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTableSortModel.java index f6a02f4a..95c9008e 100644 --- a/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTableSortModel.java +++ b/org.simantics.district.network.ui/src/org/simantics/district/network/ui/techtype/table/TechTypeTableSortModel.java @@ -13,21 +13,6 @@ import org.simantics.utils.strings.AlphanumComparator; public class TechTypeTableSortModel implements ISortModel { - private static final SortDirectionEnum[] NO_DIRECTIONS = {}; - private static final boolean[] NO_BOOLEANS = {}; - - /** - * Array that contains the sort direction for every column. - * Needed to access the current sort state of a column. - */ - protected SortDirectionEnum[] sortDirections = NO_DIRECTIONS; - - /** - * Array that contains the sorted flags for every column. - * Needed to access the current sort state of a column. - */ - protected boolean[] sorted = NO_BOOLEANS; - /** * As this implementation only supports single column sorting, * this property contains the the column index of the column that @@ -61,16 +46,12 @@ public class TechTypeTableSortModel implements ISortModel { @Override public boolean isColumnIndexSorted(int columnIndex) { - if (sorted.length <= columnIndex) - return false; - return sorted[columnIndex]; + return columnIndex == currentSortColumn && !currentSortDirection.equals(SortDirectionEnum.NONE); } @Override public SortDirectionEnum getSortDirection(int columnIndex) { - if (sortDirections.length <= columnIndex) - return SortDirectionEnum.NONE; - return sortDirections[columnIndex]; + return columnIndex == currentSortColumn ? currentSortDirection : SortDirectionEnum.NONE; } @Override @@ -79,6 +60,7 @@ public class TechTypeTableSortModel implements ISortModel { } @Override + @SuppressWarnings("rawtypes") public List getComparatorsForColumnIndex(int columnIndex) { return Collections.singletonList(AlphanumComparator.COMPARATOR); } @@ -94,20 +76,15 @@ public class TechTypeTableSortModel implements ISortModel { if (!isColumnIndexSorted(columnIndex)) { clear(); } - int columnCount = bodyDataProvider.getColumnCount(); - sortDirections = ensureArraySize(sortDirections, columnCount, SortDirectionEnum.class, SortDirectionEnum.NONE); - - sortDirections[columnIndex] = sortDirection; - sorted[columnIndex] = !sortDirection.equals(SortDirectionEnum.NONE); currentSortColumn = columnIndex; currentSortDirection = sortDirection; + + bodyDataProvider.sortBy(columnIndex, sortDirection); } @Override public void clear() { - Arrays.fill(this.sortDirections, SortDirectionEnum.NONE); - Arrays.fill(this.sorted, false); this.currentSortColumn = -1; this.currentSortDirection = SortDirectionEnum.NONE; }