changeset 6162:cf90e9eb59f0

RT-35267: [TableView] TableView Column Table header arrow not consistent when hiding columns (redraw over each other)
author jgiles
date Wed, 22 Jan 2014 11:02:01 +1300
parents 8cc418ec16a0
children e46275203449
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableColumnHeader.java
diffstat 1 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableColumnHeader.java	Tue Jan 21 16:01:28 2014 +1300
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableColumnHeader.java	Wed Jan 22 11:02:01 2014 +1300
@@ -552,7 +552,7 @@
         int visibleLeafIndex = skin.getVisibleLeafIndex(getTableColumn());
         if (visibleLeafIndex == -1) return;
         
-        final int sortColumnCount = getSortColumnCount();
+        final int sortColumnCount = getVisibleSortOrderColumnCount();
         boolean showSortOrderDots = sortPos <= 3 && sortColumnCount > 1;
         
         Node _sortArrow = null;
@@ -636,7 +636,7 @@
         }
         
         sortOrderDots.getChildren().clear();
-        
+
         for (int i = 0; i <= sortPos; i++) {
             Region r = new Region();
             r.getStyleClass().add("sort-order-dot");
@@ -771,14 +771,10 @@
             return -1;
         }
 
-        final ObservableList<TableColumnBase> sortOrder = getTableViewSkin().getSortOrder();
-
+        final List<TableColumnBase> sortOrder = getVisibleSortOrderColumns();
         int pos = 0;
         for (int i = 0; i < sortOrder.size(); i++) {
             TableColumnBase _tc = sortOrder.get(i);
-            if (_tc == null || ! _tc.isSortable() || ! _tc.isVisible()) {
-                continue;
-            }
 
             if (column.equals(_tc)) {
                 return pos;
@@ -786,25 +782,31 @@
 
             pos++;
         }
+
         return -1;
     }
 
+    private List<TableColumnBase> getVisibleSortOrderColumns() {
+        final ObservableList<TableColumnBase> sortOrder = getTableViewSkin().getSortOrder();
+
+        List<TableColumnBase> visibleSortOrderColumns = new ArrayList<>();
+        for (int i = 0; i < sortOrder.size(); i++) {
+            TableColumnBase _tc = sortOrder.get(i);
+            if (_tc == null || ! _tc.isSortable() || ! _tc.isVisible()) {
+                continue;
+            }
+
+            visibleSortOrderColumns.add(_tc);
+        }
+
+        return visibleSortOrderColumns;
+    }
+
     // as with getSortPosition above, this method iterates through the sortOrder
     // list ignoring the null and non-sortable columns, so that we get the correct
     // number of columns in the sortOrder list.
-    private int getSortColumnCount() {
-        final ObservableList<TableColumnBase> sortOrder = getTableViewSkin().getSortOrder();
-
-        int pos = 0;
-        for (int i = 0; i < sortOrder.size(); i++) {
-            TableColumnBase _tc = sortOrder.get(i);
-            if (_tc == null || ! _tc.isSortable()) {
-                continue;
-            }
-
-            pos++;
-        }
-        return pos;
+    private int getVisibleSortOrderColumnCount() {
+        return getVisibleSortOrderColumns().size();
     }