mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
IJPL-172558 Plugin Advertiser with custom repositories is not efficient
🍒 Cherry-picked from review IJ-CR-150489 Co-authored-by: Roman Shevchenko <roman.shevchenko@jetbrains.com> Merge-request: IJ-MR-152069 Merged-by: Andrzej Ratajczak <Andrzej.Ratajczak@jetbrains.com> GitOrigin-RevId: 2dbb243624ca0b687806b2d9e39bb87d21db97c9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9a9f103ced
commit
3b13bba0dd
@@ -11065,6 +11065,7 @@ f:com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginsAdvertise
|
||||
- sf:setIgnoreIdeSuggestion(Z):V
|
||||
f:com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginsAdvertiserDialog
|
||||
- com.intellij.openapi.ui.DialogWrapper
|
||||
- <init>(com.intellij.openapi.project.Project,java.util.Collection):V
|
||||
- <init>(com.intellij.openapi.project.Project,java.util.Collection,java.util.List):V
|
||||
- doInstallPlugins(Z,com.intellij.openapi.application.ModalityState):V
|
||||
- getPreferredFocusedComponent():javax.swing.JComponent
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.updateSettings.impl.pluginsAdvertisement;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.plugins.*;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManagementPolicy;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.ide.plugins.PluginNode;
|
||||
import com.intellij.ide.plugins.marketplace.IdeCompatibleUpdate;
|
||||
import com.intellij.ide.plugins.marketplace.MarketplaceRequests;
|
||||
import com.intellij.ide.plugins.newui.PluginDetailsPageComponent;
|
||||
@@ -19,7 +22,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -31,7 +33,6 @@ public final class InstallAndEnableTask extends Task.Modal {
|
||||
private final Runnable myOnSuccess;
|
||||
|
||||
private final Set<PluginDownloader> myPlugins = new HashSet<>();
|
||||
private @Nullable List<PluginNode> myCustomPlugins;
|
||||
|
||||
InstallAndEnableTask(@Nullable Project project,
|
||||
@NotNull Set<PluginId> pluginIds,
|
||||
@@ -50,11 +51,7 @@ public final class InstallAndEnableTask extends Task.Modal {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
List<PluginNode> marketplacePlugins = MarketplaceRequests.loadLastCompatiblePluginDescriptors(myPluginIds);
|
||||
myCustomPlugins = RepositoryHelper.loadPluginsFromCustomRepositories(indicator);
|
||||
|
||||
List<IdeaPluginDescriptor> descriptors =
|
||||
new ArrayList<>(RepositoryHelper.mergePluginsFromRepositories(marketplacePlugins, myCustomPlugins, true));
|
||||
var descriptors = new ArrayList<IdeaPluginDescriptor>(MarketplaceRequests.loadLastCompatiblePluginDescriptors(myPluginIds));
|
||||
|
||||
if (myShowDialog) {
|
||||
MarketplaceRequests marketplace = MarketplaceRequests.getInstance();
|
||||
@@ -99,15 +96,7 @@ public final class InstallAndEnableTask extends Task.Modal {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (myCustomPlugins == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
new PluginsAdvertiserDialog(myProject,
|
||||
myPlugins,
|
||||
myCustomPlugins,
|
||||
mySelectAllInDialog,
|
||||
this::runOnSuccess)
|
||||
new PluginsAdvertiserDialog(myProject, myPlugins, mySelectAllInDialog, this::runOnSuccess)
|
||||
.doInstallPlugins(myShowDialog, myModalityState);
|
||||
}
|
||||
|
||||
@@ -117,6 +106,5 @@ public final class InstallAndEnableTask extends Task.Modal {
|
||||
}
|
||||
}
|
||||
|
||||
public Set<PluginDownloader> getPlugins() { return myPlugins; }
|
||||
public @Nullable List<PluginNode> getCustomPlugins() { return myCustomPlugins; }
|
||||
public @NotNull Set<PluginDownloader> getPlugins() { return myPlugins; }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.updateSettings.impl.pluginsAdvertisement;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
@@ -21,20 +21,19 @@ import java.util.function.Predicate;
|
||||
public final class PluginsAdvertiserDialog extends DialogWrapper {
|
||||
private final Collection<PluginDownloader> myPluginToInstall;
|
||||
private final @Nullable Project myProject;
|
||||
private final @NotNull List<PluginNode> myCustomPlugins;
|
||||
private final @Nullable Consumer<Boolean> myFinishFunction;
|
||||
private final boolean mySelectAllSuggestions;
|
||||
private @Nullable DetectedPluginsPanel myPanel;
|
||||
|
||||
PluginsAdvertiserDialog(@Nullable Project project,
|
||||
@NotNull Collection<PluginDownloader> pluginsToInstall,
|
||||
@NotNull List<PluginNode> customPlugins,
|
||||
boolean selectAllSuggestions,
|
||||
@Nullable Consumer<Boolean> finishFunction) {
|
||||
PluginsAdvertiserDialog(
|
||||
@Nullable Project project,
|
||||
@NotNull Collection<PluginDownloader> pluginsToInstall,
|
||||
boolean selectAllSuggestions,
|
||||
@Nullable Consumer<Boolean> finishFunction
|
||||
) {
|
||||
super(project);
|
||||
myProject = project;
|
||||
myPluginToInstall = pluginsToInstall;
|
||||
myCustomPlugins = customPlugins;
|
||||
myFinishFunction = finishFunction;
|
||||
mySelectAllSuggestions = selectAllSuggestions;
|
||||
setTitle(IdeBundle.message("dialog.title.choose.plugins.to.install.or.enable"));
|
||||
@@ -46,10 +45,17 @@ public final class PluginsAdvertiserDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public PluginsAdvertiserDialog(@Nullable Project project,
|
||||
@NotNull Collection<PluginDownloader> pluginsToInstall,
|
||||
@NotNull List<PluginNode> customPlugins) {
|
||||
this(project, pluginsToInstall, customPlugins, false, null);
|
||||
public PluginsAdvertiserDialog(@Nullable Project project, @NotNull Collection<PluginDownloader> pluginsToInstall) {
|
||||
this(project, pluginsToInstall, false, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated custom repositories are no longer supported by the plugin advertiser;
|
||||
* use {@link #PluginsAdvertiserDialog(Project, Collection<PluginDownloader>)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public PluginsAdvertiserDialog(@Nullable Project project, @NotNull Collection<PluginDownloader> pluginsToInstall, @NotNull List<PluginNode> ignored) {
|
||||
this(project, pluginsToInstall, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,7 +102,7 @@ public final class PluginsAdvertiserDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private boolean doInstallPlugins(@NotNull Predicate<? super PluginDownloader> predicate, @NotNull ModalityState modalityState) {
|
||||
return new PluginsAdvertiserDialogPluginInstaller(myProject, myPluginToInstall, myCustomPlugins, myFinishFunction)
|
||||
return new PluginsAdvertiserDialogPluginInstaller(myProject, myPluginToInstall, List.of(), myFinishFunction)
|
||||
.doInstallPlugins(predicate, modalityState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +77,8 @@ class DefaultImportPerformer(private val partials: Collection<PartialImportPerfo
|
||||
installAndEnableTask.run(pi)
|
||||
|
||||
if (installAndEnableTask.plugins.isEmpty()) return PluginInstallationState.NoPlugins
|
||||
val cp = installAndEnableTask.customPlugins ?: return PluginInstallationState.NoPlugins
|
||||
val restartRequiringPlugins = AtomicInteger()
|
||||
val installStatus = doInstallPlugins(project, installAndEnableTask.plugins, cp, pi, restartRequiringPlugins)
|
||||
val installStatus = doInstallPlugins(project, installAndEnableTask.plugins, pi, restartRequiringPlugins)
|
||||
|
||||
logger.info("Finished installing plugins, result: $installStatus")
|
||||
return if (restartRequiringPlugins.get() > 0) PluginInstallationState.RestartRequired else PluginInstallationState.Done
|
||||
@@ -116,13 +115,12 @@ class DefaultImportPerformer(private val partials: Collection<PartialImportPerfo
|
||||
private suspend fun doInstallPlugins(
|
||||
project: Project?,
|
||||
plugins: Collection<PluginDownloader>,
|
||||
customPlugins: List<PluginNode>,
|
||||
pi: ProgressIndicator,
|
||||
restartRequiringPlugins: AtomicInteger): Boolean = coroutineScope {
|
||||
val scope = this
|
||||
|
||||
fun createInstaller(finished: CompletableDeferred<Boolean>) =
|
||||
object : PluginsAdvertiserDialogPluginInstaller(project, plugins, customPlugins, finished::complete) {
|
||||
object : PluginsAdvertiserDialogPluginInstaller(project, plugins, emptyList(), finished::complete) {
|
||||
override fun downloadPlugins(plugins: MutableList<PluginNode>,
|
||||
customPlugins: MutableCollection<PluginNode>,
|
||||
onSuccess: Runnable?,
|
||||
@@ -183,4 +181,4 @@ private suspend fun doDownloadPlugins(
|
||||
}
|
||||
|
||||
return success
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user