use of org.zmlx.hg4idea.repo.HgRepositoryManager in project intellij-community by JetBrains.
the class HgUtil method sortByHgRoots.
@NotNull
public static Map<VirtualFile, Collection<VirtualFile>> sortByHgRoots(@NotNull Project project, @NotNull Collection<VirtualFile> files) {
Map<VirtualFile, Collection<VirtualFile>> sorted = new HashMap<>();
HgRepositoryManager repositoryManager = getRepositoryManager(project);
for (VirtualFile file : files) {
HgRepository repo = repositoryManager.getRepositoryForFile(file);
if (repo == null) {
continue;
}
Collection<VirtualFile> filesForRoot = sorted.get(repo.getRoot());
if (filesForRoot == null) {
filesForRoot = new HashSet<>();
sorted.put(repo.getRoot(), filesForRoot);
}
filesForRoot.add(file);
}
return sorted;
}
use of org.zmlx.hg4idea.repo.HgRepositoryManager in project intellij-community by JetBrains.
the class HgUtil method getRepositoryForFile.
@Nullable
public static HgRepository getRepositoryForFile(@NotNull Project project, @Nullable VirtualFile file) {
if (file == null || project.isDisposed())
return null;
HgRepositoryManager repositoryManager = getRepositoryManager(project);
VirtualFile root = getHgRootOrNull(project, file);
return repositoryManager.getRepositoryForRoot(root);
}
use of org.zmlx.hg4idea.repo.HgRepositoryManager in project intellij-community by JetBrains.
the class HgAbstractGlobalAction method actionPerformed.
public void actionPerformed(@NotNull AnActionEvent event) {
final DataContext dataContext = event.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
VirtualFile[] files = event.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
final HgRepositoryManager repositoryManager = HgUtil.getRepositoryManager(project);
List<HgRepository> repositories = repositoryManager.getRepositories();
if (!repositories.isEmpty()) {
List<HgRepository> selectedRepositories = files != null ? HgActionUtil.collectRepositoriesFromFiles(repositoryManager, Arrays.asList(files)) : ContainerUtil.<HgRepository>emptyList();
execute(project, repositories, selectedRepositories.isEmpty() ? Collections.singletonList(HgUtil.getCurrentRepository(project)) : selectedRepositories);
}
}
use of org.zmlx.hg4idea.repo.HgRepositoryManager in project intellij-community by JetBrains.
the class HgActionUtil method getSelectedRepositoryFromEvent.
@Nullable
@CalledInAwt
public static HgRepository getSelectedRepositoryFromEvent(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return null;
}
VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE);
HgRepositoryManager repositoryManager = HgUtil.getRepositoryManager(project);
return file != null ? repositoryManager.getRepositoryForFileQuick(file) : HgUtil.getCurrentRepository(project);
}
use of org.zmlx.hg4idea.repo.HgRepositoryManager in project intellij-community by JetBrains.
the class HgBranchPopup method getInstance.
/**
* @param currentRepository Current repository, which means the repository of the currently open or selected file.
*/
public static HgBranchPopup getInstance(@NotNull Project project, @NotNull HgRepository currentRepository) {
HgRepositoryManager manager = HgUtil.getRepositoryManager(project);
HgProjectSettings hgProjectSettings = ServiceManager.getService(project, HgProjectSettings.class);
HgMultiRootBranchConfig hgMultiRootBranchConfig = new HgMultiRootBranchConfig(manager.getRepositories());
Condition<AnAction> preselectActionCondition = new Condition<AnAction>() {
@Override
public boolean value(AnAction action) {
return false;
}
};
return new HgBranchPopup(currentRepository, manager, hgMultiRootBranchConfig, hgProjectSettings, preselectActionCondition);
}
Aggregations