Xtext Embedded editor not shown in wizard [message #1822516] |
Mon, 09 March 2020 08:51 |
Loredana Hozan Messages: 34 Registered: January 2019 |
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();
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03365 seconds