Java Code Examples for com.intellij.openapi.vcs.ProjectLevelVcsManager#setDirectoryMappings()

The following examples show how to use com.intellij.openapi.vcs.ProjectLevelVcsManager#setDirectoryMappings() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TfvcIntegrationEnabler.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
private void addVcsRoot(@NotNull VirtualFile root) {
    ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
    List<VirtualFile> currentVcsRoots = Arrays.asList(vcsManager.getRootsUnderVcs(myVcs));

    List<VcsDirectoryMapping> mappings = new ArrayList<>(vcsManager.getDirectoryMappings(myVcs));
    if (!currentVcsRoots.contains(root)) {
        mappings.add(new VcsDirectoryMapping(root.getPath(), myVcs.getName()));
    }

    vcsManager.setDirectoryMappings(mappings);
}
 
Example 2
Source File: RegisterMappingCheckoutListener.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean processCheckedOutDirectory(Project currentProject, File directory, VcsKey vcsKey) {
  Project project = CompositeCheckoutListener.findProjectByBaseDirLocation(directory);
  if (project != null) {
    ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
    if (!vcsManager.hasAnyMappings()) {
      vcsManager.setDirectoryMappings(Collections.singletonList(VcsDirectoryMapping.createDefault(vcsKey.getName())));
    }
    return true;
  }
  return false;
}
 
Example 3
Source File: DvcsUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void addMappingIfSubRoot(@Nonnull Project project, @Nonnull String newRepositoryPath, @Nonnull String vcsName) {
  if (project.getBasePath() != null && FileUtil.isAncestor(project.getBasePath(), newRepositoryPath, true)) {
    ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
    manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), newRepositoryPath, vcsName));
  }
}