Search in sources :

Example 1 with LayeredIcon

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

the class PyStructureViewElement method getPresentation.

@NotNull
@Override
public ItemPresentation getPresentation() {
    final PyElement element = getValue();
    final ItemPresentation presentation = element != null ? element.getPresentation() : null;
    return new ColoredItemPresentation() {

        @Nullable
        @Override
        public String getPresentableText() {
            if (element instanceof PyFile) {
                return element.getName();
            }
            return presentation != null ? presentation.getPresentableText() : PyNames.UNNAMED_ELEMENT;
        }

        @Nullable
        @Override
        public TextAttributesKey getTextAttributesKey() {
            if (isInherited()) {
                return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES;
            }
            return null;
        }

        @Nullable
        @Override
        public String getLocationString() {
            return null;
        }

        @Nullable
        @Override
        public Icon getIcon(boolean open) {
            if (element == null) {
                return null;
            }
            Icon normal_icon = element.getIcon(0);
            // override normal
            if (myIcon != null)
                normal_icon = myIcon;
            if (myVisibility == Visibility.NORMAL) {
                return normal_icon;
            } else {
                LayeredIcon icon = new LayeredIcon(2);
                icon.setIcon(normal_icon, 0);
                Icon overlay = null;
                if (myVisibility == Visibility.PRIVATE || myVisibility == Visibility.PROTECTED) {
                    overlay = PythonIcons.Python.Nodes.Lock;
                } else if (myVisibility == Visibility.PREDEFINED) {
                    overlay = PythonIcons.Python.Nodes.Cyan_dot;
                } else if (myVisibility == Visibility.INVISIBLE) {
                    overlay = PythonIcons.Python.Nodes.Red_inv_triangle;
                }
                if (overlay != null) {
                    icon.setIcon(overlay, 1);
                }
                return icon;
            }
        }
    };
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) ColoredItemPresentation(com.intellij.navigation.ColoredItemPresentation) ColoredItemPresentation(com.intellij.navigation.ColoredItemPresentation) ItemPresentation(com.intellij.navigation.ItemPresentation) LayeredIcon(com.intellij.ui.LayeredIcon) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with LayeredIcon

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

the class PySdkListCellRenderer method wrapIconWithWarningDecorator.

private static LayeredIcon wrapIconWithWarningDecorator(Icon icon) {
    final LayeredIcon layered = new LayeredIcon(2);
    layered.setIcon(icon, 0);
    final Icon overlay = AllIcons.Actions.Cancel;
    layered.setIcon(overlay, 1);
    return layered;
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) LayeredIcon(com.intellij.ui.LayeredIcon)

Example 3 with LayeredIcon

use of com.intellij.ui.LayeredIcon in project kotlin by JetBrains.

the class KotlinCallHierarchyNodeDescriptor method update.

@Override
public final boolean update() {
    CompositeAppearance oldText = myHighlightedText;
    Icon oldIcon = getIcon();
    int flags = Iconable.ICON_FLAG_VISIBILITY;
    if (isMarkReadOnly()) {
        flags |= Iconable.ICON_FLAG_READ_STATUS;
    }
    boolean changes = super.update();
    PsiElement targetElement = getTargetElement();
    String elementText = renderElement(targetElement);
    if (elementText == null) {
        String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
        if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
            myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
        }
        return true;
    }
    Icon newIcon = targetElement.getIcon(flags);
    if (changes && myIsBase) {
        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);
    }
    String packageName = null;
    if (targetElement instanceof KtElement) {
        packageName = KtPsiUtil.getPackageName((KtElement) targetElement);
    } else {
        PsiClass enclosingClass = PsiTreeUtil.getParentOfType(targetElement, PsiClass.class, false);
        if (enclosingClass != null) {
            packageName = JavaHierarchyUtil.getPackageName(enclosingClass);
        }
    }
    myHighlightedText.getEnding().addText(elementText, mainTextAttributes);
    if (usageCount > 1) {
        myHighlightedText.getEnding().addText(IdeBundle.message("node.call.hierarchy.N.usages", usageCount), HierarchyNodeDescriptor.getUsageCountPrefixAttributes());
    }
    if (packageName == null) {
        packageName = "";
    }
    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) PsiClass(com.intellij.psi.PsiClass) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) LayeredIcon(com.intellij.ui.LayeredIcon) PsiElement(com.intellij.psi.PsiElement)

Example 4 with LayeredIcon

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

the class IdeConsoleRootType method substituteIcon.

@Nullable
@Override
public Icon substituteIcon(@NotNull Project project, @NotNull VirtualFile file) {
    FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(file.getName());
    if (fileType == UnknownFileType.INSTANCE || fileType == PlainTextFileType.INSTANCE) {
        return AllIcons.Debugger.ToolConsole;
    }
    Icon icon = fileType.getIcon();
    Icon subscript = ((ScalableIcon) AllIcons.Debugger.ToolConsole).scale(.5f);
    LayeredIcon icons = new LayeredIcon(2);
    icons.setIcon(icon, 0);
    icons.setIcon(subscript, 1, 8, 8);
    return JBUI.scale(icons);
}
Also used : ScalableIcon(com.intellij.openapi.util.ScalableIcon) LayeredIcon(com.intellij.ui.LayeredIcon) PlainTextFileType(com.intellij.openapi.fileTypes.PlainTextFileType) FileType(com.intellij.openapi.fileTypes.FileType) UnknownFileType(com.intellij.openapi.fileTypes.UnknownFileType) ScalableIcon(com.intellij.openapi.util.ScalableIcon) LayeredIcon(com.intellij.ui.LayeredIcon) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with LayeredIcon

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

the class SameSignatureCallParametersProvider method createParametersLookupElement.

private static LookupElement createParametersLookupElement(final PsiMethod takeParametersFrom, PsiElement call, PsiMethod invoked) {
    final PsiParameter[] parameters = takeParametersFrom.getParameterList().getParameters();
    final String lookupString = StringUtil.join(parameters, psiParameter -> psiParameter.getName(), ", ");
    final int w = PlatformIcons.PARAMETER_ICON.getIconWidth();
    LayeredIcon icon = new LayeredIcon(2);
    icon.setIcon(PlatformIcons.PARAMETER_ICON, 0, 2 * w / 5, 0);
    icon.setIcon(PlatformIcons.PARAMETER_ICON, 1);
    LookupElementBuilder element = LookupElementBuilder.create(lookupString).withIcon(icon);
    if (PsiTreeUtil.isAncestor(takeParametersFrom, call, true)) {
        element = element.withInsertHandler(new InsertHandler<LookupElement>() {

            @Override
            public void handleInsert(InsertionContext context, LookupElement item) {
                context.commitDocument();
                for (PsiParameter parameter : CompletionUtil.getOriginalOrSelf(takeParametersFrom).getParameterList().getParameters()) {
                    VariableLookupItem.makeFinalIfNeeded(context, parameter);
                }
            }
        });
    }
    element.putUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS, Boolean.TRUE);
    return TailTypeDecorator.withTail(element, ExpectedTypesProvider.getFinalCallParameterTailType(call, invoked.getReturnType(), invoked));
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder) LookupElement(com.intellij.codeInsight.lookup.LookupElement)

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