public boolean apply(@Nullable JComponent parent) throws ConfigurationException {
    if (ApplicationManager.getApplication().isExitInProgress()) {
      needRestart = true; // don't unload or load plugins, app will exit anyway
    }

    Map<PluginId, IdeaPluginDescriptorImpl> pluginIdMap = PluginManagerCore.INSTANCE.buildPluginIdMap();
    updatePluginDependencies(pluginIdMap);
    assertCanApply(pluginIdMap);

    PluginEnabler pluginEnabler = PluginEnabler.getInstance();
    Set<PluginId> uninstallsRequiringRestart = new HashSet<>();
    for (IdeaPluginDescriptorImpl pluginDescriptor : myDynamicPluginsToUninstall) {
      myDiff.remove(pluginDescriptor);
      PluginId pluginId = pluginDescriptor.getPluginId();

      if (!needRestart) {
        needRestart = !PluginInstaller.uninstallDynamicPlugin(parent, pluginDescriptor, false);
      }

      if (needRestart) {
        uninstallsRequiringRestart.add(pluginId);
        try {
          PluginInstaller.uninstallAfterRestart(pluginDescriptor);
        }
        catch (IOException e) {
          LOG.error(e);
        }
      }
      else {
        getEnabledMap().remove(pluginId);
      }
    }

    for (PendingDynamicPluginInstall pendingPluginInstall : myDynamicPluginsToInstall.values()) {
      PluginId pluginId = pendingPluginInstall.getPluginDescriptor().getPluginId();
      if (!needRestart &&
          !uninstallsRequiringRestart.contains(pluginId)) {
        InstalledPluginsState.getInstance().trackPluginInstallation(() -> {
          needRestart = !PluginInstaller.installAndLoadDynamicPlugin(pendingPluginInstall.getFile(),
                                                                     parent,
                                                                     pendingPluginInstall.getPluginDescriptor());
        });
      }

      if (needRestart) {
        try {
          PluginInstaller.installAfterRestartAndKeepIfNecessary(pendingPluginInstall.getPluginDescriptor(),
                                                                pendingPluginInstall.getFile(),
                                                                null);
        }
        catch (IOException e) {
          LOG.error(e);
        }
      }
    }

    if (needRestart) {
      InstalledPluginsState.getInstance().setRestartRequired(true);
    }

    myDynamicPluginsToInstall.clear();
    myPluginsToRemoveOnCancel.clear();

    needRestart |= !applyEnableDisablePlugins(pluginEnabler, parent);
    myDynamicPluginsToUninstall.clear();
    myUninstalled.clear();
    myDiff.clear();

    if (needRestart) {
      InstalledPluginsState.getInstance().setRestartRequired(true);
    }

    updateButtons();

    isUIDisposedWithApply = true;

    return !needRestart;
  }
public boolean apply(@Nullable JComponent parent)