Search in sources :

Example 41 with SimpleTextAttributes

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

the class FocusDebugger method propertyChange.

@Override
public void propertyChange(PropertyChangeEvent evt) {
    final Object newValue = evt.getNewValue();
    final Object oldValue = evt.getOldValue();
    boolean affectsDebugger = false;
    if (newValue instanceof Component && isInsideDebuggerDialog((Component) newValue)) {
        affectsDebugger |= true;
    }
    if (oldValue instanceof Component && isInsideDebuggerDialog((Component) oldValue)) {
        affectsDebugger |= true;
    }
    final SimpleColoredText text = new SimpleColoredText();
    text.append(evt.getPropertyName(), maybeGrayOut(new SimpleTextAttributes(SimpleTextAttributes.STYLE_UNDERLINE, null), affectsDebugger));
    text.append(" newValue=", maybeGrayOut(SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES, affectsDebugger));
    text.append(evt.getNewValue() + "", maybeGrayOut(SimpleTextAttributes.REGULAR_ATTRIBUTES, affectsDebugger));
    text.append(" oldValue=" + evt.getOldValue(), maybeGrayOut(SimpleTextAttributes.REGULAR_ATTRIBUTES, affectsDebugger));
    myLogModel.addElement(new FocusElement(text, new Throwable()));
    SwingUtilities.invokeLater(() -> {
        if (myLog != null && myLog.isShowing()) {
            final int h = myLog.getFixedCellHeight();
            myLog.scrollRectToVisible(new Rectangle(0, myLog.getPreferredSize().height - h, myLog.getWidth(), h));
            if (myLog.getModel().getSize() > 0) {
                myLog.setSelectedIndex(myLog.getModel().getSize() - 1);
            }
        }
    });
}
Also used : SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) SimpleColoredText(com.intellij.ui.SimpleColoredText)

Example 42 with SimpleTextAttributes

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

the class SliceUsageCellRenderer method customizeCellRendererFor.

@Override
public void customizeCellRendererFor(@NotNull SliceUsage sliceUsage) {
    boolean isForcedLeaf = sliceUsage instanceof JavaSliceDereferenceUsage;
    //might come SliceTooComplexDFAUsage
    JavaSliceUsage javaSliceUsage = sliceUsage instanceof JavaSliceUsage ? (JavaSliceUsage) sliceUsage : null;
    TextChunk[] text = sliceUsage.getText();
    boolean isInsideContainer = javaSliceUsage != null && javaSliceUsage.indexNesting != 0;
    for (int i = 0, length = text.length; i < length; i++) {
        TextChunk textChunk = text[i];
        SimpleTextAttributes attributes = textChunk.getSimpleAttributesIgnoreBackground();
        if (isForcedLeaf) {
            attributes = attributes.derive(attributes.getStyle(), JBColor.LIGHT_GRAY, attributes.getBgColor(), attributes.getWaveColor());
        }
        boolean inUsage = BitUtil.isSet(attributes.getFontStyle(), Font.BOLD);
        if (isInsideContainer && inUsage) {
        //Color darker = Color.BLACK;//attributes.getBgColor() == null ? Color.BLACK : attributes.getBgColor().darker();
        //attributes = attributes.derive(SimpleTextAttributes.STYLE_OPAQUE, attributes.getFgColor(), UIUtil.getTreeBackground().brighter(), attributes.getWaveColor());
        //setMyBorder(IdeBorderFactory.createRoundedBorder(10, 3));
        //setPaintFocusBorder(true);
        }
        append(textChunk.getText(), attributes);
        if (i == 0) {
            append(FontUtil.spaceAndThinSpace());
        }
    }
    if (javaSliceUsage != null && javaSliceUsage.indexNesting != 0) {
        append(" (Tracking container '" + getContainerName(javaSliceUsage) + (javaSliceUsage.syntheticField.isEmpty() ? "" : "." + javaSliceUsage.syntheticField) + "' contents)", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
    }
    PsiElement element = sliceUsage.getElement();
    PsiMethod method;
    PsiClass aClass;
    while (true) {
        method = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
        aClass = method == null ? PsiTreeUtil.getParentOfType(element, PsiClass.class) : method.getContainingClass();
        if (aClass instanceof PsiAnonymousClass) {
            element = aClass;
        } else {
            break;
        }
    }
    int methodOptions = PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS | PsiFormatUtilBase.SHOW_CONTAINING_CLASS;
    String location = method != null ? PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, methodOptions, PsiFormatUtilBase.SHOW_TYPE, 2) : aClass != null ? PsiFormatUtil.formatClass(aClass, PsiFormatUtilBase.SHOW_NAME) : null;
    if (location != null) {
        SimpleTextAttributes attributes = SimpleTextAttributes.GRAY_ATTRIBUTES;
        append(" in " + location, attributes);
    }
    Language language = element == null ? JavaLanguage.INSTANCE : element.getLanguage();
    if (language != JavaLanguage.INSTANCE) {
        SliceLanguageSupportProvider foreignSlicing = LanguageSlicing.getProvider(element);
        if (foreignSlicing == null) {
            append(" (in " + language.getDisplayName() + " file - stopped here)", SimpleTextAttributes.EXCLUDED_ATTRIBUTES);
        }
    }
}
Also used : TextChunk(com.intellij.usages.TextChunk) Language(com.intellij.lang.Language) JavaLanguage(com.intellij.lang.java.JavaLanguage) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes)

