use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class PluginsAdvertiser method runActivity.
@Override
public void runActivity(@NotNull Project project) {
if (!UpdateSettings.getInstance().isCheckNeeded()) {
return;
}
final UnknownFeaturesCollector collectorSuggester = UnknownFeaturesCollector.getInstance(project);
final Set<UnknownFeature> unknownFeatures = collectorSuggester.getUnknownFeatures();
final KnownExtensions extensions = loadExtensions();
if (extensions != null && unknownFeatures.isEmpty()) {
return;
}
final Application application = ApplicationManager.getApplication();
if (application.isUnitTestMode() || application.isHeadlessEnvironment()) {
return;
}
//noinspection SSBasedInspection
SwingUtilities.invokeLater(() -> application.executeOnPooledThread(new Runnable() {
private final Set<PluginDownloader> myPlugins = new HashSet<>();
private List<IdeaPluginDescriptor> myAllPlugins;
private final Map<Plugin, IdeaPluginDescriptor> myDisabledPlugins = new HashMap<>();
private List<String> myBundledPlugin;
private final MultiMap<String, UnknownFeature> myFeatures = new MultiMap<>();
@Override
public void run() {
if (project.isDisposed()) {
return;
}
try {
myAllPlugins = RepositoryHelper.loadPluginsFromAllRepositories(null);
if (project.isDisposed()) {
return;
}
if (extensions == null) {
loadSupportedExtensions(myAllPlugins);
if (project.isDisposed())
return;
EditorNotifications.getInstance(project).updateAllNotifications();
}
final Map<String, Plugin> ids = new HashMap<>();
for (UnknownFeature feature : unknownFeatures) {
ProgressManager.checkCanceled();
final List<Plugin> pluginId = retrieve(feature);
if (pluginId != null) {
for (Plugin plugin : pluginId) {
ids.put(plugin.myPluginId, plugin);
myFeatures.putValue(plugin.myPluginId, feature);
}
}
}
final List<String> disabledPlugins = PluginManagerCore.getDisabledPlugins();
//include disabled plugins
for (String id : ids.keySet()) {
Plugin plugin = ids.get(id);
if (disabledPlugins.contains(id)) {
final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(PluginId.getId(id));
if (pluginDescriptor != null) {
myDisabledPlugins.put(plugin, pluginDescriptor);
}
}
}
myBundledPlugin = hasBundledPluginToInstall(ids.values());
for (IdeaPluginDescriptor loadedPlugin : myAllPlugins) {
final PluginId pluginId = loadedPlugin.getPluginId();
if (ids.containsKey(pluginId.getIdString()) && !disabledPlugins.contains(pluginId.getIdString()) && !PluginManagerCore.isBrokenPlugin(loadedPlugin)) {
myPlugins.add(PluginDownloader.createDownloader(loadedPlugin));
}
}
ApplicationManager.getApplication().invokeLater(this::onSuccess, ModalityState.NON_MODAL);
} catch (Exception e) {
LOG.info(e);
}
}
private void onSuccess() {
String message = null;
if (!myPlugins.isEmpty() || !myDisabledPlugins.isEmpty()) {
message = getAddressedMessagePresentation();
if (!myDisabledPlugins.isEmpty()) {
message += "<a href=\"enable\">Enable plugins...</a><br>";
} else {
message += "<a href=\"configure\">Configure plugins...</a><br>";
}
message += "<a href=\"ignore\">Ignore Unknown Features</a>";
} else if (myBundledPlugin != null && !PropertiesComponent.getInstance().isTrueValue(IGNORE_ULTIMATE_EDITION)) {
message = "Features covered by " + IDEA_ULTIMATE_EDITION + " (" + StringUtil.join(myBundledPlugin, ", ") + ") are detected.<br>" + "<a href=\"open\">" + CHECK_ULTIMATE_EDITION_TITLE + "</a><br>" + "<a href=\"ignoreUltimate\">" + ULTIMATE_EDITION_SUGGESTION + "</a>";
}
if (message != null) {
final ConfigurePluginsListener notificationListener = new ConfigurePluginsListener(unknownFeatures, project, myAllPlugins, myPlugins, myDisabledPlugins);
NOTIFICATION_GROUP.createNotification(DISPLAY_ID, message, NotificationType.INFORMATION, notificationListener).notify(project);
}
}
@NotNull
private String getAddressedMessagePresentation() {
final MultiMap<String, String> addressedFeatures = MultiMap.createSet();
final Set<String> ids = new LinkedHashSet<>();
for (PluginDownloader plugin : myPlugins) {
ids.add(plugin.getPluginId());
}
for (Plugin plugin : myDisabledPlugins.keySet()) {
ids.add(plugin.myPluginId);
}
for (String id : ids) {
for (UnknownFeature feature : myFeatures.get(id)) {
addressedFeatures.putValue(feature.getFeatureDisplayName(), feature.getImplementationName());
}
}
final String addressedFeaturesPresentation = StringUtil.join(addressedFeatures.entrySet(), entry -> entry.getKey() + "[" + StringUtil.join(entry.getValue(), ", ") + "]", ", ");
final int addressedFeaturesNumber = addressedFeatures.keySet().size();
final int pluginsNumber = ids.size();
return StringUtil.pluralize("Plugin", pluginsNumber) + " supporting " + StringUtil.pluralize("feature", addressedFeaturesNumber) + " (" + addressedFeaturesPresentation + ") " + (pluginsNumber == 1 ? "is" : "are") + " currently " + (myPlugins.isEmpty() ? "disabled" : "not installed") + ".<br>";
}
}));
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class VcsCommittedListsZipperAdapter method groupLocations.
public Pair<List<RepositoryLocationGroup>, List<RepositoryLocation>> groupLocations(final List<RepositoryLocation> in) {
final List<RepositoryLocationGroup> groups = new ArrayList<>();
final List<RepositoryLocation> singles = new ArrayList<>();
final MultiMap<Object, RepositoryLocation> map = new MultiMap<>();
for (RepositoryLocation location : in) {
final Object key = myGroupCreator.createKey(location);
map.putValue(key, location);
}
final Set<Object> keys = map.keySet();
for (Object key : keys) {
final Collection<RepositoryLocation> locations = map.get(key);
if (locations.size() == 1) {
singles.addAll(locations);
} else {
final RepositoryLocationGroup group = myGroupCreator.createGroup(key, locations);
groups.add(group);
}
}
return Pair.create(groups, singles);
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class AbstractDataGetter method preLoadCommitData.
@NotNull
public TIntObjectHashMap<T> preLoadCommitData(@NotNull TIntHashSet commits) throws VcsException {
TIntObjectHashMap<T> result = new TIntObjectHashMap<>();
final MultiMap<VirtualFile, String> rootsAndHashes = MultiMap.create();
commits.forEach(commit -> {
CommitId commitId = myStorage.getCommitId(commit);
if (commitId != null) {
rootsAndHashes.putValue(commitId.getRoot(), commitId.getHash().asString());
}
return true;
});
for (Map.Entry<VirtualFile, Collection<String>> entry : rootsAndHashes.entrySet()) {
VcsLogProvider logProvider = myLogProviders.get(entry.getKey());
if (logProvider != null) {
List<? extends T> details = readDetails(logProvider, entry.getKey(), ContainerUtil.newArrayList(entry.getValue()));
for (T data : details) {
int index = myStorage.getCommitIndex(data.getId(), data.getRoot());
result.put(index, data);
}
saveInCache(result);
} else {
LOG.error("No log provider for root " + entry.getKey().getPath() + ". All known log providers " + myLogProviders);
}
}
return result;
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class SimpleRefGroup method buildGroups.
public static void buildGroups(@NotNull MultiMap<VcsRefType, VcsRef> groupedRefs, boolean compact, boolean showTagNames, @NotNull List<RefGroup> result) {
if (groupedRefs.isEmpty())
return;
if (compact) {
VcsRef firstRef = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(groupedRefs.values()));
RefGroup group = ContainerUtil.getFirstItem(result);
if (group == null) {
result.add(new SimpleRefGroup(firstRef.getType().isBranch() || showTagNames ? firstRef.getName() : "", ContainerUtil.newArrayList(groupedRefs.values())));
} else {
group.getRefs().addAll(groupedRefs.values());
}
} else {
for (Map.Entry<VcsRefType, Collection<VcsRef>> entry : groupedRefs.entrySet()) {
if (entry.getKey().isBranch()) {
for (VcsRef ref : entry.getValue()) {
result.add(new SimpleRefGroup(ref.getName(), ContainerUtil.newArrayList(ref)));
}
} else {
result.add(new SimpleRefGroup(showTagNames ? ObjectUtils.notNull(ContainerUtil.getFirstItem(entry.getValue())).getName() : "", ContainerUtil.newArrayList(entry.getValue())));
}
}
}
}
use of com.intellij.util.containers.MultiMap in project intellij-community by JetBrains.
the class VcsLogRepoSizeCollector method groupRootsByVcs.
@NotNull
private static MultiMap<VcsKey, VirtualFile> groupRootsByVcs(@NotNull Map<VirtualFile, VcsLogProvider> providers) {
MultiMap<VcsKey, VirtualFile> result = MultiMap.create();
for (Map.Entry<VirtualFile, VcsLogProvider> entry : providers.entrySet()) {
VirtualFile root = entry.getKey();
VcsKey vcs = entry.getValue().getSupportedVcs();
result.putValue(vcs, root);
}
return result;
}
Aggregations