mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] update details & changes later for faster keyboard scrolling
When user moves through the table with arrows, each time selection is deleted and than added at a new row. To avoid updating details and changes twice each key press, update them later with expiring condition.
This commit is contained in:
+15
-8
@@ -16,6 +16,7 @@
|
||||
package com.intellij.vcs.log.ui.frame;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
@@ -36,6 +37,7 @@ public abstract class CommitSelectionListener implements ListSelectionListener {
|
||||
@NotNull private final VcsLogGraphTable myGraphTable;
|
||||
@NotNull private final JBLoadingPanel myLoadingPanel;
|
||||
|
||||
@Nullable private ListSelectionEvent myLastEvent;
|
||||
@Nullable private ProgressIndicator myLastRequest;
|
||||
|
||||
protected CommitSelectionListener(@NotNull VcsLogData data, @NotNull VcsLogGraphTable table, @NotNull JBLoadingPanel panel) {
|
||||
@@ -48,9 +50,14 @@ public abstract class CommitSelectionListener implements ListSelectionListener {
|
||||
public void valueChanged(@Nullable ListSelectionEvent event) {
|
||||
if (event != null && event.getValueIsAdjusting()) return;
|
||||
|
||||
myLastEvent = event;
|
||||
if (myLastRequest != null) myLastRequest.cancel();
|
||||
myLastRequest = null;
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(this::processEvent, o -> myLastEvent != event);
|
||||
}
|
||||
|
||||
public void processEvent() {
|
||||
int rows = myGraphTable.getSelectedRowCount();
|
||||
if (rows < 1) {
|
||||
myLoadingPanel.stopLoading();
|
||||
@@ -66,14 +73,14 @@ public abstract class CommitSelectionListener implements ListSelectionListener {
|
||||
List<Integer> selectionToLoad = getSelectionToLoad();
|
||||
myLogData.getCommitDetailsGetter()
|
||||
.loadCommitsData(myGraphTable.getModel().convertToCommitIds(selectionToLoad), detailsList -> {
|
||||
if (myLastRequest == indicator && !(indicator.isCanceled())) {
|
||||
LOG.assertTrue(selectionToLoad.size() == detailsList.size(),
|
||||
"Loaded incorrect number of details " + detailsList + " for selection " + selectionToLoad);
|
||||
myLastRequest = null;
|
||||
onDetailsLoaded(detailsList);
|
||||
myLoadingPanel.stopLoading();
|
||||
}
|
||||
}, indicator);
|
||||
if (myLastRequest == indicator && !(indicator.isCanceled())) {
|
||||
LOG.assertTrue(selectionToLoad.size() == detailsList.size(),
|
||||
"Loaded incorrect number of details " + detailsList + " for selection " + selectionToLoad);
|
||||
myLastRequest = null;
|
||||
onDetailsLoaded(detailsList);
|
||||
myLoadingPanel.stopLoading();
|
||||
}
|
||||
}, indicator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user