diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java index 889859fb21cb..f0f9930f02c7 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java @@ -926,6 +926,10 @@ public abstract class AbstractColorsScheme extends EditorFontCacheImpl implement } public boolean settingsEqual(Object other, @Nullable Predicate colorKeyFilter) { + return settingsEqual(other, colorKeyFilter, false); + } + + public boolean settingsEqual(Object other, @Nullable Predicate colorKeyFilter, boolean ignoreMetaInfo) { if (!(other instanceof AbstractColorsScheme otherScheme)) { return false; } @@ -936,7 +940,8 @@ public abstract class AbstractColorsScheme extends EditorFontCacheImpl implement } for (String propertyName : metaInfo.stringPropertyNames()) { - if (propertyName.equals(META_INFO_CREATION_TIME) || + if (ignoreMetaInfo || + propertyName.equals(META_INFO_CREATION_TIME) || propertyName.equals(META_INFO_MODIFIED_TIME) || propertyName.equals(META_INFO_IDE) || propertyName.equals(META_INFO_IDE_VERSION) || diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.kt b/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.kt index 4dd1dc3fe613..d3e7c9865473 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.kt +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/LafManagerImpl.kt @@ -241,6 +241,7 @@ class LafManagerImpl(private val coroutineScope: CoroutineScope) : LafManager(), } override fun loadState(element: Element) { + replaceIntellijLightThemeIfSelected(element) autodetect = element.getAttributeBooleanValue(ATTRIBUTE_AUTODETECT) preferredLightThemeId = element.getChild(ELEMENT_PREFERRED_LIGHT_LAF)?.getAttributeValue(ATTRIBUTE_THEME_NAME) preferredDarkThemeId = element.getChild(ELEMENT_PREFERRED_DARK_LAF)?.getAttributeValue(ATTRIBUTE_THEME_NAME) @@ -344,6 +345,23 @@ class LafManagerImpl(private val coroutineScope: CoroutineScope) : LafManager(), return element } + //IDEA-331405 Hide IntelliJ Light from new UI + private fun replaceIntellijLightThemeIfSelected(element: Element) { + if (!ExperimentalUI.isNewUI()) return + val replacementThemeId = "JetBrainsLightTheme" + val newThemeId = "ExperimentalLightWithLightHeader" + val prefLightThemeElement = element.getChild(ELEMENT_PREFERRED_LIGHT_LAF) + val preferredLightTheme = prefLightThemeElement?.getAttributeValue(ATTRIBUTE_THEME_NAME) + if (preferredLightTheme == replacementThemeId) { + prefLightThemeElement.setAttribute(ATTRIBUTE_THEME_NAME, newThemeId) + } + val currentThemeElement = element.getChild(ELEMENT_LAF) + val currentTheme = currentThemeElement?.getAttributeValue(ATTRIBUTE_THEME_NAME) + if (currentTheme == replacementThemeId) { + currentThemeElement.setAttribute(ATTRIBUTE_THEME_NAME, newThemeId) + } + } + override fun getInstalledLookAndFeels(): Array { return UiThemeProviderListManager.getInstance().getLaFs().map { it as UIThemeLookAndFeelInfoImpl }.toList().toTypedArray() } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/ThemeListProviderImpl.kt b/platform/platform-impl/src/com/intellij/ide/ui/laf/ThemeListProviderImpl.kt index 9f3bbe26f30b..6b794d814403 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/ThemeListProviderImpl.kt +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/ThemeListProviderImpl.kt @@ -12,8 +12,9 @@ private class ThemeListProviderImpl : ThemeListProvider { if (ExperimentalUI.isNewUI()) { result.add(uiThemeProviderListManager.getThemeListForTargetUI(TargetUIType.NEW).sortedBy { it.name }.toList()) } - result.add((uiThemeProviderListManager.getThemeListForTargetUI(TargetUIType.CLASSIC).filterNot { it.id == "IntelliJ" } - + uiThemeProviderListManager.getThemeListForTargetUI(TargetUIType.UNSPECIFIED)).sortedBy { it.name }.toList()) + result.add((uiThemeProviderListManager.getThemeListForTargetUI(TargetUIType.CLASSIC).filterNot { + it.id == "IntelliJ" || (it.id == "JetBrainsLightTheme" && ExperimentalUI.isNewUI()) + } + uiThemeProviderListManager.getThemeListForTargetUI(TargetUIType.UNSPECIFIED)).sortedBy { it.name }.toList()) return result } } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.kt b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.kt index 102541a593a6..81c71e347d53 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.kt +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.kt @@ -434,6 +434,7 @@ class EditorColorsManagerImpl @NonInjectable constructor(schemeManagerFactory: S override fun loadState(state: State) { this.state = state + hideIntellijLightSchemeIfNeeded() val colorSchemeName = state.colorScheme var colorScheme = colorSchemeName?.let { getScheme(it) } if (colorScheme == null) { @@ -456,7 +457,6 @@ class EditorColorsManagerImpl @NonInjectable constructor(schemeManagerFactory: S } } } - schemeManager.setCurrent(scheme = colorScheme, notify = isInitialConfigurationLoaded) isInitialConfigurationLoaded = true @@ -492,6 +492,22 @@ class EditorColorsManagerImpl @NonInjectable constructor(schemeManagerFactory: S activity.end() } + //IDEA-331405 Hide IntelliJ Light from new UI + private fun hideIntellijLightSchemeIfNeeded() { + if (!ExperimentalUI.isNewUI()) return + val themeName = "IntelliJ Light" + val intellijLightThemes = schemeManager.allSchemes.filter { it.name.contains(themeName) } + val customTheme = intellijLightThemes.find { it.name.startsWith("_@user_") } + if (customTheme != null) { + val defaultScheme = schemeManager.findSchemeByName(themeName) + val isSchemeCustomized = (customTheme as? AbstractColorsScheme)?.settingsEqual(defaultScheme, null, true) != true + if (isSchemeCustomized) { + return + } + } + intellijLightThemes.forEach { schemeManager.removeScheme(it) } + } + override fun isDefaultScheme(scheme: EditorColorsScheme): Boolean = scheme is DefaultColorsScheme private inner class EditorColorSchemeProcessor(