Search in sources :

Example 6 with VcsLogProvider

use of com.intellij.vcs.log.VcsLogProvider in project intellij-community by JetBrains.

the class VcsLogFileHistoryProviderImpl method canShowFileHistory.

@Override
public boolean canShowFileHistory(@NotNull Project project, @NotNull FilePath path) {
    if (!Registry.is("vcs.new.history"))
        return false;
    VcsRoot rootObject = ProjectLevelVcsManager.getInstance(project).getVcsRootObjectFor(path);
    if (rootObject == null)
        return false;
    VirtualFile root = rootObject.getPath();
    AbstractVcs vcs = rootObject.getVcs();
    if (vcs == null || root == null)
        return false;
    VcsLogData dataManager = VcsProjectLog.getInstance(project).getDataManager();
    if (dataManager == null || !dataManager.getRoots().contains(root) || dataManager.getIndex().getDataGetter() == null)
        return false;
    List<VcsLogProvider> allLogProviders = Arrays.asList(Extensions.getExtensions(VcsLogProvider.LOG_PROVIDER_EP, project));
    VcsLogProvider provider = ContainerUtil.find(allLogProviders, p -> p.getSupportedVcs().equals(vcs.getKeyInstanceMethod()));
    if (provider == null)
        return false;
    return VcsLogProperties.get(provider, VcsLogProperties.SUPPORTS_INDEXING);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsLogData(com.intellij.vcs.log.data.VcsLogData) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) VcsRoot(com.intellij.openapi.vcs.VcsRoot) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs)

Example 7 with VcsLogProvider

use of com.intellij.vcs.log.VcsLogProvider in project intellij-community by JetBrains.

the class EnableMatchCaseAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    super.update(e);
    VcsLogUi ui = e.getData(VcsLogDataKeys.VCS_LOG_UI);
    VcsLogUiProperties properties = e.getData(VcsLogInternalDataKeys.LOG_UI_PROPERTIES);
    if (ui != null && properties != null && properties.exists(MainVcsLogUiProperties.TEXT_FILTER_MATCH_CASE)) {
        boolean regexEnabled = properties.exists(MainVcsLogUiProperties.TEXT_FILTER_REGEX) && properties.get(MainVcsLogUiProperties.TEXT_FILTER_REGEX);
        if (!regexEnabled) {
            e.getPresentation().setText(MATCH_CASE);
        } else {
            Collection<VcsLogProvider> providers = ContainerUtil.newLinkedHashSet(ui.getDataPack().getLogProviders().values());
            List<VcsLogProvider> supported = ContainerUtil.filter(providers, p -> VcsLogProperties.get(p, VcsLogProperties.CASE_INSENSITIVE_REGEX));
            e.getPresentation().setVisible(true);
            e.getPresentation().setEnabled(!supported.isEmpty());
            if (providers.size() == supported.size() || supported.isEmpty()) {
                e.getPresentation().setText(MATCH_CASE);
            } else {
                String supportedText = StringUtil.join(ContainerUtil.map(supported, p -> p.getSupportedVcs().getName().toLowerCase()), ", ");
                e.getPresentation().setText(MATCH_CASE + " (" + supportedText + " only)");
            }
        }
    }
}
Also used : VcsLogDataKeys(com.intellij.vcs.log.VcsLogDataKeys) VcsLogProperties(com.intellij.vcs.log.VcsLogProperties) VcsLogInternalDataKeys(com.intellij.vcs.log.ui.VcsLogInternalDataKeys) StringUtil(com.intellij.openapi.util.text.StringUtil) Collection(java.util.Collection) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) MainVcsLogUiProperties(com.intellij.vcs.log.impl.MainVcsLogUiProperties) ContainerUtil(com.intellij.util.containers.ContainerUtil) List(java.util.List) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) VcsLogUiProperties(com.intellij.vcs.log.impl.VcsLogUiProperties) VcsLogUi(com.intellij.vcs.log.VcsLogUi) NotNull(org.jetbrains.annotations.NotNull) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) MainVcsLogUiProperties(com.intellij.vcs.log.impl.MainVcsLogUiProperties) VcsLogUiProperties(com.intellij.vcs.log.impl.VcsLogUiProperties) VcsLogUi(com.intellij.vcs.log.VcsLogUi)

Example 8 with VcsLogProvider

use of com.intellij.vcs.log.VcsLogProvider in project intellij-community by JetBrains.

the class VcsLogManager method refreshLogOnVcsEvents.

private static void refreshLogOnVcsEvents(@NotNull Map<VirtualFile, VcsLogProvider> logProviders, @NotNull VcsLogRefresher refresher, @NotNull Disposable disposableParent) {
    MultiMap<VcsLogProvider, VirtualFile> providers2roots = MultiMap.create();
    logProviders.forEach((key, value) -> providers2roots.putValue(value, key));
    for (Map.Entry<VcsLogProvider, Collection<VirtualFile>> entry : providers2roots.entrySet()) {
        Disposable disposable = entry.getKey().subscribeToRootRefreshEvents(entry.getValue(), refresher);
        Disposer.register(disposableParent, disposable);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Disposable(com.intellij.openapi.Disposable) VcsLogProvider(com.intellij.vcs.log.VcsLogProvider) Collection(java.util.Collection) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap)

Aggregations

VcsLogProvider (com.intellij.vcs.log.VcsLogProvider)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 NotNull (org.jetbrains.annotations.NotNull)5 Map (java.util.Map)4 MultiMap (com.intellij.util.containers.MultiMap)3 Collection (java.util.Collection)3 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)2 VcsRoot (com.intellij.openapi.vcs.VcsRoot)2 ContainerUtil (com.intellij.util.containers.ContainerUtil)2 Disposable (com.intellij.openapi.Disposable)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 VcsKey (com.intellij.openapi.vcs.VcsKey)1 CommitId (com.intellij.vcs.log.CommitId)1 VcsLogDataKeys (com.intellij.vcs.log.VcsLogDataKeys)1 VcsLogFilterCollection (com.intellij.vcs.log.VcsLogFilterCollection)1 VcsLogProperties (com.intellij.vcs.log.VcsLogProperties)1 VcsLogUi (com.intellij.vcs.log.VcsLogUi)1 VcsRef (com.intellij.vcs.log.VcsRef)1 com.intellij.vcs.log.data (com.intellij.vcs.log.data)1