8078514: Nightly: api/javax_swing/DefaultRowSorter/index_ModelStructChanged failure
authorssadetsky
Fri, 25 Mar 2016 11:29:32 +0300
changeset 36914 f790ef973830
parent 36913 bac425909021
child 36915 2258afe73d4c
8078514: Nightly: api/javax_swing/DefaultRowSorter/index_ModelStructChanged failure Reviewed-by: alexsch
jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java
jdk/src/java.desktop/share/classes/javax/swing/JTable.java
jdk/src/java.desktop/share/classes/sun/swing/FilePane.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java	Thu Mar 24 13:27:44 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java	Fri Mar 25 11:29:32 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
-import javax.swing.SortOrder;
 
 /**
  * An implementation of <code>RowSorter</code> that provides sorting and
@@ -495,7 +494,7 @@
      */
     public int convertRowIndexToView(int index) {
         if (modelToView == null) {
-            if (index < 0 || index >= getModelWrapper().getRowCount()) {
+            if (index < 0 || index >= modelRowCount) {
                 throw new IndexOutOfBoundsException("Invalid index");
             }
             return index;
@@ -510,7 +509,7 @@
      */
     public int convertRowIndexToModel(int index) {
         if (viewToModel == null) {
-            if (index < 0 || index >= getModelWrapper().getRowCount()) {
+            if (index < 0 || index >= modelRowCount) {
                 throw new IndexOutOfBoundsException("Invalid index");
             }
             return index;
@@ -814,7 +813,7 @@
             // When filtering this may differ from getModelWrapper().getRowCount()
             return viewToModel.length;
         }
-        return getModelWrapper().getRowCount();
+        return Math.max(getModelWrapper().getRowCount(), modelRowCount);
     }
 
     /**
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java	Thu Mar 24 13:27:44 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java	Fri Mar 25 11:29:32 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -4401,13 +4401,8 @@
         }
 
         if (sortManager != null) {
-            List<? extends RowSorter.SortKey> sortKeys =
-                    sortManager.sorter.getSortKeys();
-            if (sortKeys.size() != 0 &&
-                    sortKeys.get(0).getSortOrder() != SortOrder.UNSORTED) {
-                sortedTableChanged(null, e);
-                return;
-            }
+            sortedTableChanged(null, e);
+            return;
         }
 
         // The totalRowHeight calculated below will be incorrect if
--- a/jdk/src/java.desktop/share/classes/sun/swing/FilePane.java	Thu Mar 24 13:27:44 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/swing/FilePane.java	Fri Mar 25 11:29:32 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -913,7 +913,15 @@
 
     private class DetailsTableRowSorter extends TableRowSorter<TableModel> {
         public DetailsTableRowSorter() {
-            setModelWrapper(new SorterModelWrapper());
+            SorterModelWrapper modelWrapper = new SorterModelWrapper();
+            setModelWrapper(modelWrapper);
+            modelWrapper.getModel().addTableModelListener(
+                new TableModelListener() {
+                    @Override
+                    public void tableChanged(TableModelEvent e) {
+                        modelStructureChanged();
+                    }
+                });
         }
 
         public void updateComparators(ShellFolderColumnInfo [] columns) {