void () { TableCellEditor editor = myTable.getCellEditor(); if (editor != null) editor.cancelCellEditing(); int[] rows = myTable.getSelectedRows(); int firstRow = rows[0]; Object[] keys = new Object[rows.length]; for (int i = 0; i < rows.length; i++) { keys[i] = myModel.data.get(myTable.convertRowIndexToModel(rows[i])).first; } if (clearSubdirectoriesOnDemandOrCancel(true, keys) == Messages.YES) { int toSelect = Math.min(myModel.data.size() - 1, firstRow); if (toSelect >= 0) { selectRows(new int[]{toSelect}, false); } } }