Search in sources :

Example 16 with LayeredIcon

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

the class DartTypeHierarchyNodeDescriptor method update.

public final boolean update() {
    boolean changes = super.update();
    final DartClass dartClass = getDartClass();
    if (dartClass == 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 CompositeAppearance oldText = myHighlightedText;
    myHighlightedText = new CompositeAppearance();
    TextAttributes classNameAttributes = null;
    if (myColor != null) {
        classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
    }
    final String libraryName = DartResolveUtil.getLibraryName(dartClass.getContainingFile());
    myHighlightedText.getEnding().addText(dartClass.getName(), classNameAttributes);
    myHighlightedText.getEnding().addText(" (" + libraryName + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
    myName = myHighlightedText.getText();
    if (!Comparing.equal(myHighlightedText, oldText)) {
        changes = true;
    }
    return changes;
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) DartClass(com.jetbrains.lang.dart.psi.DartClass) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Example 17 with LayeredIcon

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

the class Struts2IconProvider method getIcon.

@Nullable
public Icon getIcon(@NotNull final PsiElement element, final int flags) {
    if (!(element instanceof PsiClass)) {
        return null;
    }
    // IconProvider queries non-physical PSI as well (e.g. completion items); check validity
    if (!element.isPhysical() || !element.isValid()) {
        return null;
    }
    // no icons when no facet present
    final Module module = ModuleUtilCore.findModuleForPsiElement(element);
    if (module == null) {
        return null;
    }
    final StrutsFacet strutsFacet = StrutsFacet.getInstance(module);
    if (strutsFacet == null) {
        return null;
    }
    // handle suitable JAVA classes --> overlay icon
    final PsiClass psiClass = (PsiClass) element;
    if (psiClass.isInterface() || psiClass.isEnum() || !psiClass.hasModifierProperty(PsiModifier.PUBLIC) || psiClass.hasModifierProperty(PsiModifier.ABSTRACT) || !JamCommonUtil.isPlainJavaFile(psiClass.getContainingFile())) {
        return null;
    }
    final StrutsModel strutsModel = StrutsManager.getInstance(psiClass.getProject()).getCombinedModel(module);
    if (strutsModel == null || !strutsModel.isActionClass(psiClass)) {
        return null;
    }
    final LayeredIcon layeredIcon = new LayeredIcon(2);
    final Icon original = PsiClassImplUtil.getClassIcon(flags, psiClass);
    layeredIcon.setIcon(original, 0);
    layeredIcon.setIcon(Struts2Icons.Action_small, 1, StrutsIcons.OVERLAY_X_OFFSET, StrutsIcons.OVERLAY_Y_OFFSET);
    return JBUI.scale(layeredIcon);
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) StrutsModel(com.intellij.struts2.dom.struts.model.StrutsModel) PsiClass(com.intellij.psi.PsiClass) LayeredIcon(com.intellij.ui.LayeredIcon) Module(com.intellij.openapi.module.Module) StrutsFacet(com.intellij.struts2.facet.StrutsFacet) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with LayeredIcon

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

the class FindAllAction method updateTemplateIcon.

private void updateTemplateIcon(@Nullable EditorSearchSession session) {
    if (session == null || getTemplatePresentation().getIcon() != null)
        return;
    Icon base = AllIcons.Actions.Find;
    Icon text = IconUtil.textToIcon("ALL", session.getComponent(), JBUI.scale(6F));
    LayeredIcon icon = new LayeredIcon(2);
    icon.setIcon(base, 0);
    icon.setIcon(text, 1, 0, base.getIconHeight() - text.getIconHeight());
    getTemplatePresentation().setIcon(icon);
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) LayeredIcon(com.intellij.ui.LayeredIcon)

Example 19 with LayeredIcon

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

the class JavaFileIconPatcher method patchIcon.

@Override
public Icon patchIcon(final Icon baseIcon, final VirtualFile file, final int flags, final Project project) {
    if (project == null) {
        return baseIcon;
    }
    Icon icon = replaceIcon(file, flags, project, baseIcon);
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    if (fileIndex.isInSource(file) && CompilerManager.getInstance(project).isExcludedFromCompilation(file)) {
        return new LayeredIcon(icon, PlatformIcons.EXCLUDED_FROM_COMPILE_ICON);
    }
    return icon;
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) LayeredIcon(com.intellij.ui.LayeredIcon)

Example 20 with LayeredIcon

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

the class CallHierarchyNodeDescriptor method update.

public final boolean update() {
    final CompositeAppearance oldText = myHighlightedText;
    final Icon oldIcon = getIcon();
    int flags = Iconable.ICON_FLAG_VISIBILITY;
    if (isMarkReadOnly()) {
        flags |= Iconable.ICON_FLAG_READ_STATUS;
    }
    boolean changes = super.update();
    final PsiElement enclosingElement = getEnclosingElement();
    if (enclosingElement == null) {
        final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
        if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
            myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
        }
        return true;
    }
    Icon newIcon = enclosingElement.getIcon(flags);
    if (changes && 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;
    }
    setIcon(newIcon);
    myHighlightedText = new CompositeAppearance();
    TextAttributes mainTextAttributes = null;
    if (myColor != null) {
        mainTextAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
    }
    if (enclosingElement instanceof PsiMethod) {
        if (enclosingElement instanceof SyntheticElement) {
            PsiFile file = enclosingElement.getContainingFile();
            myHighlightedText.getEnding().addText(file != null ? file.getName() : IdeBundle.message("node.call.hierarchy.unknown.jsp"), mainTextAttributes);
        } else {
            final PsiMethod method = (PsiMethod) enclosingElement;
            final StringBuilder buffer = new StringBuilder(128);
            final PsiClass containingClass = method.getContainingClass();
            if (containingClass != null) {
                buffer.append(ClassPresentationUtil.getNameForClass(containingClass, false));
                buffer.append('.');
            }
            final String methodText = PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_TYPE);
            buffer.append(methodText);
            myHighlightedText.getEnding().addText(buffer.toString(), mainTextAttributes);
        }
    } else if (FileTypeUtils.isInServerPageFile(enclosingElement) && enclosingElement instanceof PsiFile) {
        final PsiFile file = PsiUtilCore.getTemplateLanguageFile(enclosingElement);
        myHighlightedText.getEnding().addText(file.getName(), mainTextAttributes);
    } else {
        myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass((PsiClass) enclosingElement, false), mainTextAttributes);
    }
    if (myUsageCount > 1) {
        myHighlightedText.getEnding().addText(IdeBundle.message("node.call.hierarchy.N.usages", myUsageCount), HierarchyNodeDescriptor.getUsageCountPrefixAttributes());
    }
    if (!(FileTypeUtils.isInServerPageFile(enclosingElement) && enclosingElement instanceof PsiFile)) {
        final PsiClass containingClass = enclosingElement instanceof PsiMethod ? ((PsiMethod) enclosingElement).getContainingClass() : (PsiClass) enclosingElement;
        if (containingClass != null) {
            final String packageName = JavaHierarchyUtil.getPackageName(containingClass);
            myHighlightedText.getEnding().addText("  (" + packageName + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
        }
    }
    myName = myHighlightedText.getText();
    if (!Comparing.equal(myHighlightedText, oldText) || !Comparing.equal(getIcon(), oldIcon)) {
        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) 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