Multiline Inlay with EditorCustomElementRenderer

Answered

Hey, i have a very hard time trying to implement a multi-line Inlay with the InlayModel.addBlockElement method.
I have created a class which implements EditorCustomElementRenderer and overrides the paint method.
I would like to use a JBTextArea because i want the text to automatically split in multiple lines if it is too long, however i do not know how to paint the JBTextArea inside the overridden print method, i can draw the Text with drawString just fine but it's single line only.

My class:

public class MyClass implements EditorCustomElementRenderer {

private JBTextArea textArea;
private Color color;
public MyClass(final String problemMessage, Color color) {
textArea = new JBTextArea(problemMessage);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
this.color = color;
}

@Override
public void paint(@NotNull Inlay inlay, @NotNull Graphics graphics, @NotNull Rectangle targetRegion, @NotNull TextAttributes textAttributes) {
Editor editor = inlay.getEditor();
EditorColorsScheme colorsScheme = editor.getColorsScheme();

graphics.setFont(colorsScheme.getFont(EditorFontType.PLAIN));
graphics.setColor(color);

// todo how to draw the textArea instead of the string?
graphics.drawString(textArea.getText(), targetRegion.x, targetRegion.y + editor.getAscent());
}
0

Post is closed for comments.