use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class ComponentTree method getAttributeWrapper.
private AttributeWrapper getAttributeWrapper(RadComponent component) {
AttributeWrapper wrapper = AttributeWrapper.DEFAULT;
final HighlightDisplayLevel level = getHighlightDisplayLevel(myDesigner.getProject(), component);
if (level != null) {
TextAttributesKey attributesKey = SeverityRegistrar.getSeverityRegistrar(myDesigner.getProject()).getHighlightInfoTypeBySeverity(level.getSeverity()).getAttributesKey();
final TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey);
wrapper = new AttributeWrapper() {
@Override
public SimpleTextAttributes getAttribute(SimpleTextAttributes attributes) {
Color bgColor = textAttributes.getBackgroundColor();
try {
textAttributes.setBackgroundColor(null);
return SimpleTextAttributes.fromTextAttributes(TextAttributes.merge(attributes.toTextAttributes(), textAttributes));
} finally {
textAttributes.setBackgroundColor(bgColor);
}
}
};
}
return wrapper;
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class PyConsoleSourceHighlighter method convertAttributes.
protected TextAttributes convertAttributes(TextAttributesKey[] keys) {
EditorColorsScheme scheme = myScheme;
TextAttributes attrs = scheme.getAttributes(HighlighterColors.TEXT);
for (TextAttributesKey key : keys) {
TextAttributes attrs2 = scheme.getAttributes(key);
if (attrs2 != null) {
attrs = TextAttributes.merge(attrs, attrs2);
}
}
return attrs;
}
use of com.intellij.openapi.editor.markup.TextAttributes in project Main by SpartanRefactoring.
the class SpartanizerAnnotator method annotate.
@Override
public void annotate(@NotNull final PsiElement e, @NotNull AnnotationHolder h) {
try {
if (!Spartanizer.canTip(e) || e.getContainingFile().getName().contains("Spartanizer"))
return;
Annotation annotation = h.createInfoAnnotation(e, "Spartanize This!");
annotation.registerFix(new IntentionAction() {
@SuppressWarnings("unchecked")
@Nls
@NotNull
@Override
public String getText() {
return Toolbox.getInstance().getTipper(e).description(e);
}
@Nls
@NotNull
@Override
public String getFamilyName() {
return "SpartanizerAction";
}
@Override
public boolean isAvailable(@NotNull Project __, Editor e, PsiFile f) {
return true;
}
@Override
public void invoke(@NotNull Project p, Editor ed, PsiFile f) throws IncorrectOperationException {
Spartanizer.spartanizeElement(e);
}
@Override
public boolean startInWriteAction() {
return false;
}
});
TextAttributesKey.createTextAttributesKey("");
annotation.setEnforcedTextAttributes((new TextAttributes(null, null, JBColor.BLUE, EffectType.WAVE_UNDERSCORE, 0)));
} catch (Throwable t) {
Logger l = new Logger(this.getClass());
l.error("", t);
}
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class GroovyRefactoringUtil method highlightOccurrences.
public static void highlightOccurrences(Project project, @Nullable Editor editor, PsiElement[] elements) {
if (editor == null)
return;
ArrayList<RangeHighlighter> highlighters = new ArrayList<>();
HighlightManager highlightManager = HighlightManager.getInstance(project);
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
if (elements.length > 0) {
highlightManager.addOccurrenceHighlights(editor, elements, attributes, false, highlighters);
}
}
use of com.intellij.openapi.editor.markup.TextAttributes in project intellij-community by JetBrains.
the class EditorTextFieldControl method updateComponent.
@Override
protected void updateComponent() {
final DomElement domElement = getDomElement();
if (domElement == null || !domElement.isValid())
return;
final EditorTextField textField = getEditorTextField(getComponent());
final Project project = getProject();
ApplicationManager.getApplication().invokeLater(() -> {
if (!project.isOpen())
return;
if (!getDomWrapper().isValid())
return;
final DomElement domElement1 = getDomElement();
if (domElement1 == null || !domElement1.isValid())
return;
final DomElementAnnotationsManager manager = DomElementAnnotationsManager.getInstance(project);
final DomElementsProblemsHolder holder = manager.getCachedProblemHolder(domElement1);
final List<DomElementProblemDescriptor> errorProblems = holder.getProblems(domElement1);
final List<DomElementProblemDescriptor> warningProblems = new ArrayList<>(holder.getProblems(domElement1, true, HighlightSeverity.WARNING));
warningProblems.removeAll(errorProblems);
Color background = getDefaultBackground();
if (errorProblems.size() > 0 && textField.getText().trim().length() == 0) {
background = getErrorBackground();
} else if (warningProblems.size() > 0) {
background = getWarningBackground();
}
final Editor editor = textField.getEditor();
if (editor != null) {
final MarkupModel markupModel = editor.getMarkupModel();
markupModel.removeAllHighlighters();
if (!errorProblems.isEmpty() && editor.getDocument().getLineCount() > 0) {
final TextAttributes attributes = SimpleTextAttributes.ERROR_ATTRIBUTES.toTextAttributes();
attributes.setEffectType(EffectType.WAVE_UNDERSCORE);
attributes.setEffectColor(attributes.getForegroundColor());
markupModel.addLineHighlighter(0, 0, attributes);
editor.getContentComponent().setToolTipText(errorProblems.get(0).getDescriptionTemplate());
}
}
textField.setBackground(background);
});
}
Aggregations