Browse Source

Enable global overwrite of theme defaults.

pull/75/head
weisj 5 years ago
parent
commit
82bb79e1d7
  1. 3
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java
  2. 64
      core/src/main/java/com/github/weisj/darklaf/LafManager.java
  3. 1
      core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java

3
core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

@ -206,6 +206,9 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
Properties uiProps = new Properties();
final Theme currentTheme = LafManager.getTheme();
currentTheme.loadDefaults(uiProps, defaults);
//Load overwrites the user has set.
PropertyLoader.putProperties(LafManager.getUserProperties(), uiProps, defaults);
currentTheme.loadGlobals(uiProps, defaults);
installGlobals(uiProps, defaults);
currentTheme.loadUIProperties(uiProps, defaults);

64
core/src/main/java/com/github/weisj/darklaf/LafManager.java

@ -33,6 +33,7 @@ import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
@ -47,6 +48,7 @@ public final class LafManager {
private static Theme theme;
private static boolean logEnabled = false;
private static boolean decorationsOverwrite = true;
private static Properties properties = new Properties();
static {
enableLogging(true);
@ -215,4 +217,66 @@ public final class LafManager {
}
}
/**
* Set a custom property.
* <p>
* Note: These properties are loaded
* after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values
* specified in `[theme]_defaults.properties`.
*
* @param key the key.
* @param value the value.
*/
public static void setProperty(final String key, final String value) {
properties.setProperty(key, value);
}
/**
* Remove a custom property.
* <p>
* Note: These properties are loaded
* after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values
* specified in `[theme]_defaults.properties`.
*
* @param key the key.
*/
public static void removeProperty(final String key) {
properties.remove(key);
}
/**
* Remove all custom properties.
* <p>
* Note: These properties are loaded
* after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values
* specified in `[theme]_defaults.properties`.
*/
public static void clearProperties() {
properties.clear();
}
/**
* Get the custom properties.
* <p>
* Note: These properties are loaded
* after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values
* specified in `[theme]_defaults.properties`.
*/
public static Properties getUserProperties() {
return properties;
}
/**
* Remove a custom property.
* <p>
* Note: These properties are loaded
* after {@link Theme#loadDefaults(Properties, UIDefaults)} and should only be used to overwrite the values
* specified in `[theme]_defaults.properties`.
*
* @param key the key.
* @return the value associated with `key`.
*/
public String getProperty(final String key) {
return properties.getProperty(key);
}
}

1
core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextFieldUI.java

@ -273,6 +273,7 @@ public class DarkTextFieldUI extends DarkTextFieldUIBridge implements PropertyCh
@Override
protected void installListeners() {
super.installListeners();
JTextComponent c = getComponent();
c.addMouseListener(mouseListener);
c.addMouseMotionListener(mouseMotionListener);

Loading…
Cancel
Save