Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Solved] Custom content Assist
[Solved] Custom content Assist [message #870256] Mon, 07 May 2012 09:25 Go to next message
Eclipse UserFriend
Hi,

I have a problem with my content assist,
I try to apply a label provider on my content assist but there is no effect

i use :

@Override
public void configureContentProposalLabelProvider(Binder binder) {
binder.bind(ILabelProvider.class).
annotatedWith(ContentProposalLabelProvider.class).
to(MyLabelProvider.class);
}

with

MyLabelProvider contains method getText() and getImage() for grammar element's...

Fred.

[Updated on: Thu, 10 May 2012 12:28] by Moderator

Re: Custom content Assist [message #870349 is a reply to message #870256] Mon, 07 May 2012 13:51 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

can you share a testcase (grammar + labelprovider) as well

~Christian
Re: Custom content Assist [message #870352 is a reply to message #870349] Mon, 07 May 2012 13:54 Go to previous messageGo to next message
Eclipse UserFriend
Btw why didnt you simply implement the already generated org.xtext.example.mydsl.ui.labeling.MyDslLabelProvider
Re: Custom content Assist [message #870481 is a reply to message #870256] Tue, 08 May 2012 07:50 Go to previous messageGo to next message
Eclipse UserFriend
I have MylabelProvider for custom Outline view...
but the style don't work on my content assist !
so i search to do a link between the element...

Freddy.
Re: Custom content Assist [message #870576 is a reply to message #870481] Tue, 08 May 2012 15:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

you still did not answer my first question

~Christian
Re: Custom content Assist [message #870595 is a reply to message #870256] Tue, 08 May 2012 17:21 Go to previous messageGo to next message
Eclipse UserFriend
hum sorry... Sad

so an example :

MylabelProvider.java :

...

String text(EnumDecl enumD) {
return enumD.getEnumName().getName();
}

String image(EnumDecl enumD) {
return "enum.gif";
}

...

MyDsl.xtext :

...

EnumDecl: enumName=EnumName leftC=LeftCurlyBracket propertyEnum+=EnumPropertyName (comma+=Comma propertyEnum+=EnumPropertyName)* rightC=RightCurlyBracket;

...


result in outline vieuw :

www.hostingpics.net/viewer.php?id=962805enum.jpg

I would have the same icon in my content assist

Freddy.
Re: Custom content Assist [message #870598 is a reply to message #870595] Tue, 08 May 2012 17:33 Go to previous messageGo to next message
Eclipse UserFriend
I do not see any cross refs in the grammar you posted so there might
be a missanderstanding in what the label provider is used for.
Re: Custom content Assist [message #870671 is a reply to message #870256] Wed, 09 May 2012 06:04 Go to previous messageGo to next message
Eclipse UserFriend
I do not understand what you want...
sorry for my english very limit Embarrassed

Freddy.
Re: Custom content Assist [message #870675 is a reply to message #870671] Wed, 09 May 2012 06:08 Go to previous messageGo to next message
Eclipse UserFriend
Hi try to find out if the label provider that is injected to the
content assist is ever called for the place you are talking about. I
guess the answer is not. Never the less you can customize the
Complete methods in the proposal provider and call
createCompletionproposal with an image
Re: Custom content Assist [message #870687 is a reply to message #870256] Wed, 09 May 2012 06:58 Go to previous messageGo to next message
Eclipse UserFriend
by default the labelprovider applies to every element?
and well it just is not for my content assist !
this is why I thought that the method "configureContentProposalLabelProvider" should be used

Re: Custom content Assist [message #870696 is a reply to message #870687] Wed, 09 May 2012 07:28 Go to previous messageGo to next message
Eclipse UserFriend
No! what i say: it is only used for cross references and you do not have any cross refs
so it is not used at all in your case.
Re: Custom content Assist [message #870699 is a reply to message #870696] Wed, 09 May 2012 07:34 Go to previous messageGo to next message
Eclipse UserFriend
aaaaaah yes!
but then, what is the cross references ?!
Re: Custom content Assist [message #870701 is a reply to message #870699] Wed, 09 May 2012 07:49 Go to previous messageGo to next message
Eclipse UserFriend
If you have something like ref=[Type] in your grammar. You don't have
=> you have to find a different solution. So have a look at the
complete methods in your proposal provider
Re: Custom content Assist [message #870742 is a reply to message #870701] Wed, 09 May 2012 10:04 Go to previous messageGo to next message
Eclipse UserFriend
my proposal provider is empty...
How do I implement method or have you a link for documentation ?
Re: Custom content Assist [message #870746 is a reply to message #870742] Wed, 09 May 2012 10:06 Go to previous messageGo to next message
Eclipse UserFriend
See the abstract generated superclass
Re: Custom content Assist [message #870757 is a reply to message #870746] Wed, 09 May 2012 10:41 Go to previous messageGo to next message
Eclipse UserFriend
i have method for example :

public void completeEnumDecl_EnumName(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}

i don't see where i can to change style..
Re: Custom content Assist [message #870804 is a reply to message #870757] Wed, 09 May 2012 14:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

you did not post your complete grammar. thus its hard to tell how this could look like.
so let us asume your grammar would look like

EnumDecl: enumName=ID "{" propertyEnum+=ID ("," propertyEnum+=ID)* "}";


then you could do

public class MyDslProposalProvider extends AbstractMyDslProposalProvider {
	
	@Inject
	private IImageHelper imageHelper;
	
	@Override
	public void completeEnumDecl_EnumName(EObject model, Assignment assignment,
			ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		//icons/"Entity.gif
		acceptor.accept(createCompletionProposal("EnumName", "New EnumName", imageHelper.getImage("Entity.gif"), context));
	}

}

Re: Custom content Assist [message #870947 is a reply to message #870256] Thu, 10 May 2012 06:21 Go to previous messageGo to next message
Eclipse UserFriend
Ok ok

one last problem,
MyDSLProposalProvider is correctly call
but the method no... i think to need constructor or a method configure ?
Re: Custom content Assist [message #870949 is a reply to message #870947] Thu, 10 May 2012 06:30 Go to previous messageGo to next message
Eclipse UserFriend
Hi I do not understand your question: the method that's called
depends from the place you press crtl space
Re: Custom content Assist [message #870964 is a reply to message #870949] Thu, 10 May 2012 07:19 Go to previous messageGo to next message
Eclipse UserFriend
Ah oki very good !
effectively it work...
the method created a new item
for the cross reference (i see now) icon's is by default
Re: Custom content Assist [message #871049 is a reply to message #870256] Thu, 10 May 2012 12:27 Go to previous message
Eclipse UserFriend
thanks Christian

my problem is solved with a label provider
in fact I forgot to put the methods to enumName
I did it for enumDelc...



[Updated on: Thu, 10 May 2012 12:27] by Moderator

Previous Topic:dynamic template proposals in Xtext
Next Topic:One plugin muliple project
Goto Forum:
  


Current Time: Fri Jul 25 07:39:40 EDT 2025

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

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

Back to the top