Skip to main content



      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 04:51 Go to next message
Eclipse UserFriend
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 09:03 Go to previous messageGo to next message
Eclipse UserFriend
can you please provide the/a complete example project to ease debugging
Re: Xtext Embedded editor not shown in wizard [message #1822537 is a reply to message #1822527] Mon, 09 March 2020 10:54 Go to previous messageGo to next message
Eclipse UserFriend
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 10:54] by Moderator

Re: Xtext Embedded editor not shown in wizard [message #1822546 is a reply to message #1822537] Mon, 09 March 2020 12:45 Go to previous messageGo to next message
Eclipse UserFriend
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 04:14 Go to previous message
Eclipse UserFriend
Thank you, it worked :)
Previous Topic:Generating code from attributes in CSV
Next Topic:Unassigned Rule Calls - 'current' already created
Goto Forum:
  


Current Time: Wed Jul 23 19:28:00 EDT 2025

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

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

Back to the top