Search in sources :

Example 6 with LayeredIcon

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

the class ElementBase method overlayIcons.

@NotNull
public static Icon overlayIcons(@NotNull Icon... icons) {
    final LayeredIcon icon = new LayeredIcon(icons.length);
    int i = 0;
    for (Icon ic : icons) {
        icon.setIcon(ic, i++);
    }
    return icon;
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) RowIcon(com.intellij.ui.RowIcon) EmptyIcon(com.intellij.util.ui.EmptyIcon) LayeredIcon(com.intellij.ui.LayeredIcon) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with LayeredIcon

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

the class IconUtil method addText.

@NotNull
public static Icon addText(@NotNull Icon base, @NotNull String text) {
    LayeredIcon icon = new LayeredIcon(2);
    icon.setIcon(base, 0);
    icon.setIcon(textToIcon(text, new JLabel(), JBUI.scale(6f)), 1, SwingConstants.SOUTH_EAST);
    return icon;
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with LayeredIcon

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

the class MethodHierarchyNodeDescriptor method update.

public final boolean update() {
    int flags = Iconable.ICON_FLAG_VISIBILITY;
    if (isMarkReadOnly()) {
        flags |= Iconable.ICON_FLAG_READ_STATUS;
    }
    boolean changes = super.update();
    final PsiElement psiClass = getPsiClass();
    if (psiClass == null) {
        final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
        if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
            myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
        }
        return true;
    }
    final Icon newRawIcon = psiClass.getIcon(flags);
    final Icon newStateIcon = psiClass instanceof PsiClass ? calculateState((PsiClass) psiClass) : AllIcons.Hierarchy.MethodDefined;
    if (changes || newRawIcon != myRawIcon || newStateIcon != myStateIcon) {
        changes = true;
        myRawIcon = newRawIcon;
        myStateIcon = newStateIcon;
        Icon newIcon = myRawIcon;
        if (myIsBase) {
            final LayeredIcon icon = new LayeredIcon(2);
            icon.setIcon(newIcon, 0);
            icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0);
            newIcon = icon;
        }
        if (myStateIcon != null) {
            newIcon = new RowIcon(myStateIcon, newIcon);
        }
        setIcon(newIcon);
    }
    final CompositeAppearance oldText = myHighlightedText;
    myHighlightedText = new CompositeAppearance();
    TextAttributes classNameAttributes = null;
    if (myColor != null) {
        classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
    }
    if (psiClass instanceof PsiClass) {
        myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass((PsiClass) psiClass, false), classNameAttributes);
        myHighlightedText.getEnding().addText("  (" + JavaHierarchyUtil.getPackageName((PsiClass) psiClass) + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
    } else if (psiClass instanceof PsiFunctionalExpression) {
        myHighlightedText.getEnding().addText(ClassPresentationUtil.getFunctionalExpressionPresentation((PsiFunctionalExpression) psiClass, false));
    }
    myName = myHighlightedText.getText();
    if (!Comparing.equal(myHighlightedText, oldText)) {
        changes = true;
    }
    return changes;
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) RowIcon(com.intellij.ui.RowIcon) LayeredIcon(com.intellij.ui.LayeredIcon) RowIcon(com.intellij.ui.RowIcon)

Example 9 with LayeredIcon

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

the class TypeHierarchyNodeDescriptor method update.

