mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[file-history] use TreeNodeOnVcsRevision instead of VcsFileRevision where appropriate
This commit is contained in:
@@ -96,9 +96,10 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
@NotNull private final AsynchConsumer<VcsHistorySession> myHistoryPanelRefresh;
|
@NotNull private final AsynchConsumer<VcsHistorySession> myHistoryPanelRefresh;
|
||||||
@NotNull private final Map<VcsRevisionNumber, Integer> myRevisionsOrder = ContainerUtil.newHashMap();
|
@NotNull private final Map<VcsRevisionNumber, Integer> myRevisionsOrder = ContainerUtil.newHashMap();
|
||||||
@NotNull private final Map<VcsFileRevision, VirtualFile> myRevisionToVirtualFile = ContainerUtil.newHashMap();
|
@NotNull private final Map<VcsFileRevision, VirtualFile> myRevisionToVirtualFile = ContainerUtil.newHashMap();
|
||||||
@NotNull private final Comparator<VcsFileRevision> myRevisionsInOrderComparator = (o1, o2) -> {
|
@NotNull private final Comparator<TreeNodeOnVcsRevision> myRevisionsInOrderComparator = (o1, o2) -> {
|
||||||
// descending
|
// descending
|
||||||
return Comparing.compare(myRevisionsOrder.get(o2.getRevisionNumber()), myRevisionsOrder.get(o1.getRevisionNumber()));
|
return Comparing
|
||||||
|
.compare(myRevisionsOrder.get(o2.getRevision().getRevisionNumber()), myRevisionsOrder.get(o1.getRevision().getRevisionNumber()));
|
||||||
};
|
};
|
||||||
@NotNull private final DetailsPanel myDetails;
|
@NotNull private final DetailsPanel myDetails;
|
||||||
@NotNull private final DualView myDualView;
|
@NotNull private final DualView myDualView;
|
||||||
@@ -663,9 +664,9 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class RevisionColumnInfo extends VcsColumnInfo<VcsRevisionNumber> {
|
public static class RevisionColumnInfo extends VcsColumnInfo<VcsRevisionNumber> {
|
||||||
private final Comparator<VcsFileRevision> myComparator;
|
private final Comparator<TreeNodeOnVcsRevision> myComparator;
|
||||||
|
|
||||||
public RevisionColumnInfo(Comparator<VcsFileRevision> comparator) {
|
public RevisionColumnInfo(Comparator<TreeNodeOnVcsRevision> comparator) {
|
||||||
super(VcsBundle.message("column.name.revision.version"));
|
super(VcsBundle.message("column.name.revision.version"));
|
||||||
myComparator = comparator;
|
myComparator = comparator;
|
||||||
}
|
}
|
||||||
@@ -684,12 +685,12 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comparator<VcsFileRevision> getComparator() {
|
public Comparator<TreeNodeOnVcsRevision> getComparator() {
|
||||||
return myComparator;
|
return myComparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String valueOf(VcsFileRevision object) {
|
public String valueOf(TreeNodeOnVcsRevision object) {
|
||||||
return toString(object);
|
return toString(object.getRevision());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -714,8 +715,8 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
return toString(object);
|
return toString(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compare(VcsFileRevision o1, VcsFileRevision o2) {
|
public int compare(TreeNodeOnVcsRevision o1, TreeNodeOnVcsRevision o2) {
|
||||||
return Comparing.compare(o1.getRevisionDate(), o2.getRevisionDate());
|
return Comparing.compare(o1.getRevision().getRevisionDate(), o2.getRevision().getRevisionDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -757,17 +758,13 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
super(VcsBundle.message("column.name.revision.list.author"));
|
super(VcsBundle.message("column.name.revision.list.author"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static String toString(VcsFileRevision o) {
|
static String toString(VcsFileRevision revision) {
|
||||||
VcsFileRevision rev = o;
|
if (revision instanceof VcsFileRevisionEx) {
|
||||||
if (o instanceof TreeNodeOnVcsRevision) {
|
if (!Comparing.equal(revision.getAuthor(), ((VcsFileRevisionEx)revision).getCommitterName())) {
|
||||||
rev = ((TreeNodeOnVcsRevision)o).getRevision();
|
return revision.getAuthor() + "*";
|
||||||
}
|
|
||||||
if (rev instanceof VcsFileRevisionEx) {
|
|
||||||
if (!Comparing.equal(rev.getAuthor(), ((VcsFileRevisionEx)rev).getCommitterName())) {
|
|
||||||
return o.getAuthor() + "*";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return o.getAuthor();
|
return revision.getAuthor();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getDataOf(VcsFileRevision object) {
|
protected String getDataOf(VcsFileRevision object) {
|
||||||
@@ -775,18 +772,14 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableCellRenderer getRenderer(VcsFileRevision revision) {
|
public TableCellRenderer getRenderer(TreeNodeOnVcsRevision revision) {
|
||||||
return AUTHOR_RENDERER;
|
return AUTHOR_RENDERER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableCellRenderer getCustomizedRenderer(VcsFileRevision value, TableCellRenderer renderer) {
|
public TableCellRenderer getCustomizedRenderer(TreeNodeOnVcsRevision value, TableCellRenderer renderer) {
|
||||||
if (renderer instanceof AuthorCellRenderer) {
|
if (renderer instanceof AuthorCellRenderer) {
|
||||||
VcsFileRevision revision = value;
|
VcsFileRevision revision = value.getRevision();
|
||||||
if (value instanceof TreeNodeOnVcsRevision) {
|
|
||||||
revision = ((TreeNodeOnVcsRevision)value).getRevision();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (revision instanceof VcsFileRevisionEx) {
|
if (revision instanceof VcsFileRevisionEx) {
|
||||||
VcsFileRevisionEx ex = (VcsFileRevisionEx)revision;
|
VcsFileRevisionEx ex = (VcsFileRevisionEx)revision;
|
||||||
StringBuilder sb = new StringBuilder(StringUtil.notNullize(ex.getAuthor()));
|
StringBuilder sb = new StringBuilder(StringUtil.notNullize(ex.getAuthor()));
|
||||||
@@ -846,7 +839,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
return StringUtil.repeatSymbol('m', 80);
|
return StringUtil.repeatSymbol('m', 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TableCellRenderer getRenderer(VcsFileRevision p0) {
|
public TableCellRenderer getRenderer(TreeNodeOnVcsRevision revision) {
|
||||||
return myRenderer;
|
return myRenderer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -893,8 +886,8 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract static class VcsColumnInfo<T extends Comparable<T>> extends DualViewColumnInfo<VcsFileRevision, String>
|
abstract static class VcsColumnInfo<T extends Comparable<T>> extends DualViewColumnInfo<TreeNodeOnVcsRevision, String>
|
||||||
implements Comparator<VcsFileRevision> {
|
implements Comparator<TreeNodeOnVcsRevision> {
|
||||||
@NotNull private final ColoredTableCellRenderer myRenderer;
|
@NotNull private final ColoredTableCellRenderer myRenderer;
|
||||||
|
|
||||||
public VcsColumnInfo(String name) {
|
public VcsColumnInfo(String name) {
|
||||||
@@ -911,17 +904,17 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
|
|
||||||
protected abstract T getDataOf(VcsFileRevision o);
|
protected abstract T getDataOf(VcsFileRevision o);
|
||||||
|
|
||||||
public Comparator<VcsFileRevision> getComparator() {
|
public Comparator<TreeNodeOnVcsRevision> getComparator() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String valueOf(VcsFileRevision object) {
|
public String valueOf(TreeNodeOnVcsRevision object) {
|
||||||
T result = getDataOf(object);
|
T result = getDataOf(object.getRevision());
|
||||||
return result == null ? "" : result.toString();
|
return result == null ? "" : result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compare(VcsFileRevision o1, VcsFileRevision o2) {
|
public int compare(TreeNodeOnVcsRevision o1, TreeNodeOnVcsRevision o2) {
|
||||||
return Comparing.compare(getDataOf(o1), getDataOf(o2));
|
return Comparing.compare(getDataOf(o1.getRevision()), getDataOf(o2.getRevision()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldBeShownIsTheTree() {
|
public boolean shouldBeShownIsTheTree() {
|
||||||
@@ -934,7 +927,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TableCellRenderer getRenderer(VcsFileRevision revision) {
|
public TableCellRenderer getRenderer(TreeNodeOnVcsRevision revision) {
|
||||||
return myRenderer;
|
return myRenderer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -996,8 +989,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
int row,
|
int row,
|
||||||
int column,
|
int column,
|
||||||
Object treeNode) {
|
Object treeNode) {
|
||||||
VcsFileRevision revision = (VcsFileRevision)treeNode;
|
VcsFileRevision revision = ((TreeNodeOnVcsRevision)treeNode).getRevision();
|
||||||
if (revision == null) return;
|
|
||||||
if (myHistorySession.get().isCurrentRevision(revision.getRevisionNumber())) {
|
if (myHistorySession.get().isCurrentRevision(revision.getRevisionNumber())) {
|
||||||
makeBold(component);
|
makeBold(component);
|
||||||
}
|
}
|
||||||
@@ -1031,8 +1023,8 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
|
|||||||
|
|
||||||
int selectionSize = selection.size();
|
int selectionSize = selection.size();
|
||||||
if (selectionSize > 1) {
|
if (selectionSize > 1) {
|
||||||
List<VcsFileRevision> selectedRevisions =
|
List<VcsFileRevision> selectedRevisions = ContainerUtil.map(ContainerUtil.sorted(selection, myRevisionsInOrderComparator),
|
||||||
ContainerUtil.sorted(ContainerUtil.map(selection, TreeNodeOnVcsRevision::getRevision), myRevisionsInOrderComparator);
|
TreeNodeOnVcsRevision::getRevision);
|
||||||
VcsFileRevision olderRevision = selectedRevisions.get(0);
|
VcsFileRevision olderRevision = selectedRevisions.get(0);
|
||||||
VcsFileRevision newestRevision = selectedRevisions.get(selection.size() - 1);
|
VcsFileRevision newestRevision = selectedRevisions.get(selection.size() - 1);
|
||||||
myDiffHandler.showDiffForTwo(e.getRequiredData(CommonDataKeys.PROJECT), myFilePath, olderRevision, newestRevision);
|
myDiffHandler.showDiffForTwo(e.getRequiredData(CommonDataKeys.PROJECT), myFilePath, olderRevision, newestRevision);
|
||||||
|
|||||||
Reference in New Issue
Block a user