[file-history] remove myHistoryPanelRefresh

There is no need in a special object, FileHistorySessionPartner can just call the necessary methods directly.
This commit is contained in:
Julia Beliaeva
2018-07-09 17:35:13 +03:00
parent 40076a6110
commit 035ef2b3f9
2 changed files with 23 additions and 34 deletions
@@ -62,6 +62,7 @@ import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.ui.StatusText;
import com.intellij.util.ui.UIUtil;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.CalledInAwt;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -98,7 +99,6 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
@NotNull private final FileHistoryRefresherI myRefresherI;
@NotNull private final FilePath myFilePath;
@Nullable private final VcsRevisionNumber myStartingRevision;
@NotNull private final AsynchConsumer<VcsHistorySession> myHistoryPanelRefresh;
@NotNull private final Map<VcsRevisionNumber, Integer> myRevisionsOrder = ContainerUtil.newHashMap();
@NotNull private final Map<VcsFileRevision, VirtualFile> myRevisionToVirtualFile = ContainerUtil.newHashMap();
@NotNull private final DetailsPanel myDetails;
@@ -173,30 +173,6 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
setIsStaticAndEmbedded(true);
}
myHistoryPanelRefresh = new AsynchConsumer<VcsHistorySession>() {
@Override
public void finished() {
if (treeHistoryProvider != null) {
// scroll tree view to most recent change
final TreeTableView treeView = myDualView.getTreeView();
final int lastRow = treeView.getRowCount() - 1;
if (lastRow >= 0) {
treeView.scrollRectToVisible(treeView.getCellRect(lastRow, 0, true));
}
}
myInRefresh = false;
myTargetSelection = null;
mySplitter.revalidate();
mySplitter.repaint();
}
@Override
public void consume(@NotNull VcsHistorySession vcsHistorySession) {
FileHistoryPanelImpl.this.refresh(vcsHistorySession);
}
};
int delayMillis = 20_000;
Alarm updateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, this);
// todo react to event?
@@ -296,7 +272,8 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
return columns.toArray(new DualViewColumnInfo[0]);
}
private void refresh(@NotNull VcsHistorySession session) {
@CalledInAwt
public void setHistorySession(@NotNull VcsHistorySession session) {
myHistorySession = session;
refreshRevisionsOrder();
HistoryAsTreeProvider treeHistoryProvider = session.getHistoryAsTreeProvider();
@@ -319,6 +296,23 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
myDualView.repaint();
}
@CalledInAwt
public void finishRefresh() {
if (myHistorySession.getHistoryAsTreeProvider() != null) {
// scroll tree view to most recent change
final TreeTableView treeView = myDualView.getTreeView();
final int lastRow = treeView.getRowCount() - 1;
if (lastRow >= 0) {
treeView.scrollRectToVisible(treeView.getCellRect(lastRow, 0, true));
}
}
myInRefresh = false;
myTargetSelection = null;
mySplitter.revalidate();
mySplitter.repaint();
}
private void adjustEmptyText() {
VirtualFile virtualFile = myFilePath.getVirtualFile();
if ((virtualFile == null || !virtualFile.isValid()) && !myFilePath.getIOFile().exists()) {
@@ -443,11 +437,6 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
});
}
@NotNull
public AsynchConsumer<VcsHistorySession> getHistoryPanelRefresh() {
return myHistoryPanelRefresh;
}
public Object getData(String dataId) {
if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
VcsFileRevision[] selectedRevisions = getSelectedRevisions();
@@ -68,7 +68,7 @@ public class FileHistorySessionPartner implements VcsHistorySessionConsumer {
// TODO: Logic should be revised to just append some revisions to history panel instead of creating and showing new history session
mySession.getRevisionList().addAll(vcsFileRevisions);
VcsHistorySession copy = mySession.copyWithCachedRevision();
ApplicationManager.getApplication().invokeAndWait(() -> myFileHistoryPanel.getHistoryPanelRefresh().consume(copy));
ApplicationManager.getApplication().invokeAndWait(() -> myFileHistoryPanel.setHistorySession(copy));
};
myBuffer = new BufferedListConsumer<VcsFileRevision>(5, sessionRefresher, 1000) {
@Override
@@ -115,7 +115,7 @@ public class FileHistorySessionPartner implements VcsHistorySessionConsumer {
ApplicationManager.getApplication().invokeAndWait(() -> {
if (mySession != null && !mySession.getRevisionList().isEmpty()) {
myFileHistoryPanel.getHistoryPanelRefresh().consume(mySession.copyWithCachedRevision());
myFileHistoryPanel.setHistorySession(mySession.copyWithCachedRevision());
}
});
}
@@ -160,7 +160,7 @@ public class FileHistorySessionPartner implements VcsHistorySessionConsumer {
// nothing to be done, exit
return;
}
myFileHistoryPanel.getHistoryPanelRefresh().finished();
myFileHistoryPanel.finishRefresh();
});
}
}