Search in sources :

Example 6 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 7 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)

Example 8 with CompositeAppearance

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

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

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

Aggregations

CompositeAppearance (com.intellij.openapi.roots.ui.util.CompositeAppearance)12 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)6 LayeredIcon (com.intellij.ui.LayeredIcon)6 ItemPresentation (com.intellij.navigation.ItemPresentation)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 NavigatablePsiElement (com.intellij.psi.NavigatablePsiElement)2 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