Search in sources :

Example 1 with SimpleTextAttributes

use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.

the class ComponentTree method getAttributeWrapper.

private AttributeWrapper getAttributeWrapper(RadComponent component) {
    AttributeWrapper wrapper = AttributeWrapper.DEFAULT;
    final HighlightDisplayLevel level = getHighlightDisplayLevel(myDesigner.getProject(), component);
    if (level != null) {
        TextAttributesKey attributesKey = SeverityRegistrar.getSeverityRegistrar(myDesigner.getProject()).getHighlightInfoTypeBySeverity(level.getSeverity()).getAttributesKey();
        final TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey);
        wrapper = new AttributeWrapper() {

            @Override
            public SimpleTextAttributes getAttribute(SimpleTextAttributes attributes) {
                Color bgColor = textAttributes.getBackgroundColor();
                try {
                    textAttributes.setBackgroundColor(null);
                    return SimpleTextAttributes.fromTextAttributes(TextAttributes.merge(attributes.toTextAttributes(), textAttributes));
                } finally {
                    textAttributes.setBackgroundColor(bgColor);
                }
            }
        };
    }
    return wrapper;
}
Also used : HighlightDisplayLevel(com.intellij.codeHighlighting.HighlightDisplayLevel) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) TextAttributesKey(com.intellij.openapi.editor.colors.TextAttributesKey)

Example 2 with SimpleTextAttributes

use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.

the class ResourceBundleEditorRenderer method customize.

private boolean customize(Object value) {
    final Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
    if (!(userObject instanceof TreeElementWrapper)) {
        return false;
    }
    final TreeElement treeElement = ((TreeElementWrapper) userObject).getValue();
    if (treeElement == null) {
        return false;
    }
    final ItemPresentation presentation = treeElement.getPresentation();
    if (presentation instanceof TextAttributesPresentation) {
        final TextAttributesPresentation textAttributesPresentation = (TextAttributesPresentation) presentation;
        final String text = textAttributesPresentation.getPresentableText();
        if (text != null) {
            final SimpleTextAttributes attr = SimpleTextAttributes.fromTextAttributes(textAttributesPresentation.getTextAttributes(getColorsScheme()));
            append(text, new SimpleTextAttributes(attr.getBgColor(), attr.getFgColor(), attr.getWaveColor(), attr.getStyle() | SimpleTextAttributes.STYLE_OPAQUE));
            return true;
        }
    }
    return false;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeElementWrapper(com.intellij.ide.util.treeView.smartTree.TreeElementWrapper) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) ItemPresentation(com.intellij.navigation.ItemPresentation) TreeElement(com.intellij.ide.util.treeView.smartTree.TreeElement)

Example 3 with SimpleTextAttributes

use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.

the class DomElementsGroupNode method doUpdate.

@Override
protected void doUpdate() {
    setUniformIcon(getNodeIcon());
    clearColoredText();
    final boolean showErrors = hasErrors();
    final int childrenCount = getChildren().length;
    if (childrenCount > 0) {
        final SimpleTextAttributes textAttributes = showErrors ? getWavedAttributes(SimpleTextAttributes.STYLE_BOLD) : new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, SimpleTextAttributes.REGULAR_ATTRIBUTES.getFgColor());
        addColoredFragment(getNodeName(), textAttributes);
        addColoredFragment(" (" + childrenCount + ')', showErrors ? IdeBundle.message("dom.elements.tree.childs.contain.errors") : null, SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES);
    } else {
        addColoredFragment(getNodeName(), SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES);
    }
}
Also used : SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes)

Example 4 with SimpleTextAttributes

use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.

the class InspectionTreeHtmlWriter method serializeTreeToHtml.

