mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
VCS: in file history panel, correctly show (refresh) current revision. P4: call fstat only if revision had changed
This commit is contained in:
@@ -22,14 +22,29 @@ import java.util.List;
|
||||
|
||||
public abstract class VcsHistorySession {
|
||||
private final List<VcsFileRevision> myRevisions;
|
||||
private volatile VcsRevisionNumber myCachedRevisionNumber;
|
||||
private final Object myLock;
|
||||
private VcsRevisionNumber myCachedRevisionNumber;
|
||||
|
||||
protected VcsRevisionNumber getCachedRevision() {
|
||||
synchronized (myLock) {
|
||||
return myCachedRevisionNumber;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setCachedRevision(final VcsRevisionNumber number) {
|
||||
synchronized (myLock) {
|
||||
myCachedRevisionNumber = number;
|
||||
}
|
||||
}
|
||||
|
||||
public VcsHistorySession(List<VcsFileRevision> revisions) {
|
||||
myLock = new Object();
|
||||
myRevisions = revisions;
|
||||
myCachedRevisionNumber = calcCurrentRevisionNumber();
|
||||
}
|
||||
|
||||
protected VcsHistorySession(List<VcsFileRevision> revisions, VcsRevisionNumber currentRevisionNumber) {
|
||||
myLock = new Object();
|
||||
myRevisions = revisions;
|
||||
myCachedRevisionNumber = currentRevisionNumber;
|
||||
}
|
||||
@@ -47,7 +62,7 @@ public abstract class VcsHistorySession {
|
||||
protected abstract VcsRevisionNumber calcCurrentRevisionNumber();
|
||||
|
||||
public final VcsRevisionNumber getCurrentRevisionNumber() {
|
||||
return myCachedRevisionNumber;
|
||||
return getCachedRevision();
|
||||
}
|
||||
|
||||
public boolean isCurrentRevision(VcsRevisionNumber rev) {
|
||||
@@ -56,9 +71,10 @@ public abstract class VcsHistorySession {
|
||||
}
|
||||
|
||||
public synchronized boolean refresh() {
|
||||
final VcsRevisionNumber oldValue = myCachedRevisionNumber;
|
||||
myCachedRevisionNumber = calcCurrentRevisionNumber();
|
||||
return !Comparing.equal(oldValue, myCachedRevisionNumber);
|
||||
final VcsRevisionNumber oldValue = getCachedRevision();
|
||||
final VcsRevisionNumber newNumber = calcCurrentRevisionNumber();
|
||||
setCachedRevision(newNumber);
|
||||
return !Comparing.equal(oldValue, newNumber);
|
||||
}
|
||||
|
||||
public boolean allowAsyncRefresh() {
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.intellij.openapi.vcs.history;
|
||||
import com.intellij.history.LocalHistory;
|
||||
import com.intellij.history.LocalHistoryAction;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.*;
|
||||
@@ -21,7 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.PanelWithActionsAndCloseButton;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Getter;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -295,7 +295,7 @@ public class FileHistoryPanelImpl<S extends CommittedChangeList, U extends Chang
|
||||
createSession(new Consumer<VcsHistorySession>() {
|
||||
public void consume(final VcsHistorySession session) {
|
||||
if (session != null) {
|
||||
if (myHistorySession.allowAsyncRefresh()) {
|
||||
if (session.allowAsyncRefresh()) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
refresh(session);
|
||||
@@ -476,9 +476,14 @@ public class FileHistoryPanelImpl<S extends CommittedChangeList, U extends Chang
|
||||
|
||||
final TreeCellRenderer defaultCellRenderer = myDualView.getTree().getCellRenderer();
|
||||
|
||||
myDualView.setTreeCellRenderer(new MyTreeCellRenderer(defaultCellRenderer, myHistorySession));
|
||||
final Getter<VcsHistorySession> sessionGetter = new Getter<VcsHistorySession>() {
|
||||
public VcsHistorySession get() {
|
||||
return myHistorySession;
|
||||
}
|
||||
};
|
||||
myDualView.setTreeCellRenderer(new MyTreeCellRenderer(defaultCellRenderer, sessionGetter));
|
||||
|
||||
myDualView.setCellWrapper(new MyCellWrapper(myHistorySession));
|
||||
myDualView.setCellWrapper(new MyCellWrapper(sessionGetter));
|
||||
|
||||
TableViewModel sortableModel = myDualView.getFlatView().getTableViewModel();
|
||||
sortableModel.setSortable(true);
|
||||
@@ -1425,9 +1430,9 @@ public class FileHistoryPanelImpl<S extends CommittedChangeList, U extends Chang
|
||||
|
||||
private class MyTreeCellRenderer implements TreeCellRenderer {
|
||||
private final TreeCellRenderer myDefaultCellRenderer;
|
||||
private final VcsHistorySession myHistorySession;
|
||||
private final Getter<VcsHistorySession> myHistorySession;
|
||||
|
||||
public MyTreeCellRenderer(final TreeCellRenderer defaultCellRenderer, final VcsHistorySession historySession) {
|
||||
public MyTreeCellRenderer(final TreeCellRenderer defaultCellRenderer, final Getter<VcsHistorySession> historySession) {
|
||||
myDefaultCellRenderer = defaultCellRenderer;
|
||||
myHistorySession = historySession;
|
||||
}
|
||||
@@ -1447,10 +1452,10 @@ public class FileHistoryPanelImpl<S extends CommittedChangeList, U extends Chang
|
||||
|
||||
if (revision != null) {
|
||||
|
||||
if (Comparing.equal(revision.getRevisionNumber(), myHistorySession.getCurrentRevisionNumber())) {
|
||||
if (myHistorySession.get().isCurrentRevision(revision.getRevisionNumber())) {
|
||||
makeBold(result);
|
||||
}
|
||||
if (!selected && Comparing.equal(revision.getRevisionNumber(), myHistorySession.getCurrentRevisionNumber())) {
|
||||
if (!selected && myHistorySession.get().isCurrentRevision(revision.getRevisionNumber())) {
|
||||
result.setBackground(new Color(188, 227, 231));
|
||||
((JComponent)result).setOpaque(false);
|
||||
}
|
||||
@@ -1467,9 +1472,9 @@ public class FileHistoryPanelImpl<S extends CommittedChangeList, U extends Chang
|
||||
}
|
||||
|
||||
private static class MyCellWrapper implements CellWrapper {
|
||||
private final VcsHistorySession myHistorySession;
|
||||
private final Getter<VcsHistorySession> myHistorySession;
|
||||
|
||||
public MyCellWrapper(final VcsHistorySession historySession) {
|
||||
public MyCellWrapper(final Getter<VcsHistorySession> historySession) {
|
||||
myHistorySession = historySession;
|
||||
}
|
||||
|
||||
@@ -1483,7 +1488,7 @@ public class FileHistoryPanelImpl<S extends CommittedChangeList, U extends Chang
|
||||
Object treeNode) {
|
||||
VcsFileRevision revision = (VcsFileRevision)treeNode;
|
||||
if (revision == null) return;
|
||||
if (myHistorySession.isCurrentRevision(revision.getRevisionNumber())) {
|
||||
if (myHistorySession.get().isCurrentRevision(revision.getRevisionNumber())) {
|
||||
makeBold(component);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user