Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Customizing XtextAnnotation
Customizing XtextAnnotation [message #1842969] Thu, 08 July 2021 09:29 Go to next message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello,

I am a beginner in Xtext. I want to add markers programmatically to my editor, and I've done it thanks to the following method :

private void createInformativeMarker(IAnnotationModelExtension extension, XtextEditor editor) {
		Issue.IssueImpl issue = new Issue.IssueImpl();
		INode node = NodeModelUtils.findActualNodeFor(associatedObject);
		int start = node.getOffset();
		int length = node.getLength();
		int line = node.getStartLine();
		issue.setSyntaxError(false);
		issue.setSeverity(Severity.INFO);
		issue.setLineNumber(line);
		issue.setMessage(markerInformation());
		String type = "org.eclipse.xtext.ui.editor.info";
		XtextAnnotation rangeIndicator = new XtextAnnotation(type, true, editor.getDocument(),issue, false);
		this.annotation = rangeIndicator;
		extension.modifyAnnotationPosition(rangeIndicator, new Position(start, length));
	}


The type I provided seems to be the information icon. I wanted to know if it was possible to provide my own icons to this marker ? Simply giving the image path does not seem to do the trick.

Thanks !
Re: Customizing XtextAnnotation [message #1842974 is a reply to message #1842969] Thu, 08 July 2021 11:09 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The XtextAnnotation.getImages() method demonstrates icon switching. However it is private, so you probably need to create a derived XtextAnnotation that overrides the paint() method from which getImages() is called.

Regards

Ed Willink
Re: Customizing XtextAnnotation [message #1843176 is a reply to message #1842974] Mon, 19 July 2021 09:47 Go to previous message
Ryana Karaki is currently offline Ryana KarakiFriend
Messages: 19
Registered: May 2021
Junior Member
Hello,

Thank you for your proposition, if I manage to make it work I'll post it here !
Previous Topic:Highlight keywords with dashes
Next Topic:Problems changing hover size & colors (Xtext 2.24)
Goto Forum:
  


Current Time: Thu Mar 28 08:23:22 GMT 2024

Powered by FUDForum. Page generated in 0.05185 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top