Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext Embedded editor not shown in wizard
Xtext Embedded editor not shown in wizard [message #1822516] Mon, 09 March 2020 08:51 Go to next message
Loredana Hozan is currently offline Loredana HozanFriend
Messages: 20
Registered: January 2019
Junior Member
Hello, my goal was to have a wizard that creates my dsl file. In the wizard i would have an xtext editor embedded and certain lists of function which the user would be able to add inside the editor. I have followed tutorials and examples found on the forum, github and a tutorial from XtextCon, I have used a synthetic resource and i am not using the @Inject-ed resourceProvider and embedded editorFactory as they were both nulls at runtime, instead i initialized them myself, everything looks fine during debug, but the editor is not appear in the page, and i don't know why. Maybe it's also worth mentioning that the editor would not be based directly inside the parent composite, as i have other swt widgets inside the wizard page and the xtextEditorComposite is part of the parent composite. Here is the code for the editor:
                Composite xtextEditorComposite = new Composite(container, SWT.NONE);
		GridData gd_xtextEditorComposite = new GridData(SWT.FILL, SWT.FILL, false, false, 3, 1);
		gd_xtextEditorComposite.heightHint = 136;
		xtextEditorComposite.setLayoutData(gd_xtextEditorComposite);
		
		RuleActivator validDslActivator=RuleActivator.getInstance();
		Injector injector=validDslActivator.getInjector(RuleActivator.DSL_RULE_RULE);
		

		IEditedResourceProvider validResourceProvider=new IEditedResourceProvider() {
			
			@Override
			public XtextResource createResource() {
				URI resourceUri=URI.createURI("synthetic:/temproraryFile"+".valid");
				XtextResourceSetProvider resourceProvider=(XtextResourceSetProvider) IResourceServiceProvider.Registry.INSTANCE
					    .getResourceServiceProvider(resourceUri)
					    .get(IResourceSetProvider.class);
				ResourceSet resourceSet=resourceProvider.get(ResourcesPlugin.getWorkspace().getRoot().getProject(configurationPOJO.getProject));
				
				XtextResource validXtextResource=(XtextResource)resourceSet.createResource(resourceUri);
				resourceSet.getResources().add(validXtextResource);
				return validXtextResource;
			}
		};
		EmbeddedEditorFactory embeddedEditorFactory=injector.getInstance(EmbeddedEditorFactory.class);
		EmbeddedEditor validXtextEditor=embeddedEditorFactory.newEditor(validResourceProvider).showErrorAndWarningAnnotations().withParent(xtextEditorComposite);
		LineNumberRulerColumn lineNumberRulerColumn = new LineNumberRulerColumn();
		validXtextEditor.getViewer().addVerticalRulerColumn(lineNumberRulerColumn);
		validXtextEditor.getDocument().set("");
		EmbeddedEditorModelAccess model= 
				validXtextEditor.createPartialEditor("","hello","",false);
		xtextEditorComposite.pack();
Re: Xtext Embedded editor not shown in wizard [message #1822527 is a reply to message #1822516] Mon, 09 March 2020 13:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13628
Registered: July 2009
Senior Member
can you please provide the/a complete example project to ease debugging

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext Embedded editor not shown in wizard [message #1822537 is a reply to message #1822527] Mon, 09 March 2020 14:54 Go to previous messageGo to next message
Loredana Hozan is currently offline Loredana HozanFriend
Messages: 20
Registered: January 2019
Junior Member
Thanks for the response, i've used the "new file wizard" template at the creation of the plugin and i've named my wizard "SWT Embedded Xtext Editor". I've added the previous code to the wizard page and the goal was to see the xtext editor in the page.
index.php/fa/37544/0/

[Updated on: Mon, 09 March 2020 14:54]

Report message to a moderator

Re: Xtext Embedded editor not shown in wizard [message #1822546 is a reply to message #1822537] Mon, 09 March 2020 16:45 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 114
Registered: February 2016
Senior Member
You have to set the layout of the xtextEditorComposite as well:

xtextEditorComposite.setLayout(new GridLayout());

Re: Xtext Embedded editor not shown in wizard [message #1822569 is a reply to message #1822546] Tue, 10 March 2020 08:14 Go to previous message
Loredana Hozan is currently offline Loredana HozanFriend
Messages: 20
Registered: January 2019
Junior Member
Thank you, it worked :)
Previous Topic:Generating code from attributes in CSV
Next Topic:Unassigned Rule Calls - 'current' already created
Goto Forum:
  


Current Time: Thu Oct 22 15:54:22 GMT 2020

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

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

Back to the top