private void serializeTreeToHtml() {
    appendHeader();
    appendTree((builder) -> {
        final InspectionTreeTailRenderer tailRenderer = new InspectionTreeTailRenderer(myTree.getContext()) {

            @Override
            protected void appendText(String text, SimpleTextAttributes attributes) {
                builder.append(escapeNonBreakingSymbols(text));
            }

            @Override
            protected void appendText(String text) {
                builder.append(escapeNonBreakingSymbols(text));
            }
        };
        traverseInspectionTree(myTree.getRoot(), (n) -> {
            final int nodeId = System.identityHashCode(n);
            builder.append("<li><label for=\"").append(nodeId).append("\">").append(convertNodeToHtml(n)).append("&nbsp;<span class=\"grayout\">");
            tailRenderer.appendTailText(n);
            builder.append("</span></label><input type=\"checkbox\" ");
            if (n instanceof InspectionRootNode) {
                builder.append("checked");
            }
            builder.append(" onclick=\"navigate(").append(nodeId).append(")\" ");
            builder.append(" id=\"").append(nodeId).append("\" />");
            if (n instanceof RefElementAndDescriptorAware) {
                RefEntity e = ((RefElementAndDescriptorAware) n).getElement();
                if (e != null) {
                    builder.append("<div id=\"d").append(nodeId).append("\" style=\"display:none\">");
                    ((RefElementAndDescriptorAware) n).getPresentation().getComposer().compose(builder, e);
                    builder.append("</div>");
                }
            }
            builder.append("<ol class=\"tree\">");
        }, (n) -> builder.append("</ol></li>"));
    });
    HTMLExportUtil.writeFile(myOutputDir, "index.html", myBuilder, myTree.getContext().getProject());
    InspectionTreeHtmlExportResources.copyInspectionReportResources(myOutputDir);
}
Also used : RefEntity(com.intellij.codeInspection.reference.RefEntity) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes)

Example 5 with SimpleTextAttributes

use of com.intellij.ui.SimpleTextAttributes in project intellij-community by JetBrains.

the class InspectionTreeCellRenderer method getMainForegroundAttributes.

private static SimpleTextAttributes getMainForegroundAttributes(InspectionTreeNode node) {
    SimpleTextAttributes foreground = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    if (node instanceof RefElementNode) {
        RefEntity refElement = ((RefElementNode) node).getElement();
        if (refElement instanceof RefElement) {
            refElement = ((RefElement) refElement).getContainingEntry();
            if (((RefElement) refElement).isEntry() && ((RefElement) refElement).isPermanentEntry()) {
                foreground = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.blue);
            }
        }
    }
    final FileStatus nodeStatus = node.getNodeStatus();
    if (nodeStatus != FileStatus.NOT_CHANGED) {
        foreground = new SimpleTextAttributes(foreground.getBgColor(), nodeStatus.getColor(), foreground.getWaveColor(), foreground.getStyle());
    }
    return foreground;
}
Also used : RefElement(com.intellij.codeInspection.reference.RefElement) FileStatus(com.intellij.openapi.vcs.FileStatus) RefEntity(com.intellij.codeInspection.reference.RefEntity) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes)

Aggregations

SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)87 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)15 JBColor (com.intellij.ui.JBColor)11 NotNull (org.jetbrains.annotations.NotNull)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 SimpleColoredComponent (com.intellij.ui.SimpleColoredComponent)7 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)7 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)6 TextRange (com.intellij.openapi.util.TextRange)6 NodeDescriptor (com.intellij.ide.util.treeView.NodeDescriptor)5 ItemPresentation (com.intellij.navigation.ItemPresentation)4 FileStatus (com.intellij.openapi.vcs.FileStatus)4 PresentationData (com.intellij.ide.projectView.PresentationData)3 PsiElement (com.intellij.psi.PsiElement)3 SimpleColoredText (com.intellij.ui.SimpleColoredText)3 List (java.util.List)3 PsIssue (com.android.tools.idea.gradle.structure.model.PsIssue)2 PTableItem (com.android.tools.idea.uibuilder.property.ptable.PTableItem)2 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)2 RefEntity (com.intellij.codeInspection.reference.RefEntity)2