Search in sources :

Example 41 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.

the class InstalledPluginsTableModel method updatePluginDependencies.

protected void updatePluginDependencies() {
    myDependentToRequiredListMap.clear();
    final int rowCount = getRowCount();
    for (int i = 0; i < rowCount; i++) {
        final IdeaPluginDescriptor descriptor = getObjectAt(i);
        final PluginId pluginId = descriptor.getPluginId();
        myDependentToRequiredListMap.remove(pluginId);
        if (descriptor instanceof IdeaPluginDescriptorImpl && ((IdeaPluginDescriptorImpl) descriptor).isDeleted())
            continue;
        final Boolean enabled = myEnabled.get(pluginId);
        if (enabled == null || enabled.booleanValue()) {
            PluginManagerCore.checkDependants(descriptor, pluginId1 -> PluginManager.getPlugin(pluginId1), dependantPluginId -> {
                final Boolean enabled1 = myEnabled.get(dependantPluginId);
                if ((enabled1 == null && !ourState.wasUpdated(dependantPluginId)) || (enabled1 != null && !enabled1.booleanValue())) {
                    Set<PluginId> required = myDependentToRequiredListMap.get(pluginId);
                    if (required == null) {
                        required = new HashSet<>();
                        myDependentToRequiredListMap.put(pluginId, required);
                    }
                    required.add(dependantPluginId);
                }
                return true;
            });
            if (enabled == null && !myDependentToRequiredListMap.containsKey(pluginId) && PluginManagerCore.isCompatible(descriptor)) {
                myEnabled.put(pluginId, true);
            }
        }
    }
}
Also used : PluginId(com.intellij.openapi.extensions.PluginId)

Example 42 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.

the class PluginDownloader method createDownloader.

@NotNull
public static PluginDownloader createDownloader(@NotNull IdeaPluginDescriptor descriptor, @Nullable String host, @Nullable BuildNumber buildNumber, boolean forceHttps) throws IOException {
    try {
        String url = getUrl(descriptor, host, buildNumber);
        String id = descriptor.getPluginId().getIdString();
        PluginDownloader downloader = new PluginDownloader(id, url, descriptor.getName(), descriptor.getVersion(), buildNumber, forceHttps);
        downloader.setDescriptor(descriptor);
        downloader.setDescription(descriptor.getDescription());
        List<PluginId> depends;
        if (descriptor instanceof PluginNode) {
            depends = ((PluginNode) descriptor).getDepends();
        } else {
            depends = new ArrayList<>(Arrays.asList(descriptor.getDependentPluginIds()));
        }
        downloader.setDepends(depends);
        return downloader;
    } catch (URISyntaxException e) {
        throw new IOException(e);
    }
}
Also used : IOException(java.io.IOException) PluginId(com.intellij.openapi.extensions.PluginId) NotNull(org.jetbrains.annotations.NotNull)

Example 43 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.

the class IdeaPluginDescriptorImpl method readExternal.

