Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Customizing XtextSourceViewer(I overrided this class, but how to bind to my subclass?)
Customizing XtextSourceViewer [message #734707] Sun, 09 October 2011 12:07 Go to next message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
Hi,

I have customized the default DocumentAdapter that is used to display adapted text and vice versa for sending the correct text in the system, which works in a default eclipse plugin (I mean without the xtext framework). Now the good part is that I see that the XtextSourceViewer overrides the default SourceViewer where the DocumentAdapter is located. So if I can switch this documentadapter to my adapter it should still work.
The problem is I'm confused with all the bindings that set up the Xtext framework.

Normally (without the xtext framework) you get a TextEditor from the plugin wizard to create editors (in a plain simple eclipse editor plugin) where a link to the Sourceviewer is. How to get to it in the xtext framework? I see the editor plugin now refers to an AbstractGuiceAwareExecutableExtensionFactory, so I'll have to do some binding?

Phil

ps: if you need to know the reason why I customized the documentadapter: http://www.eclipse.org/forums/index.php/t/243013/

[Updated on: Sun, 09 October 2011 12:11]

Report message to a moderator

Re: Customizing XtextSourceViewer [message #734708 is a reply to message #734707] Sun, 09 October 2011 12:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

what about something like

public class MyDslXtextSourceViewer extends XtextSourceViewer {

	public MyDslXtextSourceViewer(Composite parent, IVerticalRuler ruler,
			IOverviewRuler overviewRuler, boolean showsAnnotationOverview,
			int styles) {
		super(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
	}
	
	@Override
	protected IDocumentAdapter createDocumentAdapter() {
		// TODO return your adapter instance
		return super.createDocumentAdapter();
	}

}


public class MyDslXtextSourceViewerFactory implements XtextSourceViewer.Factory {
	
	public XtextSourceViewer createSourceViewer(Composite parent,
			IVerticalRuler ruler, IOverviewRuler overviewRuler,
			boolean showsAnnotationOverview, int styles) {
		return new MyDslXtextSourceViewer(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
	}

}


(in the ui module)
public Class<? extends XtextSourceViewer.Factory> bindXtextSourceViewer$Factory() {
		return MyDslXtextSourceViewerFactory.class;
	}


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Customizing XtextSourceViewer [message #734709 is a reply to message #734708] Sun, 09 October 2011 12:42 Go to previous message
Phil R is currently offline Phil RFriend
Messages: 99
Registered: September 2011
Member
Thank you Christian for your help over and over again! Your support is amazing! thx
Previous Topic:My first XText
Next Topic:Switch off automatic validation
Goto Forum:
  


Current Time: Sat Apr 20 01:23:13 GMT 2024

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

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

Back to the top