Search in sources :

Example 21 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 22 with IdeaPluginDescriptor

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

the class GitConfig method read.

/**
   * Creates an instance of GitConfig by reading information from the specified {@code .git/config} file.
   * <p/>
   * If some section is invalid, it is skipped, and a warning is reported.
   */
@NotNull
static GitConfig read(@NotNull File configFile) {
    GitConfig emptyConfig = new GitConfig(Collections.<Remote>emptyList(), Collections.<Url>emptyList(), Collections.<BranchConfig>emptyList());
    if (!configFile.exists()) {
        LOG.info("No .git/config file at " + configFile.getPath());
        return emptyConfig;
    }
    Ini ini = new Ini();
    // duplicate keys (e.g. url in [remote])
    ini.getConfig().setMultiOption(true);
    // don't need tree structure: it corrupts url in section name (e.g. [url "http://github.com/"]
    ini.getConfig().setTree(false);
    try {
        ini.load(configFile);
    } catch (IOException e) {
        LOG.warn("Couldn't load .git/config file at " + configFile.getPath(), e);
        return emptyConfig;
    }
    IdeaPluginDescriptor plugin = PluginManager.getPlugin(PluginManagerCore.getPluginByClassName(GitConfig.class.getName()));
    ClassLoader classLoader = plugin == null ? // null e.g. if IDEA is started from IDEA
    GitConfig.class.getClassLoader() : plugin.getPluginClassLoader();
    Pair<Collection<Remote>, Collection<Url>> remotesAndUrls = parseRemotes(ini, classLoader);
    Collection<BranchConfig> trackedInfos = parseTrackedInfos(ini, classLoader);
    return new GitConfig(remotesAndUrls.getFirst(), remotesAndUrls.getSecond(), trackedInfos);
}
Also used : Ini(org.ini4j.Ini) IOException(java.io.IOException) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 23 with IdeaPluginDescriptor

use of com.intellij.ide.plugins.IdeaPluginDescriptor in project intellij-elixir by KronicDeth.

the class Submitter method errorBean.

@NotNull
private static ErrorBean errorBean(@NotNull IdeaLoggingEvent[] events, String additionalInfo) {
    IdeaLoggingEvent event = events[0];
    ErrorBean bean = new ErrorBean(event.getThrowable(), IdeaLogger.ourLastActionId);
    bean.setDescription(additionalInfo);
    bean.setMessage(event.getMessage());
    Throwable throwable = event.getThrowable();
    if (throwable != null) {
        final PluginId pluginId = IdeErrorsDialog.findPluginId(throwable);
        if (pluginId != null) {
            final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
            if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
                bean.setPluginName(ideaPluginDescriptor.getName());
                bean.setPluginVersion(ideaPluginDescriptor.getVersion());
            }
        }
    }
    Object data = event.getData();
    if (data instanceof LogMessageEx) {
        bean.setAttachments(includedAttachments((LogMessageEx) data));
    }
    return bean;
}
Also used : ErrorBean(com.intellij.errorreport.bean.ErrorBean) LogMessageEx(com.intellij.diagnostic.LogMessageEx) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) NotNull(org.jetbrains.annotations.NotNull)

Example 24 with IdeaPluginDescriptor

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

the class ExtensionsRootType method getPluginResourcesRootName.

@Nullable
private String getPluginResourcesRootName(VirtualFile resourcesDir) throws IOException {
    PluginId ownerPluginId = getOwner(resourcesDir);
    if (ownerPluginId == null)
        return null;
    if (PluginManagerCore.CORE_PLUGIN_ID.equals(ownerPluginId.getIdString())) {
        return PlatformUtils.getPlatformPrefix();
    }
    IdeaPluginDescriptor plugin = PluginManager.getPlugin(ownerPluginId);
    if (plugin != null) {
        return plugin.getName();
    }
    return null;
}
Also used : IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) Nullable(org.jetbrains.annotations.Nullable)

Example 25 with IdeaPluginDescriptor

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

the class GutterIconsConfigurable method createUIComponents.

private void createUIComponents() {
    myList = new CheckBoxList<GutterIconDescriptor>() {

        @Override
        protected JComponent adjustRendering(JComponent rootComponent, JCheckBox checkBox, int index, boolean selected, boolean hasFocus) {
            JPanel panel = new JPanel(new BorderLayout());
            panel.setBorder(BorderFactory.createEmptyBorder());
            GutterIconDescriptor descriptor = myList.getItemAt(index);
            Icon icon = descriptor == null ? null : descriptor.getIcon();
            JLabel label = new JLabel(icon == null ? EmptyIcon.ICON_16 : icon);
            label.setOpaque(true);
            label.setPreferredSize(new Dimension(25, -1));
            label.setHorizontalAlignment(SwingConstants.CENTER);
            panel.add(label, BorderLayout.WEST);
            panel.add(checkBox, BorderLayout.CENTER);
            panel.setBackground(getBackground(false));
            label.setBackground(getBackground(selected));
            if (!checkBox.isOpaque()) {
                checkBox.setOpaque(true);
            }
            checkBox.setBorder(null);
            PluginDescriptor pluginDescriptor = myFirstDescriptors.get(descriptor);
            if (pluginDescriptor instanceof IdeaPluginDescriptor) {
                SeparatorWithText separator = new SeparatorWithText();
                String name = ((IdeaPluginDescriptor) pluginDescriptor).getName();
                separator.setCaption("IDEA CORE".equals(name) ? "Common" : name);
                panel.add(separator, BorderLayout.NORTH);
            }
            return panel;
        }

        @Nullable
        @Override
        protected Point findPointRelativeToCheckBox(int x, int y, @NotNull JCheckBox checkBox, int index) {
            return super.findPointRelativeToCheckBoxWithAdjustedRendering(x, y, checkBox, index);
        }
    };
    myList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    myList.setBorder(BorderFactory.createEmptyBorder());
}
Also used : IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginDescriptor(com.intellij.openapi.extensions.PluginDescriptor) SeparatorWithText(com.intellij.ui.SeparatorWithText) EmptyIcon(com.intellij.util.ui.EmptyIcon) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)40 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 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)2