Search in sources :

Example 26 with EditorColorsManager

use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.

the class HighlightUtil method highlightElements.

public static void highlightElements(@NotNull final Collection<? extends PsiElement> elementCollection, @NotNull final String statusBarText) {
    if (elementCollection.isEmpty()) {
        return;
    }
    final Application application = ApplicationManager.getApplication();
    application.invokeLater(() -> {
        final PsiElement[] elements = PsiUtilCore.toPsiElementArray(elementCollection);
        final PsiElement firstElement = elements[0];
        if (!firstElement.isValid()) {
            return;
        }
        final Project project = firstElement.getProject();
        final FileEditorManager editorManager = FileEditorManager.getInstance(project);
        final EditorColorsManager editorColorsManager = EditorColorsManager.getInstance();
        final Editor editor = editorManager.getSelectedTextEditor();
        if (editor == null) {
            return;
        }
        final EditorColorsScheme globalScheme = editorColorsManager.getGlobalScheme();
        final TextAttributes textattributes = globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
        final HighlightManager highlightManager = HighlightManager.getInstance(project);
        highlightManager.addOccurrenceHighlights(editor, elements, textattributes, true, null);
        final FindManager findmanager = FindManager.getInstance(project);
        FindModel findmodel = findmanager.getFindNextModel();
        if (findmodel == null) {
            findmodel = findmanager.getFindInFileModel();
        }
        findmodel.setSearchHighlighters(true);
        findmanager.setFindWasPerformed();
        findmanager.setFindNextModel(findmodel);
        application.invokeLater(() -> {
            final WindowManager windowManager = WindowManager.getInstance();
            final StatusBar statusBar = windowManager.getStatusBar(project);
            if (statusBar != null) {
                statusBar.setInfo(statusBarText);
            }
        });
    });
}
Also used : FindModel(com.intellij.find.FindModel) HighlightManager(com.intellij.codeInsight.highlighting.HighlightManager) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) StatusBar(com.intellij.openapi.wm.StatusBar) WindowManager(com.intellij.openapi.wm.WindowManager) Project(com.intellij.openapi.project.Project) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FindManager(com.intellij.find.FindManager) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) Editor(com.intellij.openapi.editor.Editor) Application(com.intellij.openapi.application.Application) PsiElement(com.intellij.psi.PsiElement)

Example 27 with EditorColorsManager

use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.

the class EditorTextField method initOneLineMode.

private void initOneLineMode(final EditorEx editor) {
    final boolean isOneLineMode = isOneLineMode();
    // set mode in editor
    editor.setOneLineMode(isOneLineMode);
    EditorColorsManager colorsManager = EditorColorsManager.getInstance();
    final EditorColorsScheme defaultScheme = UIUtil.isUnderDarcula() ? colorsManager.getGlobalScheme() : colorsManager.getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME);
    EditorColorsScheme customGlobalScheme = isOneLineMode ? defaultScheme : null;
    editor.setColorsScheme(editor.createBoundColorSchemeDelegate(customGlobalScheme));
    EditorColorsScheme colorsScheme = editor.getColorsScheme();
    editor.getSettings().setCaretRowShown(false);
    // color scheme settings:
    setupEditorFont(editor);
    updateBorder(editor);
    editor.setBackgroundColor(getBackgroundColor(isEnabled(), colorsScheme));
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager)

Example 28 with EditorColorsManager

use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.

the class JavaMarkObjectActionHandler method getAutoMarkupColor.

public static Color getAutoMarkupColor() {
    final EditorColorsManager manager = EditorColorsManager.getInstance();
    final TextAttributes textAttributes = manager.getGlobalScheme().getAttributes(JavaHighlightInfoTypes.STATIC_FIELD.getAttributesKey());
    return textAttributes.getForegroundColor();
}
Also used : TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager)

Example 29 with EditorColorsManager

use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.

the class HippieWordCompletionHandler method highlightWord.

private static void highlightWord(final CompletionVariant variant, final Project project) {
    HighlightManager highlightManager = HighlightManager.getInstance(project);
    EditorColorsManager colorManager = EditorColorsManager.getInstance();
    TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
    highlightManager.addOccurrenceHighlight(variant.editor, variant.offset, variant.offset + variant.variant.length(), attributes, HighlightManager.HIDE_BY_ANY_KEY, null, null);
}
Also used : HighlightManager(com.intellij.codeInsight.highlighting.HighlightManager) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager)

Example 30 with EditorColorsManager

use of com.intellij.openapi.editor.colors.EditorColorsManager in project intellij-community by JetBrains.

the class CallHierarchyNodeDescriptor method navigate.

public void navigate(boolean requestFocus) {
    if (!myNavigateToReference) {
        PsiElement element = getPsiElement();
        if (element instanceof Navigatable && ((Navigatable) element).canNavigate()) {
            ((Navigatable) element).navigate(requestFocus);
        }
        return;
    }
    final PsiReference firstReference = myReferences.get(0);
    final PsiElement element = firstReference.getElement();
    if (element == null)
        return;
    final PsiElement callElement = element.getParent();
    if (callElement instanceof Navigatable && ((Navigatable) callElement).canNavigate()) {
        ((Navigatable) callElement).navigate(requestFocus);
    } else {
        final PsiFile psiFile = callElement.getContainingFile();
        if (psiFile == null || psiFile.getVirtualFile() == null)
            return;
        FileEditorManager.getInstance(myProject).openFile(psiFile.getVirtualFile(), requestFocus);
    }
    Editor editor = PsiUtilBase.findEditor(callElement);
    if (editor != null) {
        HighlightManager highlightManager = HighlightManager.getInstance(myProject);
        EditorColorsManager colorManager = EditorColorsManager.getInstance();
        TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
        ArrayList<RangeHighlighter> highlighters = new ArrayList<>();
        for (PsiReference psiReference : myReferences) {
            final PsiElement eachElement = psiReference.getElement();
            if (eachElement != null) {
                final PsiElement eachMethodCall = eachElement.getParent();
                if (eachMethodCall != null) {
                    final TextRange textRange = eachMethodCall.getTextRange();
                    highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, false, highlighters);
                }
            }
        }
    }
}
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) TextRange(com.intellij.openapi.util.TextRange) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) Editor(com.intellij.openapi.editor.Editor) Navigatable(com.intellij.pom.Navigatable)

Aggregations

EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)43 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)37 HighlightManager (com.intellij.codeInsight.highlighting.HighlightManager)22 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)14 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)9 Editor (com.intellij.openapi.editor.Editor)7 Project (com.intellij.openapi.project.Project)7 TextRange (com.intellij.openapi.util.TextRange)7 TextAttributesKey (com.intellij.openapi.editor.colors.TextAttributesKey)6 ArrayList (java.util.ArrayList)6 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)4 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)3 WindowManager (com.intellij.openapi.wm.WindowManager)3 PsiElement (com.intellij.psi.PsiElement)3 Nullable (org.jetbrains.annotations.Nullable)3 FindManager (com.intellij.find.FindManager)2 FindModel (com.intellij.find.FindModel)2 Application (com.intellij.openapi.application.Application)2 Document (com.intellij.openapi.editor.Document)2 StatusBar (com.intellij.openapi.wm.StatusBar)2