Java Code Examples for com.intellij.util.containers.ContainerUtil#map2Map()

The following examples show how to use com.intellij.util.containers.ContainerUtil#map2Map() . 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: AbstractModelBuilderTest.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
protected <T> Map<String, T> getModulesMap(final Class<T> aClass) {
  final DomainObjectSet<? extends IdeaModule> ideaModules = allModels.getIdeaProject().getModules();

  final String filterKey = "to_filter";
  final Map<String, T> map = ContainerUtil.map2Map(ideaModules, (Function<IdeaModule, Pair<String, T>>)module -> {
    final T value = allModels.getExtraProject(module, aClass);
    final String key = value != null ? module.getGradleProject().getPath() : filterKey;
    return Pair.create(key, value);
  });

  map.remove(filterKey);
  return map;
}
 
Example 2
Source File: SearchEverywhereUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
public SearchEverywhereUI(Project project, List<? extends SearchEverywhereContributor<?>> contributors) {
  super(project);
  List<SEResultsEqualityProvider> equalityProviders = SEResultsEqualityProvider.getProviders();
  myBufferedListener = new ThrottlingListenerWrapper(THROTTLING_TIMEOUT, mySearchListener, Runnable::run);
  mySearcher = new MultiThreadSearcher(myBufferedListener, run -> ApplicationManager.getApplication().invokeLater(run), equalityProviders);
  myShownContributors = contributors;
  Map<String, String> namesMap = ContainerUtil.map2Map(contributors, c -> Pair.create(c.getSearchProviderId(), c.getFullGroupName()));
  myContributorsFilter =
          new PersistentSearchEverywhereContributorFilter<>(ContainerUtil.map(contributors, c -> c.getSearchProviderId()), SearchEverywhereConfiguration.getInstance(project), namesMap::get,
                                                            c -> null);

  init();

  initSearchActions();

  myResultsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  myResultsList.addListSelectionListener(e -> {
    int[] selectedIndices = myResultsList.getSelectedIndices();
    if (selectedIndices.length > 1) {
      boolean multiSelection = Arrays.stream(selectedIndices).allMatch(i -> myListModel.getContributorForIndex(i).isMultiSelectionSupported());
      if (!multiSelection) {
        int index = myResultsList.getLeadSelectionIndex();
        myResultsList.setSelectedIndex(index);
      }
    }
  });

  mySelectionTracker = new SEListSelectionTracker(myResultsList, myListModel);
  myResultsList.addListSelectionListener(mySelectionTracker);
}
 
Example 3
Source File: OrderEntrySerializationUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static Map<String, OrderEntryType> getProvidersAsMap() {
  return ContainerUtil.map2Map(OrderEntryType.EP_NAME.getExtensionList(), orderEntryType -> Pair.create(orderEntryType.getId(), orderEntryType));
}
 
Example 4
Source File: VcsLogRefresherImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private Map<VirtualFile, VcsLogProvider> getProvidersForRoots(@Nonnull Set<VirtualFile> roots) {
  return ContainerUtil.map2Map(roots,
                               root -> Pair.create(root, myProviders.get(root)));
}
 
Example 5
Source File: VcsLogRefresherImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
Map<VirtualFile, VcsLogProvider.Requirements> asMap(@Nonnull Collection<VirtualFile> roots) {
  return ContainerUtil
          .map2Map(roots, root -> Pair.<VirtualFile, VcsLogProvider.Requirements>create(root, this));
}