Search in sources :

Example 11 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class SelectPluginsStep method buildRequires.

private String buildRequires(final IdeaPluginDescriptor descriptor) {
    StringBuilder requiresBuffer = new StringBuilder();
    for (PluginId id : StartupWizardModel.getNonOptionalDependencies(descriptor)) {
        final IdeaPluginDescriptor dependent = findPlugin(id);
        if (dependent != null) {
            String name = getAbbreviatedName(dependent);
            if (requiresBuffer.length() == 0) {
                requiresBuffer.append("   (requires ");
            } else {
                requiresBuffer.append(", ");
            }
            requiresBuffer.append(name);
        }
    }
    List<IdeaPluginDescriptor> requiredBy = myModel.getDependentsOnEarlierPages(descriptor, false);
    if (requiredBy.size() > 0) {
        if (requiresBuffer.length() > 0) {
            requiresBuffer.append(", ");
        } else {
            requiresBuffer.append("   (");
        }
        requiresBuffer.append("required by ");
        requiresBuffer.append(StringUtil.join(requiredBy, ideaPluginDescriptor -> getAbbreviatedName(ideaPluginDescriptor), ", "));
    }
    if (requiresBuffer.length() > 0) {
        requiresBuffer.append(")");
    }
    return requiresBuffer.toString();
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) StringUtil(com.intellij.openapi.util.text.StringUtil) WizardNavigationState(com.intellij.ui.wizard.WizardNavigationState) CollectionListModel(com.intellij.ui.CollectionListModel) ArrayList(java.util.ArrayList) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) java.awt.event(java.awt.event) WizardStep(com.intellij.ui.wizard.WizardStep) NotNull(org.jetbrains.annotations.NotNull) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) PluginId(com.intellij.openapi.extensions.PluginId) Collections(java.util.Collections) ClickListener(com.intellij.ui.ClickListener) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) javax.swing(javax.swing) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId)

Example 12 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class UpdatePluginsFromCustomRepositoryTest method testOnlyCompatiblePluginsAreChecked.

@Test
public void testOnlyCompatiblePluginsAreChecked() throws Exception {
    Map<PluginId, PluginDownloader> toUpdate = new LinkedHashMap<>();
    IdeaPluginDescriptor[] descriptors = new IdeaPluginDescriptor[] { loadDescriptor("plugin1.xml"), loadDescriptor("plugin2.xml") };
    BuildNumber currentBuildNumber = BuildNumber.fromString("IU-142.100");
    for (IdeaPluginDescriptor descriptor : descriptors) {
        PluginDownloader downloader = PluginDownloader.createDownloader(descriptor, null, currentBuildNumber);
        UpdateChecker.checkAndPrepareToInstall(downloader, new InstalledPluginsState(), toUpdate, new ArrayList<>(), null);
    }
    assertEquals("Found: " + toUpdate.size(), 1, toUpdate.size());
    PluginDownloader downloader = toUpdate.values().iterator().next();
    assertNotNull(downloader);
    assertEquals("0.1", downloader.getPluginVersion());
}
Also used : PluginDownloader(com.intellij.openapi.updateSettings.impl.PluginDownloader) InstalledPluginsState(com.intellij.ide.plugins.InstalledPluginsState) BuildNumber(com.intellij.openapi.util.BuildNumber) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 13 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class InspectionEP method getLocalizedString.

@Nullable
private String getLocalizedString(String bundleName, String key) {
    final String baseName = bundleName != null ? bundleName : bundle == null ? ((IdeaPluginDescriptor) myPluginDescriptor).getResourceBundleBaseName() : bundle;
    if (baseName == null || key == null) {
        if (bundleName != null) {
            LOG.warn(implementationClass);
        }
        return null;
    }
    final ResourceBundle resourceBundle = AbstractBundle.getResourceBundle(baseName, myPluginDescriptor.getPluginClassLoader());
    return CommonBundle.message(resourceBundle, key);
}
Also used : ResourceBundle(java.util.ResourceBundle) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Example 14 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class CheckRequiredPluginsActivity method runCheck.

