quick doc and tips are broken under darcula

This commit is contained in:
Konstantin Bulenkov
2014-04-02 01:29:20 +02:00
parent 70d6d69ef8
commit ffe1edd1db
2 changed files with 24 additions and 21 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -205,6 +205,8 @@ public class TipUIUtil {
public static JEditorPane createTipBrowser() {
JEditorPane browser = new JEditorPane();
browser.setEditable(false);
HTMLEditorKit editorKit = new HTMLEditorKit();
browser.setEditorKit(editorKit);
browser.setBackground(UIUtil.getTextFieldBackground());
browser.addHyperlinkListener(
new HyperlinkListener() {
@@ -215,23 +217,16 @@ public class TipUIUtil {
}
}
);
HTMLEditorKit kit;
try {
// set default CSS for plugin tips
URL resource = ResourceUtil.getResource(TipUIUtil.class, "/tips/css/", UIUtil.isUnderDarcula() ? "tips_darcula.css" : "tips.css");
final StyleSheet styleSheet = new StyleSheet();
styleSheet.loadRules(new InputStreamReader(resource.openStream()), resource);
kit = new HTMLEditorKit() {
@Override
public StyleSheet getStyleSheet() {
return styleSheet;
}
};
StyleSheet sheet = new StyleSheet();
sheet.loadRules(new InputStreamReader(resource.openStream()), resource);
editorKit.setStyleSheet(sheet);
}
catch (IOException ignored) {
kit = new HTMLEditorKit();
}
browser.setEditorKit(kit);
return browser;
}
}
@@ -1919,16 +1919,24 @@ public class UIUtil {
@NonNls String family = font != null ? font.getFamily() : "Tahoma";
int size = font != null ? font.getSize() : 11;
final StyleSheet style = new StyleSheet();
style.addStyleSheet(DEFAULT_HTML_KIT_CSS);
style.addRule(String.format("body, div, p { font-family: %s; font-size: %s; } p { margin-top: 0; }", family, size));
final String customCss = String.format("body, div, p { font-family: %s; font-size: %s; } p { margin-top: 0; }", family, size);
return new HTMLEditorKit() {
@Override
public StyleSheet getStyleSheet() {
return style;
}
};
if (isUnderDarcula()) {
final HTMLEditorKit kit = new HTMLEditorKit();
kit.getStyleSheet().addRule(customCss);
return kit;
} else {
final StyleSheet style = new StyleSheet();
style.addStyleSheet(DEFAULT_HTML_KIT_CSS);
style.addRule(customCss);
return new HTMLEditorKit() {
@Override
public StyleSheet getStyleSheet() {
return style;
}
};
}
}
public static void removeScrollBorder(final Component c) {