use of javax.swing.text.html.StyleSheet in project intellij-community by JetBrains.
the class NotificationMessageElement method installJep.
protected JEditorPane installJep(@NotNull JEditorPane myEditorPane) {
String message = StringUtil.join(this.getText(), "<br>");
myEditorPane.setEditable(false);
myEditorPane.setOpaque(false);
myEditorPane.setEditorKit(UIUtil.getHTMLEditorKit());
myEditorPane.setHighlighter(null);
final StyleSheet styleSheet = ((HTMLDocument) myEditorPane.getDocument()).getStyleSheet();
final Style style = styleSheet.addStyle(MSG_STYLE, null);
styleSheet.addStyle(LINK_STYLE, style);
myEditorPane.setText(message);
return myEditorPane;
}
use of javax.swing.text.html.StyleSheet in project intellij-community by JetBrains.
the class TipUIUtil method createTipBrowser.
@NotNull
public static JEditorPane createTipBrowser() {
JEditorPane browser = new JEditorPane();
browser.setEditable(false);
browser.setBackground(UIUtil.getTextFieldBackground());
browser.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
BrowserUtil.browse(e.getURL());
}
}
});
URL resource = ResourceUtil.getResource(TipUIUtil.class, "/tips/css/", UIUtil.isUnderDarcula() ? "tips_darcula.css" : "tips.css");
final StyleSheet styleSheet = UIUtil.loadStyleSheet(resource);
HTMLEditorKit kit = new HTMLEditorKit() {
@Override
public StyleSheet getStyleSheet() {
return styleSheet != null ? styleSheet : super.getStyleSheet();
}
};
browser.setEditorKit(kit);
return browser;
}
use of javax.swing.text.html.StyleSheet in project intellij-community by JetBrains.
the class UIUtil method loadStyleSheet.
@Nullable
public static StyleSheet loadStyleSheet(@Nullable URL url) {
if (url == null)
return null;
try {
StyleSheet styleSheet = new StyleSheet();
styleSheet.loadRules(new InputStreamReader(url.openStream(), CharsetToolkit.UTF8), url);
return styleSheet;
} catch (IOException e) {
LOG.warn(url + " loading failed", e);
return null;
}
}
use of javax.swing.text.html.StyleSheet in project intellij-community by JetBrains.
the class PluginManagerMain method init.
protected void init() {
GuiUtils.replaceJSplitPaneWithIDEASplitter(main);
HTMLEditorKit kit = new HTMLEditorKit();
StyleSheet sheet = kit.getStyleSheet();
// list-style-type: none;
sheet.addRule("ul {margin-left: 16px}");
myDescriptionTextArea.setEditorKit(kit);
myDescriptionTextArea.setEditable(false);
myDescriptionTextArea.addHyperlinkListener(new MyHyperlinkListener());
JScrollPane installedScrollPane = createTable();
myPluginHeaderPanel = new PluginHeaderPanel(this);
myHeader.setBackground(UIUtil.getTextFieldBackground());
myPluginHeaderPanel.getPanel().setBackground(UIUtil.getTextFieldBackground());
myPluginHeaderPanel.getPanel().setOpaque(true);
myHeader.add(myPluginHeaderPanel.getPanel(), BorderLayout.CENTER);
installTableActions();
myTablePanel.add(installedScrollPane, BorderLayout.CENTER);
UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, myPanelDescription);
myPanelDescription.setBorder(JBUI.Borders.emptyLeft(7));
final JPanel header = new JPanel(new BorderLayout()) {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
final Color bg = UIUtil.getTableBackground(false);
((Graphics2D) g).setPaint(new GradientPaint(0, 0, ColorUtil.shift(bg, 1.4), 0, getHeight(), ColorUtil.shift(bg, 0.9)));
g.fillRect(0, 0, getWidth(), getHeight());
}
};
header.setBorder(new CustomLineBorder(1, 1, 0, 1));
final JLabel mySortLabel = new JLabel();
mySortLabel.setForeground(UIUtil.getLabelDisabledForeground());
mySortLabel.setBorder(JBUI.Borders.empty(1, 1, 1, 5));
mySortLabel.setIcon(AllIcons.General.SplitDown);
mySortLabel.setHorizontalTextPosition(SwingConstants.LEADING);
header.add(mySortLabel, BorderLayout.EAST);
myTablePanel.add(header, BorderLayout.NORTH);
myToolbarPanel.setLayout(new BorderLayout());
myActionToolbar = ActionManager.getInstance().createActionToolbar("PluginManager", getActionGroup(true), true);
final JComponent component = myActionToolbar.getComponent();
myToolbarPanel.add(component, BorderLayout.CENTER);
myToolbarPanel.add(myFilter, BorderLayout.WEST);
new ClickListener() {
@Override
public boolean onClick(@NotNull MouseEvent event, int clickCount) {
JBPopupFactory.getInstance().createActionGroupPopup("Sort by:", createSortersGroup(), DataManager.getInstance().getDataContext(pluginTable), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true).showUnderneathOf(mySortLabel);
return true;
}
}.installOn(mySortLabel);
final TableModelListener modelListener = new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
String text = "Sort by:";
if (pluginsModel.isSortByStatus()) {
text += " status,";
}
if (pluginsModel.isSortByRating()) {
text += " rating,";
}
if (pluginsModel.isSortByDownloads()) {
text += " downloads,";
}
if (pluginsModel.isSortByUpdated()) {
text += " updated,";
}
text += " name";
mySortLabel.setText(text);
}
};
pluginTable.getModel().addTableModelListener(modelListener);
modelListener.tableChanged(null);
myDescriptionScrollPane.setBackground(UIUtil.getTextFieldBackground());
Border border = new BorderUIResource.LineBorderUIResource(new JBColor(Gray._220, Gray._55), 1);
myInfoPanel.setBorder(border);
}
use of javax.swing.text.html.StyleSheet in project intellij-community by JetBrains.
the class DarculaLaf method patchStyledEditorKit.
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
private void patchStyledEditorKit(UIDefaults defaults) {
URL url = getClass().getResource(getPrefix() + (JBUI.isUsrHiDPI() ? "@2x.css" : ".css"));
StyleSheet styleSheet = UIUtil.loadStyleSheet(url);
defaults.put("StyledEditorKit.JBDefaultStyle", styleSheet);
try {
Field keyField = HTMLEditorKit.class.getDeclaredField("DEFAULT_STYLES_KEY");
keyField.setAccessible(true);
AppContext.getAppContext().put(keyField.get(null), UIUtil.loadStyleSheet(url));
} catch (Exception e) {
log(e);
}
}
Aggregations