From 035ef2b3f973e4883f23d22a4ce7676bca2a27ac Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Tue, 24 Apr 2018 19:04:44 +0300 Subject: [PATCH] [file-history] remove myHistoryPanelRefresh There is no need in a special object, FileHistorySessionPartner can just call the necessary methods directly. --- .../vcs/history/FileHistoryPanelImpl.java | 51 ++++++++----------- .../history/FileHistorySessionPartner.java | 6 +-- 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index 33fc3bb17a0a..2ec4df4bb707 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -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 myHistoryPanelRefresh; @NotNull private final Map myRevisionsOrder = ContainerUtil.newHashMap(); @NotNull private final Map myRevisionToVirtualFile = ContainerUtil.newHashMap(); @NotNull private final DetailsPanel myDetails; @@ -173,30 +173,6 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme setIsStaticAndEmbedded(true); } - myHistoryPanelRefresh = new AsynchConsumer() { - @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 getHistoryPanelRefresh() { - return myHistoryPanelRefresh; - } - public Object getData(String dataId) { if (CommonDataKeys.NAVIGATABLE.is(dataId)) { VcsFileRevision[] selectedRevisions = getSelectedRevisions(); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java index 255069917e7a..01a0414e9691 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistorySessionPartner.java @@ -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(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(); }); } }