Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Update of resource description
Update of resource description [message #1060667] Mon, 27 May 2013 15:49 Go to next message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
Is there a way to update the resource description manually? At the moment only when I save the computeExportedObjects() method is called. So unsaved elements are not covered by xtext then.

Which method is necessary to call to update the resource description?
Re: Update of resource description [message #1061370 is a reply to message #1060667] Fri, 31 May 2013 11:05 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1156
Registered: July 2009
Senior Member
Hi,

you should implement and bind an IDefaultResourceDescriptionStrategy extending DefaultResourceDescriptionStrategy to create customized object and reference descriptions. The corresponding methods should also be called for a dirty state (unsaved file).

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Update of resource description [message #1061878 is a reply to message #1061370] Tue, 04 June 2013 13:42 Go to previous messageGo to next message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
Thx for your suggestions. I'm not sure if I understand you right - have I to bind my IDefaultResourceDescriptionStrategy in this way? :

public class PldxRuntimeModule extends org.itea2.amalthea.model.variability.xtext.AbstractPldxRuntimeModule {
	
	public Class<? extends DefaultResourceDescriptionStrategy> bindDefaultResourceDescriptionStrategy() {
	    return IDefaultResourceDescriptionStrategy.class;
	}
}


Are there any examples what to do in the IDefaultResourceDescriptionStrategy class? I've no idea how to realise that the resource description is updated when I define it. Can I just call a method in this class then and accordingly the resource description is updated?

Cheers,
Phil
Re: Update of resource description [message #1061880 is a reply to message #1061878] Tue, 04 June 2013 13:48 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1156
Registered: July 2009
Senior Member
No, return MyResourceDescriptionStrategy. MyResourceDescriptionStrategy should extend DefaultResourceDescriptionStrategy. There you implement whatever is needed for your descriptions. The descriptions cannot be updated. They can only be created. Note, that the creation is done before the model is linked.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Update of resource description [message #1061920 is a reply to message #1061880] Tue, 04 June 2013 17:40 Go to previous messageGo to next message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
Ok, thx that make sense.

But I still don't understand how this class should help me with my problem. How can I then call the creation mechanism of the resource description from another plugin?

Also the implementation of the class seems too complex for me without any examples. I reckon the method createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) is necessary to implement in order to refer to the current elements of my diagram? So is it similiar to the computeExportedObjects() method?:

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));
				}
			}
		}
	return exportedObjects;
}


Sry for this bundle of dumb questions, but I haven't worked so much with xtext yet and still have problems with the whole context.
Re: Update of resource description [message #1061947 is a reply to message #1061920] Wed, 05 June 2013 05:56 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1156
Registered: July 2009
Senior Member
The description strategy is used whenever a model changes, even in the dirty editor state - when typing. (You may want to have a look at this.)

Maybe you should explain what you want to achieve, rather than what you are doing. My feeling is that you try to create the index yourself rather than using the ones that are already there.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Update of resource description [message #1061979 is a reply to message #1061947] Wed, 05 June 2013 08:49 Go to previous messageGo to next message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
Ok, I've got a GMF Editor where a node implement an IXtextAwareEditPart in order to make use of a Xtext grammar. The Xtext grammar acces specific elements of this diagram (see immage).

index.php/fa/15141/0/

The problem is when I add new elements to the gmf diagram, it needs to be saved - otherwise the newly elements aren't visible in the xtext grammar (so the save mechanism of the gmf editor start the resource description mechanism of xtext). This behaviour is what I would like to change.

Inside my GMF project I know the point, when an update of the resource description has to be happen. The problem is that I don't know how to tell my Xtext project to do this.

Hopefully you understand my use case, so maybe the description strategy isn't the right way for this?

Cheers,
Phil

[Updated on: Wed, 05 June 2013 13:31]

Report message to a moderator

Re: Update of resource description [message #1062724 is a reply to message #1061979] Mon, 10 June 2013 13:53 Go to previous messageGo to next message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
wasn't it clear enough?
Re: Update of resource description [message #1062764 is a reply to message #1061979] Mon, 10 June 2013 16:11 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2904
Registered: July 2009
Senior Member
Am 05.06.13 10:49, schrieb Phil H:
> Ok, I've got a GMF Editor where a node implement an IXtextAwareEditPart in order to make use of a Xtext grammar. The Xtext grammar acces specific elements of this diagram (see immage).
>
>
>
> The problem is when I add new elements to the gmf diagram, it needs to be saved - otherwise the newly elements aren't visible in the xtext grammar (so the save mechanism of the gmf editor start the resource description mechanism of xtext). This behaviour is what I would like to change.
>
> Inside my GMF project I know the point, when an update of the resource description has to be hapen. The problem is that I don't know how to tell my Xtext project to do this.
>
> Hopefully you understand my use case, so maybe the description strategy isn't the right way for this?
>
> Cheers,
> Phil
>

What you are looking for is the
org.eclipse.xtext.ui.editor.AbstractDirtyStateAwareEditorCallback. You
should use a subtype of this class and register the resource that is
currently edited in the dirty state of the workbench. This'll allow to
contribute the changes to other editors without saving the diagram.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Update of resource description [message #1062924 is a reply to message #1062764] Tue, 11 June 2013 12:27 Go to previous message
Phil H is currently offline Phil H
Messages: 267
Registered: November 2012
Senior Member
Thx Sebastian so far.

Just to clarify if I have understand right, I implement AbstractDirtyStateAwareEditorCallback:

public class MyAbstractDirtyStateAwareEditorCallback extends AbstractDirtyStateAwareEditorCallback{
	
	//do the action here?

}


and bind it to my UiModule:

public void configureMyAbstractDirtyStateAwareEditorCallback(com.google.inject.Binder binder) {
	binder.bind(MyAbstractDirtyStateAwareEditorCallback.class).annotatedWith(
	Names.named("MyAbstractDirtyStateAwareEditorCallback")).to(MyAbstractDirtyStateAwareEditorCallback.class);
}


That's what I found out so far, but I'm not sure
Previous Topic:Xtext Problem View Not getting updated
Next Topic:AutoEdit slows down editing of large documents
Goto Forum:
  


Current Time: Thu Oct 23 08:08:07 GMT 2014

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

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