Search in sources :

Example 11 with Style

use of javax.swing.text.Style in project groovy-core by groovy.

the class ConsoleSupport method addStylesToDocument.

protected void addStylesToDocument(JTextPane outputArea) {
    StyledDocument doc = outputArea.getStyledDocument();
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    Style regular = doc.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "Monospaced");
    promptStyle = doc.addStyle("prompt", regular);
    StyleConstants.setForeground(promptStyle, Color.BLUE);
    commandStyle = doc.addStyle("command", regular);
    StyleConstants.setForeground(commandStyle, Color.MAGENTA);
    outputStyle = doc.addStyle("output", regular);
    StyleConstants.setBold(outputStyle, true);
}
Also used : StyledDocument(javax.swing.text.StyledDocument) Style(javax.swing.text.Style)

Example 12 with Style

use of javax.swing.text.Style in project groovy-core by groovy.

the class GroovyFilter method init.

private void init() {
    StyleContext styleContext = StyleContext.getDefaultStyleContext();
    Style defaultStyle = styleContext.getStyle(StyleContext.DEFAULT_STYLE);
    Style comment = styleContext.addStyle(COMMENT, defaultStyle);
    StyleConstants.setForeground(comment, COMMENT_COLOR);
    StyleConstants.setItalic(comment, true);
    Style quotes = styleContext.addStyle(QUOTES, defaultStyle);
    StyleConstants.setForeground(quotes, Color.MAGENTA.darker().darker());
    Style charQuotes = styleContext.addStyle(SINGLE_QUOTES, defaultStyle);
    StyleConstants.setForeground(charQuotes, Color.GREEN.darker().darker());
    Style slashyQuotes = styleContext.addStyle(SLASHY_QUOTES, defaultStyle);
    StyleConstants.setForeground(slashyQuotes, Color.ORANGE.darker());
    Style digit = styleContext.addStyle(DIGIT, defaultStyle);
    StyleConstants.setForeground(digit, Color.RED.darker());
    Style operation = styleContext.addStyle(OPERATION, defaultStyle);
    StyleConstants.setBold(operation, true);
    Style ident = styleContext.addStyle(IDENT, defaultStyle);
    Style reservedWords = styleContext.addStyle(RESERVED_WORD, defaultStyle);
    StyleConstants.setBold(reservedWords, true);
    StyleConstants.setForeground(reservedWords, Color.BLUE.darker().darker());
    Style leftParens = styleContext.addStyle(IDENT, defaultStyle);
    getRootNode().putStyle(SLASH_STAR_COMMENT, comment);
    getRootNode().putStyle(SLASH_SLASH_COMMENT, comment);
    getRootNode().putStyle(QUOTES, quotes);
    getRootNode().putStyle(SINGLE_QUOTES, charQuotes);
    getRootNode().putStyle(SLASHY_QUOTES, slashyQuotes);
    getRootNode().putStyle(new String[] { HEX_INTEGER_LITERAL, OCTAL_INTEGER_LITERAL, BINARY_INTEGER_LITERAL, DECIMAL_FLOATING_POINT_LITERAL, HEXADECIMAL_FLOATING_POINT_LITERAL, DECIMAL_INTEGER_LITERAL }, digit);
    getRootNode().putStyle(OPERATION, operation);
    StructuredSyntaxDocumentFilter.LexerNode node = createLexerNode();
    node.putStyle(RESERVED_WORDS, reservedWords);
    node.putStyle(LEFT_PARENS, leftParens);
    getRootNode().putChild(OPERATION, node);
    getRootNode().putStyle(IDENT, ident);
    node = createLexerNode();
    node.putStyle(RESERVED_WORDS, reservedWords);
    getRootNode().putChild(IDENT, node);
}
Also used : Style(javax.swing.text.Style) StyleContext(javax.swing.text.StyleContext)

Example 13 with Style

use of javax.swing.text.Style in project groovy by apache.

the class GroovyFilter method init.

private void init() {
    StyleContext styleContext = StyleContext.getDefaultStyleContext();
    Style defaultStyle = styleContext.getStyle(StyleContext.DEFAULT_STYLE);
    Style comment = styleContext.addStyle(COMMENT, defaultStyle);
    StyleConstants.setForeground(comment, COMMENT_COLOR);
    StyleConstants.setItalic(comment, true);
    Style quotes = styleContext.addStyle(QUOTES, defaultStyle);
    StyleConstants.setForeground(quotes, Color.MAGENTA.darker().darker());
    Style charQuotes = styleContext.addStyle(SINGLE_QUOTES, defaultStyle);
    StyleConstants.setForeground(charQuotes, Color.GREEN.darker().darker());
    Style slashyQuotes = styleContext.addStyle(SLASHY_QUOTES, defaultStyle);
    StyleConstants.setForeground(slashyQuotes, Color.ORANGE.darker());
    Style digit = styleContext.addStyle(DIGIT, defaultStyle);
    StyleConstants.setForeground(digit, Color.RED.darker());
    Style operation = styleContext.addStyle(OPERATION, defaultStyle);
    StyleConstants.setBold(operation, true);
    Style ident = styleContext.addStyle(IDENT, defaultStyle);
    Style reservedWords = styleContext.addStyle(RESERVED_WORD, defaultStyle);
    StyleConstants.setBold(reservedWords, true);
    StyleConstants.setForeground(reservedWords, Color.BLUE.darker().darker());
    Style leftParens = styleContext.addStyle(IDENT, defaultStyle);
    getRootNode().putStyle(SLASH_STAR_COMMENT, comment);
    getRootNode().putStyle(SLASH_SLASH_COMMENT, comment);
    getRootNode().putStyle(QUOTES, quotes);
    getRootNode().putStyle(SINGLE_QUOTES, charQuotes);
    getRootNode().putStyle(SLASHY_QUOTES, slashyQuotes);
    getRootNode().putStyle(new String[] { HEX_INTEGER_LITERAL, OCTAL_INTEGER_LITERAL, BINARY_INTEGER_LITERAL, DECIMAL_FLOATING_POINT_LITERAL, HEXADECIMAL_FLOATING_POINT_LITERAL, DECIMAL_INTEGER_LITERAL }, digit);
    getRootNode().putStyle(OPERATION, operation);
    StructuredSyntaxDocumentFilter.LexerNode node = createLexerNode();
    node.putStyle(RESERVED_WORDS, reservedWords);
    node.putStyle(LEFT_PARENS, leftParens);
    getRootNode().putChild(OPERATION, node);
    getRootNode().putStyle(IDENT, ident);
    node = createLexerNode();
    node.putStyle(RESERVED_WORDS, reservedWords);
    getRootNode().putChild(IDENT, node);
}
Also used : Style(javax.swing.text.Style) StyleContext(javax.swing.text.StyleContext)