public static void runCheck(@NotNull final Project project) {
    List<DependencyOnPlugin> dependencies = ExternalDependenciesManager.getInstance(project).getDependencies(DependencyOnPlugin.class);
    if (dependencies.isEmpty())
        return;
    List<String> customRepositories = UpdateSettings.getInstance().getStoredPluginHosts();
    final List<String> errorMessages = new ArrayList<>();
    final List<String> missingCustomRepositories = new ArrayList<>();
    final List<IdeaPluginDescriptor> disabled = new ArrayList<>();
    final List<PluginId> notInstalled = new ArrayList<>();
    for (DependencyOnPlugin dependency : dependencies) {
        PluginId pluginId = PluginId.getId(dependency.getPluginId());
        String channel = dependency.getChannel();
        String customRepository = getCustomRepository(pluginId, channel);
        if (!StringUtil.isEmpty(channel) && customRepositoryNotSpecified(customRepositories, customRepository)) {
            errorMessages.add("Custom repository '" + customRepository + "' required for '" + project.getName() + "' project isn't installed.");
            missingCustomRepositories.add(customRepository);
        }
        IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
        if (plugin == null) {
            errorMessages.add("Plugin '" + dependency.getPluginId() + "' required for '" + project.getName() + "' project isn't installed.");
            notInstalled.add(pluginId);
            continue;
        }
        if (!plugin.isEnabled()) {
            errorMessages.add("Plugin '" + plugin.getName() + "' required for '" + project.getName() + "' project is disabled.");
            disabled.add(plugin);
            continue;
        }
        String minVersion = dependency.getMinVersion();
        if (minVersion != null && VersionComparatorUtil.compare(plugin.getVersion(), minVersion) < 0) {
            errorMessages.add("Project '" + project.getName() + "' requires plugin  '" + plugin.getName() + "' version '" + minVersion + "' or higher, but '" + plugin.getVersion() + "' is installed.");
        }
        String maxVersion = dependency.getMaxVersion();
        if (maxVersion != null && VersionComparatorUtil.compare(plugin.getVersion(), maxVersion) > 0) {
            errorMessages.add("Project '" + project.getName() + "' requires plugin  '" + plugin.getName() + "' version '" + maxVersion + "' or lower, but '" + plugin.getVersion() + "' is installed.");
        }
    }
    if (!errorMessages.isEmpty()) {
        if (!missingCustomRepositories.isEmpty()) {
            errorMessages.add("<a href=\"addRepositories\">Add custom repositories and install required plugins</a>");
        } else if (!disabled.isEmpty() && notInstalled.isEmpty()) {
            String plugins = disabled.size() == 1 ? disabled.get(0).getName() : "required plugins";
            errorMessages.add("<a href=\"enable\">Enable " + plugins + "</a>");
        } else if (!disabled.isEmpty() || !notInstalled.isEmpty()) {
            errorMessages.add("<a href=\"install\">Install required plugins</a>");
        }
        NOTIFICATION_GROUP.createNotification("Required plugins weren't loaded", StringUtil.join(errorMessages, "<br>"), NotificationType.ERROR, new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull final Notification notification, @NotNull HyperlinkEvent event) {
                if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    if ("addRepositories".equals(event.getDescription())) {
                        UpdateSettings.getInstance().getStoredPluginHosts().addAll(missingCustomRepositories);
                    }
                    if ("enable".equals(event.getDescription())) {
                        notification.expire();
                        for (IdeaPluginDescriptor descriptor : disabled) {
                            PluginManagerCore.enablePlugin(descriptor.getPluginId().getIdString());
                        }
                        PluginManagerMain.notifyPluginsUpdated(project);
                    } else if ("install".equals(event.getDescription()) || "addRepositories".equals(event.getDescription())) {
                        Set<String> pluginIds = new HashSet<>();
                        for (IdeaPluginDescriptor descriptor : disabled) {
                            pluginIds.add(descriptor.getPluginId().getIdString());
                        }
                        for (PluginId pluginId : notInstalled) {
                            pluginIds.add(pluginId.getIdString());
                        }
                        PluginsAdvertiser.installAndEnablePlugins(pluginIds, () -> notification.expire());
                    }
                }
            }
        }).notify(project);
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) NotNull(org.jetbrains.annotations.NotNull) DependencyOnPlugin(com.intellij.externalDependencies.DependencyOnPlugin)

Example 15 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-community by JetBrains.

the class HelpManagerImpl method createHelpSet.

@Nullable
private static HelpSet createHelpSet() {
    String urlToHelp = ApplicationInfo.getInstance().getHelpURL() + "/" + HELP_HS;
    HelpSet mainHelpSet = loadHelpSet(urlToHelp);
    if (mainHelpSet == null)
        return null;
    // merge plugins help sets
    IdeaPluginDescriptor[] pluginDescriptors = PluginManagerCore.getPlugins();
    for (IdeaPluginDescriptor pluginDescriptor : pluginDescriptors) {
        HelpSetPath[] sets = pluginDescriptor.getHelpSets();
        for (HelpSetPath hsPath : sets) {
            String url = "jar:file:///" + pluginDescriptor.getPath().getAbsolutePath() + "/help/" + hsPath.getFile() + "!";
            if (!hsPath.getPath().startsWith("/")) {
                url += "/";
            }
            url += hsPath.getPath();
            HelpSet pluginHelpSet = loadHelpSet(url);
            if (pluginHelpSet != null) {
                mainHelpSet.add(pluginHelpSet);
            }
        }
    }
    return mainHelpSet;
}
Also used : HelpSet(javax.help.HelpSet) HelpSetPath(com.intellij.ide.plugins.HelpSetPath) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)41 PluginId (com.intellij.openapi.extensions.PluginId)19 NotNull (org.jetbrains.annotations.NotNull)11 Nullable (org.jetbrains.annotations.Nullable)8 Project (com.intellij.openapi.project.Project)4 File (java.io.File)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 ErrorBean (com.intellij.errorreport.bean.ErrorBean)3 ApplicationInfoEx (com.intellij.openapi.application.ex.ApplicationInfoEx)3 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)3 URL (java.net.URL)3 LogMessageEx (com.intellij.diagnostic.LogMessageEx)2 CantRunException (com.intellij.execution.CantRunException)2 PluginClassLoader (com.intellij.ide.plugins.cl.PluginClassLoader)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)2 PluginDescriptor (com.intellij.openapi.extensions.PluginDescriptor)2 ShowSettingsUtil (com.intellij.openapi.options.ShowSettingsUtil)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2