[branchPopup]: IDEA-174227 show current branch names for don't sync mode

* if user don't want to track repositories synchronously we have to show
 current branch name as an additional info near each Repo node;
* the same for sync but diverged branch case;
This commit is contained in:
Nadya Zabrodina
2017-06-09 16:10:09 +03:00
parent 41e4977a73
commit a36c17efd7
3 changed files with 11 additions and 7 deletions

View File

@@ -123,7 +123,7 @@ public abstract class DvcsBranchPopup<Repo extends Repository> {
return popupGroup;
}
private boolean userWantsSyncControl() {
protected boolean userWantsSyncControl() {
return (myVcsSettings.getSyncSetting() != DvcsSyncSettings.Value.DONT_SYNC);
}
@@ -142,7 +142,7 @@ public abstract class DvcsBranchPopup<Repo extends Repository> {
}
}
protected boolean isBranchesDiverged() {
private boolean isBranchesDiverged() {
return myRepositoryManager.moreThanOneRoot() && myMultiRootBranchConfig.diverged() && userWantsSyncControl();
}

View File

@@ -28,7 +28,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Condition;
import com.intellij.util.containers.ContainerUtil;
import git4idea.GitUtil;
import git4idea.branch.GitBranchUtil;
import git4idea.config.GitVcsSettings;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryManager;
@@ -45,6 +44,7 @@ import static com.intellij.dvcs.ui.BranchActionUtil.FAVORITE_BRANCH_COMPARATOR;
import static com.intellij.dvcs.ui.BranchActionUtil.getNumOfTopShownBranches;
import static com.intellij.util.ObjectUtils.tryCast;
import static com.intellij.util.containers.ContainerUtil.map;
import static git4idea.branch.GitBranchUtil.getDisplayableBranchText;
import static java.util.stream.Collectors.toList;
/**
@@ -152,7 +152,8 @@ class GitBranchPopup extends DvcsBranchPopup<GitRepository> {
popupGroup.addSeparator("Repositories");
List<ActionGroup> rootActions = DvcsUtil.sortRepositories(myRepositoryManager.getRepositories()).stream()
.map(repo -> new RootAction<>(repo, new GitBranchPopupActions(repo.getProject(), repo).createActions(),
isBranchesDiverged() ? GitBranchUtil.getDisplayableBranchText(repo) : null)).collect(toList());
!userWantsSyncControl() || myMultiRootBranchConfig.diverged() ? getDisplayableBranchText(repo) : null))
.collect(toList());
wrapWithMoreActionIfNeeded(myProject, popupGroup, rootActions, rootActions.size() > MAX_NUM ? DEFAULT_NUM : MAX_NUM,
SHOW_ALL_REPOSITORIES);
return popupGroup;

View File

@@ -42,6 +42,7 @@ import static com.intellij.dvcs.ui.BranchActionGroupPopup.wrapWithMoreActionIfNe
import static com.intellij.dvcs.ui.BranchActionUtil.FAVORITE_BRANCH_COMPARATOR;
import static com.intellij.dvcs.ui.BranchActionUtil.getNumOfTopShownBranches;
import static java.util.stream.Collectors.toList;
import static org.zmlx.hg4idea.util.HgUtil.getDisplayableBranchOrBookmarkText;
/**
@@ -126,9 +127,11 @@ public class HgBranchPopup extends DvcsBranchPopup<HgRepository> {
protected DefaultActionGroup createRepositoriesActions() {
DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
popupGroup.addSeparator("Repositories");
List<ActionGroup> rootActions = DvcsUtil.sortRepositories(myRepositoryManager.getRepositories()).stream().map(
repo -> new RootAction<>(repo, new HgBranchPopupActions(repo.getProject(), repo).createActions(),
isBranchesDiverged() ? HgUtil.getDisplayableBranchOrBookmarkText(repo) : null)).collect(toList());
List<ActionGroup> rootActions = DvcsUtil.sortRepositories(myRepositoryManager.getRepositories()).stream()
.map(repo -> new RootAction<>(repo, new HgBranchPopupActions(repo.getProject(), repo).createActions(),
!userWantsSyncControl() || myMultiRootBranchConfig.diverged()
? getDisplayableBranchOrBookmarkText(repo) : null))
.collect(toList());
wrapWithMoreActionIfNeeded(myProject, popupGroup, rootActions, rootActions.size() > MAX_NUM ? DEFAULT_NUM : MAX_NUM,
SHOW_ALL_REPOSITORIES);
return popupGroup;