Example 14 with Style

use of javax.swing.text.Style in project groovy by apache.

the class ConsoleSupport method addStylesToDocument.

protected void addStylesToDocument(JTextPane outputArea) {
    StyledDocument doc = outputArea.getStyledDocument();
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    Style regular = doc.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "Monospaced");
    promptStyle = doc.addStyle("prompt", regular);
    StyleConstants.setForeground(promptStyle, Color.BLUE);
    commandStyle = doc.addStyle("command", regular);
    StyleConstants.setForeground(commandStyle, Color.MAGENTA);
    outputStyle = doc.addStyle("output", regular);
    StyleConstants.setBold(outputStyle, true);
}
Also used : StyledDocument(javax.swing.text.StyledDocument) Style(javax.swing.text.Style)

Example 15 with Style

use of javax.swing.text.Style in project intellij-community by JetBrains.

the class EditableNotificationMessageElement method updateStyle.

protected void updateStyle(@NotNull JEditorPane editorPane, @Nullable JTree tree, Object value, boolean selected, boolean hasFocus) {
    super.updateStyle(editorPane, tree, value, selected, hasFocus);
    final HTMLDocument htmlDocument = (HTMLDocument) editorPane.getDocument();
    final Style linkStyle = htmlDocument.getStyleSheet().getStyle(LINK_STYLE);
    StyleConstants.setForeground(linkStyle, IdeTooltipManager.getInstance().getLinkForeground(false));
    StyleConstants.setItalic(linkStyle, true);
    HTMLDocument.Iterator iterator = htmlDocument.getIterator(HTML.Tag.A);
    while (iterator.isValid()) {
        boolean disabledLink = false;
        final AttributeSet attributes = iterator.getAttributes();
        if (attributes instanceof SimpleAttributeSet) {
            final Object attribute = attributes.getAttribute(HTML.Attribute.HREF);
            if (attribute instanceof String && disabledLinks.containsKey(attribute)) {
                disabledLink = true;
                //TODO [Vlad] add support for disabled link text update
                ////final String linkText = disabledLinks.get(attribute);
                //if (linkText != null) {
                //}
                ((SimpleAttributeSet) attributes).removeAttribute(HTML.Attribute.HREF);
            }
            if (attribute == null) {
                disabledLink = true;
            }
        }
        if (!disabledLink) {
            htmlDocument.setCharacterAttributes(iterator.getStartOffset(), iterator.getEndOffset() - iterator.getStartOffset(), linkStyle, false);
        }
        iterator.next();
    }
}
Also used : SimpleAttributeSet(javax.swing.text.SimpleAttributeSet) SimpleAttributeSet(javax.swing.text.SimpleAttributeSet) AttributeSet(javax.swing.text.AttributeSet) HTMLDocument(javax.swing.text.html.HTMLDocument) Style(javax.swing.text.Style)

Aggregations

Style (javax.swing.text.Style)16 BadLocationException (javax.swing.text.BadLocationException)5 StyledDocument (javax.swing.text.StyledDocument)4 BaseType (com.google.security.zynamics.binnavi.disassembly.types.BaseType)3 HTMLDocument (javax.swing.text.html.HTMLDocument)3 StyleContext (javax.swing.text.StyleContext)2 TypeMember (com.google.security.zynamics.binnavi.disassembly.types.TypeMember)1 LoadingNode (com.intellij.ui.LoadingNode)1 BorderLayout (java.awt.BorderLayout)1 Date (java.util.Date)1 Entry (java.util.Map.Entry)1 JPanel (javax.swing.JPanel)1 JSplitPane (javax.swing.JSplitPane)1 JTabbedPane (javax.swing.JTabbedPane)1 JTable (javax.swing.JTable)1 JTextPane (javax.swing.JTextPane)1 AttributeSet (javax.swing.text.AttributeSet)1 SimpleAttributeSet (javax.swing.text.SimpleAttributeSet)1 StyleSheet (javax.swing.text.html.StyleSheet)1 AssertionResult (org.apache.jmeter.assertions.AssertionResult)1