# HG changeset patch # User ssadetsky # Date 1458894572 -10800 # Node ID f790ef973830fe22c1bb386028747ca3c4127705 # Parent bac425909021e75646f679b75c2269caa08bd089 8078514: Nightly: api/javax_swing/DefaultRowSorter/index_ModelStructChanged failure Reviewed-by: alexsch diff -r bac425909021 -r f790ef973830 jdk/src/java.desktop/share/classes/javax/swing/DefaultRowSorter.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 RowSorter 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); } /** diff -r bac425909021 -r f790ef973830 jdk/src/java.desktop/share/classes/javax/swing/JTable.java --- 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 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 diff -r bac425909021 -r f790ef973830 jdk/src/java.desktop/share/classes/sun/swing/FilePane.java --- 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 { 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) {