IntelliJ Themes:

- accept colors starting with two `#` as valid colors because IntelliJ IDEA does it too
- fixed wrong error message when a color reference is missing

(issue #26)
This commit is contained in:
Karl Tauber
2019-12-06 11:13:50 +01:00
parent adcef385b0
commit b4c1a97687

View File

@@ -230,7 +230,9 @@ public class IntelliJTheme
if( uiValue == null ) {
// fix errors (missing '#' for colors)
if( !valueStr.startsWith( "#" ) && (key.endsWith( "ground" ) || key.endsWith( "Color" )) )
valueStr = "#" + valueStr;
valueStr = fixColorIfValid( "#" + valueStr, valueStr );
else if( valueStr.startsWith( "##" ) )
valueStr = fixColorIfValid( valueStr.substring( 1 ), valueStr );
else if( key.endsWith( ".border" ) || key.endsWith( "Border" ) ) {
List<String> parts = StringUtils.split( valueStr, ',' );
if( parts.size() == 5 && !parts.get( 4 ).startsWith( "#" ) ) {
@@ -277,6 +279,17 @@ public class IntelliJTheme
}
}
private String fixColorIfValid( String newColorStr, String colorStr ) {
try {
// check whether it is valid
UIDefaultsLoader.parseColorRGBA( newColorStr );
return newColorStr;
} catch( IllegalArgumentException ex ) {
return colorStr;
}
}
private void applyColorPalette( UIDefaults defaults ) {
if( icons == null )
return;