use of com.intellij.history.integration.ui.models.RevisionItem in project intellij-community by JetBrains.
the class RevisionsList method updateData.
public void updateData(HistoryDialogModel model) {
Set<Long> sel = new THashSet<>();
MyModel m = (MyModel) table.getModel();
for (int i : table.getSelectedRows()) {
if (i >= m.getRowCount())
continue;
sel.add(m.getValueAt(i, 0).revision.getChangeSetId());
}
List<RevisionItem> newRevs = model.getRevisions();
Date today = new Date();
Map<RevisionItem, Period> periods = new THashMap<>();
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;
}
}
table.setModel(new MyModel(newRevs, periods));
for (int i = 0; i < newRevs.size(); i++) {
RevisionItem r = newRevs.get(i);
if (sel.contains(r.revision.getChangeSetId())) {
table.getSelectionModel().addSelectionInterval(i, i);
}
}
if (table.getSelectionModel().isSelectionEmpty()) {
table.getSelectionModel().addSelectionInterval(0, 0);
}
}
Aggregations