Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
crogoz committed Sep 12, 2024
1 parent 567e174 commit 6bc3b5a
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@
import com.intellij.externalDependencies.DependencyOnPlugin;
import com.intellij.externalDependencies.ExternalDependenciesManager;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerConfigurable;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationGroupManager;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.PluginsAdvertiser;
import com.intellij.util.text.VersionComparatorUtil;
import java.util.Optional;
import java.util.Set;

@Service(Service.Level.PROJECT)
public final class PluginUpdateCheckerService {

private static final String PLUGIN_ID = "palantir-gradle-jdks"
private final Logger logger = Logger.getInstance(PluginUpdateCheckerService.class);
private final Project project;

Expand All @@ -45,7 +44,7 @@ public PluginUpdateCheckerService(Project project) {
}

public void checkPluginVersion() {
PluginId pluginId = PluginId.getId("palantir-gradle-jdks");
PluginId pluginId = PluginId.getId(PLUGIN_ID);
IdeaPluginDescriptor pluginDescriptor = PluginManagerCore.getPlugin(pluginId);
if (pluginDescriptor == null) {
logger.info("Plugin " + pluginId + " not found");
Expand All @@ -63,24 +62,16 @@ public void checkPluginVersion() {
.orElse(true);

if (!isPluginUpToDate) {
NotificationGroupManager.getInstance()
Notification notification = NotificationGroupManager.getInstance()
.getNotificationGroup("Update Palantir plugins")
.createNotification(
"Update palantir-gradle-jdks plugin",
String.format(
"Please update the plugin in the Settings window to a version higher than '%s'",
maybeMinVersion.get()),
NotificationType.ERROR)
.notify(project);
Runnable runnable = () -> {
ShowSettingsUtil.getInstance()
.showSettingsDialog(
ProjectUtil.currentOrDefaultProject(project),
PluginManagerConfigurable.class,
_configurable -> PluginManagerConfigurable.showPluginConfigurableAndEnable(
project, Set.of(pluginDescriptor)));
};
ApplicationManager.getApplication().invokeLater(runnable);
NotificationType.ERROR);
notification.notify(project);
PluginsAdvertiser.installAndEnablePlugins(Set.of(PLUGIN_ID), notification::expire);
}
}
}

0 comments on commit 6bc3b5a

Please sign in to comment.