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