From 54a53fb527247491fc8051ed4b0e72f53c510aab Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 24 May 2025 13:02:29 +0200 Subject: [PATCH] IntelliJ Themes: fixed logging false errors when loading 3rd party `.theme.json` files (issue #990) --- CHANGELOG.md | 2 + .../com/formdev/flatlaf/IntelliJTheme.java | 39 ++++++++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f16dfde0..b9a0ebca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ FlatLaf Change Log - Extras: Support JSVG 2.0.0. Minimum JSVG version is now 1.6.0. (issue #997) - JideSplitButton: Fixed updating popup when switching theme. (issue #1000) +- IntelliJ Themes: Fixed logging false errors when loading 3rd party + `.theme.json` files. (issue #990) ## 3.6 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java index 8992328d..21874425 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java @@ -413,22 +413,37 @@ public class IntelliJTheme key.equals( "Tree.rightChildIndent" ) ) return; // ignore + // ignore icons + if( key.endsWith( "Icon" ) ) + return; // ignore + // map keys key = uiKeyMapping.getOrDefault( key, key ); if( key.isEmpty() ) return; // ignore key - // exclude properties + // exclude properties (1st level) int dot = key.indexOf( '.' ); - if( dot > 0 && uiKeyExcludes.contains( key.substring( 0, dot + 1 ) ) ) + if( dot > 0 && uiKeyExcludesStartsWith.contains( key.substring( 0, dot + 1 ) ) ) return; + // exclude properties (2st level) + int dot2 = (dot > 0) ? key.indexOf( '.', dot + 1 ) : -1; + if( dot2 > 0 && uiKeyExcludesStartsWith.contains( key.substring( 0, dot2 + 1 ) ) ) + return; + + // exclude properties (contains) + for( String s : uiKeyExcludesContains ) { + if( key.contains( s ) ) + return; + } + if( uiKeyDoNotOverride.contains( key ) && jsonUIKeys.contains( key ) ) return; jsonUIKeys.add( key ); - String valueStr = value.toString(); + String valueStr = value.toString().trim(); // map named colors String uiValue = namedColors.get( valueStr ); @@ -657,7 +672,8 @@ public class IntelliJTheme } } - private static final Set uiKeyExcludes; + private static final Set uiKeyExcludesStartsWith; + private static final String[] uiKeyExcludesContains; private static final Set uiKeyDoNotOverride; /** Rename UI default keys (key --> value). */ private static final Map uiKeyMapping = new HashMap<>(); @@ -669,7 +685,7 @@ public class IntelliJTheme static { // IntelliJ UI properties that are not used in FlatLaf - uiKeyExcludes = new HashSet<>( Arrays.asList( + uiKeyExcludesStartsWith = new HashSet<>( Arrays.asList( "ActionButton.", "ActionToolbar.", "ActionsList.", "AppInspector.", "AssignedMnemonic.", "Autocomplete.", "AvailableMnemonic.", "Badge.", "Banner.", "BigSpinner.", "Bookmark.", "BookmarkIcon.", "BookmarkMnemonicAssigned.", "BookmarkMnemonicAvailable.", @@ -703,14 +719,24 @@ public class IntelliJTheme // possible typos in .theme.json files "Checkbox.", "Toolbar.", "Tooltip.", "UiDesigner.", "link." ) ); + uiKeyExcludesContains = new String[] { + ".darcula." + }; uiKeyDoNotOverride = new HashSet<>( Arrays.asList( "TabbedPane.selectedForeground" ) ); + // "*." + uiKeyMapping.put( "*.fontFace", "" ); // ignore (used in OnePauintxi themes) + uiKeyMapping.put( "*.fontSize", "" ); // ignore (used in OnePauintxi themes) + // Button uiKeyMapping.put( "Button.minimumSize", "" ); // ignore (used in Material Theme UI Lite) + // CheckBox.iconSize + uiKeyMapping.put( "CheckBox.iconSize", "" ); // ignore (used in Rider themes) + // ComboBox uiKeyMapping.put( "ComboBox.background", "" ); // ignore uiKeyMapping.put( "ComboBox.buttonBackground", "" ); // ignore @@ -751,6 +777,9 @@ public class IntelliJTheme uiKeyMapping.put( "ProgressBar.trackColor", "ProgressBar.background" ); uiKeyMapping.put( "ProgressBar.progressColor", "ProgressBar.foreground" ); + // RadioButton + uiKeyMapping.put( "RadioButton.iconSize", "" ); // ignore (used in Rider themes) + // ScrollBar uiKeyMapping.put( "ScrollBar.trackColor", "ScrollBar.track" ); uiKeyMapping.put( "ScrollBar.thumbColor", "ScrollBar.thumb" );