void (@NotNull EditorColorsScheme oldScheme, EditorColorsScheme newScheme, @Nullable Runnable onDone) { String productName = ApplicationNamesInfo.getInstance().getFullProductName(); LafManager lafManager = LafManager.getInstance(); boolean isDarkEditorTheme = ColorUtil.isDark(newScheme.getDefaultBackground()); // 1. Before we start messing around with LaF changes, we better remember the OLD scheme for the current LaF, // because if the user decides to switch the theme, it will make no sense to remember the new scheme for the old theme (IDEA-323306). // 2. But we also need to prevent the LaF manager from remembering it automatically. // 3. In case the user does NOT decide to change the theme, we'll remember the new scheme later. lafManager.rememberSchemeForLaf(oldScheme); lafManager.setRememberSchemeForLaf(false); boolean lafChanged = false; UIThemeLookAndFeelInfo suitableLaf = null; String schemeName = Scheme.getBaseName(newScheme.getName()); for (UIThemeLookAndFeelInfo laf : SequencesKt.asIterable(UiThemeProviderListManager.Companion.getInstance().getLaFs())) { if (schemeName.equals(laf.getEditorSchemeId())) { suitableLaf = laf; break; } } UIThemeLookAndFeelInfo currentLafInfo = lafManager.getCurrentUIThemeLookAndFeel(); Boolean isDark = currentLafInfo == null ? null : currentLafInfo.isDark(); if (isDarkEditorTheme && (isDark != null && !isDark)) { if (/*applyAlways ||*/ Messages.showYesNoDialog( ApplicationBundle.message("color.scheme.theme.change.confirmation", "dark", productName), ApplicationBundle.message("color.scheme.theme.change.confirmation.title", productName), Messages.getYesButton(), Messages.getNoButton(), Messages.getQuestionIcon()/*, doNotAskOption*/) == Messages.YES) { lafManager.setCurrentLookAndFeel(suitableLaf == null ? Objects.requireNonNull(lafManager.getDefaultDarkLaf()) : suitableLaf, true); lafChanged = true; lafManager.updateUI(); SwingUtilities.invokeLater(DarculaInstaller::install); } } else if (!isDarkEditorTheme && (isDark != null && isDark)) { if (/*applyAlways ||*/Messages.showYesNoDialog( ApplicationBundle.message("color.scheme.theme.change.confirmation", "bright", productName), ApplicationBundle.message("color.scheme.theme.change.confirmation.title", productName), Messages.getYesButton(), Messages.getNoButton(), Messages.getQuestionIcon()/*, doNotAskOption*/) == Messages.YES) { lafManager.setCurrentLookAndFeel(suitableLaf == null ? Objects.requireNonNull(lafManager.getDefaultLightLaf()) : suitableLaf, true); lafChanged = true; lafManager.updateUI(); SwingUtilities.invokeLater(DarculaInstaller::uninstall); } } lafManager.setRememberSchemeForLaf(true); if (!lafChanged) { // the user decided to keep the new scheme for the old theme, so remember it. lafManager.rememberSchemeForLaf(newScheme); } if (onDone != null) { SwingUtilities.invokeLater(onDone); } }