public final boolean update() {
    boolean changes = super.update();
    if (getPsiElement() == null) {
        final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
        if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
            myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
        }
        return true;
    }
    if (changes && myIsBase) {
        final LayeredIcon icon = new LayeredIcon(2);
        icon.setIcon(getIcon(), 0);
        icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0);
        setIcon(icon);
    }
    final PsiElement psiElement = getPsiClass();
    final CompositeAppearance oldText = myHighlightedText;
    myHighlightedText = new CompositeAppearance();
    TextAttributes classNameAttributes = null;
    if (myColor != null) {
        classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
    }
    if (psiElement instanceof PsiClass) {
        myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass((PsiClass) psiElement, false), classNameAttributes);
        myHighlightedText.getEnding().addText(" (" + JavaHierarchyUtil.getPackageName((PsiClass) psiElement) + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
    } else if (psiElement instanceof PsiFunctionalExpression) {
        myHighlightedText.getEnding().addText(ClassPresentationUtil.getFunctionalExpressionPresentation(((PsiFunctionalExpression) psiElement), false));
    }
    myName = myHighlightedText.getText();
    if (!Comparing.equal(myHighlightedText, oldText)) {
        changes = true;
    }
    return changes;
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) PsiFunctionalExpression(com.intellij.psi.PsiFunctionalExpression) PsiClass(com.intellij.psi.PsiClass) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) PsiElement(com.intellij.psi.PsiElement)

Example 10 with LayeredIcon

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

the class EditorWindow method getFileIcon.

/**
   * @return icon which represents file's type and modification status
   */
private Icon getFileIcon(@NotNull final VirtualFile file) {
    if (!file.isValid()) {
        Icon fakeIcon = FileTypes.UNKNOWN.getIcon();
        assert fakeIcon != null : "Can't find the icon for unknown file type";
        return fakeIcon;
    }
    final Icon baseIcon = IconUtil.getIcon(file, Iconable.ICON_FLAG_READ_STATUS, getManager().getProject());
    int count = 1;
    final Icon pinIcon;
    final EditorComposite composite = findFileComposite(file);
    if (composite != null && composite.isPinned()) {
        count++;
        pinIcon = AllIcons.Nodes.TabPin;
    } else {
        pinIcon = null;
    }
    final Icon modifiedIcon;
    UISettings settings = UISettings.getInstance();
    if (settings.getMarkModifiedTabsWithAsterisk() || !settings.getHideTabsIfNeed()) {
        modifiedIcon = settings.getMarkModifiedTabsWithAsterisk() && composite != null && composite.isModified() ? MODIFIED_ICON : GAP_ICON;
        count++;
    } else {
        modifiedIcon = null;
    }
    if (count == 1)
        return baseIcon;
    int i = 0;
    final LayeredIcon result = new LayeredIcon(count);
    int xShift = !settings.getHideTabsIfNeed() ? 4 : 0;
    result.setIcon(baseIcon, i++, xShift, 0);
    if (pinIcon != null)
        result.setIcon(pinIcon, i++, xShift, 0);
    if (modifiedIcon != null)
        result.setIcon(modifiedIcon, i++);
    return JBUI.scale(result);
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) UISettings(com.intellij.ide.ui.UISettings) EmptyIcon(com.intellij.util.ui.EmptyIcon) LayeredIcon(com.intellij.ui.LayeredIcon)

Aggregations

LayeredIcon (com.intellij.ui.LayeredIcon)26 CompositeAppearance (com.intellij.openapi.roots.ui.util.CompositeAppearance)6 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)5 RowIcon (com.intellij.ui.RowIcon)5 NotNull (org.jetbrains.annotations.NotNull)5 EmptyIcon (com.intellij.util.ui.EmptyIcon)4 PsiClass (com.intellij.psi.PsiClass)3 ItemPresentation (com.intellij.navigation.ItemPresentation)2 PsiElement (com.intellij.psi.PsiElement)2 PsiFile (com.intellij.psi.PsiFile)2 DartClass (com.jetbrains.lang.dart.psi.DartClass)2 Nullable (org.jetbrains.annotations.Nullable)2 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 IconLayerProvider (com.intellij.ide.IconLayerProvider)1 UISettings (com.intellij.ide.ui.UISettings)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 Language (com.intellij.lang.Language)1 StructureViewTestUtil.getIcon (com.intellij.lang.javascript.StructureViewTestUtil.getIcon)1 JSNamedElement (com.intellij.lang.javascript.psi.JSNamedElement)1