@Override
 public void apply() throws ConfigurationException {
   myDependenciesManager.setAllDependencies(myListModel.getItems());
 }
 @Override
 public boolean isModified() {
   return !new HashSet<ProjectExternalDependency>(myDependenciesManager.getAllDependencies())
       .equals(new HashSet<ProjectExternalDependency>(myListModel.getItems()));
 }
 @Override
 public void reset() {
   List<ProjectExternalDependency> dependencies = myDependenciesManager.getAllDependencies();
   myListModel.replaceAll(dependencies);
 }
 public ExternalDependenciesConfigurable(Project project) {
   myDependenciesManager = ExternalDependenciesManager.getInstance(project);
 }
  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<String>();
    final List<String> missingCustomRepositories = new ArrayList<String>();
    final List<IdeaPluginDescriptor> disabled = new ArrayList<IdeaPluginDescriptor>();
    final List<PluginId> notInstalled = new ArrayList<PluginId>();
    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 '"
                + minVersion
                + "' 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<String>();
                      for (IdeaPluginDescriptor descriptor : disabled) {
                        pluginIds.add(descriptor.getPluginId().getIdString());
                      }
                      for (PluginId pluginId : notInstalled) {
                        pluginIds.add(pluginId.getIdString());
                      }
                      PluginsAdvertiser.installAndEnablePlugins(
                          pluginIds, () -> notification.expire());
                    }
                  }
                }
              })
          .notify(project);
    }
  }
 @Override
 public void runActivity(@NotNull final Project project) {
   // will trigger 'loadState' and run check if required plugins are specified
   ExternalDependenciesManager.getInstance(project);
 }