Search in sources :

Example 16 with ItemPresentation

use of com.intellij.navigation.ItemPresentation in project android by JetBrains.

the class LazyValueResourceElementWrapper method getPresentation.

@Override
public ItemPresentation getPresentation() {
    return new ItemPresentation() {

        @Override
        @Nullable
        public String getPresentableText() {
            final String name = myResourceInfo.getName();
            final VirtualFile file = myResourceInfo.getContainingFile();
            final VirtualFile dir = file.getParent();
            if (dir == null) {
                return name;
            }
            return name + " (..." + File.separatorChar + dir.getName() + File.separatorChar + file.getName() + ')';
        }

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

        @Override
        public Icon getIcon(boolean open) {
            return null;
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ItemPresentation(com.intellij.navigation.ItemPresentation)

Example 17 with ItemPresentation

use of com.intellij.navigation.ItemPresentation in project intellij-plugins by JetBrains.

the class GrStepDefinitionPresentationProvider method getPresentation.

@Nullable
@Override
public ItemPresentation getPresentation(@NotNull final GrMethodCall item) {
    if (!GrCucumberUtil.isStepDefinition(item))
        return null;
    return new ItemPresentation() {

        @Nullable
        @Override
        public String getPresentableText() {
            final String stepRef = GrCucumberUtil.getCucumberStepRef(item).getText();
            final String pattern = GrCucumberUtil.getStepDefinitionPattern(item).getText();
            return CucumberBundle.message("step.definition.0.1", stepRef, pattern);
        }

        @Nullable
        @Override
        public String getLocationString() {
            final PsiFile file = item.getContainingFile();
            final ItemPresentation presentation = ItemPresentationProviders.getItemPresentation(file);
            LOG.assertTrue(presentation != null, file.getClass().getName());
            return presentation.getPresentableText();
        }

        @Nullable
        @Override
        public Icon getIcon(boolean unused) {
            return null;
        }
    };
}
Also used : ItemPresentation(com.intellij.navigation.ItemPresentation) PsiFile(com.intellij.psi.PsiFile) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with ItemPresentation

use of com.intellij.navigation.ItemPresentation in project intellij-plugins by JetBrains.

the class DartHierarchyNodeDescriptor method update.

@Override
public boolean update() {
    boolean changes = super.update();
    final CompositeAppearance oldText = myHighlightedText;
    myHighlightedText = new CompositeAppearance();
    NavigatablePsiElement element = (NavigatablePsiElement) getPsiElement();
    if (element == null) {
        return invalidElement();
    }
    final ItemPresentation presentation = element.getPresentation();
    if (presentation != null) {
        if (element instanceof DartMethodDeclaration) {
            if (DartComponentType.typeOf(element) != DartComponentType.CONSTRUCTOR) {
                // Do not print constructors as Class.Class.Class(args) Class
                final DartClass cls = PsiTreeUtil.getParentOfType(element, DartClass.class);
                if (cls != null) {
                    myHighlightedText.getEnding().addText(cls.getName() + ".");
                }
            }
        }
        myHighlightedText.getEnding().addText(presentation.getPresentableText());
        PsiFile file = element.getContainingFile();
        if (file != null) {
            myHighlightedText.getEnding().addText(" (" + file.getName() + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
        }
    }
    myName = myHighlightedText.getText();
    if (!Comparing.equal(myHighlightedText, oldText)) {
        changes = true;
    }
    return changes;
}
Also used : DartClass(com.jetbrains.lang.dart.psi.DartClass) DartMethodDeclaration(com.jetbrains.lang.dart.psi.DartMethodDeclaration) ItemPresentation(com.intellij.navigation.ItemPresentation) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) PsiFile(com.intellij.psi.PsiFile) NavigatablePsiElement(com.intellij.psi.NavigatablePsiElement)

Example 19 with ItemPresentation

use of com.intellij.navigation.ItemPresentation in project intellij-plugins by JetBrains.

the class DartMethodHierarchyNodeDescriptor method update.

public final boolean update() {
    boolean changes = super.update();
    final CompositeAppearance oldText = myHighlightedText;
    myHighlightedText = new CompositeAppearance();
    DartClass dartClass = getType();
    if (dartClass == null) {
        if (!myHighlightedText.getText().startsWith(INVALID_PREFIX)) {
            myHighlightedText.getBeginning().addText(INVALID_PREFIX, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
        }
        return true;
    }
    final ItemPresentation presentation = dartClass.getPresentation();
    Icon baseIcon = null;
    Icon stateIcon = null;
    if (presentation != null) {
        myHighlightedText.getEnding().addText(presentation.getPresentableText());
        PsiFile file = dartClass.getContainingFile();
        if (file != null) {
            myHighlightedText.getEnding().addText(" (" + file.getName() + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
        }
        baseIcon = presentation.getIcon(false);
        stateIcon = calculateStateIcon(dartClass);
    }
    if (changes || baseIcon != myRawIcon || stateIcon != myStateIcon) {
        changes = true;
        Icon newIcon = myRawIcon = baseIcon;
        myStateIcon = stateIcon;
        if (myIsBase) {
            final LayeredIcon icon = new LayeredIcon(2);
            icon.setIcon(newIcon, 0);
            newIcon = icon;
            icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0);
        }
        if (myStateIcon != null) {
            newIcon = new RowIcon(myStateIcon, newIcon);
        }
        setIcon(newIcon);
    }
    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) ItemPresentation(com.intellij.navigation.ItemPresentation) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) PsiFile(com.intellij.psi.PsiFile) RowIcon(com.intellij.ui.RowIcon) LayeredIcon(com.intellij.ui.LayeredIcon) RowIcon(com.intellij.ui.RowIcon)

Example 20 with ItemPresentation

use of com.intellij.navigation.ItemPresentation in project intellij-plugins by JetBrains.

the class DartNamedElementNode method buildPresentationText.

@Nullable
private static String buildPresentationText(DartComponent dartComponent) {
    final ItemPresentation presentation = dartComponent.getPresentation();
    if (presentation == null) {
        return dartComponent.getName();
    }
    final StringBuilder result = new StringBuilder();
    if (dartComponent instanceof DartClass) {
        result.append(dartComponent.getName());
        final String location = presentation.getLocationString();
        if (location != null && !location.isEmpty()) {
            result.append(" ").append(location);
        }
    } else {
        result.append(presentation.getPresentableText());
    }
    return result.toString();
}
Also used : DartClass(com.jetbrains.lang.dart.psi.DartClass) ItemPresentation(com.intellij.navigation.ItemPresentation) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ItemPresentation (com.intellij.navigation.ItemPresentation)40 NotNull (org.jetbrains.annotations.NotNull)10 NavigationItem (com.intellij.navigation.NavigationItem)8 Nullable (org.jetbrains.annotations.Nullable)8 PsiFile (com.intellij.psi.PsiFile)6 Parent (org.elixir_lang.navigation.item_presentation.Parent)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 PsiElement (com.intellij.psi.PsiElement)5 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)4 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)3 CompositeAppearance (com.intellij.openapi.roots.ui.util.CompositeAppearance)3 NavigatablePsiElement (com.intellij.psi.NavigatablePsiElement)3 LayeredIcon (com.intellij.ui.LayeredIcon)3 DartClass (com.jetbrains.lang.dart.psi.DartClass)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 ColoredItemPresentation (com.intellij.navigation.ColoredItemPresentation)2 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 JBColor (com.intellij.ui.JBColor)2 RowIcon (com.intellij.ui.RowIcon)2