Search in sources :

Example 1 with CompositeAppearance

use of com.intellij.openapi.roots.ui.util.CompositeAppearance in project intellij-community by JetBrains.

the class PyHierarchyNodeDescriptor method update.

@Override
public boolean update() {
    boolean changes = super.update();
    final CompositeAppearance oldText = myHighlightedText;
    myHighlightedText = new CompositeAppearance();
    NavigatablePsiElement element = (NavigatablePsiElement) getPsiElement();
    if (element == null) {
        final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
        if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
            myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
        }
        return true;
    }
    final ItemPresentation presentation = element.getPresentation();
    if (presentation != null) {
        if (element instanceof PyFunction) {
            final PyClass cls = ((PyFunction) element).getContainingClass();
            if (cls != null) {
                myHighlightedText.getEnding().addText(cls.getName() + ".");
            }
        }
        myHighlightedText.getEnding().addText(presentation.getPresentableText());
        myHighlightedText.getEnding().addText(" " + presentation.getLocationString(), HierarchyNodeDescriptor.getPackageNameAttributes());
    }
    myName = myHighlightedText.getText();
    if (!Comparing.equal(myHighlightedText, oldText)) {
        changes = true;
    }
    return changes;
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyFunction(com.jetbrains.python.psi.PyFunction) ItemPresentation(com.intellij.navigation.ItemPresentation) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) NavigatablePsiElement(com.intellij.psi.NavigatablePsiElement)

Example 2 with CompositeAppearance

use of com.intellij.openapi.roots.ui.util.CompositeAppearance 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 3 with CompositeAppearance

use of com.intellij.openapi.roots.ui.util.CompositeAppearance 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 4 with CompositeAppearance

use of com.intellij.openapi.roots.ui.util.CompositeAppearance in project intellij-community by JetBrains.

the class AntBuildFileNodeDescriptor method update.

public boolean update() {
    CompositeAppearance oldAppearance = myAppearance;
    myAppearance = new CompositeAppearance();
    myAppearance.getEnding().addText(myBuildFile.getPresentableName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    final AntBuildModelBase buildModel = myBuildFile.getModelIfRegistered();
    if (buildModel != null) {
        AntTargetNodeDescriptor.addShortcutText(buildModel.getDefaultTargetActionId(), myAppearance);
    }
    myAppearance.setIcon(AntIcons.Build);
    myName = myBuildFile.getPresentableName();
    return !Comparing.equal(myAppearance, oldAppearance);
}
Also used : AntBuildModelBase(com.intellij.lang.ant.config.AntBuildModelBase) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance)

Example 5 with CompositeAppearance

use of com.intellij.openapi.roots.ui.util.CompositeAppearance in project intellij-community by JetBrains.

the class AntTargetNodeDescriptor method update.

public boolean update() {
    final CompositeAppearance oldText = myHighlightedText;
    final boolean isMeta = myTarget instanceof MetaTarget;
    setIcon(isMeta ? AntIcons.MetaTarget : AntIcons.Target);
    myHighlightedText = new CompositeAppearance();
    final AntBuildFile buildFile = isMeta ? ((MetaTarget) myTarget).getBuildFile() : myTarget.getModel().getBuildFile();
    final Color color = buildFile.isTargetVisible(myTarget) ? UIUtil.getLabelForeground() : UIUtil.getLabelDisabledForeground();
    TextAttributes nameAttributes = new TextAttributes(color, null, null, EffectType.BOXED, myTarget.isDefault() ? Font.BOLD : Font.PLAIN);
    myHighlightedText.getEnding().addText(myTarget.getDisplayName(), nameAttributes);
    AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(myProject);
    final ArrayList<String> addedNames = new ArrayList<>(4);
    for (final ExecutionEvent event : antConfiguration.getEventsForTarget(myTarget)) {
        final String presentableName;
        if ((event instanceof ExecuteCompositeTargetEvent)) {
            presentableName = ((ExecuteCompositeTargetEvent) event).getMetaTargetName();
            if (presentableName.equals(myTarget.getName())) {
                continue;
            }
        } else {
            presentableName = event.getPresentableName();
        }
        if (!addedNames.contains(presentableName)) {
            addedNames.add(presentableName);
            myHighlightedText.getEnding().addText(" (" + presentableName + ')', ourPostfixAttributes);
        }
    }
    final RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
    final VirtualFile vFile = buildFile.getVirtualFile();
    if (vFile != null) {
        for (AntBeforeRunTask task : runManager.getBeforeRunTasks(AntBeforeRunTaskProvider.ID)) {
            if (task.isRunningTarget(myTarget)) {
                myHighlightedText.getEnding().addText(" (Before Run/Debug)", ourPostfixAttributes);
                break;
            }
        }
    }
    myName = myHighlightedText.getText();
    final AntBuildTargetBase target = getTarget();
    if (!addShortcutText(target.getActionId())) {
        if (target.isDefault()) {
            addShortcutText(((AntBuildModelBase) target.getModel()).getDefaultTargetActionId());
        }
    }
    return !Comparing.equal(myHighlightedText, oldText);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RunManagerEx(com.intellij.execution.RunManagerEx) JBColor(com.intellij.ui.JBColor) MetaTarget(com.intellij.lang.ant.config.impl.MetaTarget) ArrayList(java.util.ArrayList) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) ExecuteCompositeTargetEvent(com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) AntBeforeRunTask(com.intellij.lang.ant.config.impl.AntBeforeRunTask)

Aggregations

CompositeAppearance (com.intellij.openapi.roots.ui.util.CompositeAppearance)13 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)6 LayeredIcon (com.intellij.ui.LayeredIcon)6 ItemPresentation (com.intellij.navigation.ItemPresentation)4 NavigatablePsiElement (com.intellij.psi.NavigatablePsiElement)3 PsiClass (com.intellij.psi.PsiClass)3 PsiElement (com.intellij.psi.PsiElement)3 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)3 DartClass (com.jetbrains.lang.dart.psi.DartClass)3 PsiFile (com.intellij.psi.PsiFile)2 RowIcon (com.intellij.ui.RowIcon)2 RunManagerEx (com.intellij.execution.RunManagerEx)1 NodeDescriptor (com.intellij.ide.util.treeView.NodeDescriptor)1 AntBuildModelBase (com.intellij.lang.ant.config.AntBuildModelBase)1 AntBeforeRunTask (com.intellij.lang.ant.config.impl.AntBeforeRunTask)1 ExecuteCompositeTargetEvent (com.intellij.lang.ant.config.impl.ExecuteCompositeTargetEvent)1 MetaTarget (com.intellij.lang.ant.config.impl.MetaTarget)1 SdkType (com.intellij.openapi.projectRoots.SdkType)1 ModifiableCellAppearanceEx (com.intellij.openapi.roots.ui.ModifiableCellAppearanceEx)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1