public void testScopeBased() throws Exception { NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null)); NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null)); NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject()); scopeManager.addScope(xScope); scopeManager.addScope(utilScope); EditorColorsManager manager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone(); manager.addColorsScheme(scheme); EditorColorsManager.getInstance().setGlobalScheme(scheme); TextAttributesKey xKey = ScopeAttributesUtil.getScopeTextAttributeKey(xScope.getName()); TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC); scheme.setAttributes(xKey, xAttributes); TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName()); TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD); scheme.setAttributes(utilKey, utilAttributes); try { testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test(); } finally { scopeManager.removeAllSets(); } }
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof FileInfo) { Project project = mySwitcherPanel.project; VirtualFile virtualFile = ((FileInfo)value).getFirst(); String renderedName = ((FileInfo)value).getNameForRendering(); setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, project)); FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(virtualFile); open = FileEditorManager.getInstance(project).isFileOpen(virtualFile); TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN); append(renderedName, SimpleTextAttributes.fromTextAttributes(attributes)); // calc color the same way editor tabs do this, i.e. including EPs Color color = EditorTabbedContainer.calcTabColor(project, virtualFile); if (!selected && color != null) { setBackground(color); } SpeedSearchUtil.applySpeedSearchHighlighting(mySwitcherPanel, this, false, selected); } }
public void testEffectType() throws Exception { assertEquals(EffectType.BOXED, readEffectType(null)); assertEquals(EffectType.BOXED, readEffectType("")); assertEquals(EffectType.BOXED, readEffectType("WRONG")); assertEquals(EffectType.BOXED, readEffectType("0")); assertEquals(EffectType.BOXED, readEffectType("BORDER")); assertEquals(EffectType.LINE_UNDERSCORE, readEffectType("1")); assertEquals(EffectType.LINE_UNDERSCORE, readEffectType("LINE")); assertEquals(EffectType.WAVE_UNDERSCORE, readEffectType("2")); assertEquals(EffectType.WAVE_UNDERSCORE, readEffectType("WAVE")); assertEquals(EffectType.STRIKEOUT, readEffectType("3")); assertEquals(EffectType.STRIKEOUT, readEffectType("STRIKEOUT")); assertEquals(EffectType.BOLD_LINE_UNDERSCORE, readEffectType("4")); assertEquals(EffectType.BOLD_LINE_UNDERSCORE, readEffectType("BOLD_LINE")); assertEquals(EffectType.BOLD_DOTTED_LINE, readEffectType("5")); assertEquals(EffectType.BOLD_DOTTED_LINE, readEffectType("BOLD_DOTTED_LINE")); assertEquals(EffectType.BOXED, readEffectType("6")); }
private void updateCursorHighlighting() { hideBalloon(); if (myCursorHighlighter != null) { HighlightManager.getInstance(mySearchResults.getProject()).removeSegmentHighlighter(mySearchResults.getEditor(), myCursorHighlighter); myCursorHighlighter = null; } final FindResult cursor = mySearchResults.getCursor(); Editor editor = mySearchResults.getEditor(); if (cursor != null && cursor.getEndOffset() <= editor.getDocument().getTextLength()) { Set<RangeHighlighter> dummy = new HashSet<RangeHighlighter>(); Color color = editor.getColorsScheme().getColor(EditorColors.CARET_COLOR); highlightRange(cursor, new TextAttributes(null, null, color, EffectType.ROUNDED_BOX, 0), dummy); if (!dummy.isEmpty()) { myCursorHighlighter = dummy.iterator().next(); } editor.getScrollingModel().runActionOnScrollingFinished(new Runnable() { @Override public void run() { showReplacementPreview(); } }); } }
private void highlightUsages() { if (mySearchResults.getEditor() == null) return; if (mySearchResults.getMatchesCount() >= mySearchResults.getMatchesLimit()) return; for (FindResult range : mySearchResults.getOccurrences()) { if (range.getEndOffset() > mySearchResults.getEditor().getDocument().getTextLength()) continue; TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES); if (range.getLength() == 0) { attributes = attributes.clone(); attributes.setEffectType(EffectType.BOXED); attributes.setEffectColor(attributes.getBackgroundColor()); } if (mySearchResults.isExcluded(range)) { highlightRange(range, strikeout(), myHighlighters); } else { highlightRange(range, attributes, myHighlighters); } } updateInSelectionHighlighters(); if (!myListeningSelection) { mySearchResults.getEditor().getSelectionModel().addSelectionListener(this); myListeningSelection = true; } }
/** * Gets the text attributes for the specified style. * * @param style The style. * @return The text attributes. */ private TextAttributesKey[] getTextAttributesKeyForStyle(final IStyle style) { @Nullable TextAttributesKey[] attributes = this.styleMap.getOrDefault(style, null); if (attributes == null) { final String name = "STYLE_" + style.hashCode(); @SuppressWarnings("deprecation") final TextAttributesKey attribute = createTextAttributesKey( name, new TextAttributes( style.color(), style.backgroundColor(), null, (style.underscore() ? EffectType.LINE_UNDERSCORE : null), (style.bold() ? Font.BOLD : Font.PLAIN) + (style.italic() ? Font.ITALIC : Font.PLAIN) ) ); attributes = new TextAttributesKey[]{attribute}; this.styleMap.put(style, attributes); } return attributes; }
protected void syntaxError(String annotation, Token offendingToken) { // Annotation annot = new Annotation(20, 30, HighlightSeverity.ERROR, "Test!", "Test Message!"); // HighlightInfo info = HighlightInfo.fromAnnotation(annot); // List<HighlightInfo> al = new ArrayList<HighlightInfo>(); // al.add(info); // UpdateHighlightersUtil.setHighlightersToEditor(project, doc, 20, 30, al, null, 0) final TextAttributes attr = new TextAttributes(); attr.setForegroundColor(JBColor.RED); attr.setEffectColor(JBColor.RED); attr.setEffectType(EffectType.WAVE_UNDERSCORE); MarkupModel markupModel = editor.getMarkupModel(); RangeHighlighter h = markupModel.addRangeHighlighter(startIndex+offendingToken.getStartIndex(), startIndex+offendingToken.getStopIndex()+1, HighlighterLayer.ERROR, // layer attr, HighlighterTargetArea.EXACT_RANGE); h.putUserData(SYNTAX_HIGHLIGHTING_TAG, offendingToken); // store any non-null value to tag it }
public void testScopeBased() throws Exception { NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_SOURCE, null)); NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null)); NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject()); scopeManager.addScope(xScope); scopeManager.addScope(utilScope); EditorColorsManager manager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone(); manager.addColorsScheme(scheme); EditorColorsManager.getInstance().setGlobalScheme(scheme); TextAttributesKey xKey = ColorAndFontOptions.getScopeTextAttributeKey(xScope.getName()); TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, EffectType.BOXED, Font.ITALIC); scheme.setAttributes(xKey, xAttributes); TextAttributesKey utilKey = ColorAndFontOptions.getScopeTextAttributeKey(utilScope.getName()); TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD); scheme.setAttributes(utilKey, utilAttributes); try { testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test(); } finally { scopeManager.removeAllSets(); } }
private static void paintBorder(Graphics g, EditorImpl editor, int startOffset, int endOffset, EffectType effectType) { Point startPoint = offsetToXY(editor, startOffset); Point endPoint = offsetToXY(editor, endOffset); int height = endPoint.y - startPoint.y; int startX = startPoint.x; int startY = startPoint.y; int endX = endPoint.x; if (height == 0) { int width = endX == startX ? 1 : endX - startX - 1; if (effectType == EffectType.ROUNDED_BOX) { UIUtil.drawRectPickedOut((Graphics2D)g, startX, startY, width, editor.getLineHeight() - 1); } else { g.drawRect(startX, startY, width, editor.getLineHeight() - 1); } return; } BorderGraphics border = new BorderGraphics(g, startX, startY, effectType); border.horizontalTo(editor.getMaxWidthInRange(startOffset, endOffset) - 1); border.verticalRel(height - 1); border.horizontalTo(endX); border.verticalRel(editor.getLineHeight()); border.horizontalTo(0); border.verticalRel(-height + 1); border.horizontalTo(startX); border.verticalTo(startY); }
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof VirtualFile) { VirtualFile virtualFile = (VirtualFile)value; String name = virtualFile.getPresentableName(); setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, myProject)); FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile); TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null , null, EffectType.LINE_UNDERSCORE, Font.PLAIN); append(name, SimpleTextAttributes.fromTextAttributes(attributes)); if (!selected && FileEditorManager.getInstance(myProject).isFileOpen(virtualFile)) { setBackground(LightColors.SLIGHTLY_GREEN); } } }
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof FileInfo) { VirtualFile virtualFile = ((FileInfo)value).getFirst(); String name = virtualFile instanceof VirtualFilePathWrapper ? ((VirtualFilePathWrapper)virtualFile).getPresentablePath() : UISettings.getInstance().SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES ? UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(myProject, virtualFile) : virtualFile.getName(); setIcon(IconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, myProject)); FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile); open = FileEditorManager.getInstance(myProject).isFileOpen(virtualFile); TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null , null, EffectType.LINE_UNDERSCORE, Font.PLAIN); append(name, SimpleTextAttributes.fromTextAttributes(attributes)); // calc color the same way editor tabs do this, i.e. including extensions Color color = EditorTabbedContainer.calcTabColor(myProject, virtualFile); if (!selected && color != null) { setBackground(color); } } }
private void highlightUsages() { if (mySearchResults.getEditor() == null) return; if (mySearchResults.getMatchesCount() >= mySearchResults.getMatchesLimit()) return; for (FindResult range : mySearchResults.getOccurrences()) { TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES); if (range.getLength() == 0) { attributes = attributes.clone(); attributes.setEffectType(EffectType.BOXED); attributes.setEffectColor(attributes.getBackgroundColor()); } if (mySearchResults.isExcluded(range)) { highlightRange(range, strikout(attributes), myHighlighters); } else { highlightRange(range, attributes, myHighlighters); } } updateInSelectionHighlighters(); if (!myListeningSelection) { mySearchResults.getEditor().getSelectionModel().addSelectionListener(this); myListeningSelection = true; } }
public Token addDecisionEventHighlighter(PreviewState previewState, MarkupModel markupModel, DecisionEventInfo info, Color errorStripeColor, EffectType effectType) { TokenStream tokens = previewState.parsingResult.parser.getInputStream(); Token startToken = tokens.get(info.startIndex); Token stopToken = tokens.get(info.stopIndex); TextAttributes textAttributes = new TextAttributes(JBColor.BLACK, JBColor.WHITE, errorStripeColor, effectType, Font.PLAIN); textAttributes.setErrorStripeColor(errorStripeColor); final RangeHighlighter rangeHighlighter = markupModel.addRangeHighlighter( startToken.getStartIndex(), stopToken.getStopIndex()+1, HighlighterLayer.ADDITIONAL_SYNTAX, textAttributes, HighlighterTargetArea.EXACT_RANGE); rangeHighlighter.putUserData(DECISION_EVENT_INFO_KEY, info); rangeHighlighter.setErrorStripeMarkColor(errorStripeColor); return startToken; }
public void highlightAndOfferHint(Editor editor, int offset, Interval sourceInterval, JBColor color, EffectType effectType, String hintText) { CaretModel caretModel = editor.getCaretModel(); final TextAttributes attr = new TextAttributes(); attr.setForegroundColor(color); attr.setEffectColor(color); attr.setEffectType(effectType); MarkupModel markupModel = editor.getMarkupModel(); markupModel.addRangeHighlighter( sourceInterval.a, sourceInterval.b, InputPanel.TOKEN_INFO_LAYER, // layer attr, HighlighterTargetArea.EXACT_RANGE ); if ( hintText.contains("<") ) { hintText = hintText.replaceAll("<", "<"); } // HINT caretModel.moveToOffset(offset); // info tooltip only shows at cursor :( HintManager.getInstance().showInformationHint(editor, hintText); }
@Nonnull public static GwtTextAttributes createTextAttributes(TextAttributes textAttributes) { GwtColor foreground = null; GwtColor background = null; Color foregroundColor = textAttributes.getForegroundColor(); if (foregroundColor != null) { foreground = createColor(foregroundColor); } Color backgroundColor = textAttributes.getBackgroundColor(); if (backgroundColor != null) { background = createColor(backgroundColor); } int flags = 0; flags = BitUtil.set(flags, GwtTextAttributes.BOLD, (textAttributes.getFontType() & Font.BOLD) != 0); flags = BitUtil.set(flags, GwtTextAttributes.ITALIC, (textAttributes.getFontType() & Font.ITALIC) != 0); flags = BitUtil.set(flags, GwtTextAttributes.UNDERLINE, textAttributes.getEffectType() == EffectType.LINE_UNDERSCORE); flags = BitUtil.set(flags, GwtTextAttributes.LINE_THROUGH, textAttributes.getEffectType() == EffectType.STRIKEOUT); return new GwtTextAttributes(foreground, background, flags); }
@Override protected void customizeCellRenderer(@Nonnull JList list, Object value, int index, boolean selected, boolean hasFocus) { if (value instanceof FileInfo) { Project project = mySwitcherPanel.project; VirtualFile virtualFile = ((FileInfo)value).getFirst(); String renderedName = ((FileInfo)value).getNameForRendering(); setIcon(VfsIconUtil.getIcon(virtualFile, Iconable.ICON_FLAG_READ_STATUS, project)); FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(virtualFile); open = FileEditorManager.getInstance(project).isFileOpen(virtualFile); TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN); append(renderedName, SimpleTextAttributes.fromTextAttributes(attributes)); // calc color the same way editor tabs do this, i.e. including EPs Color color = EditorTabbedContainer.calcTabColor(project, virtualFile); if (!selected && color != null) { setBackground(color); } SpeedSearchUtil.applySpeedSearchHighlighting(mySwitcherPanel, this, false, selected); } }
private void updateCursorHighlighting() { hideBalloon(); if (myCursorHighlighter != null) { HighlightManager.getInstance(mySearchResults.getProject()).removeSegmentHighlighter(mySearchResults.getEditor(), myCursorHighlighter); myCursorHighlighter = null; } final FindResult cursor = mySearchResults.getCursor(); Editor editor = mySearchResults.getEditor(); if (cursor != null) { Set<RangeHighlighter> dummy = new HashSet<RangeHighlighter>(); Color color = editor.getColorsScheme().getColor(EditorColors.CARET_COLOR); highlightRange(cursor, new TextAttributes(null, null, color, EffectType.ROUNDED_BOX, 0), dummy); if (!dummy.isEmpty()) { myCursorHighlighter = dummy.iterator().next(); } editor.getScrollingModel().runActionOnScrollingFinished(new Runnable() { @Override public void run() { showReplacementPreview(); } }); } }
private void highlightUsages() { if (mySearchResults.getEditor() == null) return; if (mySearchResults.getMatchesCount() >= mySearchResults.getMatchesLimit()) return; for (FindResult range : mySearchResults.getOccurrences()) { TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES); if (range.getLength() == 0) { attributes = attributes.clone(); attributes.setEffectType(EffectType.BOXED); attributes.setEffectColor(attributes.getBackgroundColor()); } if (mySearchResults.isExcluded(range)) { highlightRange(range, strikeout(), myHighlighters); } else { highlightRange(range, attributes, myHighlighters); } } updateInSelectionHighlighters(); if (!myListeningSelection) { mySearchResults.getEditor().getSelectionModel().addSelectionListener(this); myListeningSelection = true; } }
public void testSharedScopeBased() throws Exception { NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_ANY, null)); NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null)); NamedScopesHolder scopeManager = DependencyValidationManager.getInstance(getProject()); scopeManager.addScope(xScope); scopeManager.addScope(utilScope); EditorColorsManager manager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone(); manager.addColorsScheme(scheme); EditorColorsManager.getInstance().setGlobalScheme(scheme); TextAttributesKey xKey = ScopeAttributesUtil.getScopeTextAttributeKey(xScope.getName()); TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, null, Font.ITALIC); scheme.setAttributes(xKey, xAttributes); TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName()); TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD); scheme.setAttributes(utilKey, utilAttributes); NamedScope projectScope = PackagesScopesProvider.getInstance(myProject).getProjectProductionScope(); TextAttributesKey projectKey = ScopeAttributesUtil.getScopeTextAttributeKey(projectScope.getName()); TextAttributes projectAttributes = new TextAttributes(null, null, Color.blue, EffectType.BOXED, Font.ITALIC); scheme.setAttributes(projectKey, projectAttributes); try { testFile(BASE_PATH + "/scopeBased/x/Shared.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test(); } finally { scopeManager.removeAllSets(); } }
public HyperlinkLabel(String text, final Color textForegroundColor, final Color textBackgroundColor, final Color textEffectColor) { myAnchorAttributes = new TextAttributes(textForegroundColor, textBackgroundColor, textEffectColor, EffectType.LINE_UNDERSCORE, Font.PLAIN); enforceBackgroundOutsideText(textBackgroundColor); setHyperlinkText(text); enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK); setOpaque(false); }
@NotNull public static SimpleTextAttributes fromTextAttributes(TextAttributes attributes) { if (attributes == null) return REGULAR_ATTRIBUTES; Color foregroundColor = attributes.getForegroundColor(); if (foregroundColor == null) foregroundColor = REGULAR_ATTRIBUTES.getFgColor(); int style = attributes.getFontType(); if (attributes.getEffectColor() != null) { EffectType effectType = attributes.getEffectType(); if (effectType == EffectType.STRIKEOUT) { style |= STYLE_STRIKEOUT; } else if (effectType == EffectType.WAVE_UNDERSCORE) { style |= STYLE_WAVED; } else if (effectType == EffectType.LINE_UNDERSCORE || effectType == EffectType.BOLD_LINE_UNDERSCORE || effectType == EffectType.BOLD_DOTTED_LINE) { style |= STYLE_UNDERLINE; } else if (effectType == EffectType.SEARCH_MATCH) { style |= STYLE_SEARCH_MATCH; } else { // not supported } } return new SimpleTextAttributes(attributes.getBackgroundColor(), foregroundColor, attributes.getEffectColor(), style); }
public TextAttributes toTextAttributes() { Color effectColor; EffectType effectType; if (isWaved()) { effectColor = myWaveColor; effectType = EffectType.WAVE_UNDERSCORE; } else if (isStrikeout()) { effectColor = myWaveColor; effectType = EffectType.STRIKEOUT; } else if (isUnderline()) { effectColor = myWaveColor; effectType = EffectType.LINE_UNDERSCORE; } else if (isBoldDottedLine()) { effectColor = myWaveColor; effectType = EffectType.BOLD_DOTTED_LINE; } else if (isSearchMatch()) { effectColor = myWaveColor; effectType = EffectType.SEARCH_MATCH; } else { effectColor = null; effectType = null; } return new TextAttributes(myFgColor, null, effectColor, effectType, myStyle & FONT_MASK); }
public LineExtensionInfo(@NotNull String text, @Nullable Color color, @Nullable EffectType effectType, @Nullable Color effectColor, @JdkConstants.FontStyle int fontType) { myText = text; myColor = color; myEffectType = effectType; myEffectColor = effectColor; myFontType = fontType; }
@Override public boolean equals(final TextAttributes attributes1, final TextAttributes attributes2) { Color effectColor = attributes1.getEffectColor(); EffectType effectType = attributes1.getEffectType(); return effectColor != null && effectColor.equals(attributes2.getEffectColor()) && (EffectType.BOXED == effectType || EffectType.ROUNDED_BOX == effectType) && effectType == attributes2.getEffectType(); }
private void paintBorder(Graphics g, EditorImpl editor, int startOffset, int endOffset, EffectType effectType) { if (!myClipDetector.rangeCanBeVisible(startOffset, endOffset)) return; Point startPoint = offsetToXY(editor, startOffset); Point endPoint = offsetToXY(editor, endOffset); int height = endPoint.y - startPoint.y; int startX = startPoint.x; int startY = startPoint.y; int endX = endPoint.x; int lineHeight = editor.getLineHeight(); if (height == 0) { int width = endX == startX ? 1 : endX - startX - 1; if (effectType == EffectType.ROUNDED_BOX) { UIUtil.drawRectPickedOut((Graphics2D)g, startX, startY, width, lineHeight - 1); } else { g.drawRect(startX, startY, width, lineHeight - 1); } return; } BorderGraphics border = new BorderGraphics(g, startX, startY, effectType); border.horizontalTo(editor.getMaxWidthInRange(startOffset, endOffset) - 1); border.verticalRel(height - 1); border.horizontalTo(endX); if (endX > 0) { border.verticalRel(lineHeight); border.horizontalTo(0); border.verticalRel(-height + 1); } else if (height > lineHeight) { border.verticalRel(-height + lineHeight + 1); } border.horizontalTo(startX); border.verticalTo(startY); }
public static void paintFoldedEffect(Graphics g, int foldingXStart, int y, int foldingXEnd, int lineHeight, Color effectColor, EffectType effectType) { if (effectColor == null || effectType != EffectType.BOXED) return; g.setColor(effectColor); g.drawRect(foldingXStart, y, foldingXEnd - foldingXStart, lineHeight - 1); }
public BorderGraphics(Graphics graphics, int startX, int stIntY, EffectType effectType) { myGraphics = graphics; myX = startX; myY = stIntY; myEffectType = effectType; }
private void lineTo(int x, int y) { if (myEffectType == EffectType.ROUNDED_BOX) { UIUtil.drawLinePickedOut(myGraphics, myX, myY, x, y); } else { UIUtil.drawLine(myGraphics, myX, myY, x, y); } myX = x; myY = y; }
public void reset(ColorAndFontDescription description) { if (description.isFontEnabled()) { myLabelFont.setEnabled(true); myCbBold.setEnabled(true); myCbItalic.setEnabled(true); int fontType = description.getFontType(); myCbBold.setSelected((fontType & Font.BOLD) != 0); myCbItalic.setSelected((fontType & Font.ITALIC) != 0); } else { myLabelFont.setEnabled(false); myCbBold.setSelected(false); myCbBold.setEnabled(false); myCbItalic.setSelected(false); myCbItalic.setEnabled(false); } updateColorChooser(myCbForeground, myForegroundChooser, description.isForegroundEnabled(), description.isForegroundChecked(), description.getForegroundColor()); updateColorChooser(myCbBackground, myBackgroundChooser, description.isBackgroundEnabled(), description.isBackgroundChecked(), description.getBackgroundColor()); updateColorChooser(myCbErrorStripe, myErrorStripeColorChooser, description.isErrorStripeEnabled(), description.isErrorStripeChecked(), description.getErrorStripeColor()); EffectType effectType = description.getEffectType(); updateColorChooser(myCbEffects, myEffectsColorChooser, description.isEffectsColorEnabled(), description.isEffectsColorChecked(), description.getEffectColor()); if (description.isEffectsColorEnabled() && description.isEffectsColorChecked()) { myEffectsCombo.setEnabled(true); myEffectsModel.setEffectName(ContainerUtil.reverseMap(myEffectsMap).get(effectType)); } else { myEffectsCombo.setEnabled(false); } setInheritanceInfo(description); myLabelFont.setEnabled(myCbBold.isEnabled() || myCbItalic.isEnabled()); }
@Override public void apply(EditorColorsScheme scheme) { TextAttributesKey key = myDiffType.getAttributesKey(); TextAttributes attrs = new TextAttributes(null, myBackgroundColor, null, EffectType.BOXED, Font.PLAIN); attrs.setErrorStripeColor(myStripebarColor); scheme.setAttributes(key, attrs); }
@NotNull @Override public UsagePresentation getPresentation() { final UsagePresentation presentation = super.getPresentation(); return new UsagePresentation() { @Override @NotNull public TextChunk[] getText() { return new TextChunk[]{ new TextChunk(new TextAttributes(JBColor.RED, null, null, EffectType.WAVE_UNDERSCORE, Font.PLAIN), getTooltipText()) }; } @Override @NotNull public String getPlainText() { return presentation.getPlainText(); } @Override public Icon getIcon() { return presentation.getIcon(); } @Override public String getTooltipText() { return "Too complex to analyze, analysis stopped here"; } }; }
public static void setupRenderer(SimpleColoredComponent renderer, Project project, Bookmark bookmark, boolean selected) { VirtualFile file = bookmark.getFile(); if (!file.isValid()) { return; } PsiManager psiManager = PsiManager.getInstance(project); PsiElement fileOrDir = file.isDirectory() ? psiManager.findDirectory(file) : psiManager.findFile(file); if (fileOrDir != null) { renderer.setIcon(fileOrDir.getIcon(0)); } String description = bookmark.getDescription(); if (description != null) { renderer.append(description + " ", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); } FileStatus fileStatus = FileStatusManager.getInstance(project).getStatus(file); TextAttributes attributes = new TextAttributes(fileStatus.getColor(), null, null, EffectType.LINE_UNDERSCORE, Font.PLAIN); renderer.append(file.getName(), SimpleTextAttributes.fromTextAttributes(attributes)); if (bookmark.getLine() >= 0) { renderer.append(":", SimpleTextAttributes.GRAYED_ATTRIBUTES); renderer.append(String.valueOf(bookmark.getLine() + 1), SimpleTextAttributes.GRAYED_ATTRIBUTES); } if (!selected) { FileColorManager colorManager = FileColorManager.getInstance(project); if (fileOrDir instanceof PsiFile) { Color color = colorManager.getRendererBackground((PsiFile)fileOrDir); if (color != null) { renderer.setBackground(color); } } } }
public void testYieldInNestedFunction() { // highlight func declaration first, lest we get an "Extra fragment highlighted" error. EditorColorsManager manager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone(); manager.addColorsScheme(scheme); EditorColorsManager.getInstance().setGlobalScheme(scheme); TextAttributesKey xKey = TextAttributesKey.find("PY.FUNC_DEFINITION"); TextAttributes xAttributes = new TextAttributes(Color.red, Color.black, Color.white, EffectType.BOXED, Font.BOLD); scheme.setAttributes(xKey, xAttributes); doTest(); }
private static TextAttributes createCompilationErrorAttr() { TextAttributes attr = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES).clone(); attr.setForegroundColor(JBColor.RED); attr.setEffectColor(JBColor.RED); attr.setEffectType(EffectType.LINE_UNDERSCORE); attr.setFontType(Font.PLAIN); return attr; }
public void testSharedScopeBased() throws Exception { NamedScope xScope = new NamedScope("xxx", new PatternPackageSet("x..*", PatternPackageSet.SCOPE_ANY, null)); NamedScope utilScope = new NamedScope("util", new PatternPackageSet("java.util.*", PatternPackageSet.SCOPE_LIBRARY, null)); NamedScopesHolder scopeManager = DependencyValidationManager.getInstance(getProject()); scopeManager.addScope(xScope); scopeManager.addScope(utilScope); EditorColorsManager manager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = (EditorColorsScheme)manager.getGlobalScheme().clone(); manager.addColorsScheme(scheme); EditorColorsManager.getInstance().setGlobalScheme(scheme); TextAttributesKey xKey = ColorAndFontOptions.getScopeTextAttributeKey(xScope.getName()); TextAttributes xAttributes = new TextAttributes(Color.cyan, Color.darkGray, Color.blue, null, Font.ITALIC); scheme.setAttributes(xKey, xAttributes); TextAttributesKey utilKey = ColorAndFontOptions.getScopeTextAttributeKey(utilScope.getName()); TextAttributes utilAttributes = new TextAttributes(Color.gray, Color.magenta, Color.orange, EffectType.STRIKEOUT, Font.BOLD); scheme.setAttributes(utilKey, utilAttributes); NamedScope projectScope = PackagesScopesProvider.getInstance(myProject).getProjectProductionScope(); TextAttributesKey projectKey = ColorAndFontOptions.getScopeTextAttributeKey(projectScope.getName()); TextAttributes projectAttributes = new TextAttributes(null, null, Color.blue, EffectType.BOXED, Font.ITALIC); scheme.setAttributes(projectKey, projectAttributes); try { testFile(BASE_PATH + "/scopeBased/x/Shared.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test(); } finally { scopeManager.removeAllSets(); } }
@Override @NotNull public List<HighlightInfoType> getSeveritiesHighlightInfoTypes() { final List<HighlightInfoType> result = new ArrayList<HighlightInfoType>(); final TextAttributes attributes = new TextAttributes(); attributes.setEffectType(EffectType.WAVE_UNDERSCORE); attributes.setEffectColor(new Color(0, 128, 0)); result.add(new HighlightInfoType.HighlightInfoTypeImpl(TYPO, TextAttributesKey.createTextAttributesKey("TYPO", attributes))); return result; }