Browse Source

Moved responsibility of loading the accent properties to the theme class.

pull/154/head
weisj 5 years ago
parent
commit
9b7b08791d
  1. 4
      core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java
  2. 14
      theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java

4
core/src/main/java/com/github/weisj/darklaf/task/AccentColorAdjustmentTask.java

@ -49,8 +49,8 @@ public class AccentColorAdjustmentTask extends ColorAdjustmentTask {
public void applyColors(final Theme currentTheme, final Properties properties,
final Color accentColor, final Color selectionColor) {
Properties props = currentTheme.loadPropertyFile("accents", true);
if (props.isEmpty()) return;
Properties props = currentTheme.loadAccentProperties();
if (props == null || props.isEmpty()) return;
if (accentColor != null) {
adjustColors(MAIN_ACCENT_LIST_KEY, accentColor, props, properties);
}

14
theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java

@ -213,6 +213,16 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme> {
PropertyLoader.putProperties(loadPropertyFile(propertySuffix), properties, currentDefaults);
}
/**
* Load the properties specifying how to map the colors from the {@link AccentColorRule} are mapped to the
* properties.
*
* @return the properties providing the mapping rules.
*/
public Properties loadAccentProperties() {
return loadPropertyFile("accents", true);
}
/**
* Load a .properties file using {@link #getLoaderClass()}} to resolve the file path.
* <p>
@ -235,6 +245,10 @@ public abstract class Theme implements Comparable<Theme>, Comparator<Theme> {
protected final Properties loadWithClass(final String name, final Class<?> loaderClass) {
final Properties properties = new Properties();
try (InputStream stream = loaderClass.getResourceAsStream(name)) {
if (stream == null) {
LOGGER.log(Level.SEVERE, "Could not load " + name + ".properties. File not found");
return properties;
}
properties.load(stream);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Could not load " + name + ".properties. " + e.getMessage(), e.getStackTrace());

Loading…
Cancel
Save