mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[log] Remove the obsolete NoGraphTableModel & simplify the code which used to use it
This commit is contained in:
@@ -34,7 +34,6 @@ import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.messages.Topic;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.vcs.log.*;
|
||||
import com.intellij.vcs.log.impl.TimedVcsCommitImpl;
|
||||
import com.intellij.vcs.log.util.StopWatch;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -506,8 +505,7 @@ public class VcsLogDataHolder implements Disposable {
|
||||
}
|
||||
|
||||
public void getFilteredDetailsFromTheVcs(@NotNull final VcsLogFilterCollection filterCollection,
|
||||
@NotNull final Consumer<List<Pair<Hash, VirtualFile>>> success,
|
||||
final int maxCount) {
|
||||
@NotNull final Consumer<List<Hash>> success, final int maxCount) {
|
||||
runInBackground(new ThrowableConsumer<ProgressIndicator, VcsException>() {
|
||||
@Override
|
||||
public void consume(ProgressIndicator indicator) throws VcsException {
|
||||
@@ -520,24 +518,16 @@ public class VcsLogDataHolder implements Disposable {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<CommitWithRoot> details = ContainerUtil.map(entry.getValue().getCommitsMatchingFilter(root, filterCollection, maxCount),
|
||||
new Function<TimedVcsCommit, CommitWithRoot>() {
|
||||
@Override
|
||||
public CommitWithRoot fun(TimedVcsCommit timedVcsCommit) {
|
||||
return new CommitWithRoot(root, timedVcsCommit.getHash(),
|
||||
timedVcsCommit.getParents(),
|
||||
timedVcsCommit.getTime());
|
||||
}
|
||||
});
|
||||
logs.add(details);
|
||||
List<TimedVcsCommit> matchingCommits = entry.getValue().getCommitsMatchingFilter(root, filterCollection, maxCount);
|
||||
logs.add(matchingCommits);
|
||||
}
|
||||
|
||||
final List<? extends TimedVcsCommit> compoundLog = myMultiRepoJoiner.join(logs);
|
||||
|
||||
final List<Pair<Hash, VirtualFile>> list = ContainerUtil.map(compoundLog, new Function<TimedVcsCommit, Pair<Hash, VirtualFile>>() {
|
||||
final List<Hash> list = ContainerUtil.map(compoundLog, new Function<TimedVcsCommit, Hash>() {
|
||||
@Override
|
||||
public Pair<Hash, VirtualFile> fun(TimedVcsCommit timedVcsCommit) {
|
||||
return Pair.create(timedVcsCommit.getHash(), ((CommitWithRoot)timedVcsCommit).myRoot);
|
||||
public Hash fun(TimedVcsCommit commit) {
|
||||
return commit.getHash();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -551,16 +541,6 @@ public class VcsLogDataHolder implements Disposable {
|
||||
}, "Looking for more results...");
|
||||
}
|
||||
|
||||
private static class CommitWithRoot extends TimedVcsCommitImpl {
|
||||
|
||||
@NotNull private final VirtualFile myRoot;
|
||||
|
||||
public CommitWithRoot(@NotNull VirtualFile root, @NotNull Hash hash, @NotNull List<Hash> parents, long timeStamp) {
|
||||
super(hash, parents, timeStamp);
|
||||
myRoot = root;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<VirtualFile, VcsUser> getCurrentUser() {
|
||||
return myCurrentUser;
|
||||
|
||||
@@ -3,9 +3,7 @@ package com.intellij.vcs.log.data;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -16,7 +14,6 @@ import com.intellij.vcs.log.ui.VcsLogUI;
|
||||
import com.intellij.vcs.log.ui.tables.AbstractVcsLogTableModel;
|
||||
import com.intellij.vcs.log.ui.tables.EmptyTableModel;
|
||||
import com.intellij.vcs.log.ui.tables.GraphTableModel;
|
||||
import com.intellij.vcs.log.ui.tables.NoGraphTableModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -32,9 +29,6 @@ public class VcsLogFilterer {
|
||||
@NotNull private final VcsLogDataHolder myLogDataHolder;
|
||||
@NotNull private final VcsLogUI myUI;
|
||||
|
||||
// TODO remove after new Graph supports filtering
|
||||
private static final boolean USE_NEW_GRAPH_FOR_FILTERING = true;
|
||||
|
||||
public VcsLogFilterer(@NotNull VcsLogDataHolder logDataHolder, @NotNull VcsLogUI ui) {
|
||||
myLogDataHolder = logDataHolder;
|
||||
myUI = ui;
|
||||
@@ -44,33 +38,13 @@ public class VcsLogFilterer {
|
||||
public AbstractVcsLogTableModel applyFiltersAndUpdateUi(@NotNull DataPack dataPack, @NotNull VcsLogFilterCollection filters) {
|
||||
List<VcsLogDetailsFilter> detailsFilters = filters.getDetailsFilters();
|
||||
|
||||
// it is important to apply graph filters first:
|
||||
// if we apply other filters first, we loose the graph and won't be able to apple graph filters in that case
|
||||
// (e.g. won't be able to find out if a commit belongs to the branch selected by user).
|
||||
|
||||
// hide invisible nodes from the graph
|
||||
applyGraphFilters(dataPack, filters.getBranchFilter());
|
||||
|
||||
// apply details filters, and use simple table without graph (we can't filter by details and keep the graph yet).
|
||||
final AbstractVcsLogTableModel model;
|
||||
if (USE_NEW_GRAPH_FOR_FILTERING) {
|
||||
model = updateFacadeAndCreateModel(dataPack, detailsFilters);
|
||||
}
|
||||
else {
|
||||
if (!detailsFilters.isEmpty()) {
|
||||
List<Pair<Hash, VirtualFile>> filteredCommits = filterByDetails(dataPack, detailsFilters);
|
||||
model = new NoGraphTableModel(dataPack, myLogDataHolder, myUI, filteredCommits, LoadMoreStage.INITIAL);
|
||||
}
|
||||
else {
|
||||
model = new GraphTableModel(dataPack, myLogDataHolder, myUI, LoadMoreStage.INITIAL);
|
||||
}
|
||||
}
|
||||
return model;
|
||||
return applyDetailsFilter(dataPack, detailsFilters);
|
||||
}
|
||||
|
||||
private AbstractVcsLogTableModel updateFacadeAndCreateModel(DataPack dataPack, List<VcsLogDetailsFilter> detailsFilters) {
|
||||
private AbstractVcsLogTableModel applyDetailsFilter(DataPack dataPack, List<VcsLogDetailsFilter> detailsFilters) {
|
||||
if (!detailsFilters.isEmpty()) {
|
||||
List<Pair<Hash, VirtualFile>> filteredCommits = filterByDetails(dataPack, detailsFilters);
|
||||
List<Hash> filteredCommits = filterByDetails(dataPack, detailsFilters);
|
||||
if (filteredCommits.isEmpty()) {
|
||||
return new EmptyTableModel(dataPack, myLogDataHolder, myUI, LoadMoreStage.INITIAL);
|
||||
}
|
||||
@@ -85,11 +59,11 @@ public class VcsLogFilterer {
|
||||
return new GraphTableModel(dataPack, myLogDataHolder, myUI, LoadMoreStage.INITIAL);
|
||||
}
|
||||
|
||||
private Condition<Integer> getFilterFromCommits(List<Pair<Hash, VirtualFile>> filteredCommits) {
|
||||
final Set<Integer> commitSet = ContainerUtil.map2Set(filteredCommits, new Function<Pair<Hash, VirtualFile>, Integer>() {
|
||||
private Condition<Integer> getFilterFromCommits(List<Hash> filteredCommits) {
|
||||
final Set<Integer> commitSet = ContainerUtil.map2Set(filteredCommits, new Function<Hash, Integer>() {
|
||||
@Override
|
||||
public Integer fun(Pair<Hash, VirtualFile> pair) {
|
||||
return myLogDataHolder.putHash(pair.getFirst());
|
||||
public Integer fun(Hash hash) {
|
||||
return myLogDataHolder.putHash(hash);
|
||||
}
|
||||
});
|
||||
return new Condition<Integer>() {
|
||||
@@ -104,22 +78,17 @@ public class VcsLogFilterer {
|
||||
@NotNull final LoadMoreStage loadMoreStage, @NotNull final Runnable onSuccess) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
int maxCount = loadMoreStage == LoadMoreStage.INITIAL ? LOAD_MORE_COMMITS_FIRST_STEP_LIMIT : -1;
|
||||
myLogDataHolder.getFilteredDetailsFromTheVcs(filters, new Consumer<List<Pair<Hash, VirtualFile>>>() {
|
||||
myLogDataHolder.getFilteredDetailsFromTheVcs(filters, new Consumer<List<Hash>>() {
|
||||
@Override
|
||||
public void consume(List<Pair<Hash, VirtualFile>> details) {
|
||||
public void consume(List<Hash> hashes) {
|
||||
LoadMoreStage newLoadMoreStage = advanceLoadMoreStage(loadMoreStage);
|
||||
AbstractVcsLogTableModel model;
|
||||
if (!USE_NEW_GRAPH_FOR_FILTERING) {
|
||||
model = new NoGraphTableModel(dataPack, myLogDataHolder, myUI, details, newLoadMoreStage);
|
||||
if (hashes.isEmpty()) {
|
||||
model = new EmptyTableModel(dataPack, myLogDataHolder, myUI, newLoadMoreStage);
|
||||
}
|
||||
else {
|
||||
if (details.isEmpty()) {
|
||||
model = new EmptyTableModel(dataPack, myLogDataHolder, myUI, newLoadMoreStage);
|
||||
}
|
||||
else {
|
||||
dataPack.getGraphFacade().setFilter(getFilterFromCommits(details));
|
||||
model = new GraphTableModel(dataPack, myLogDataHolder, myUI, newLoadMoreStage);
|
||||
}
|
||||
dataPack.getGraphFacade().setFilter(getFilterFromCommits(hashes));
|
||||
model = new GraphTableModel(dataPack, myLogDataHolder, myUI, newLoadMoreStage);
|
||||
}
|
||||
myUI.setModel(model);
|
||||
myUI.repaintUI();
|
||||
@@ -154,8 +123,8 @@ public class VcsLogFilterer {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<Pair<Hash, VirtualFile>> filterByDetails(@NotNull DataPack dataPack, @NotNull List<VcsLogDetailsFilter> detailsFilters) {
|
||||
List<Pair<Hash, VirtualFile>> result = ContainerUtil.newArrayList();
|
||||
private List<Hash> filterByDetails(@NotNull DataPack dataPack, @NotNull List<VcsLogDetailsFilter> detailsFilters) {
|
||||
List<Hash> result = ContainerUtil.newArrayList();
|
||||
int topCommits = myLogDataHolder.getSettings().getRecentCommitsCount();
|
||||
List<Integer> visibleCommits = VcsLogUtil.getVisibleCommits(dataPack.getGraphFacade());
|
||||
for (int i = 0; i < topCommits && i < visibleCommits.size(); i++) {
|
||||
@@ -179,7 +148,7 @@ public class VcsLogFilterer {
|
||||
}
|
||||
});
|
||||
if (allFiltersMatch) {
|
||||
result.add(Pair.create(details.getHash(), details.getRoot()));
|
||||
result.add(details.getHash());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.intellij.vcs.log.ui.tables;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Attachment;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.VcsRef;
|
||||
import com.intellij.vcs.log.VcsShortCommitDetails;
|
||||
import com.intellij.vcs.log.data.DataPack;
|
||||
import com.intellij.vcs.log.data.LoadMoreStage;
|
||||
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;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class NoGraphTableModel extends AbstractVcsLogTableModel<CommitCell> {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(NoGraphTableModel.class);
|
||||
|
||||
@NotNull private final List<Pair<Hash, VirtualFile>> myCommitsWithRoots;
|
||||
|
||||
public NoGraphTableModel(@NotNull DataPack dataPack, @NotNull VcsLogDataHolder logDataHolder, @NotNull VcsLogUI ui,
|
||||
@NotNull List<Pair<Hash, VirtualFile>> commitsWithRoots, @NotNull LoadMoreStage loadMoreStage) {
|
||||
super(logDataHolder, ui, dataPack, loadMoreStage);
|
||||
myCommitsWithRoots = commitsWithRoots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return myCommitsWithRoots.size();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public VirtualFile getRoot(int rowIndex) {
|
||||
Pair<Hash, VirtualFile> commit = myCommitsWithRoots.get(rowIndex);
|
||||
if (commit != null) {
|
||||
return commit.getSecond();
|
||||
}
|
||||
else {
|
||||
LOG.error("Couldn't identify root for commit at " + rowIndex, new Attachment("loaded_commits", myCommitsWithRoots.toString()));
|
||||
return FAKE_ROOT;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected CommitCell getCommitColumnCell(int index, @Nullable VcsShortCommitDetails details) {
|
||||
String subject = "";
|
||||
Collection<VcsRef> refs = Collections.emptyList();
|
||||
if (details != null) {
|
||||
subject = details.getSubject();
|
||||
refs = myDataPack.getRefsModel().refsToCommit(details.getHash());
|
||||
}
|
||||
return new CommitCell(subject, refs);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<CommitCell> getCommitColumnClass() {
|
||||
return CommitCell.class;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Hash getHashAtRow(int row) {
|
||||
return myCommitsWithRoots.get(row).getFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowOfCommit(@NotNull Hash hash) {
|
||||
for (int i = 0; i < myCommitsWithRoots.size(); i++) {
|
||||
if (hash.equals(myCommitsWithRoots.get(i).getFirst())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowOfCommitByPartOfHash(@NotNull String hash) {
|
||||
String lowercaseHash = hash.toLowerCase();
|
||||
for (int i = 0; i < myCommitsWithRoots.size(); i++) {
|
||||
Hash commit = myCommitsWithRoots.get(i).getFirst();
|
||||
if (commit.toString().toLowerCase().startsWith(lowercaseHash)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user