// used in upsource
protected void readExternal(@NotNull Element element) {
    final PluginBean pluginBean = XmlSerializer.deserialize(element, PluginBean.class);
    url = pluginBean.url;
    myName = pluginBean.name;
    String idString = pluginBean.id;
    if (idString == null || idString.isEmpty()) {
        idString = myName;
    }
    myId = idString == null ? null : PluginId.getId(idString);
    String internalVersionString = pluginBean.formatVersion;
    if (internalVersionString != null) {
        try {
            //noinspection ResultOfMethodCallIgnored
            Integer.parseInt(internalVersionString);
        } catch (NumberFormatException e) {
            LOG.error(new PluginException("Invalid value in plugin.xml format version: '" + internalVersionString + "'", e, myId));
        }
    }
    myUseIdeaClassLoader = pluginBean.useIdeaClassLoader;
    myAllowBundledUpdate = pluginBean.allowBundledUpdate;
    if (pluginBean.ideaVersion != null) {
        mySinceBuild = pluginBean.ideaVersion.sinceBuild;
        myUntilBuild = convertExplicitBigNumberInUntilBuildToStar(pluginBean.ideaVersion.untilBuild);
    }
    myResourceBundleBaseName = pluginBean.resourceBundle;
    myDescriptionChildText = pluginBean.description;
    myChangeNotes = pluginBean.changeNotes;
    myVersion = pluginBean.pluginVersion;
    if (myVersion == null) {
        myVersion = PluginManagerCore.getBuildNumber().asStringWithoutProductCode();
    }
    myCategory = pluginBean.category;
    if (pluginBean.vendor != null) {
        myVendor = pluginBean.vendor.name;
        myVendorEmail = pluginBean.vendor.email;
        myVendorUrl = pluginBean.vendor.url;
        myVendorLogoPath = pluginBean.vendor.logo;
    }
    // preserve items order as specified in xml (filterBadPlugins will not fail if module comes first)
    Set<PluginId> dependentPlugins = new LinkedHashSet<>();
    Set<PluginId> optionalDependentPlugins = new LinkedHashSet<>();
    if (pluginBean.dependencies != null) {
        myOptionalConfigs = new THashMap<>();
        for (PluginDependency dependency : pluginBean.dependencies) {
            String text = dependency.pluginId;
            if (!StringUtil.isEmpty(text)) {
                PluginId id = PluginId.getId(text);
                dependentPlugins.add(id);
                if (dependency.optional) {
                    optionalDependentPlugins.add(id);
                    if (!StringUtil.isEmpty(dependency.configFile)) {
                        myOptionalConfigs.put(id, dependency.configFile);
                    }
                }
            }
        }
    }
    myDependencies = dependentPlugins.isEmpty() ? PluginId.EMPTY_ARRAY : dependentPlugins.toArray(new PluginId[dependentPlugins.size()]);
    myOptionalDependencies = optionalDependentPlugins.isEmpty() ? PluginId.EMPTY_ARRAY : optionalDependentPlugins.toArray(new PluginId[optionalDependentPlugins.size()]);
    if (pluginBean.helpSets == null || pluginBean.helpSets.length == 0) {
        myHelpSets = HelpSetPath.EMPTY;
    } else {
        myHelpSets = new HelpSetPath[pluginBean.helpSets.length];
        PluginHelpSet[] sets = pluginBean.helpSets;
        for (int i = 0, n = sets.length; i < n; i++) {
            PluginHelpSet pluginHelpSet = sets[i];
            myHelpSets[i] = new HelpSetPath(pluginHelpSet.file, pluginHelpSet.path);
        }
    }
    myAppComponents = pluginBean.applicationComponents;
    myProjectComponents = pluginBean.projectComponents;
    myModuleComponents = pluginBean.moduleComponents;
    if (myAppComponents == null)
        myAppComponents = ComponentConfig.EMPTY_ARRAY;
    if (myProjectComponents == null)
        myProjectComponents = ComponentConfig.EMPTY_ARRAY;
    if (myModuleComponents == null)
        myModuleComponents = ComponentConfig.EMPTY_ARRAY;
    StringInterner interner = new StringInterner();
    List<Element> extensions = copyElements(pluginBean.extensions, interner);
    if (extensions != null) {
        myExtensions = MultiMap.createSmart();
        for (Element extension : extensions) {
            myExtensions.putValue(ExtensionsAreaImpl.extractEPName(extension), extension);
        }
    }
    List<Element> extensionPoints = copyElements(pluginBean.extensionPoints, interner);
    if (extensionPoints != null) {
        myExtensionsPoints = MultiMap.createSmart();
        for (Element extensionPoint : extensionPoints) {
            myExtensionsPoints.putValue(StringUtil.notNullize(extensionPoint.getAttributeValue(ExtensionsAreaImpl.ATTRIBUTE_AREA)), extensionPoint);
        }
    }
    myActionsElements = copyElements(pluginBean.actions, interner);
    if (pluginBean.modules != null && !pluginBean.modules.isEmpty()) {
        myModules = pluginBean.modules;
    }
}
Also used : PluginException(com.intellij.diagnostic.PluginException) Element(org.jdom.Element) PluginId(com.intellij.openapi.extensions.PluginId) StringInterner(com.intellij.util.containers.StringInterner)

