svn: Refactoring - provide access to reload branches logic through corresponding NewRootBunch methods (instead of using BranchesLoader directly)

This commit is contained in:
Konstantin Kolosovsky
2014-08-09 23:44:32 +04:00
parent 60c4e91ff0
commit e708d036c8
4 changed files with 27 additions and 13 deletions
@@ -111,7 +111,7 @@ public class BranchConfigurationDialog extends DialogWrapper {
if (!configuration.getBranchUrls().contains(selectedUrl)) {
configuration
.addBranches(selectedUrl, new InfoStorage<List<SvnBranchItem>>(new ArrayList<SvnBranchItem>(), InfoReliability.empty));
mySvnBranchConfigManager.reloadBranches(myRoot, selectedUrl);
mySvnBranchConfigManager.reloadBranchesAsync(myRoot, selectedUrl, InfoReliability.setByUser);
listModel.fireItemAdded();
myLocationList.setSelectedIndex(listModel.getSize() - 1);
}
@@ -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<SvnBranchConfigurationNew>(configuration, InfoReliability.defaultValues), false);
@@ -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<SvnBranchConfigurationNew>(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;
}
}
}
}
@@ -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);
}
});
}