[log] Disable loading more details for filtering

* It looks like Git is able to filter faster on its own,
  than return us details.
* It is one step less, therefore if there are not many details,
  user will wait less time.
* It consumes less memory, since we don't expand the cache by extra n
  commits.

The code which handles "load more" is kept in the VcsLogDataHolder by
now: maybe this decision will be changed or somehow modified.
This commit is contained in:
Kirill Likhodedov
2013-10-27 16:41:27 +04:00
parent edbfd4d055
commit 82a93b8201
2 changed files with 11 additions and 22 deletions
@@ -55,7 +55,7 @@ public class VcsLogFilterer {
AbstractVcsLogTableModel model;
if (!detailsFilters.isEmpty()) {
List<VcsFullCommitDetails> filteredCommits = filterByDetails(graphModel, detailsFilters);
model = new NoGraphTableModel(myLogDataHolder, myUI, filteredCommits, myLogDataHolder.getDataPack().getRefsModel(), true);
model = new NoGraphTableModel(myUI, filteredCommits, myLogDataHolder.getDataPack().getRefsModel(), true);
}
else {
model = new GraphTableModel(myLogDataHolder, myUI);
@@ -69,12 +69,13 @@ public class VcsLogFilterer {
}
}
public void requestVcs(@NotNull Collection<VcsLogFilter> filters) {
public void requestVcs(@NotNull Collection<VcsLogFilter> filters, final Runnable onSuccess) {
myLogDataHolder.getFilteredDetailsFromTheVcs(filters, new Consumer<List<VcsFullCommitDetails>>() {
@Override
public void consume(List<VcsFullCommitDetails> details) {
myUI.setModel(new NoGraphTableModel(myLogDataHolder, myUI, details, myLogDataHolder.getDataPack().getRefsModel(), false));
myUI.setModel(new NoGraphTableModel(myUI, details, myLogDataHolder.getDataPack().getRefsModel(), false));
myUI.updateUI();
onSuccess.run();
}
});
}
@@ -8,7 +8,6 @@ import com.intellij.vcs.log.VcsFullCommitDetails;
import com.intellij.vcs.log.VcsRef;
import com.intellij.vcs.log.VcsShortCommitDetails;
import com.intellij.vcs.log.data.RefsModel;
import com.intellij.vcs.log.data.VcsLogDataHolder;
import com.intellij.vcs.log.graph.render.CommitCell;
import com.intellij.vcs.log.ui.VcsLogUI;
import org.jetbrains.annotations.NotNull;
@@ -20,15 +19,13 @@ public class NoGraphTableModel extends AbstractVcsLogTableModel<CommitCell> {
private static final Logger LOG = Logger.getInstance(NoGraphTableModel.class);
@NotNull private final VcsLogDataHolder myLogDataHolder;
@NotNull private final VcsLogUI myUi;
@NotNull private final List<VcsFullCommitDetails> myCommits;
@NotNull private final RefsModel myRefsModel;
private final boolean myAllowLoadingMoreRequest;
private boolean myAllowLoadingMoreRequest;
public NoGraphTableModel(@NotNull VcsLogDataHolder logDataHolder, @NotNull VcsLogUI UI,
@NotNull List<VcsFullCommitDetails> commits, @NotNull RefsModel refsModel, boolean allowLoadingMoreRequest) {
myLogDataHolder = logDataHolder;
public NoGraphTableModel(@NotNull VcsLogUI UI, @NotNull List<VcsFullCommitDetails> commits, @NotNull RefsModel refsModel,
boolean allowLoadingMoreRequest) {
myUi = UI;
myCommits = commits;
myRefsModel = refsModel;
@@ -56,23 +53,14 @@ public class NoGraphTableModel extends AbstractVcsLogTableModel<CommitCell> {
return;
}
Runnable success = new Runnable() {
myUi.getTable().setPaintBusy(true);
myUi.getFilterer().requestVcs(myUi.collectFilters(), new Runnable() {
@Override
public void run() {
myUi.applyFiltersAndUpdateUi();
myUi.getTable().setPaintBusy(false);
}
};
VcsLogDataHolder.LoadingState state = myLogDataHolder.loadMoreDetails(success);
if (state == VcsLogDataHolder.LoadingState.LOADING) {
myUi.getTable().setPaintBusy(true);
}
else if (state == VcsLogDataHolder.LoadingState.LIMIT_REACHED) {
myUi.getFilterer().requestVcs(myUi.collectFilters());
}
else {
myUi.getTable().setPaintBusy(false);
}
});
myAllowLoadingMoreRequest = false; // Don't send the request to VCS twice
}
@Nullable