From fd739eed76652c44fedf6b29ec9b1107c79b162a Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Fri, 13 May 2016 16:59:33 +0300 Subject: [PATCH] [vcs-log] separate details panel notifications * selection changed -- rebuild the whole component; * some details were loaded -- set new details and request for branches; * containing branches calculated -- just take branches from cache. However, this does not solve problem with branches hanging completely. For that, need to rewrite ContainingBranchesGetter. Also, it would not hurt to request full details for the whole selection, not one by one. --- .../vcs/log/ui/frame/DetailsPanel.java | 26 +++++++++++++++---- .../intellij/vcs/log/ui/frame/MainFrame.java | 4 +-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java index 3a514e3653fb..86c2a24422cf 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java @@ -199,13 +199,26 @@ class DetailsPanel extends JPanel implements ListSelectionListener { } rebuildCommitPanels(); + updateCommitDetails(true); + } + public void detailsChanged() { + myLoadingPanel.stopLoading(); + updateCommitDetails(true); + } + + public void branchesChanged() { + updateCommitDetails(false); + } + + private void updateCommitDetails(boolean requestBranches) { + int[] rows = myGraphTable.getSelectedRows(); Set newCommitDetails = ContainerUtil.newHashSet(); - for (int i = 0; i < rows.length; i++) { + for (int i = 0; i < Math.min(rows.length, MAX_ROWS); i++) { int row = rows[i]; VcsFullCommitDetails commitData = myGraphTable.getModel().getFullDetails(row); CommitPanel commitPanel = getCommitPanel(i); - commitPanel.setCommit(commitData); + commitPanel.setCommit(commitData, requestBranches); if (commitData instanceof LoadingDetails) { myLoadingPanel.startLoading(); } @@ -283,7 +296,7 @@ class DetailsPanel extends JPanel implements ListSelectionListener { add(myDataPanel); } - public void setCommit(@NotNull VcsFullCommitDetails commitData) { + public void setCommit(@NotNull VcsFullCommitDetails commitData, boolean requestBranches) { if (!Comparing.equal(myCommit, commitData)) { if (commitData instanceof LoadingDetails) { myDataPanel.setData(null); @@ -298,10 +311,13 @@ class DetailsPanel extends JPanel implements ListSelectionListener { myCommit = commitData; } - List branches = null; - if (!(commitData instanceof LoadingDetails)) { + List branches; + if (!(commitData instanceof LoadingDetails) && requestBranches) { branches = myLogData.getContainingBranchesGetter().requestContainingBranches(commitData.getRoot(), commitData.getId()); } + else { + branches = myLogData.getContainingBranchesGetter().getContainingBranchesFromCache(commitData.getRoot(), commitData.getId()); + } if (!Comparing.equal(myCommit, commitData) || myBranches != branches) { myDataPanel.setBranches(branches); diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/MainFrame.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/MainFrame.java index 8147ffa9f29c..10cd2bfbfeb9 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/MainFrame.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/MainFrame.java @@ -151,9 +151,9 @@ public class MainFrame extends JPanel implements DataProvider, Disposable { myGraphTable.initColumnSize(); myGraphTable.repaint(); }; - myFullDetailsLoadedListener = () -> myDetailsPanel.valueChanged(null); + myFullDetailsLoadedListener = myDetailsPanel::detailsChanged; myContainingBranchesListener = () -> { - myDetailsPanel.valueChanged(null); + myDetailsPanel.branchesChanged(); myGraphTable.repaint(); // we may need to repaint highlighters }; myLogData.getMiniDetailsGetter().addDetailsLoadedListener(myMiniDetailsLoadedListener);