mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Load all infromation from custom repositories instead of ID only. PluginNode constructor introduced for small refactoring. #IDEA-136729 fixed
This commit is contained in:
@@ -101,11 +101,8 @@ public class InstallPluginAction extends AnAction implements DumbAware {
|
||||
pluginNode = (PluginNode)descr;
|
||||
}
|
||||
else if (descr instanceof IdeaPluginDescriptorImpl) {
|
||||
PluginId pluginId = descr.getPluginId();
|
||||
pluginNode = new PluginNode(pluginId);
|
||||
pluginNode.setName(descr.getName());
|
||||
pluginNode = new PluginNode(descr.getPluginId(), descr.getName(), "-1");
|
||||
pluginNode.setDepends(Arrays.asList(descr.getDependentPluginIds()), descr.getOptionalDependentPluginIds());
|
||||
pluginNode.setSize("-1");
|
||||
pluginNode.setRepositoryName(PluginInstaller.UNKNOWN_HOST_MARKER);
|
||||
}
|
||||
|
||||
@@ -156,7 +153,7 @@ public class InstallPluginAction extends AnAction implements DumbAware {
|
||||
}
|
||||
};
|
||||
final List<IdeaPluginDescriptor> plugins = myHost.getPluginsModel().getAllPlugins();
|
||||
PluginManagerMain.downloadPlugins(list, PluginManagerMain.mapToPluginIds(plugins), onInstallRunnable, pluginEnabler, cleanupRunnable);
|
||||
PluginManagerMain.downloadPlugins(list, plugins, onInstallRunnable, pluginEnabler, cleanupRunnable);
|
||||
}
|
||||
catch (final IOException e1) {
|
||||
ourInstallingNodes.removeAll(list);
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -58,7 +59,7 @@ public class PluginInstaller {
|
||||
private PluginInstaller() { }
|
||||
|
||||
public static boolean prepareToInstall(List<PluginNode> pluginsToInstall,
|
||||
List<PluginId> allPlugins,
|
||||
List<IdeaPluginDescriptor> allPlugins,
|
||||
PluginManagerMain.PluginEnabler pluginEnabler,
|
||||
@NotNull ProgressIndicator indicator) {
|
||||
updateUrls(pluginsToInstall, indicator);
|
||||
@@ -111,7 +112,7 @@ public class PluginInstaller {
|
||||
}
|
||||
|
||||
private static boolean prepareToInstall(List<PluginNode> pluginsToInstall,
|
||||
List<PluginId> allPlugins,
|
||||
List<IdeaPluginDescriptor> allPlugins,
|
||||
Set<PluginNode> installedDependant,
|
||||
PluginManagerMain.PluginEnabler pluginEnabler,
|
||||
@NotNull ProgressIndicator indicator) {
|
||||
@@ -138,7 +139,7 @@ public class PluginInstaller {
|
||||
|
||||
private static boolean prepareToInstall(PluginNode pluginNode,
|
||||
List<PluginId> pluginIds,
|
||||
List<PluginId> allPlugins,
|
||||
List<IdeaPluginDescriptor> allPlugins,
|
||||
Set<PluginNode> installedDependant,
|
||||
PluginManagerMain.PluginEnabler pluginEnabler,
|
||||
@NotNull ProgressIndicator indicator) throws IOException {
|
||||
@@ -159,11 +160,15 @@ public class PluginInstaller {
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginNode depPlugin = new PluginNode(depPluginId);
|
||||
depPlugin.setSize("-1");
|
||||
depPlugin.setName(depPluginId.getIdString()); //prevent from exceptions
|
||||
IdeaPluginDescriptor depPluginDescriptor = findPluginInRepo(depPluginId, allPlugins);
|
||||
PluginNode depPlugin;
|
||||
if (depPluginDescriptor instanceof PluginNode) {
|
||||
depPlugin = (PluginNode) depPluginDescriptor;
|
||||
} else {
|
||||
depPlugin = new PluginNode(depPluginId, depPluginId.getIdString(), "-1");
|
||||
}
|
||||
|
||||
if (isPluginInRepo(depPluginId, allPlugins)) {
|
||||
if (depPluginDescriptor != null) {
|
||||
if (ArrayUtil.indexOf(optionalDependentPluginIds, depPluginId) != -1) {
|
||||
optionalDeps.add(depPlugin);
|
||||
}
|
||||
@@ -248,8 +253,9 @@ public class PluginInstaller {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isPluginInRepo(PluginId depPluginId, List<PluginId> allPlugins) {
|
||||
return allPlugins.contains(depPluginId);
|
||||
@Nullable
|
||||
private static IdeaPluginDescriptor findPluginInRepo(PluginId depPluginId, List<IdeaPluginDescriptor> allPlugins) {
|
||||
return allPlugins.stream().parallel().filter(p -> p.getPluginId().equals(depPluginId)).findAny().orElse(null);
|
||||
}
|
||||
|
||||
public static void prepareToUninstall(PluginId pluginId) throws IOException {
|
||||
|
||||
@@ -74,6 +74,7 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces;
|
||||
|
||||
@@ -242,11 +243,6 @@ public abstract class PluginManagerMain implements Disposable {
|
||||
return pluginTable;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<PluginId> mapToPluginIds(List<IdeaPluginDescriptor> plugins) {
|
||||
return ContainerUtil.map(plugins, descriptor -> descriptor.getPluginId());
|
||||
}
|
||||
|
||||
private static String getTextPrefix() {
|
||||
final int fontSize = JBUI.scale(12);
|
||||
final int m1 = JBUI.scale(2);
|
||||
@@ -414,11 +410,15 @@ public abstract class PluginManagerMain implements Disposable {
|
||||
final List<PluginId> allPlugins,
|
||||
final Runnable onSuccess,
|
||||
@Nullable final Runnable cleanup) throws IOException {
|
||||
return downloadPlugins(plugins, allPlugins, onSuccess, new PluginEnabler.HEADLESS(), cleanup);
|
||||
return downloadPlugins(plugins,
|
||||
allPlugins.stream().map(p -> new PluginNode(p, p.getIdString(), "-1")).collect(Collectors.toList()),
|
||||
onSuccess,
|
||||
new PluginEnabler.HEADLESS(),
|
||||
cleanup);
|
||||
}
|
||||
|
||||
public static boolean downloadPlugins(final List<PluginNode> plugins,
|
||||
final List<PluginId> allPlugins,
|
||||
final List<IdeaPluginDescriptor> allPlugins,
|
||||
final Runnable onSuccess,
|
||||
PluginEnabler pluginEnabler,
|
||||
@Nullable final Runnable cleanup) throws IOException {
|
||||
|
||||
@@ -70,6 +70,12 @@ public class PluginNode implements IdeaPluginDescriptor {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public PluginNode(PluginId id, String name, String size) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
+4
-4
@@ -248,7 +248,7 @@ public class PluginsAdvertiser implements StartupActivity {
|
||||
final PluginsAdvertiserDialog advertiserDialog =
|
||||
new PluginsAdvertiserDialog(null,
|
||||
myPlugins.toArray(new PluginDownloader[myPlugins.size()]),
|
||||
PluginManagerMain.mapToPluginIds(myAllPlugins));
|
||||
myAllPlugins);
|
||||
if (advertiserDialog.showAndGet()) {
|
||||
onSuccess.run();
|
||||
}
|
||||
@@ -362,7 +362,7 @@ public class PluginsAdvertiser implements StartupActivity {
|
||||
}
|
||||
|
||||
if (message != null) {
|
||||
final ConfigurePluginsListener notificationListener = new ConfigurePluginsListener(unknownFeatures, project, PluginManagerMain.mapToPluginIds(myAllPlugins), myPlugins, myDisabledPlugins);
|
||||
final ConfigurePluginsListener notificationListener = new ConfigurePluginsListener(unknownFeatures, project, myAllPlugins, myPlugins, myDisabledPlugins);
|
||||
NOTIFICATION_GROUP.createNotification(DISPLAY_ID, message, NotificationType.INFORMATION, notificationListener).notify(project);
|
||||
}
|
||||
}
|
||||
@@ -479,13 +479,13 @@ public class PluginsAdvertiser implements StartupActivity {
|
||||
private static class ConfigurePluginsListener implements NotificationListener {
|
||||
private final Set<UnknownFeature> myUnknownFeatures;
|
||||
private final Project myProject;
|
||||
private final List<PluginId> myAllPlugins;
|
||||
private final List<IdeaPluginDescriptor> myAllPlugins;
|
||||
private final Set<PluginDownloader> myPlugins;
|
||||
private final Map<Plugin, IdeaPluginDescriptor> myDisabledPlugins;
|
||||
|
||||
public ConfigurePluginsListener(Set<UnknownFeature> unknownFeatures,
|
||||
Project project,
|
||||
List<PluginId> allPlugins,
|
||||
List<IdeaPluginDescriptor> allPlugins,
|
||||
Set<PluginDownloader> plugins,
|
||||
Map<Plugin, IdeaPluginDescriptor> disabledPlugins) {
|
||||
myUnknownFeatures = unknownFeatures;
|
||||
|
||||
+2
-3
@@ -17,7 +17,6 @@ package com.intellij.openapi.updateSettings.impl.pluginsAdvertisement;
|
||||
|
||||
import com.intellij.ide.plugins.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.updateSettings.impl.DetectedPluginsPanel;
|
||||
@@ -37,12 +36,12 @@ public class PluginsAdvertiserDialog extends DialogWrapper {
|
||||
|
||||
@Nullable private final Project myProject;
|
||||
private final PluginDownloader[] myUploadedPlugins;
|
||||
private final List<PluginId> myAllPlugins;
|
||||
private final List<IdeaPluginDescriptor> myAllPlugins;
|
||||
private final Set<String> mySkippedPlugins = new HashSet<>();
|
||||
|
||||
private final PluginManagerMain.PluginEnabler.HEADLESS pluginHelper = new PluginManagerMain.PluginEnabler.HEADLESS();
|
||||
|
||||
PluginsAdvertiserDialog(@Nullable Project project, PluginDownloader[] plugins, List<PluginId> allPlugins) {
|
||||
PluginsAdvertiserDialog(@Nullable Project project, PluginDownloader[] plugins, List<IdeaPluginDescriptor> allPlugins) {
|
||||
super(project);
|
||||
myProject = project;
|
||||
Arrays.sort(plugins, (o1, o2) -> o1.getPluginName().compareToIgnoreCase(o2.getPluginName()));
|
||||
|
||||
Reference in New Issue
Block a user