use of com.intellij.codeInsight.highlighting.HighlightManager in project intellij-community by JetBrains.
the class GrIntroduceHandlerBase method showDialog.
@Nullable
private Settings showDialog(@NotNull GrIntroduceContext context) {
// Add occurrences highlighting
ArrayList<RangeHighlighter> highlighters = new ArrayList<>();
HighlightManager highlightManager = null;
if (context.getEditor() != null) {
highlightManager = HighlightManager.getInstance(context.getProject());
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
if (context.getOccurrences().length > 1) {
highlightManager.addOccurrenceHighlights(context.getEditor(), context.getOccurrences(), attributes, true, highlighters);
}
}
GrIntroduceDialog<Settings> dialog = getDialog(context);
dialog.show();
if (dialog.isOK()) {
if (context.getEditor() != null) {
for (RangeHighlighter highlighter : highlighters) {
highlightManager.removeSegmentHighlighter(context.getEditor(), highlighter);
}
}
return dialog.getSettings();
} else {
if (context.getOccurrences().length > 1) {
WindowManager.getInstance().getStatusBar(context.getProject()).setInfo(GroovyRefactoringBundle.message("press.escape.to.remove.the.highlighting"));
}
}
return null;
}
use of com.intellij.codeInsight.highlighting.HighlightManager in project intellij-community by JetBrains.
the class GroovyRefactoringUtil method highlightOccurrencesByRanges.
public static void highlightOccurrencesByRanges(Project project, Editor editor, TextRange[] ranges) {
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);
for (TextRange range : ranges) {
highlightManager.addRangeHighlight(editor, range.getStartOffset(), range.getEndOffset(), attributes, false, highlighters);
}
}
use of com.intellij.codeInsight.highlighting.HighlightManager in project intellij-community by JetBrains.
the class HighlightUtils method highlightElements.
public static void highlightElements(@NotNull final Collection<? extends PsiElement> elementCollection) {
if (elementCollection.isEmpty()) {
return;
}
if (elementCollection.contains(null)) {
throw new IllegalArgumentException("Nulls passed in collection: " + elementCollection);
}
final Application application = ApplicationManager.getApplication();
application.invokeLater(() -> {
final PsiElement[] elements = PsiUtilCore.toPsiElementArray(elementCollection);
final PsiElement firstElement = elements[0];
if (ContainerUtil.exists(elements, element -> !element.isValid())) {
return;
}
final Project project = firstElement.getProject();
if (project.isDisposed())
return;
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 WindowManager windowManager = WindowManager.getInstance();
final StatusBar statusBar = windowManager.getStatusBar(project);
statusBar.setInfo(InspectionGadgetsBundle.message("press.escape.to.remove.highlighting.message"));
final FindManager findmanager = FindManager.getInstance(project);
FindModel findmodel = findmanager.getFindNextModel();
if (findmodel == null) {
findmodel = findmanager.getFindInFileModel();
}
findmodel.setSearchHighlighters(true);
findmanager.setFindWasPerformed();
findmanager.setFindNextModel(findmodel);
});
}
use of com.intellij.codeInsight.highlighting.HighlightManager in project intellij-community by JetBrains.
the class InplaceRefactoring method finish.
public void finish(boolean success) {
if (!ourRenamersStack.isEmpty() && ourRenamersStack.peek() == this) {
ourRenamersStack.pop();
}
if (myHighlighters != null) {
if (!myProject.isDisposed()) {
final HighlightManager highlightManager = HighlightManager.getInstance(myProject);
for (RangeHighlighter highlighter : myHighlighters) {
highlightManager.removeSegmentHighlighter(myEditor, highlighter);
}
}
myHighlighters = null;
myEditor.putUserData(INPLACE_RENAMER, null);
}
if (myBalloon != null) {
if (!isRestart()) {
myBalloon.hide();
}
}
}
use of com.intellij.codeInsight.highlighting.HighlightManager in project intellij-community by JetBrains.
the class ExtractMethodHandler method highlightPrepareError.
public static void highlightPrepareError(PrepareFailedException e, PsiFile file, Editor editor, final Project project) {
if (e.getFile() == file) {
final TextRange textRange = e.getTextRange();
final HighlightManager highlightManager = HighlightManager.getInstance(project);
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, true, null);
final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(textRange.getStartOffset());
editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE);
WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
}
}
Aggregations