mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
IDEA-264566 "Updates available" icon disappears after IDEA restart
GitOrigin-RevId: 9d3c7f5a5020fd9311e31c3c1dd227268a55da02
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5de604bd33
commit
cbfd2f4ad9
@@ -712,6 +712,7 @@ dialog.title.clear.read.only.file.status=Clear Read-Only Status
|
||||
handle.ro.file.status.type.using.file.system=using file system
|
||||
|
||||
unscramble.dialog.title=Analyze Stack Trace
|
||||
find.ide.update.title=Find IDE Update
|
||||
updates.checking.progress=Checking for Updates
|
||||
updates.checking.platform=Checking for IDE updates
|
||||
updates.checking.plugins=Checking for plugin updates
|
||||
|
||||
@@ -188,6 +188,23 @@ object UpdateChecker {
|
||||
CheckForUpdateResult(UpdateStrategy.State.CONNECTION_ERROR, e)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun checkForPlatformUpdates(indicator: ProgressIndicator?): Triple<CheckForUpdateResult, List<PluginDownloader>?, Collection<IdeaPluginDescriptor>?> {
|
||||
indicator?.text = IdeBundle.message("updates.checking.platform")
|
||||
val platformUpdates = checkForPlatformUpdates(UpdateSettings.getInstance(), indicator)
|
||||
|
||||
if (platformUpdates.state == UpdateStrategy.State.CONNECTION_ERROR || platformUpdates.state == UpdateStrategy.State.NOTHING_LOADED ||
|
||||
platformUpdates.updatedChannel == null || platformUpdates.newBuild == null) {
|
||||
return Triple(platformUpdates, null, null)
|
||||
}
|
||||
|
||||
indicator?.text = IdeBundle.message("updates.checking.plugins")
|
||||
val (pluginUpdates, customRepoPlugins, _) = checkForPluginUpdates(platformUpdates.newBuild.apiVersion, indicator)
|
||||
val updatedPlugins = (pluginUpdates.enabled.asSequence() + pluginUpdates.disabled.asSequence()).filter { !isIgnored(it.descriptor) }.toList()
|
||||
|
||||
return Triple(platformUpdates, updatedPlugins, customRepoPlugins)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Throws(IOException::class, JDOMException::class)
|
||||
fun loadProductData(indicator: ProgressIndicator?): Product? =
|
||||
|
||||
@@ -10,13 +10,22 @@ import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.ide.plugins.PluginStateListener;
|
||||
import com.intellij.ide.plugins.PluginStateManager;
|
||||
import com.intellij.ide.plugins.newui.PluginUpdatesService;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.BuildNumber;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import kotlin.Triple;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -32,6 +41,10 @@ import static java.util.Objects.requireNonNull;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class UpdateSettingsEntryPointActionProvider implements SettingsEntryPointAction.ActionProvider {
|
||||
private static final String NEXT_RUN_KEY_BUILD = "NextRunPlatformUpdateBuild";
|
||||
private static final String NEXT_RUN_KEY_VERSION = "NextRunPlatformUpdateVersion";
|
||||
|
||||
private static String myNextRunPlatformUpdateVersion;
|
||||
private static CheckForUpdateResult myPlatformUpdateInfo;
|
||||
private static @Nullable Collection<IdeaPluginDescriptor> myIncompatiblePlugins;
|
||||
|
||||
@@ -46,10 +59,34 @@ public class UpdateSettingsEntryPointActionProvider implements SettingsEntryPoin
|
||||
public static class LifecycleListener implements AppLifecycleListener {
|
||||
@Override
|
||||
public void appStarted() {
|
||||
preparePrevPlatformUpdate();
|
||||
initPluginsListeners();
|
||||
}
|
||||
}
|
||||
|
||||
private static void preparePrevPlatformUpdate() {
|
||||
PropertiesComponent properties = PropertiesComponent.getInstance();
|
||||
BuildNumber newBuildForUpdate = BuildNumber.fromString(properties.getValue(NEXT_RUN_KEY_BUILD));
|
||||
|
||||
if (newBuildForUpdate != null) {
|
||||
if (newBuildForUpdate.compareTo(ApplicationInfo.getInstance().getBuild()) > 0) {
|
||||
myNextRunPlatformUpdateVersion = properties.getValue(NEXT_RUN_KEY_VERSION);
|
||||
|
||||
if (myNextRunPlatformUpdateVersion != null) {
|
||||
SettingsEntryPointAction.updateState(IconState.ApplicationUpdate);
|
||||
}
|
||||
else {
|
||||
properties.unsetValue(NEXT_RUN_KEY_BUILD);
|
||||
properties.unsetValue(NEXT_RUN_KEY_VERSION);
|
||||
}
|
||||
}
|
||||
else {
|
||||
properties.unsetValue(NEXT_RUN_KEY_BUILD);
|
||||
properties.unsetValue(NEXT_RUN_KEY_VERSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void initPluginsListeners() {
|
||||
if (myUpdatesService == null) {
|
||||
myUpdatesService = PluginUpdatesService.connectWithUpdates(descriptors -> {
|
||||
@@ -92,10 +129,32 @@ public class UpdateSettingsEntryPointActionProvider implements SettingsEntryPoin
|
||||
public static void newPlatformUpdate(@Nullable CheckForUpdateResult platformUpdateInfo,
|
||||
@Nullable List<PluginDownloader> updatedPlugins,
|
||||
@Nullable Collection<IdeaPluginDescriptor> incompatiblePlugins) {
|
||||
newPlatformUpdate(platformUpdateInfo, updatedPlugins, incompatiblePlugins, true);
|
||||
}
|
||||
|
||||
private static void newPlatformUpdate(@Nullable CheckForUpdateResult platformUpdateInfo,
|
||||
@Nullable List<PluginDownloader> updatedPlugins,
|
||||
@Nullable Collection<IdeaPluginDescriptor> incompatiblePlugins,
|
||||
boolean updateMainAction) {
|
||||
myPlatformUpdateInfo = platformUpdateInfo;
|
||||
myUpdatedPlugins = updatedPlugins;
|
||||
myIncompatiblePlugins = incompatiblePlugins;
|
||||
SettingsEntryPointAction.updateState(platformUpdateInfo != null ? IconState.ApplicationUpdate : IconState.Current);
|
||||
myNextRunPlatformUpdateVersion = null;
|
||||
|
||||
if (updateMainAction) {
|
||||
SettingsEntryPointAction.updateState(platformUpdateInfo != null ? IconState.ApplicationUpdate : IconState.Current);
|
||||
}
|
||||
|
||||
PropertiesComponent properties = PropertiesComponent.getInstance();
|
||||
if (platformUpdateInfo == null) {
|
||||
properties.unsetValue(NEXT_RUN_KEY_BUILD);
|
||||
properties.unsetValue(NEXT_RUN_KEY_VERSION);
|
||||
}
|
||||
else {
|
||||
BuildInfo build = requireNonNull(platformUpdateInfo.getNewBuild());
|
||||
properties.setValue(NEXT_RUN_KEY_BUILD, build.toString());
|
||||
properties.setValue(NEXT_RUN_KEY_VERSION, build.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
public static void newPluginUpdates(@Nullable Collection<PluginDownloader> updatedPlugins,
|
||||
@@ -133,7 +192,59 @@ public class UpdateSettingsEntryPointActionProvider implements SettingsEntryPoin
|
||||
public @NotNull Collection<AnAction> getUpdateActions(@NotNull DataContext context) {
|
||||
List<AnAction> actions = new ArrayList<>();
|
||||
|
||||
if (myPlatformUpdateInfo != null) {
|
||||
if (myNextRunPlatformUpdateVersion != null) {
|
||||
actions.add(new DumbAwareAction(IdeBundle.message("settings.entry.point.update.ide.action",
|
||||
ApplicationNamesInfo.getInstance().getFullProductName(),
|
||||
myNextRunPlatformUpdateVersion)) {
|
||||
{
|
||||
getTemplatePresentation().putClientProperty(ICON_KEY, IconState.ApplicationUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
Ref<Triple<CheckForUpdateResult, List<PluginDownloader>, Collection<IdeaPluginDescriptor>>> refResult = new Ref<>();
|
||||
|
||||
ProgressManager.getInstance().run(new Task.Modal(e.getProject(), IdeBundle.message("find.ide.update.title"), true) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
refResult.set(UpdateChecker.checkForPlatformUpdates(indicator));
|
||||
}
|
||||
});
|
||||
|
||||
Triple<CheckForUpdateResult, List<PluginDownloader>, Collection<IdeaPluginDescriptor>> result = refResult.get();
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
CheckForUpdateResult platformUpdateInfo = result.getFirst();
|
||||
if (platformUpdateInfo.getState() == UpdateStrategy.State.CONNECTION_ERROR) {
|
||||
Exception error = platformUpdateInfo.getError();
|
||||
Messages.showErrorDialog(e.getProject(),
|
||||
IdeBundle.message("updates.error.connection.failed", error == null ? "" : error.getMessage()),
|
||||
IdeBundle.message("find.ide.update.title"));
|
||||
return;
|
||||
}
|
||||
if (platformUpdateInfo.getState() == UpdateStrategy.State.NOTHING_LOADED ||
|
||||
platformUpdateInfo.getUpdatedChannel() == null || platformUpdateInfo.getNewBuild() == null) {
|
||||
Messages.showInfoMessage(e.getProject(), IdeBundle.message("updates.no.updates.notification"),
|
||||
IdeBundle.message("find.ide.update.title"));
|
||||
newPlatformUpdate(null, null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
newPlatformUpdate(platformUpdateInfo, result.getSecond(), result.getThird(), false);
|
||||
|
||||
boolean updateStarted = new UpdateInfoDialog(e.getProject(), requireNonNull(myPlatformUpdateInfo.getUpdatedChannel()),
|
||||
requireNonNull(myPlatformUpdateInfo.getNewBuild()),
|
||||
myPlatformUpdateInfo.getPatches(), true, myUpdatedPlugins, myIncompatiblePlugins)
|
||||
.showAndGet();
|
||||
if (updateStarted) {
|
||||
newPlatformUpdate(null, null, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (myPlatformUpdateInfo != null) {
|
||||
actions.add(new DumbAwareAction(IdeBundle.message("settings.entry.point.update.ide.action",
|
||||
ApplicationNamesInfo.getInstance().getFullProductName(),
|
||||
requireNonNull(myPlatformUpdateInfo.getNewBuild()).getVersion())) {
|
||||
|
||||
Reference in New Issue
Block a user