Example usage for com.intellij.openapi.roots.ui.util CompositeAppearance CompositeAppearance

List of usage examples for com.intellij.openapi.roots.ui.util CompositeAppearance CompositeAppearance

Introduction

In this page you can find the example usage for com.intellij.openapi.roots.ui.util CompositeAppearance CompositeAppearance.

Prototype

CompositeAppearance

Source Link

Usage

From source file:com.headwire.aem.tooling.intellij.explorer.AbstractSlingServerNodeDescriptor.java

License:Apache License

public AbstractSlingServerNodeDescriptor(final Project project, final NodeDescriptor parentDescriptor,
        final T target) {
    super(project, parentDescriptor);
    myTarget = target;//from  www. j a va2 s .c  om
    myHighlightedText = new CompositeAppearance();
}

From source file:com.headwire.aem.tooling.intellij.explorer.SlingServerModuleNodeDescriptor.java

License:Apache License

public boolean update() {
    final CompositeAppearance oldText = myHighlightedText;
    myHighlightedText = new CompositeAppearance();
    final Color color = UIUtil.getLabelForeground();
    TextAttributes nameAttributes = new TextAttributes(color, null, null, EffectType.BOXED, Font.PLAIN);

    //AS TODO: This is the Server Configuration Module Name
    //        myHighlightedText.getEnding().addText(myTarget.getSymbolicName(), nameAttributes);
    myHighlightedText.getEnding().addText(myTarget.getName(), nameAttributes);
    if (myTarget.getStatus() != null) {
        myHighlightedText.getEnding().addText(" (" + myTarget.getStatus().getName() + ')',
                ourPostfixAttributes);/*from   www .j av a 2  s.  co  m*/
    }
    return !Comparing.equal(myHighlightedText, oldText);
}

From source file:com.headwire.aem.tooling.intellij.explorer.SlingServerNodeDescriptor.java

License:Apache License

public boolean update() {
    final CompositeAppearance oldText = myHighlightedText;
    myHighlightedText = new CompositeAppearance();
    final Color color = UIUtil.getLabelForeground();
    TextAttributes nameAttributes = new TextAttributes(color, null, null, EffectType.BOXED, Font.PLAIN);
    myHighlightedText.getEnding().addText(myTarget.getName() + " at " + myTarget.getHost(), nameAttributes);
    if (myTarget.getServerStatus() != null) {
        myHighlightedText.getEnding().addText(" (" + myTarget.getServerStatus().getName() + ')',
                ourPostfixAttributes);// ww w.j a v  a  2s  . co  m
    }
    return !Comparing.equal(myHighlightedText, oldText);
}

From source file:com.intellij.ide.hierarchy.call.CallHierarchyNodeDescriptor.java

License:Apache License

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;
    }//from   w  ww  .  ja  v a2s  .  c  o m

    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 = IconDescriptorUpdaters.getIcon(enclosingElement, 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 JspHolderMethod) {
          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,
                    PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_PARAMETERS, PsiFormatUtil.SHOW_TYPE);
            buffer.append(methodText);

            myHighlightedText.getEnding().addText(buffer.toString(), mainTextAttributes);
        }
    }
    /*else if (JspPsiUtil.isInJspFile(enclosingElement) && enclosingElement instanceof PsiFile) {
      final JspFile file = JspPsiUtil.getJspFile(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 (!(JspPsiUtil.isInJspFile(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;
}

From source file:com.intellij.ide.hierarchy.HierarchyNodeDescriptor.java

License:Apache License

protected HierarchyNodeDescriptor(final Project project, final NodeDescriptor parentDescriptor,
        final PsiElement element, final boolean isBase) {
    super(project, parentDescriptor, element);
    myHighlightedText = new CompositeAppearance();
    myName = "";//  w  w w .  j  a  v a  2 s. c  o m
    myIsBase = isBase;
}

From source file:com.intellij.ide.hierarchy.method.MethodHierarchyNodeDescriptor.java

License:Apache License

public final boolean update() {
    int flags = Iconable.ICON_FLAG_VISIBILITY;
    if (isMarkReadOnly()) {
        flags |= Iconable.ICON_FLAG_READ_STATUS;
    }/*from  w ww .ja  v  a  2  s . com*/

    boolean changes = super.update();

    final PsiClass 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 = IconDescriptorUpdaters.getIcon(psiClass, flags);
    final Icon newStateIcon = calculateState(psiClass);

    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) {
            final RowIcon icon = new RowIcon(2);
            icon.setIcon(myStateIcon, 0);
            icon.setIcon(newIcon, 1);
            newIcon = icon;
        }

        setIcon(newIcon);
    }

    final CompositeAppearance oldText = myHighlightedText;

    myHighlightedText = new CompositeAppearance();
    TextAttributes classNameAttributes = null;
    if (myColor != null) {
        classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
    }
    myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass(psiClass, false),
            classNameAttributes);
    myHighlightedText.getEnding().addText("  (" + JavaHierarchyUtil.getPackageName(psiClass) + ")",
            HierarchyNodeDescriptor.getPackageNameAttributes());
    myName = myHighlightedText.getText();

    if (!Comparing.equal(myHighlightedText, oldText)) {
        changes = true;
    }
    return changes;
}

