From e708d036c845142b1532e743c8012c23feeddb17 Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Sat, 9 Aug 2014 23:44:32 +0400 Subject: [PATCH] svn: Refactoring - provide access to reload branches logic through corresponding NewRootBunch methods (instead of using BranchesLoader directly) --- .../BranchConfigurationDialog.java | 2 +- .../DefaultBranchConfigInitializer.java | 4 +-- .../idea/svn/branchConfig/NewRootBunch.java | 31 ++++++++++++++----- .../svn/branchConfig/SelectBranchPopup.java | 3 +- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchConfigurationDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchConfigurationDialog.java index 52d087f8b017..0e0fce947088 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchConfigurationDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchConfigurationDialog.java @@ -111,7 +111,7 @@ public class BranchConfigurationDialog extends DialogWrapper { if (!configuration.getBranchUrls().contains(selectedUrl)) { configuration .addBranches(selectedUrl, new InfoStorage>(new ArrayList(), InfoReliability.empty)); - mySvnBranchConfigManager.reloadBranches(myRoot, selectedUrl); + mySvnBranchConfigManager.reloadBranchesAsync(myRoot, selectedUrl, InfoReliability.setByUser); listModel.fireItemAdded(); myLocationList.setSelectedIndex(listModel.getSize() - 1); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultBranchConfigInitializer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultBranchConfigInitializer.java index ec3d67053b45..37b78459448c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultBranchConfigInitializer.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultBranchConfigInitializer.java @@ -15,7 +15,6 @@ */ package org.jetbrains.idea.svn.branchConfig; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; @@ -65,8 +64,7 @@ public class DefaultBranchConfigInitializer implements Runnable { if (configuration != null) { for (String url : configuration.getBranchUrls()) { - ApplicationManager.getApplication().executeOnPooledThread( - new BranchesLoader(myProject, myBunch, url, InfoReliability.defaultValues, myRoot, true)); + myBunch.reloadBranchesAsync(myRoot, url, InfoReliability.defaultValues); } myBunch.updateForRoot(myRoot, new InfoStorage(configuration, InfoReliability.defaultValues), false); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/NewRootBunch.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/NewRootBunch.java index 6e4bfa2c3c8a..6f7f4185a815 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/NewRootBunch.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/NewRootBunch.java @@ -56,7 +56,8 @@ public class NewRootBunch { previous = null; override = true; myMap.put(root, config); - } else { + } + else { previous = existing.getValue(); override = existing.accept(config); } @@ -93,16 +94,23 @@ public class NewRootBunch { result = new SvnBranchConfigurationNew(); myMap.put(root, new InfoStorage(result, InfoReliability.empty)); myBranchesLoader.run(new DefaultBranchConfigInitializer(myProject, this, root)); - } else { + } + else { result = value.getValue(); } return result; } } - public void reloadBranches(@NotNull final VirtualFile root, @NotNull final String branchParentUrl) { - ApplicationManager.getApplication() - .executeOnPooledThread(new BranchesLoader(myProject, this, branchParentUrl, InfoReliability.setByUser, root, true)); + public void reloadBranchesAsync(@NotNull final VirtualFile root, + @NotNull final String branchLocation, + @NotNull final InfoReliability reliability) { + ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { + @Override + public void run() { + reloadBranches(root, branchLocation, reliability, true); + } + }); } public void reloadBranches(@NotNull VirtualFile root, @Nullable SvnBranchConfigurationNew prev, @NotNull SvnBranchConfigurationNew next) { @@ -114,11 +122,18 @@ public class NewRootBunch { // check if cancel had been put if (!vcs.isVcsBackgroundOperationsAllowed(root)) return; if (!oldUrls.contains(newBranchUrl)) { - new BranchesLoader(myProject, this, newBranchUrl, InfoReliability.defaultValues, root, true).run(); + reloadBranches(root, newBranchUrl, InfoReliability.defaultValues, true); } } } + public void reloadBranches(@NotNull VirtualFile root, + @NotNull String branchLocation, + @NotNull InfoReliability reliability, + boolean passive) { + new BranchesLoader(myProject, this, branchLocation, reliability, root, passive).run(); + } + @Nullable @CalledInBackground public SVNURL getWorkingBranchWithReload(final SVNURL svnurl, final VirtualFile root) { @@ -128,7 +143,7 @@ public class NewRootBunch { final String group = configuration.getGroupToLoadToReachUrl(svnurl); if (group != null) { - new BranchesLoader(myProject, this, group, InfoReliability.setByUser, root, true).run(); + reloadBranches(root, group, InfoReliability.setByUser, true); } result.set(myMap.get(root).getValue().getWorkingBranch(svnurl)); } @@ -147,4 +162,4 @@ public class NewRootBunch { return result; } } -} +} \ No newline at end of file diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SelectBranchPopup.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SelectBranchPopup.java index f48fc6489406..445ce4e9afe3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SelectBranchPopup.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SelectBranchPopup.java @@ -219,7 +219,8 @@ public class SelectBranchPopup { @Override protected void runImpl(@NotNull ProgressIndicator indicator) { final NewRootBunch manager = SvnBranchConfigurationManager.getInstance(myProject).getSvnBranchConfigManager(); - new BranchesLoader(myProject, manager, selectedBranchesHolder, InfoReliability.setByUser, myVcsRoot, false).run(); + + manager.reloadBranches(myVcsRoot, selectedBranchesHolder, InfoReliability.setByUser, false); } }); }