com.intellij.openapi.editor.colors.EditorColors Java Examples
The following examples show how to use
com.intellij.openapi.editor.colors.EditorColors.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InplaceRefactoring.java From consulo with Apache License 2.0 | 6 votes |
public static EditorEx createPreviewComponent(Project project, FileType languageFileType) { Document document = EditorFactory.getInstance().createDocument(""); UndoUtil.disableUndoFor(document); EditorEx previewEditor = (EditorEx)EditorFactory.getInstance().createEditor(document, project, languageFileType, true); previewEditor.setOneLineMode(true); final EditorSettings settings = previewEditor.getSettings(); settings.setAdditionalLinesCount(0); settings.setAdditionalColumnsCount(1); settings.setRightMarginShown(false); settings.setFoldingOutlineShown(false); settings.setLineNumbersShown(false); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setVirtualSpace(false); previewEditor.setHorizontalScrollbarVisible(false); previewEditor.setVerticalScrollbarVisible(false); previewEditor.setCaretEnabled(false); settings.setLineCursorWidth(1); final Color bg = previewEditor.getColorsScheme().getColor(EditorColors.CARET_ROW_COLOR); previewEditor.setBackgroundColor(bg); previewEditor.setBorder(BorderFactory.createCompoundBorder(new DottedBorder(Color.gray), new LineBorder(bg, 2))); return previewEditor; }
Example #2
Source File: FlowInPlaceRenamer.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
private static void addHighlights(List<TextRange> ranges, Editor editor, ArrayList<RangeHighlighter> highlighters) { EditorColorsManager colorsManager = EditorColorsManager.getInstance(); TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES); HighlightManager highlightManager = HighlightManager.getInstance(editor.getProject()); Iterator iterator = ranges.iterator(); while (iterator.hasNext()) { TextRange range = (TextRange) iterator.next(); //highlightManager.addOccurrenceHighlight(editor, range.getStartOffset() + 1, range.getEndOffset() - 1, attributes, 0, highlighters, (Color) null); highlightManager.addRangeHighlight(editor, range.getStartOffset() + 1, range.getEndOffset() - 1, attributes, false, highlighters); } iterator = highlighters.iterator(); while (iterator.hasNext()) { RangeHighlighter highlighter = (RangeHighlighter) iterator.next(); highlighter.setGreedyToLeft(true); highlighter.setGreedyToRight(true); } }
Example #3
Source File: NewClassDialog.java From json2java4idea with Apache License 2.0 | 6 votes |
private void createUIComponents() { final EditorFactory editorFactory = EditorFactory.getInstance(); jsonDocument = editorFactory.createDocument(EMPTY_TEXT); jsonEditor = editorFactory.createEditor(jsonDocument, project, JsonFileType.INSTANCE, false); final EditorSettings settings = jsonEditor.getSettings(); settings.setWhitespacesShown(true); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setLineNumbersShown(true); settings.setFoldingOutlineShown(false); settings.setRightMarginShown(false); settings.setVirtualSpace(false); settings.setWheelFontChangeEnabled(false); settings.setUseSoftWraps(false); settings.setAdditionalColumnsCount(0); settings.setAdditionalLinesCount(1); final EditorColorsScheme colorsScheme = jsonEditor.getColorsScheme(); colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null); jsonEditor.getContentComponent().setFocusable(true); jsonPanel = (JPanel) jsonEditor.getComponent(); }
Example #4
Source File: NativeEditorNotificationProvider.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
NativeEditorActionsPanel(VirtualFile file, VirtualFile root, String actionName) { super(EditorColors.GUTTER_BACKGROUND); myFile = file; myRoot = root; myAction = ActionManager.getInstance().getAction(actionName); icon(FlutterIcons.Flutter); text("Flutter commands"); // Ensure this project is a Flutter project by updating the menu action. It will only be visible for Flutter projects. myAction.update(AnActionEvent.createFromDataContext(ActionPlaces.EDITOR_TOOLBAR, myAction.getTemplatePresentation(), makeContext())); isVisible = myAction.getTemplatePresentation().isVisible(); createActionLabel(myAction.getTemplatePresentation().getText(), this::performAction) .setToolTipText(myAction.getTemplatePresentation().getDescription()); createActionLabel(FlutterBundle.message("flutter.androidstudio.open.hide.notification.text"), () -> { showNotification = false; EditorNotifications.getInstance(myProject).updateAllNotifications(); }).setToolTipText(FlutterBundle.message("flutter.androidstudio.open.hide.notification.description")); }
Example #5
Source File: FlutterSampleActionsPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
FlutterSampleActionsPanel(@NotNull List<FlutterSample> samples) { super(EditorColors.GUTTER_BACKGROUND); icon(FlutterIcons.Flutter); text("View hosted code sample"); for (int i = 0; i < samples.size(); i++) { if (i != 0) { myLinksPanel.add(new JSeparator(SwingConstants.VERTICAL)); } final FlutterSample sample = samples.get(i); final HyperlinkLabel label = createActionLabel(sample.getClassName(), () -> browseTo(sample)); label.setToolTipText(sample.getHostedDocsUrl()); } }
Example #6
Source File: FlutterSampleActionsPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
FlutterSampleActionsPanel(@NotNull List<FlutterSample> samples) { super(EditorColors.GUTTER_BACKGROUND); icon(FlutterIcons.Flutter); text("View hosted code sample"); for (int i = 0; i < samples.size(); i++) { if (i != 0) { myLinksPanel.add(new JSeparator(SwingConstants.VERTICAL)); } final FlutterSample sample = samples.get(i); final HyperlinkLabel label = createActionLabel(sample.getClassName(), () -> browseTo(sample)); label.setToolTipText(sample.getHostedDocsUrl()); } }
Example #7
Source File: NativeEditorNotificationProvider.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
NativeEditorActionsPanel(VirtualFile file, VirtualFile root, String actionName) { super(EditorColors.GUTTER_BACKGROUND); myFile = file; myRoot = root; myAction = ActionManager.getInstance().getAction(actionName); icon(FlutterIcons.Flutter); text("Flutter commands"); // Ensure this project is a Flutter project by updating the menu action. It will only be visible for Flutter projects. myAction.update(AnActionEvent.createFromDataContext(ActionPlaces.EDITOR_TOOLBAR, myAction.getTemplatePresentation(), makeContext())); isVisible = myAction.getTemplatePresentation().isVisible(); createActionLabel(myAction.getTemplatePresentation().getText(), this::performAction) .setToolTipText(myAction.getTemplatePresentation().getDescription()); createActionLabel(FlutterBundle.message("flutter.androidstudio.open.hide.notification.text"), () -> { showNotification = false; EditorNotifications.getInstance(myProject).updateAllNotifications(); }).setToolTipText(FlutterBundle.message("flutter.androidstudio.open.hide.notification.description")); }
Example #8
Source File: AbstractRefactoringPanel.java From IntelliJDeodorant with MIT License | 6 votes |
private static void highlightPsiElement(PsiElement psiElement, boolean openInEditor) { if (openInEditor) { EditorHelper.openInEditor(psiElement); } Editor editor = FileEditorManager.getInstance(psiElement.getProject()).getSelectedTextEditor(); if (editor == null) { return; } TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); editor.getMarkupModel().addRangeHighlighter( psiElement.getTextRange().getStartOffset(), psiElement.getTextRange().getEndOffset(), HighlighterLayer.SELECTION, attributes, HighlighterTargetArea.EXACT_RANGE ); }
Example #9
Source File: InplaceRefactoring.java From consulo with Apache License 2.0 | 6 votes |
private void highlightTemplateVariables(Template template, Editor topLevelEditor) { //add highlights if (myHighlighters != null) { // can be null if finish is called during testing Map<TextRange, TextAttributes> rangesToHighlight = new HashMap<TextRange, TextAttributes>(); final TemplateState templateState = TemplateManagerImpl.getTemplateState(topLevelEditor); if (templateState != null) { EditorColorsManager colorsManager = EditorColorsManager.getInstance(); for (int i = 0; i < templateState.getSegmentsCount(); i++) { final TextRange segmentOffset = templateState.getSegmentRange(i); final String name = template.getSegmentName(i); TextAttributes attributes = null; if (name.equals(PRIMARY_VARIABLE_NAME)) { attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES); } else if (name.equals(OTHER_VARIABLE_NAME)) { attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); } if (attributes == null) continue; rangesToHighlight.put(segmentOffset, attributes); } } addHighlights(rangesToHighlight, topLevelEditor, myHighlighters, HighlightManager.getInstance(myProject)); } }
Example #10
Source File: Utils.java From idea-gitignore with MIT License | 6 votes |
/** * Creates and configures template preview editor. * * @param document virtual editor document * @param project current project * @return editor */ @NotNull public static Editor createPreviewEditor(@NotNull Document document, @Nullable Project project, boolean isViewer) { EditorEx editor = (EditorEx) EditorFactory.getInstance().createEditor(document, project, IgnoreFileType.INSTANCE, isViewer); editor.setCaretEnabled(!isViewer); final EditorSettings settings = editor.getSettings(); settings.setLineNumbersShown(false); settings.setAdditionalColumnsCount(1); settings.setAdditionalLinesCount(0); settings.setRightMarginShown(false); settings.setFoldingOutlineShown(false); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setVirtualSpace(false); settings.setWheelFontChangeEnabled(false); EditorColorsScheme colorsScheme = editor.getColorsScheme(); colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null); return editor; }
Example #11
Source File: HighlightingUtil.java From needsmoredojo with Apache License 2.0 | 6 votes |
public static void highlightElement(Editor editor, @NotNull com.intellij.openapi.project.Project project, @NotNull PsiElement[] elements) { final HighlightManager highlightManager = HighlightManager.getInstance(project); final EditorColorsManager editorColorsManager = EditorColorsManager.getInstance(); final EditorColorsScheme globalScheme = editorColorsManager.getGlobalScheme(); final TextAttributes textattributes = globalScheme.getAttributes( EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES); highlightManager.addOccurrenceHighlights( editor, elements, textattributes, true, null); final WindowManager windowManager = WindowManager.getInstance(); final StatusBar statusBar = windowManager.getStatusBar(project); statusBar.setInfo("Press Esc to remove highlighting"); }
Example #12
Source File: LivePreview.java From consulo with Apache License 2.0 | 6 votes |
private void updateCursorHighlighting() { hideBalloon(); if (myCursorHighlighter != null) { removeHighlighter(myCursorHighlighter); myCursorHighlighter = null; } final FindResult cursor = mySearchResults.getCursor(); Editor editor = mySearchResults.getEditor(); if (cursor != null && cursor.getEndOffset() <= editor.getDocument().getTextLength()) { Color color = editor.getColorsScheme().getColor(EditorColors.CARET_COLOR); myCursorHighlighter = addHighlighter(cursor.getStartOffset(), cursor.getEndOffset(), new TextAttributes(null, null, color, EffectType.ROUNDED_BOX, Font.PLAIN)); editor.getScrollingModel().runActionOnScrollingFinished(() -> showReplacementPreview()); } }
Example #13
Source File: DiffLineSeparatorRenderer.java From consulo with Apache License 2.0 | 6 votes |
@Override public void paint(Editor editor, Graphics g, Rectangle r) { if (!myCondition.get()) return; int y = r.y; int lineHeight = myEditor.getLineHeight(); EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx(); int annotationsOffset = gutter.getAnnotationsAreaOffset(); int annotationsWidth = gutter.getAnnotationsAreaWidth(); if (annotationsWidth != 0) { g.setColor(editor.getColorsScheme().getColor(EditorColors.GUTTER_BACKGROUND)); g.fillRect(annotationsOffset, y, annotationsWidth, lineHeight); } draw(g, 0, y, lineHeight, myEditor.getColorsScheme()); }
Example #14
Source File: TemplateEditorUtil.java From consulo with Apache License 2.0 | 6 votes |
private static Editor createEditor(boolean isReadOnly, final Document document, final Project project) { EditorFactory editorFactory = EditorFactory.getInstance(); Editor editor = (isReadOnly ? editorFactory.createViewer(document, project) : editorFactory.createEditor(document, project)); EditorSettings editorSettings = editor.getSettings(); editorSettings.setVirtualSpace(false); editorSettings.setLineMarkerAreaShown(false); editorSettings.setIndentGuidesShown(false); editorSettings.setLineNumbersShown(false); editorSettings.setFoldingOutlineShown(false); EditorColorsScheme scheme = editor.getColorsScheme(); scheme.setColor(EditorColors.CARET_ROW_COLOR, null); VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (file != null) { EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(file, scheme, project); ((EditorEx) editor).setHighlighter(highlighter); } return editor; }
Example #15
Source File: CtrlMouseHandler.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private HighlightersSet installHighlighterSet(@Nonnull Info info, @Nonnull EditorEx editor, boolean highlighterOnly) { editor.getContentComponent().addKeyListener(myEditorKeyListener); editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener); if (info.isNavigatable()) { editor.setCustomCursor(CtrlMouseHandler.class, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } List<RangeHighlighter> highlighters = new ArrayList<>(); if (!highlighterOnly || info.isNavigatable()) { TextAttributes attributes = info.isNavigatable() ? EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR) : new TextAttributes(null, HintUtil.getInformationColor(), null, null, Font.PLAIN); for (TextRange range : info.getRanges()) { TextAttributes attr = NavigationUtil.patchAttributesColor(attributes, range, editor); final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), HighlighterLayer.HYPERLINK, attr, HighlighterTargetArea.EXACT_RANGE); highlighters.add(highlighter); } } return new HighlightersSet(highlighters, editor, info); }
Example #16
Source File: EditorPainter.java From consulo with Apache License 2.0 | 6 votes |
private boolean paintFoldingBackground(TextAttributes innerAttributes, float x, int y, float width, @Nonnull FoldRegion foldRegion) { if (innerAttributes.getBackgroundColor() != null && !isSelected(foldRegion)) { paintBackground(innerAttributes, x, y, width); Color borderColor = myEditor.getColorsScheme().getColor(EditorColors.FOLDED_TEXT_BORDER_COLOR); if (borderColor != null) { Shape border = getBorderShape(x, y, width, myLineHeight, 2, false); if (border != null) { myGraphics.setColor(borderColor); myGraphics.fill(border); } } return true; } else { return false; } }
Example #17
Source File: HighlightUsagesHandlerBase.java From consulo with Apache License 2.0 | 6 votes |
protected void performHighlighting() { boolean clearHighlights = HighlightUsagesHandler.isClearHighlights(myEditor); EditorColorsManager manager = EditorColorsManager.getInstance(); TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); TextAttributes writeAttributes = manager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES); HighlightUsagesHandler.highlightRanges(HighlightManager.getInstance(myEditor.getProject()), myEditor, attributes, clearHighlights, myReadUsages); HighlightUsagesHandler.highlightRanges(HighlightManager.getInstance(myEditor.getProject()), myEditor, writeAttributes, clearHighlights, myWriteUsages); if (!clearHighlights) { WindowManager.getInstance().getStatusBar(myEditor.getProject()).setInfo(myStatusText); HighlightHandlerBase.setupFindModel(myEditor.getProject()); // enable f3 navigation } if (myHintText != null) { HintManager.getInstance().showInformationHint(myEditor, myHintText); } }
Example #18
Source File: EditorTextFieldCellRenderer.java From consulo with Apache License 2.0 | 6 votes |
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean focused, int row, int column) { RendererComponent panel = getEditorPanel(table); EditorEx editor = panel.getEditor(); editor.getColorsScheme().setEditorFontSize(table.getFont().getSize()); editor.getColorsScheme().setColor(EditorColors.SELECTION_BACKGROUND_COLOR, table.getSelectionBackground()); editor.getColorsScheme().setColor(EditorColors.SELECTION_FOREGROUND_COLOR, table.getSelectionForeground()); editor.setBackgroundColor(selected ? table.getSelectionBackground() : table.getBackground()); panel.setSelected(!Comparing.equal(editor.getBackgroundColor(), table.getBackground())); panel.setBorder(null); // prevents double border painting when ExtendedItemRendererComponentWrapper is used customizeEditor(editor, table, value, selected, row, column); return panel; }
Example #19
Source File: ExtractIncludeFileBase.java From consulo with Apache License 2.0 | 5 votes |
private static void highlightInEditor(final Project project, final IncludeDuplicate pair, final Editor editor) { final HighlightManager highlightManager = HighlightManager.getInstance(project); EditorColorsManager colorsManager = EditorColorsManager.getInstance(); TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); final int startOffset = pair.getStart().getTextRange().getStartOffset(); final int endOffset = pair.getEnd().getTextRange().getEndOffset(); highlightManager.addRangeHighlight(editor, startOffset, endOffset, attributes, true, null); final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(startOffset); editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE); }
Example #20
Source File: LivePreview.java From consulo with Apache License 2.0 | 5 votes |
private TextAttributes createAttributes(FindResult range) { EditorColorsScheme colorsScheme = mySearchResults.getEditor().getColorsScheme(); if (mySearchResults.isExcluded(range)) { return new TextAttributes(null, null, colorsScheme.getDefaultForeground(), EffectType.STRIKEOUT, Font.PLAIN); } TextAttributes attributes = colorsScheme.getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES); if (range.getLength() == 0) { attributes = attributes.clone(); attributes.setEffectType(EffectType.BOXED); attributes.setEffectColor(attributes.getBackgroundColor()); } return attributes; }
Example #21
Source File: BreadcrumbsComponent.java From consulo with Apache License 2.0 | 5 votes |
public static Color getBackgroundColor(boolean selected, boolean hovered, boolean light, boolean navigationCrumb) { return EditorColorsManager.getInstance().getGlobalScheme().getAttributes(hovered ? EditorColors.BREADCRUMBS_HOVERED : selected ? EditorColors.BREADCRUMBS_CURRENT : light && !navigationCrumb ? EditorColors.BREADCRUMBS_INACTIVE : EditorColors.BREADCRUMBS_DEFAULT) .getBackgroundColor(); }
Example #22
Source File: ExtractMethodHelper.java From consulo with Apache License 2.0 | 5 votes |
private static void highlightInEditor(@Nonnull final Project project, @Nonnull final SimpleMatch match, @Nonnull final Editor editor, Map<SimpleMatch, RangeHighlighter> highlighterMap) { final List<RangeHighlighter> highlighters = new ArrayList<>(); final HighlightManager highlightManager = HighlightManager.getInstance(project); final EditorColorsManager colorsManager = EditorColorsManager.getInstance(); final TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); final int startOffset = match.getStartElement().getTextRange().getStartOffset(); final int endOffset = match.getEndElement().getTextRange().getEndOffset(); highlightManager.addRangeHighlight(editor, startOffset, endOffset, attributes, true, highlighters); highlighterMap.put(match, highlighters.get(0)); final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(startOffset); editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE); }
Example #23
Source File: HighlightUsagesHandler.java From consulo with Apache License 2.0 | 5 votes |
public static void highlightOtherOccurrences(final List<PsiElement> otherOccurrences, Editor editor, boolean clearHighlights) { EditorColorsManager manager = EditorColorsManager.getInstance(); TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); PsiElement[] elements = PsiUtilCore.toPsiElementArray(otherOccurrences); doHighlightElements(editor, elements, attributes, clearHighlights); }
Example #24
Source File: HippieWordCompletionHandler.java From consulo with Apache License 2.0 | 5 votes |
private static void highlightWord(final CompletionVariant variant, final Project project, CompletionData data) { int delta = data.startOffset < variant.offset ? variant.variant.length() - data.myWordUnderCursor.length() : 0; 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 + delta, variant.offset + variant.variant.length() + delta, attributes, HighlightManager.HIDE_BY_ANY_KEY, null, null); }
Example #25
Source File: AbstractValueHint.java From consulo with Apache License 2.0 | 5 votes |
public void invokeHint(Runnable hideRunnable) { myHideRunnable = hideRunnable; if (!canShowHint()) { hideHint(); return; } if (myType == ValueHintType.MOUSE_ALT_OVER_HINT) { EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); TextAttributes attributes = scheme.getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR); attributes = NavigationUtil.patchAttributesColor(attributes, myCurrentRange, myEditor); myHighlighter = myEditor.getMarkupModel().addRangeHighlighter(myCurrentRange.getStartOffset(), myCurrentRange.getEndOffset(), HighlighterLayer.SELECTION + 1, attributes, HighlighterTargetArea.EXACT_RANGE); Component internalComponent = myEditor.getContentComponent(); myStoredCursor = internalComponent.getCursor(); internalComponent.addKeyListener(myEditorKeyListener); internalComponent.setCursor(hintCursor()); if (LOG.isDebugEnabled()) { LOG.debug("internalComponent.setCursor(hintCursor())"); } } else { evaluateAndShowHint(); } }
Example #26
Source File: ExtractMethodPanel.java From IntelliJDeodorant with MIT License | 5 votes |
/** * Opens definition of method and highlights statements, which should be extracted. * * @param sourceMethod method from which code is proposed to be extracted into separate method. * @param scope scope of the current project. * @param slice computation slice. */ private static void openDefinition(@Nullable PsiMethod sourceMethod, AnalysisScope scope, ASTSlice slice) { new Task.Backgroundable(scope.getProject(), "Search Definition") { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); } @Override public void onSuccess() { if (sourceMethod != null) { Set<SmartPsiElementPointer<PsiElement>> statements = slice.getSliceStatements(); PsiStatement psiStatement = (PsiStatement) statements.iterator().next().getElement(); if (psiStatement != null && psiStatement.isValid()) { EditorHelper.openInEditor(psiStatement); Editor editor = FileEditorManager.getInstance(sourceMethod.getProject()).getSelectedTextEditor(); if (editor != null) { TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); editor.getMarkupModel().removeAllHighlighters(); statements.stream() .filter(statement -> statement.getElement() != null) .forEach(statement -> editor.getMarkupModel().addRangeHighlighter(statement.getElement().getTextRange().getStartOffset(), statement.getElement().getTextRange().getEndOffset(), HighlighterLayer.SELECTION, attributes, HighlighterTargetArea.EXACT_RANGE)); } } } } }.queue(); }
Example #27
Source File: CompositeSoftWrapPainter.java From consulo with Apache License 2.0 | 5 votes |
private void initDelegateIfNecessary() { if (myDelegate != null && myDelegate.canUse()) { return; } if (++mySymbolsDrawingIndex < SYMBOLS.size()) { TextDrawingCallback callback = myEditor.getTextDrawingCallback(); ColorProvider colorHolder = ColorProvider.byColorScheme(myEditor, EditorColors.SOFT_WRAP_SIGN_COLOR); myDelegate = new TextBasedSoftWrapPainter(SYMBOLS.get(mySymbolsDrawingIndex), myEditor, callback, colorHolder); initDelegateIfNecessary(); return; } myDelegate = new ArrowSoftWrapPainter(myEditor); }
Example #28
Source File: DesktopSelectionModelImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public TextAttributes getTextAttributes() { if (myTextAttributes == null) { TextAttributes textAttributes = new TextAttributes(); EditorColorsScheme scheme = myEditor.getColorsScheme(); textAttributes.setForegroundColor(scheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR)); textAttributes.setBackgroundColor(scheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR)); myTextAttributes = textAttributes; } return myTextAttributes; }
Example #29
Source File: CallerChooserBase.java From consulo with Apache License 2.0 | 5 votes |
private void updateEditorTexts(final MethodNodeBase<M> node) { final MethodNodeBase<M> parentNode = (MethodNodeBase)node.getParent(); final String callerText = node != myRoot ? getText(node.getMethod()) : ""; final Document callerDocument = myCallerEditor.getDocument(); final String calleeText = node != myRoot ? getText(parentNode.getMethod()) : ""; final Document calleeDocument = myCalleeEditor.getDocument(); ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { callerDocument.setText(callerText); calleeDocument.setText(calleeText); } }); final M caller = node.getMethod(); final PsiElement callee = parentNode != null ? parentNode.getElementToSearch() : null; if (caller != null && caller.isPhysical() && callee != null) { HighlightManager highlighter = HighlightManager.getInstance(myProject); EditorColorsManager colorManager = EditorColorsManager.getInstance(); TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES); int start = getStartOffset(caller); for (PsiElement element : findElementsToHighlight(caller, callee)) { highlighter.addRangeHighlight(myCallerEditor, element.getTextRange().getStartOffset() - start, element.getTextRange().getEndOffset() - start, attributes, false, null); } } }
Example #30
Source File: EditorGutterComponentImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public Color getBackground() { if (myEditor.isInDistractionFreeMode() || !myPaintBackground) { return myEditor.getBackgroundColor(); } Color color = myEditor.getColorsScheme().getColor(EditorColors.GUTTER_BACKGROUND); return color != null ? color : EditorColors.GUTTER_BACKGROUND.getDefaultColor(); }