void (HistoryDialogModel model) { Set<Long> sel = new HashSet<>(); TableModel tm = table.getModel(); for (int i : table.getSelectedRows()) { if (i >= tm.getRowCount()) continue; sel.add(((RevisionItem)tm.getValueAt(i, 0)).revision.getChangeSetId()); } List<RevisionItem> newRevs = model.getRevisions(); Date today = new Date(); Map<RevisionItem, Period> periods = new HashMap<>(); for (int i = 0; i < newRevs.size(); i++) { RevisionItem each = newRevs.get(i); boolean recent = today.getTime() - each.revision.getTimestamp() < 1000 * 60 * 60 * RECENT_PERIOD; if (recent) { if (i == 0) { periods.put(each, Period.RECENT); } } else { periods.put(each, periods.isEmpty() ? Period.OLD : Period.OLDER); break; } } setModel(new MyModel(newRevs, periods)); FilteringTableModel<?> fm = getFilteringModel(); for (int i = 0; i < fm.getRowCount(); i++) { RevisionItem r = (RevisionItem)fm.getValueAt(i, 0); if (sel.contains(r.revision.getChangeSetId())) { table.getSelectionModel().addSelectionInterval(i, i); } } if (table.getSelectionModel().isSelectionEmpty()) { table.getSelectionModel().addSelectionInterval(0, 0); } }