mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[log] Allow null roots in the GraphTableModel.
Some rows may be empty (contain no commits): for instance, in the case of graph filtered by branch, when there will be just graph fragments drawn. Therefore it is not an error to have a null node, and therefore it is not an error to receive the FAKE_ROOT in the color manager. Supply correct root to the LoadingDetails (the root is known because is taken from the Branch of a Node).
This commit is contained in:
@@ -80,7 +80,7 @@ public abstract class DataGetter<T extends VcsShortCommitDetails> implements Dis
|
||||
@NotNull
|
||||
private T loadingDetails(Node node, Hash hash) {
|
||||
TaskDescriptor descriptor = runLoadAroundCommitData(node);
|
||||
T loadingDetails = (T)new LoadingDetails(hash, descriptor.getTaskNum());
|
||||
T loadingDetails = (T)new LoadingDetails(hash, descriptor.getTaskNum(), node.getBranch().getRepositoryRoot());
|
||||
return loadingDetails;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public abstract class DataGetter<T extends VcsShortCommitDetails> implements Dis
|
||||
// fill the cache with temporary "Loading" values to avoid producing queries for each commit that has not been cached yet,
|
||||
// even if it will be loaded within a previous query
|
||||
if (!myCache.isKeyCached(hash)) {
|
||||
myCache.put(hash, (T)new LoadingDetails(hash, taskNumber));
|
||||
myCache.put(hash, (T)new LoadingDetails(hash, taskNumber, commitNode.getBranch().getRepositoryRoot()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.intellij.vcs.log.data;
|
||||
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.vcs.log.Hash;
|
||||
import com.intellij.vcs.log.impl.VcsFullCommitDetailsImpl;
|
||||
import com.intellij.vcs.log.ui.tables.AbstractVcsLogTableModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -18,9 +18,8 @@ public class LoadingDetails extends VcsFullCommitDetailsImpl {
|
||||
|
||||
private final long myLoadingTaskIndex;
|
||||
|
||||
public LoadingDetails(@NotNull Hash hash, long loadingTaskIndex) {
|
||||
super(hash, Collections.<Hash>emptyList(), -1, AbstractVcsLogTableModel.UNKNOWN_ROOT,
|
||||
"Loading...", "", "", "", "", "", -1, Collections.<Change>emptyList());
|
||||
public LoadingDetails(@NotNull Hash hash, long loadingTaskIndex, @NotNull VirtualFile root) {
|
||||
super(hash, Collections.<Hash>emptyList(), -1, root, "Loading...", "", "", "", "", "", -1, Collections.<Change>emptyList());
|
||||
myLoadingTaskIndex = loadingTaskIndex;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.vcs.log.ui.tables.AbstractVcsLogTableModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -51,6 +52,9 @@ public class VcsLogColorManagerImpl implements VcsLogColorManager {
|
||||
@NotNull
|
||||
@Override
|
||||
public Color getRootColor(@NotNull VirtualFile root) {
|
||||
if (root == AbstractVcsLogTableModel.FAKE_ROOT) {
|
||||
return UIUtil.getTableBackground();
|
||||
}
|
||||
Color color = myRoots2Colors.get(root);
|
||||
if (color == null) {
|
||||
LOG.error("No color record for root " + root + ". All roots: " + myRoots2Colors);
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class AbstractVcsLogTableModel<T> extends AbstractTableModel {
|
||||
|
||||
public static final VirtualFile UNKNOWN_ROOT = NullVirtualFile.INSTANCE;
|
||||
public static final VirtualFile FAKE_ROOT = NullVirtualFile.INSTANCE;
|
||||
|
||||
public static final int ROOT_COLUMN = 0;
|
||||
public static final int COMMIT_COLUMN = 1;
|
||||
|
||||
@@ -100,13 +100,7 @@ public class GraphTableModel extends AbstractVcsLogTableModel<GraphCommitCell> {
|
||||
@Override
|
||||
protected VirtualFile getRoot(int rowIndex) {
|
||||
Node commitNode = myDataPack.getGraphModel().getGraph().getCommitNodeInRow(rowIndex);
|
||||
if (commitNode != null) {
|
||||
return commitNode.getBranch().getRepositoryRoot();
|
||||
}
|
||||
else {
|
||||
LOG.error("Couldn't identify commit node at " + rowIndex);
|
||||
return UNKNOWN_ROOT;
|
||||
}
|
||||
return commitNode != null ? commitNode.getBranch().getRepositoryRoot() : FAKE_ROOT;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -84,7 +84,7 @@ public class NoGraphTableModel extends AbstractVcsLogTableModel<CommitCell> {
|
||||
}
|
||||
else {
|
||||
LOG.error("Couldn't identify root for commit at " + rowIndex, new Attachment("loaded_commits", myCommits.toString()));
|
||||
return UNKNOWN_ROOT;
|
||||
return FAKE_ROOT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user