From source file:com.intellij.ide.hierarchy.type.TypeHierarchyNodeDescriptor.java

License:Apache License

public final boolean update() {
    boolean changes = super.update();

    if (myElement == null) {
        final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
        if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
            myHighlightedText.getBeginning().addText(invalidPrefix,
                    HierarchyNodeDescriptor.getInvalidPrefixAttributes());
        }//w w  w .j a  v  a 2s.c  o m
        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 PsiClass psiClass = getPsiClass();

    final CompositeAppearance oldText = myHighlightedText;

    myHighlightedText = new CompositeAppearance();

    TextAttributes classNameAttributes = null;
    if (myColor != null) {
        classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
    }
    myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass(psiClass, false),
            classNameAttributes);
    myHighlightedText.getEnding().addText(" (" + JavaHierarchyUtil.getPackageName(psiClass) + ")",
            HierarchyNodeDescriptor.getPackageNameAttributes());
    myName = myHighlightedText.getText();

    if (!Comparing.equal(myHighlightedText, oldText)) {
        changes = true;
    }
    return changes;
}

From source file:com.intellij.ide.structureView.impl.StructureNodeRenderer.java

License:Apache License

public static CellAppearanceEx forNodeDescriptorInTree(Object node, boolean expanded) {
    NodeDescriptor descriptor = getNodeDescriptor(node);
    if (descriptor == null)
        return FileAppearanceService.getInstance().empty();
    String name = descriptor.toString();
    Object psiElement = descriptor.getElement();
    ModifiableCellAppearanceEx result;//from   w w  w .j  ava  2  s. co  m
    if (psiElement instanceof PsiElement && !((PsiElement) psiElement).isValid()) {
        result = CompositeAppearance.single(name);
    } else {
        PsiClass psiClass = getContainingClass(psiElement);
        if (isInheritedMember(node, psiClass) && psiClass != null) {
            CompositeAppearance.DequeEnd ending = new CompositeAppearance().getEnding();
            ending.addText(name, applyDeprecation(psiElement, SimpleTextAttributes.DARK_TEXT));
            ending.addComment(psiClass.getName(),
                    applyDeprecation(psiClass, SimpleTextAttributes.GRAY_ATTRIBUTES));
            result = ending.getAppearance();
        } else {
            SimpleTextAttributes textAttributes = applyDeprecation(psiElement,
                    SimpleTextAttributes.REGULAR_ATTRIBUTES);
            result = CompositeAppearance.single(name, textAttributes);
        }
    }

    result.setIcon(descriptor.getIcon());
    return result;
}

From source file:com.intellij.lang.ant.config.explorer.AntBuildFileNodeDescriptor.java

License:Apache License

public boolean update() {
    setIcon(ApacheAntIcons.AntInstallation);

    CompositeAppearance oldAppearance = myAppearance;
    myAppearance = new CompositeAppearance();
    myAppearance.getEnding().addText(myBuildFile.getPresentableName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    myAppearance.setIcon(getIcon());//from www.  ja v a 2s .  c o  m
    final AntBuildModelBase buildModel = myBuildFile.getModelIfRegistered();
    if (buildModel != null) {
        AntTargetNodeDescriptor.addShortcutText(buildModel.getDefaultTargetActionId(), myAppearance);
    }
    myName = myBuildFile.getPresentableName();
    return !Comparing.equal(myAppearance, oldAppearance);
}

From source file:com.intellij.lang.ant.config.explorer.AntTargetNodeDescriptor.java

License:Apache License

public AntTargetNodeDescriptor(final Project project, final NodeDescriptor parentDescriptor,
        final AntBuildTargetBase target) {
    super(project, parentDescriptor);
    myTarget = target;//from   ww  w  .  java2  s .  co  m
    myHighlightedText = new CompositeAppearance();
}