Search in sources :

Example 86 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class ArrangementColorsProviderImpl method getTextAttributes.

@NotNull
@Override
public TextAttributes getTextAttributes(@NotNull ArrangementSettingsToken token, boolean selected) {
    final TextAttributes cached;
    if (selected) {
        cached = mySelectedAttributesCache.get(token);
    } else {
        cached = myNormalAttributesCache.get(token);
    }
    if (cached != null) {
        return cached;
    }
    TextAttributes result = null;
    if (myColorsAware != null) {
        result = myColorsAware.getTextAttributes(EditorColorsManager.getInstance().getGlobalScheme(), token, selected);
    }
    if (result == null) {
        result = selected ? myDefaultSelectedAttributes : myDefaultNormalAttributes;
    }
    if (selected) {
        mySelectedAttributesCache.put(token, result);
    } else {
        myNormalAttributesCache.put(token, result);
    }
    return result;
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) NotNull(org.jetbrains.annotations.NotNull)

Example 87 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class ArrangementAtomMatchConditionComponent method setSelected.

/**
   * Instructs current component that it should {@link #getUiComponent() draw} itself according to the given 'selected' state.
   *
   * @param selected  flag that indicates if current component should be drawn as 'selected'
   */
@Override
public void setSelected(boolean selected) {
    boolean notifyListener = selected != mySelected;
    mySelected = selected;
    TextAttributes attributes = updateComponentText(selected);
    myBorder.setColor(myColorsProvider.getBorderColor(selected));
    myBackgroundColor = attributes.getBackgroundColor();
    if (notifyListener && myListener != null) {
        myListener.stateChanged();
    }
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes)

Example 88 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class ArrangementAtomMatchConditionComponent method updateComponentText.

@NotNull
private TextAttributes updateComponentText(boolean selected) {
    myTextControl.clear();
    TextAttributes attributes = myColorsProvider.getTextAttributes(myCondition.getType(), selected);
    myTextControl.append(getComponentText(), SimpleTextAttributes.fromTextAttributes(attributes));
    return attributes;
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) NotNull(org.jetbrains.annotations.NotNull)

Example 89 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class ColorAndFontOptions method initScopesDescriptors.

private static void initScopesDescriptors(@NotNull List<EditorSchemeAttributeDescriptor> descriptions, @NotNull MyColorScheme scheme) {
    Set<Pair<NamedScope, NamedScopesHolder>> namedScopes = new THashSet<>(new TObjectHashingStrategy<Pair<NamedScope, NamedScopesHolder>>() {

        @Override
        public int computeHashCode(@NotNull final Pair<NamedScope, NamedScopesHolder> object) {
            return object.getFirst().getName().hashCode();
        }

        @Override
        public boolean equals(@NotNull final Pair<NamedScope, NamedScopesHolder> o1, @NotNull final Pair<NamedScope, NamedScopesHolder> o2) {
            return o1.getFirst().getName().equals(o2.getFirst().getName());
        }
    });
    Project[] projects = ProjectManager.getInstance().getOpenProjects();
    for (Project project : projects) {
        DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl) DependencyValidationManager.getInstance(project);
        List<Pair<NamedScope, NamedScopesHolder>> cachedScopes = validationManager.getScopeBasedHighlightingCachedScopes();
        namedScopes.addAll(cachedScopes);
    }
    List<Pair<NamedScope, NamedScopesHolder>> list = new ArrayList<>(namedScopes);
    Collections.sort(list, (o1, o2) -> o1.getFirst().getName().compareToIgnoreCase(o2.getFirst().getName()));
    for (Pair<NamedScope, NamedScopesHolder> pair : list) {
        NamedScope namedScope = pair.getFirst();
        String name = namedScope.getName();
        TextAttributesKey textAttributesKey = ScopeAttributesUtil.getScopeTextAttributeKey(name);
        if (scheme.getAttributes(textAttributesKey) == null) {
            scheme.setAttributes(textAttributesKey, new TextAttributes());
        }
        NamedScopesHolder holder = pair.getSecond();
        PackageSet value = namedScope.getValue();
        String toolTip = holder.getDisplayName() + (value == null ? "" : ": " + value.getText());
        addSchemedDescription(descriptions, name, SCOPES_GROUP, textAttributesKey, scheme, holder.getIcon(), toolTip);
    }
}
Also used : NamedScopesHolder(com.intellij.psi.search.scope.packageSet.NamedScopesHolder) PackageSet(com.intellij.psi.search.scope.packageSet.PackageSet) THashSet(gnu.trove.THashSet) DependencyValidationManagerImpl(com.intellij.packageDependencies.DependencyValidationManagerImpl) Project(com.intellij.openapi.project.Project) NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) Pair(com.intellij.openapi.util.Pair)

Example 90 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.

the class HighlightNamesUtil method mergeWithScopeAttributes.

private static TextAttributes mergeWithScopeAttributes(@Nullable PsiElement element, @NotNull HighlightInfoType type, @NotNull TextAttributesScheme colorsScheme) {
    TextAttributes regularAttributes = HighlightInfo.getAttributesByType(element, type, colorsScheme);
    if (element == null)
        return regularAttributes;
    TextAttributes scopeAttributes = getScopeAttributes(element, colorsScheme);
    return TextAttributes.merge(scopeAttributes, regularAttributes);
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Aggregations

TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)205 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)40 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)31 NotNull (org.jetbrains.annotations.NotNull)29 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)28 HighlightManager (com.intellij.codeInsight.highlighting.HighlightManager)26 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)26 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)23 TextRange (com.intellij.openapi.util.TextRange)21 Nullable (org.jetbrains.annotations.Nullable)21 ArrayList (java.util.ArrayList)19 Editor (com.intellij.openapi.editor.Editor)18 Project (com.intellij.openapi.project.Project)17 PsiElement (com.intellij.psi.PsiElement)12 HighlightInfoType (com.intellij.codeInsight.daemon.impl.HighlightInfoType)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 JBColor (com.intellij.ui.JBColor)10 Document (com.intellij.openapi.editor.Document)9 ContainerUtil (com.intellij.util.containers.ContainerUtil)9 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)8