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;
}
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();
}
}
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;
}
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);
}
}
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);
}
Aggregations