Search in sources :

Example 26 with TextAttributes

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

the class IntroduceVariableHandler method getSettings.

@Override
public IntroduceVariableSettings getSettings(Project project, Editor editor, PsiExpression expr, PsiExpression[] occurrences, TypeSelectorManagerImpl typeSelectorManager, boolean declareFinalIfAll, boolean anyAssignmentLHS, final InputValidator validator, PsiElement anchor, JavaReplaceChoice replaceChoice) {
    if (replaceChoice == null && ApplicationManager.getApplication().isUnitTestMode()) {
        replaceChoice = JavaReplaceChoice.NO;
    }
    if (replaceChoice != null) {
        return super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS, validator, anchor, replaceChoice);
    }
    ArrayList<RangeHighlighter> highlighters = new ArrayList<>();
    HighlightManager highlightManager = null;
    if (editor != null) {
        highlightManager = HighlightManager.getInstance(project);
        EditorColorsManager colorsManager = EditorColorsManager.getInstance();
        TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
        if (occurrences.length > 1) {
            highlightManager.addOccurrenceHighlights(editor, occurrences, attributes, true, highlighters);
        }
    }
    IntroduceVariableDialog dialog = new IntroduceVariableDialog(project, expr, occurrences.length, anyAssignmentLHS, declareFinalIfAll, typeSelectorManager, validator);
    if (!dialog.showAndGet()) {
        if (occurrences.length > 1) {
            WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
        }
    } else {
        if (editor != null) {
            for (RangeHighlighter highlighter : highlighters) {
                highlightManager.removeSegmentHighlighter(editor, highlighter);
            }
        }
    }
    return dialog;
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) HighlightManager(com.intellij.codeInsight.highlighting.HighlightManager) ArrayList(java.util.ArrayList) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager)

Example 27 with TextAttributes

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

the class InplaceIntroduceParameterPopup method getTextAttributesForAdd.

private static TextAttributes getTextAttributesForAdd() {
    final TextAttributes textAttributes = new TextAttributes();
    textAttributes.setEffectType(EffectType.ROUNDED_BOX);
    textAttributes.setEffectColor(JBColor.RED);
    return textAttributes;
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Example 28 with TextAttributes

use of com.intellij.openapi.editor.markup.TextAttributes 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 29 with TextAttributes

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

the class CoverageLineMarkerRenderer method paint.

public void paint(Editor editor, Graphics g, Rectangle r) {
    final TextAttributes color = editor.getColorsScheme().getAttributes(myKey);
    Color bgColor = color.getBackgroundColor();
    if (bgColor == null) {
        bgColor = color.getForegroundColor();
    }
    if (editor.getSettings().isLineNumbersShown() || ((EditorGutterComponentEx) editor.getGutter()).isAnnotationsShown()) {
        if (bgColor != null) {
            bgColor = ColorUtil.toAlpha(bgColor, 150);
        }
    }
    if (bgColor != null) {
        g.setColor(bgColor);
    }
    g.fillRect(r.x, r.y, r.width, r.height);
    final LineData lineData = getLineData(editor.xyToLogicalPosition(new Point(0, r.y)).line);
    if (lineData != null && lineData.isCoveredByOneTest()) {
        g.drawImage(ImageLoader.loadFromResource("/gutter/unique.png"), r.x, r.y, 8, 8, editor.getComponent());
    }
}
Also used : LineData(com.intellij.rt.coverage.data.LineData) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Example 30 with TextAttributes

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

the class EclipseThemeOptionHandler method toBackgroundAttributes.

private static TextAttributes toBackgroundAttributes(@NotNull TextAttributes attributes) {
    TextAttributes backgroundAttrs = attributes.clone();
    backgroundAttrs.setBackgroundColor(attributes.getForegroundColor());
    backgroundAttrs.setForegroundColor(null);
    return backgroundAttrs;
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes)

Aggregations

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