diff --git a/platform/platform-api/src/com/intellij/ui/table/TableView.java b/platform/platform-api/src/com/intellij/ui/table/TableView.java index 8f9f07fb41fb..a563c820f815 100644 --- a/platform/platform-api/src/com/intellij/ui/table/TableView.java +++ b/platform/platform-api/src/com/intellij/ui/table/TableView.java @@ -199,17 +199,21 @@ public class TableView extends BaseTableView implements ItemsProvider, Sel @NotNull public List getSelectedObjects() { - final int[] selectedRows = getSelectedRows(); - if (selectedRows == null || selectedRows.length == 0) { + ListSelectionModel selectionModel = getSelectionModel(); + int minSelectionIndex = selectionModel.getMinSelectionIndex(); + int maxSelectionIndex = selectionModel.getMaxSelectionIndex(); + if (minSelectionIndex == -1 || maxSelectionIndex == -1) { return Collections.emptyList(); } List result = new SmartList(); ListTableModel model = getListTableModel(); - for (int selectedRow : selectedRows) { - int modelIndex = convertRowIndexToModel(selectedRow); - if (modelIndex >= 0 && modelIndex < model.getRowCount()) { - result.add(model.getRowValue(modelIndex)); + for (int i = minSelectionIndex; i <= maxSelectionIndex; i++) { + if (selectionModel.isSelectedIndex(i)) { + int modelIndex = convertRowIndexToModel(i); + if (modelIndex >= 0 && modelIndex < model.getRowCount()) { + result.add(model.getRowValue(modelIndex)); + } } } return result; diff --git a/platform/util/src/com/intellij/ui/TableUtil.java b/platform/util/src/com/intellij/ui/TableUtil.java index 0b352e1a440c..28aa8d96e24c 100644 --- a/platform/util/src/com/intellij/ui/TableUtil.java +++ b/platform/util/src/com/intellij/ui/TableUtil.java @@ -105,14 +105,15 @@ public class TableUtil { } ListSelectionModel selectionModel = table.getSelectionModel(); - if (selectionModel.isSelectionEmpty()) { + int minSelectionIndex = selectionModel.getMinSelectionIndex(); + int maxSelectionIndex = selectionModel.getMaxSelectionIndex(); + if (minSelectionIndex == -1 || maxSelectionIndex == -1) { return false; } - int minSelectionIndex = selectionModel.getMinSelectionIndex(); TableModel model = table.getModel(); boolean removed = false; - for (int index = table.getRowCount() - 1; index >= 0; index--) { + for (int index = maxSelectionIndex; index >= 0; index--) { if (selectionModel.isSelectedIndex(index) && (applyable == null || applyable.isOperationApplyable(model, index))) { itemRemovable.removeRow(index); removed = true; @@ -127,7 +128,7 @@ public class TableUtil { if (count == 0) { table.clearSelection(); } - else if (table.getSelectedRow() == -1) { + else if (selectionModel.getMinSelectionIndex() == -1) { if (minSelectionIndex >= model.getRowCount()) { selectionModel.setSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1); }