Synchronize changes from the Model to the Embedded Editor in Xtext [message #1830598] |
Wed, 29 July 2020 14:28 |
Georgiana Ecobici Messages: 23 Registered: July 2019 |
Junior Member |
|
|
I used XText to define a DSL Grammar, then I used the XText EmbeddedEditor to use XText editor in it.
I have some issues regarding the synchronization, I obtained the model object that contains my content inside the XText editor, but If I modify in Java directly my Model object, the changes are not reflected in the EmbeddedEditor.
The model is updated like below:
DslscenarioProvider p = eeView.getProvider();
XtextResource resource = p.getResource();
EList<EObject> content = resource.getContents();
if (content.size() > 0 && content.get(0) instanceof Model) {
Model domainModel = (Model) resource.getContents().get(0);
Type type = domainModel.getType();
if (type != null) {
type.setName("test");
}
resource.relink();
}
The EmbeddedEditor is added inside an Eclipse ViewPart:
public class EmbeddedEditorView extends ViewPart {
public void redrawParent() {
getParent().redraw(); // parent = composite
}
@Override
public void createPartControl(Composite parent) {
top = new Composite(parent, SWT.NONE);
top.setLayout(new GridLayout());
DslscenarioActivator activator = DslscenarioActivator.getInstance();
Injector injector = activator .getInjector(DslscenarioActivator.ORG_EDITOR_DSLSCENARIO_DSL);
provider = injector.getInstance(DslscenarioProvider.class);
EmbeddedEditorFactory factory = injector.getInstance(EmbeddedEditorFactory.class);
EmbeddedEditor editor = factory.newEditor(provider).withParent(top);
model = editor.createPartialEditor("", "", "", false);
}
}
The redrawParent is called after doing some changes on the model object, however the view is not updated, even if the model is updated.
Do you have other suggestions?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02767 seconds