Integration of GMF and Xtext -> Problem with ResourceDescription [message #1058633] |
Tue, 14 May 2013 15:09 |
Phil H Messages: 267 Registered: November 2012 |
Senior Member |
|
|
Hi,
I'm trying to integrate GMF and Xtext at the moment. First I want to outline what I want to have, before I explain my problem.
In the GMF Editor you are able to create nodes, which should be reused by the Xtext grammar. In order to specify some constraints for the model, you can click on a specific node label which opens a xtext based cell editor.
To achieve this, the Xtext grammar reuse the existing ecore from the EMF/GMF project. Furthermore I created a custom Resource Description with an acording manager and service provider. The Resource Description filters the necessary objects, as you can see below:
protected List<IEObjectDescription> computeExportedObjects() {
List<IEObjectDescription> exportedObjects = new ArrayList<IEObjectDescription>();
Map<String, String> userData = new HashMap<String, String>();
for (TreeIterator<EObject> iterator = resource.getAllContents(); iterator.hasNext();) {
EObject eObject = iterator.next();
if (eObject instanceof Feature) {
String qualifiedName = ((Feature) eObject).getName();
if (qualifiedName != null) {
exportedObjects.add(new EObjectDescription(qualifiedNameConverter.toQualifiedName(qualifiedName), eObject,userData));
}
....
In the GMF Editor, I implemented the IXtextAwareEditPart interface in the corresponding edit part, which uses an XtextDirectEditManager and I also created a new DirectEditPolicy.
When I run the editor now, and reference the Objects in the xtext cell editor it seems to work. But when I add new model elements to my diagram, xtext dont get the reference to them. I need to save the whole diagram first in order that the computeExportedObjects() method is called again and the content assitant offers me the newly added elements.
Is there a way to get the exportedObjects updated every time when there a changes happen in the diagram (for example adding or deleting elements) ?? Because I've not much knowledge about xtext, it's hard for me to find a hook.
Cheers,
Phil
|
|
|
|
Powered by
FUDForum. Page generated in 0.02239 seconds