Example 43 with SimpleTextAttributes

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

the class VcsLinkedTextComponent method render.

public void render(@NotNull ColoredTreeCellRenderer renderer) {
    boolean isActive = mySelected || myUnderlined;
    SimpleTextAttributes linkTextAttributes = isActive ? SimpleTextAttributes.LINK_ATTRIBUTES : SimpleTextAttributes.SYNTHETIC_ATTRIBUTES;
    isActive = isActive || !myTransparent;
    SimpleTextAttributes wrappedTextAttributes = PushLogTreeUtil.addTransparencyIfNeeded(SimpleTextAttributes.REGULAR_ATTRIBUTES, isActive);
    if (!StringUtil.isEmptyOrSpaces(myTextBefore)) {
        renderer.append(myTextBefore, wrappedTextAttributes);
        renderer.append(" ");
    }
    if (!StringUtil.isEmptyOrSpaces(myHandledLink)) {
        renderer.append(myHandledLink, PushLogTreeUtil.addTransparencyIfNeeded(linkTextAttributes, isActive), this);
    }
    renderer.append(myTextAfter, wrappedTextAttributes);
}
Also used : SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes)

Example 44 with SimpleTextAttributes

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

the class AbstractInfoCellRenderer method appendFrameInfo.

protected void appendFrameInfo(@NotNull FrameInfo info, boolean selected) {
    append(info.toSimpleString());
    final SimpleTextAttributes additionalInfoColorAttributes = selected ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES;
    if (info.getPackageName() != null && info.getPackageName().length() > 0) {
        append(" (" + info.getPackageName() + ")", additionalInfoColorAttributes);
    }
    if (info.isInnerClass() && info.getFileName() != null) {
        String location = info.getFileName();
        if (info.getFileLine() >= 0) {
            location += ":" + info.getFileLine();
        }
        append(" " + location, additionalInfoColorAttributes);
    }
}
Also used : SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes)

Example 45 with SimpleTextAttributes

use of com.intellij.ui.SimpleTextAttributes in project android by JetBrains.

the class PNameRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(@NotNull JTable table, @NotNull Object value, boolean isSelected, boolean cellHasFocus, int row, int column) {
    myRenderer.clear();
    PTable ptable = (PTable) table;
    PTableItem item = (PTableItem) value;
    myRenderer.getTableCellRendererComponent(table, value, isSelected, cellHasFocus, row, column);
    myRenderer.setBackground(isSelected ? UIUtil.getTableSelectionBackground() : table.getBackground());
    boolean hoveringOnStar = ptable.isHover(row, column) && hitTestStarIcon(ptable.getHoverPosition().x);
    myStarLabel.setIcon(getStar(item.getStarState(), isSelected, hoveringOnStar));
    myPanel.setBackground(isSelected ? UIUtil.getTableSelectionBackground() : table.getBackground());
    SimpleTextAttributes attr = SimpleTextAttributes.REGULAR_ATTRIBUTES;
    SearchUtil.appendFragments(((PTable) table).getSpeedSearch().getEnteredPrefix(), item.getName(), attr.getStyle(), attr.getFgColor(), attr.getBgColor(), myRenderer);
    myRenderer.setToolTipText(item.getTooltipText());
    return myPanel;
}
Also used : SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) PTableItem(com.android.tools.idea.uibuilder.property.ptable.PTableItem) PTable(com.android.tools.idea.uibuilder.property.ptable.PTable)

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