@Override public UIDefaults getDefaults() { try { final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults"); superMethod.setAccessible(true); final UIDefaults metalDefaults = (UIDefaults) superMethod.invoke(new MetalLookAndFeel()); final UIDefaults defaults = (UIDefaults) superMethod.invoke(base); if (SystemInfo.isLinux) { if (!Registry.is("darcula.use.native.fonts.on.linux")) { Font font = findFont("DejaVu Sans"); if (font != null) { for (Object key : defaults.keySet()) { if (key instanceof String && ((String) key).endsWith(".font")) { defaults.put(key, new FontUIResource(font.deriveFont(13f))); } } } } else if (Arrays.asList("CN", "JP", "KR", "TW") .contains(Locale.getDefault().getCountry())) { for (Object key : defaults.keySet()) { if (key instanceof String && ((String) key).endsWith(".font")) { final Font font = defaults.getFont(key); if (font != null) { defaults.put(key, new FontUIResource("Dialog", font.getStyle(), font.getSize())); } } } } } LafManagerImpl.initInputMapDefaults(defaults); initIdeaDefaults(defaults); patchStyledEditorKit(defaults); patchComboBox(metalDefaults, defaults); defaults.remove("Spinner.arrowButtonBorder"); defaults.put("Spinner.arrowButtonSize", JBUI.size(16, 5).asUIResource()); MetalLookAndFeel.setCurrentTheme(createMetalTheme()); if (SystemInfo.isWindows && Registry.is("ide.win.frame.decoration")) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); } if (SystemInfo.isLinux && JBUI.isHiDPI()) { applySystemFonts(defaults); } defaults.put("EditorPane.font", defaults.getFont("TextField.font")); return defaults; } catch (Exception e) { log(e); } return super.getDefaults(); }
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") protected void loadDefaults(UIDefaults defaults) { final Properties properties = new Properties(); final String osSuffix = SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux"; try { InputStream stream = getClass().getResourceAsStream(getPrefix() + ".properties"); properties.load(stream); stream.close(); stream = getClass().getResourceAsStream(getPrefix() + "_" + osSuffix + ".properties"); properties.load(stream); stream.close(); HashMap<String, Object> darculaGlobalSettings = new HashMap<String, Object>(); final String prefix = getPrefix() + "."; for (String key : properties.stringPropertyNames()) { if (key.startsWith(prefix)) { darculaGlobalSettings.put( key.substring(prefix.length()), parseValue(key, properties.getProperty(key))); } } for (Object key : defaults.keySet()) { if (key instanceof String && ((String) key).contains(".")) { final String s = (String) key; final String darculaKey = s.substring(s.lastIndexOf('.') + 1); if (darculaGlobalSettings.containsKey(darculaKey)) { defaults.put(key, darculaGlobalSettings.get(darculaKey)); } } } for (String key : properties.stringPropertyNames()) { final String value = properties.getProperty(key); defaults.put(key, parseValue(key, value)); } } catch (IOException e) { log(e); } }