Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Dynamic Template Proposal
Dynamic Template Proposal [message #696686] Thu, 14 July 2011 14:39 Go to next message
Markus Schindler is currently offline Markus SchindlerFriend
Messages: 30
Registered: July 2009
Member
Hello,

I have a dsl which does a mapping of 2 other dsl. For example:
DSL Mapping:
mapping Entity A (from dsl Entities) {
field a to Class B field x (from dsl Classes)
field b to Class B field y
field c to Class B field z
}

Now, I want to make a proposals after "mapping" to select a Entity from dsl 1. After selecting a Entity, all fields of Entity A should inserted also,
so the mapping looks like this:

mapping Entity A {
field a to [FIELD]
field b to [FIELD]
field c to [FIELD]
}

Where [FIELD] should be properties of the template, where I can navigate using tabs.

Is this possible?


I achieved this already as a "normal" content proposal without the template features. But I had one BIG problem:

public void completeMapping(...)
IScope scope = provider.getScope(model, DomainmodelPackage.eINSTANCE.getEntity());

for (IEObjectDescription element : scope.getAllElements()) {
StringBuffer b = new StringBuffer();
b.append(element.getName().toString());
b.append(" {\n");

Entity x = (Entity ) element.getEObjectOrProxy();
for(AbstractField f : x.getFeatures()){ <
b.append("\n"+f.getName()+"(TYPE) {}\n");
}
b.append("}");

ICompletionProposal completionProposal = createCompletionProposal(...
// register proposal
acceptor.accept(completionProposal);
}
}

Problem is, the x.getFeatures is always empty, I think that is, because the Entity is from an other Dsl. And I got only a proxy. So how can I get now
the "real" object?


I tried to get the Entity_Fields also by Scoping:
IScope scope2 = provider.getScope(element.getEObjectOrProxy(), DomainmodelPackage.eINSTANCE.getProperty_Field());
for (IEObjectDescription element2 : scope2.getAllElements()) {
b.append("\n"+element2.getName()+"(TYPE) {}\n");
}

but, this rises a NullPointer from my ScopeProvider, because the ScopeProvider should only deliever Fields from the selected Entity.
val entity = EcoreUtil2::getContainerOfType(context, typeof(Entity));
val d = entity.features.filter(e | e.isJavaType).map(e | e.createIEObjectDescription()); <-- NullPointer

Any hints? Maybe a configurable Scoping Problem?

Regards,
Markus
Re: Dynamic Template Proposal [message #696733 is a reply to message #696686] Thu, 14 July 2011 18:09 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

have you tried actually resolving the proxy (you can check whether it is a proxy and then ask for its URI)? Once you have the Entity, you don't need to ask the scope provider for visible fields (as that may not only be its own ones). You simply iterate over its fields.

Alex
Re: Dynamic Template Proposal [message #696992 is a reply to message #696733] Fri, 15 July 2011 09:24 Go to previous messageGo to next message
Markus Schindler is currently offline Markus SchindlerFriend
Messages: 30
Registered: July 2009
Member
Hi Alex,

> have you tried actually resolving the proxy (you can check whether it is a proxy and then ask for its URI)?

thanks, for that tip, it works to resolve the proxy (for the "normal" content assist).
Any tips to get this as template proposal working?

Regards,
Markus
Re: Dynamic Template Proposal [message #696997 is a reply to message #696992] Fri, 15 July 2011 09:46 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

a) check out this blog if you consider going via the template infrastructure
b) there was a thread in this forum about a way to make the CompletionProposal having template functionality. I think, the bottom line is that you have to create your own ConfigurableCompletionProposal (maybe adapting setUpLinkedMode). As I have not looked into that topic, I cannot be more precise

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
Previous Topic:Xtext beginner : Issue in xpand workflow generator
Next Topic:Beginner problem
Goto Forum:
  


Current Time: Thu Apr 25 03:50:14 GMT 2024

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

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

Back to the top