<commit_before>/*
 * Copyright 2000-2014 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.ide.customize;

import com.intellij.ide.WelcomeWizardUtil;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.plugins.RepositoryHelper;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import icons.PlatformImplIcons;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.io.File;
import java.util.*;

public class PluginGroups {
  static final String CORE = "Core";
  private static final int MAX_DESCR_LENGTH = 55;
  
  public static final String IDEA_VIM_PLUGIN_ID = "IdeaVIM";

  final Map<String, Pair<Icon, List<String>>> myTree = new LinkedHashMap<String, Pair<Icon, List<String>>>();
  final Map<String, String> myFeaturedPlugins = new LinkedHashMap<String, String>();

  private final Map<String, List<IdSet>> myGroups = new LinkedHashMap<String, List<IdSet>>();
  private final Map<String, String> myDescriptions = new LinkedHashMap<String, String>();
  private final List<IdeaPluginDescriptor> myPluginsFromRepository = new ArrayList<IdeaPluginDescriptor>();
  private Collection<String> myDisabledPluginIds = new HashSet<String>();
  private IdeaPluginDescriptor[] myAllPlugins;
  private boolean myInitialized = false;
  private Set<String> myFeaturedIds = new HashSet<String>();

  public PluginGroups() {
    myAllPlugins = PluginManagerCore.loadDescriptors(null);
    try {
      myPluginsFromRepository.addAll(RepositoryHelper.loadPlugins(null));
    }
    catch (Exception e) {
      //OK, it's offline
    }
    PluginManagerCore.loadDisabledPlugins(new File(PathManager.getConfigPath()).getPath(), myDisabledPluginIds);

    initGroups(myTree, myFeaturedPlugins);
  }

  protected void
  initGroups(Map<String, Pair<Icon, List<String>>> tree, Map<String, String> featuredPlugins) {
    tree.put(CORE, Pair.create((Icon)null, Arrays.asList(
      "com.intellij.copyright",
      "com.intellij.java-i18n",
      "org.intellij.intelliLang",
      "com.intellij.properties",
      "Refactor-X",//?
      "Type Migration",
      "ZKM"
    )));
    tree.put("Java Frameworks", Pair.create(PlatformImplIcons.JavaFrameworks, Arrays.asList(
      "com.intellij.appengine",
      "org.intellij.grails",
      "com.intellij.gwt",
      "com.intellij.vaadin",
      "JBoss Seam:com.intellij.seam,com.intellij.seam.pages,com.intellij.seam.pageflow",
      "JBoss jBPM:JBPM",
      "Struts:StrutsAssistant,com.intellij.struts2",
      "com.intellij.hibernate",
      "Spring:com.intellij.spring.batch," +
      "com.intellij.spring.data," +
      "com.intellij.spring.integration," +
      "com.intellij.spring.osgi," +
      "com.intellij.spring.security," +
      "com.intellij.spring," +
      "com.intellij.spring.webflow," +
      "com.intellij.spring.ws,com.intellij.aop",
      "J2EE:com.intellij.javaee.batch," +
      "com.intellij.beanValidation," +
      "com.intellij.cdi," +
      "com.intellij.javaee," +
      "com.intellij.jsf," +
      "com.intellij.javaee.extensions," +
      "com.jetbrains.restWebServices," +
      "Java EE: Web Services (JAX-WS)," +
      "com.intellij.javaee.webSocket," +
      "com.intellij.jsp," +
      "com.intellij.persistence",
      "com.intellij.freemarker",
      "com.intellij.tapestry",
      "com.intellij.velocity",
      "GuiceyIDEA",
      "com.intellij.aspectj",
      "Osmorc"
    )));
    tree.put("Build Tools", Pair.create(PlatformImplIcons.BuildTools, Arrays.asList(
      "AntSupport",
      "Maven:org.jetbrains.idea.maven,org.jetbrains.idea.maven.ext",
      "org.jetbrains.plugins.gradle"
    )));
    tree.put("Web Development", Pair.create(PlatformImplIcons.WebDevelopment, Arrays.asList(
      "HTML:HtmlTools,QuirksMode,W3Validators",
      "org.jetbrains.plugins.haml",
      "com.jetbrains.plugins.jade",
      "com.intellij.css",
      "org.jetbrains.plugins.less",
      "org.jetbrains.plugins.sass",
      "org.jetbrains.plugins.stylus",
      "JavaScript:JavaScript,JavaScriptDebugger,JSIntentionPowerPack",//TODO: Inspection-JS
      "org.coffeescript",
      "com.intellij.flex",
      "com.intellij.plugins.html.instantEditing",
      "com.jetbrains.restClient"
    )));

    addVcsGroup(tree);

    tree.put("Test Tools", Pair.create(PlatformImplIcons.TestTools, Arrays.asList(
      "JUnit",
      "TestNG-J",
      "cucumber-java",
      "cucumber",
      "Coverage:Coverage,Emma"
    )));
    tree.put("Application Servers", Pair.create(PlatformImplIcons.ApplicationServers, Arrays.asList(
      "com.intellij.javaee.view",
      "Geronimo",
      "GlassFish",
      "JBoss",
      "Jetty",
      "Resin",
      "Tomcat",
      "Weblogic",
      "WebSphere",
      "com.intellij.dmserver",
      "JSR45Plugin"
    )));
    tree.put("Clouds", Pair.create(PlatformImplIcons.Clouds, Arrays.asList(
      "CloudFoundry",
      "CloudBees",
      "Heroku",
      "OpenShift"
    )));
    //myTree.put("Groovy", Arrays.asList("org.intellij.grails"));
    //TODO Scala -> Play 2.x (Play 2.0 Support)
    tree.put("Swing", Pair.create(PlatformImplIcons.Swing, Arrays.asList(
      "com.intellij.uiDesigner"//TODO JavaFX?
    )));
    tree.put("Android", Pair.create(PlatformImplIcons.Android, Arrays.asList(
      "org.jetbrains.android",
      "com.intellij.android-designer")));
    tree.put("Database Tools", Pair.create(PlatformImplIcons.DatabaseTools, Arrays.asList(
      "com.intellij.database"
    )));
    tree.put("Other Tools", Pair.create(PlatformImplIcons.OtherTools, Arrays.asList(
      "ByteCodeViewer",
      "com.intellij.dsm",
      "org.jetbrains.idea.eclipse",
      "Remote Access:com.jetbrains.plugins.webDeployment,org.jetbrains.plugins.remote-run",
      "Task Management:com.intellij.tasks,com.intellij.tasks.timeTracking",
      "org.jetbrains.plugins.terminal",
      "com.intellij.diagram",
      "org.jetbrains.plugins.yaml",
      "XSLT and XPath:XPathView,XSLT-Debugger"
    )));
    tree.put("Plugin Development", Pair.create(PlatformImplIcons.PluginDevelopment, Arrays.asList("DevKit")));

    featuredPlugins.put("Scala", "Custom Languages:Plugin for Scala language support:org.intellij.scala");
    featuredPlugins.put("Live Edit Tool",
                        "Web Development:Provides live edit HTML/CSS/JavaScript:com.intellij.plugins.html.instantEditing");
    addVimPlugin(featuredPlugins);
    featuredPlugins.put("NodeJS", "JavaScript:Node.js integration:NodeJS");
    featuredPlugins.put("Atlassian Connector",
                        "Tools Integration:Integration for Atlassian JIRA, Bamboo, Cricible, FishEye:atlassian-idea-plugin");
  }

  protected static void addVcsGroup(Map<String, Pair<Icon, List<String>>> tree) {
    tree.put("Version Controls", Pair.create(PlatformImplIcons.VersionControls, Arrays.asList(
      "ClearcasePlugin",
      "CVS",
      "Git4Idea",
      "org.jetbrains.plugins.github",
      "hg4idea",
      "PerforceDirectPlugin",
      "Subversion",
      "TFS"
    )));
  }

  protected static void addVimPlugin(Map<String, String> featuredPlugins) {
    featuredPlugins.put("IdeaVIM", "Editor:Emulates Vim editor:" + IDEA_VIM_PLUGIN_ID);
  }

  protected static void addLuaPlugin(Map<String, String> featuredPlugins) {
    featuredPlugins.put("Lua", "Custom Languages:Lua language integration:Lua");
  }

  protected static void addMarkdownPlugin(Map<String, String> featuredPlugins) {
    featuredPlugins.put("Markdown", "Custom Languages:Markdown language integration:net.nicoulaj.idea.markdown");
  }

  protected static void addConfigurationServerPlugin(Map<String, String> featuredPlugins) {
    featuredPlugins.put("Configuration Server",
                        "Team Work:Supports sharing settings between installations of IntelliJ Platform based products used by the same developer on different computers:IdeaServerPlugin");
  }

  protected static void addTeamCityPlugin(Map<String, String> featuredPlugins) {
    featuredPlugins.put("TeamCity Integration",
                        "Tools Integration:Integration with JetBrains TeamCity - innovative solution for continuous integration and build management:Jetbrains TeamCity Plugin");
  }

  private void initIfNeed() {
    if (myInitialized) return;
    myInitialized = true;
    for (Map.Entry<String, Pair<Icon, List<String>>> entry : myTree.entrySet()) {<commit_msg>The name of the Vim emulation plugin is "IdeaVim", "IdeaVIM" is the plugin ID<commit_after>/*
 * Copyright 2000-2014 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.ide.customize;

import com.intellij.ide.WelcomeWizardUtil;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.plugins.RepositoryHelper;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import icons.PlatformImplIcons;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.io.File;
import java.util.*;

public class PluginGroups {
  static final String CORE = "Core";
  private static final int MAX_DESCR_LENGTH = 55;
  
  public static final String IDEA_VIM_PLUGIN_ID = "IdeaVIM";

  final Map<String, Pair<Icon, List<String>>> myTree = new LinkedHashMap<String, Pair<Icon, List<String>>>();
  final Map<String, String> myFeaturedPlugins = new LinkedHashMap<String, String>();

  private final Map<String, List<IdSet>> myGroups = new LinkedHashMap<String, List<IdSet>>();
  private final Map<String, String> myDescriptions = new LinkedHashMap<String, String>();
  private final List<IdeaPluginDescriptor> myPluginsFromRepository = new ArrayList<IdeaPluginDescriptor>();
  private Collection<String> myDisabledPluginIds = new HashSet<String>();
  private IdeaPluginDescriptor[] myAllPlugins;
  private boolean myInitialized = false;
  private Set<String> myFeaturedIds = new HashSet<String>();

  public PluginGroups() {
    myAllPlugins = PluginManagerCore.loadDescriptors(null);
    try {
      myPluginsFromRepository.addAll(RepositoryHelper.loadPlugins(null));
    }
    catch (Exception e) {
      //OK, it's offline
    }
    PluginManagerCore.loadDisabledPlugins(new File(PathManager.getConfigPath()).getPath(), myDisabledPluginIds);

    initGroups(myTree, myFeaturedPlugins);
  }

  protected void
  initGroups(Map<String, Pair<Icon, List<String>>> tree, Map<String, String> featuredPlugins) {
    tree.put(CORE, Pair.create((Icon)null, Arrays.asList(
      "com.intellij.copyright",
      "com.intellij.java-i18n",
      "org.intellij.intelliLang",
      "com.intellij.properties",
      "Refactor-X",//?
      "Type Migration",
      "ZKM"
    )));
    tree.put("Java Frameworks", Pair.create(PlatformImplIcons.JavaFrameworks, Arrays.asList(
      "com.intellij.appengine",
      "org.intellij.grails",
      "com.intellij.gwt",
      "com.intellij.vaadin",
      "JBoss Seam:com.intellij.seam,com.intellij.seam.pages,com.intellij.seam.pageflow",
      "JBoss jBPM:JBPM",
      "Struts:StrutsAssistant,com.intellij.struts2",
      "com.intellij.hibernate",
      "Spring:com.intellij.spring.batch," +
      "com.intellij.spring.data," +
      "com.intellij.spring.integration," +
      "com.intellij.spring.osgi," +
      "com.intellij.spring.security," +
      "com.intellij.spring," +
      "com.intellij.spring.webflow," +
      "com.intellij.spring.ws,com.intellij.aop",
      "J2EE:com.intellij.javaee.batch," +
      "com.intellij.beanValidation," +
      "com.intellij.cdi," +
      "com.intellij.javaee," +
      "com.intellij.jsf," +
      "com.intellij.javaee.extensions," +
      "com.jetbrains.restWebServices," +
      "Java EE: Web Services (JAX-WS)," +
      "com.intellij.javaee.webSocket," +
      "com.intellij.jsp," +
      "com.intellij.persistence",
      "com.intellij.freemarker",
      "com.intellij.tapestry",
      "com.intellij.velocity",
      "GuiceyIDEA",
      "com.intellij.aspectj",
      "Osmorc"
    )));
    tree.put("Build Tools", Pair.create(PlatformImplIcons.BuildTools, Arrays.asList(
      "AntSupport",
      "Maven:org.jetbrains.idea.maven,org.jetbrains.idea.maven.ext",
      "org.jetbrains.plugins.gradle"
    )));
    tree.put("Web Development", Pair.create(PlatformImplIcons.WebDevelopment, Arrays.asList(
      "HTML:HtmlTools,QuirksMode,W3Validators",
      "org.jetbrains.plugins.haml",
      "com.jetbrains.plugins.jade",
      "com.intellij.css",
      "org.jetbrains.plugins.less",
      "org.jetbrains.plugins.sass",
      "org.jetbrains.plugins.stylus",
      "JavaScript:JavaScript,JavaScriptDebugger,JSIntentionPowerPack",//TODO: Inspection-JS
      "org.coffeescript",
      "com.intellij.flex",
      "com.intellij.plugins.html.instantEditing",
      "com.jetbrains.restClient"
    )));

    addVcsGroup(tree);

    tree.put("Test Tools", Pair.create(PlatformImplIcons.TestTools, Arrays.asList(
      "JUnit",
      "TestNG-J",
      "cucumber-java",
      "cucumber",
      "Coverage:Coverage,Emma"
    )));
    tree.put("Application Servers", Pair.create(PlatformImplIcons.ApplicationServers, Arrays.asList(
      "com.intellij.javaee.view",
      "Geronimo",
      "GlassFish",
      "JBoss",
      "Jetty",
      "Resin",
      "Tomcat",
      "Weblogic",
      "WebSphere",
      "com.intellij.dmserver",
      "JSR45Plugin"
    )));
    tree.put("Clouds", Pair.create(PlatformImplIcons.Clouds, Arrays.asList(
      "CloudFoundry",
      "CloudBees",
      "Heroku",
      "OpenShift"
    )));
    //myTree.put("Groovy", Arrays.asList("org.intellij.grails"));
    //TODO Scala -> Play 2.x (Play 2.0 Support)
    tree.put("Swing", Pair.create(PlatformImplIcons.Swing, Arrays.asList(
      "com.intellij.uiDesigner"//TODO JavaFX?
    )));
    tree.put("Android", Pair.create(PlatformImplIcons.Android, Arrays.asList(
      "org.jetbrains.android",
      "com.intellij.android-designer")));
    tree.put("Database Tools", Pair.create(PlatformImplIcons.DatabaseTools, Arrays.asList(
      "com.intellij.database"
    )));
    tree.put("Other Tools", Pair.create(PlatformImplIcons.OtherTools, Arrays.asList(
      "ByteCodeViewer",
      "com.intellij.dsm",
      "org.jetbrains.idea.eclipse",
      "Remote Access:com.jetbrains.plugins.webDeployment,org.jetbrains.plugins.remote-run",
      "Task Management:com.intellij.tasks,com.intellij.tasks.timeTracking",
      "org.jetbrains.plugins.terminal",
      "com.intellij.diagram",
      "org.jetbrains.plugins.yaml",
      "XSLT and XPath:XPathView,XSLT-Debugger"
    )));
    tree.put("Plugin Development", Pair.create(PlatformImplIcons.PluginDevelopment, Arrays.asList("DevKit")));

    featuredPlugins.put("Scala", "Custom Languages:Plugin for Scala language support:org.intellij.scala");
    featuredPlugins.put("Live Edit Tool",
                        "Web Development:Provides live edit HTML/CSS/JavaScript:com.intellij.plugins.html.instantEditing");
    addVimPlugin(featuredPlugins);
    featuredPlugins.put("NodeJS", "JavaScript:Node.js integration:NodeJS");
    featuredPlugins.put("Atlassian Connector",
                        "Tools Integration:Integration for Atlassian JIRA, Bamboo, Cricible, FishEye:atlassian-idea-plugin");
  }

  protected static void addVcsGroup(Map<String, Pair<Icon, List<String>>> tree) {
    tree.put("Version Controls", Pair.create(PlatformImplIcons.VersionControls, Arrays.asList(
      "ClearcasePlugin",
      "CVS",
      "Git4Idea",
      "org.jetbrains.plugins.github",
      "hg4idea",
      "PerforceDirectPlugin",
      "Subversion",
      "TFS"
    )));
  }

  protected static void addVimPlugin(Map<String, String> featuredPlugins) {
    featuredPlugins.put("IdeaVim", "Editor:Emulates Vim editor:" + IDEA_VIM_PLUGIN_ID);
  }

  protected static void addLuaPlugin(Map<String, String> featuredPlugins) {
    featuredPlugins.put("Lua", "Custom Languages:Lua language integration:Lua");
  }

  protected static void addMarkdownPlugin(Map<String, String> featuredPlugins) {
    featuredPlugins.put("Markdown", "Custom Languages:Markdown language integration:net.nicoulaj.idea.markdown");
  }

  protected static void addConfigurationServerPlugin(Map<String, String> featuredPlugins) {
    featuredPlugins.put("Configuration Server",
                        "Team Work:Supports sharing settings between installations of IntelliJ Platform based products used by the same developer on different computers:IdeaServerPlugin");
  }

  protected static void addTeamCityPlugin(Map<String, String> featuredPlugins) {
    featuredPlugins.put("TeamCity Integration",
                        "Tools Integration:Integration with JetBrains TeamCity - innovative solution for continuous integration and build management:Jetbrains TeamCity Plugin");
  }

  private void initIfNeed() {
    if (myInitialized) return;
    myInitialized = true;
    for (Map.Entry<String, Pair<Icon, List<String>>> entry : myTree.entrySet()) {
{'fraction_non_alphanumeric': 0.12918427039324018, 'fraction_numerical': 0.0028165962517603727, 'mean_word_length': 3.8130865484880085, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6616150', 'n_tokens_mistral': 6140, 'n_tokens_neox': 5915, 'n_words': 1049}