Example 44 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.

the class PluginClassCache method dumpPluginClassStatistics.

public void dumpPluginClassStatistics() {
    if (!Boolean.valueOf(System.getProperty("idea.is.internal")).booleanValue())
        return;
    List<PluginId> counters;
    synchronized (ourLock) {
        //noinspection unchecked
        counters = new ArrayList(Arrays.asList(myClassCounts.keys()));
    }
    counters.sort((o1, o2) -> myClassCounts.get(o2) - myClassCounts.get(o1));
    for (PluginId id : counters) {
        PluginManagerCore.getLogger().info(id + " loaded " + myClassCounts.get(id) + " classes");
    }
}
Also used : PluginId(com.intellij.openapi.extensions.PluginId)

Example 45 with PluginId

use of com.intellij.openapi.extensions.PluginId in project intellij-community by JetBrains.

the class IntentionDescriptionPanel method setupPoweredByPanel.

private void setupPoweredByPanel(final IntentionActionMetaData actionMetaData) {
    PluginId pluginId = actionMetaData == null ? null : actionMetaData.getPluginId();
    JComponent owner;
    if (pluginId == null) {
        @NonNls String label = XmlStringUtil.wrapInHtml("<b>" + ApplicationNamesInfo.getInstance().getFullProductName() + "</b>");
        owner = new JLabel(label);
    } else {
        final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(pluginId);
        HyperlinkLabel label = new HyperlinkLabel(CodeInsightBundle.message("powered.by.plugin", pluginDescriptor.getName()));
        label.addHyperlinkListener(new HyperlinkListener() {

            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                final ShowSettingsUtil util = ShowSettingsUtil.getInstance();
                final PluginManagerConfigurable pluginConfigurable = new PluginManagerConfigurable(PluginManagerUISettings.getInstance());
                final Project project = ProjectManager.getInstance().getDefaultProject();
                util.editConfigurable(project, pluginConfigurable, () -> pluginConfigurable.select(pluginDescriptor));
            }
        });
        owner = label;
    }
    //myPoweredByContainer.setVisible(true);
    myPoweredByPanel.removeAll();
    myPoweredByPanel.add(owner, BorderLayout.CENTER);
}
Also used : NonNls(org.jetbrains.annotations.NonNls) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) PluginManagerConfigurable(com.intellij.ide.plugins.PluginManagerConfigurable) Project(com.intellij.openapi.project.Project) HyperlinkListener(javax.swing.event.HyperlinkListener) HyperlinkLabel(com.intellij.ui.HyperlinkLabel)

Aggregations

PluginId (com.intellij.openapi.extensions.PluginId)54 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)25 NotNull (org.jetbrains.annotations.NotNull)10 IOException (java.io.IOException)8 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)6 Project (com.intellij.openapi.project.Project)6 Nullable (org.jetbrains.annotations.Nullable)6 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)5 PluginException (com.intellij.diagnostic.PluginException)4 DataContext (com.intellij.openapi.actionSystem.DataContext)4 NonNls (org.jetbrains.annotations.NonNls)4 ErrorBean (com.intellij.errorreport.bean.ErrorBean)3 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)3 PluginDownloader (com.intellij.openapi.updateSettings.impl.PluginDownloader)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 File (java.io.File)3 AbstractMessage (com.intellij.diagnostic.AbstractMessage)2 LogMessageEx (com.intellij.diagnostic.LogMessageEx)2 CantRunException (com.intellij.execution.CantRunException)2 DataManager (com.intellij.ide.DataManager)2