Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Solved] Custom content Assist
[Solved] Custom content Assist [message #870256] Mon, 07 May 2012 13:25 Go to next message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 16:28]

Report message to a moderator

Re: Custom content Assist [message #870349 is a reply to message #870256] Mon, 07 May 2012 17:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

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

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom content Assist [message #870352 is a reply to message #870349] Mon, 07 May 2012 17:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Btw why didnt you simply implement the already generated org.xtext.example.mydsl.ui.labeling.MyDslLabelProvider

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom content Assist [message #870481 is a reply to message #870256] Tue, 08 May 2012 11:50 Go to previous messageGo to next message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 19:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

you still did not answer my first question

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom content Assist [message #870595 is a reply to message #870256] Tue, 08 May 2012 21:21 Go to previous messageGo to next message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 21:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
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.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom content Assist [message #870671 is a reply to message #870256] Wed, 09 May 2012 10:04 Go to previous messageGo to next message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 10:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom content Assist [message #870687 is a reply to message #870256] Wed, 09 May 2012 10:58 Go to previous messageGo to next message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 11:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
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.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom content Assist [message #870699 is a reply to message #870696] Wed, 09 May 2012 11:34 Go to previous messageGo to next message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 11:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom content Assist [message #870742 is a reply to message #870701] Wed, 09 May 2012 14:04 Go to previous messageGo to next message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 14:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
See the abstract generated superclass

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom content Assist [message #870757 is a reply to message #870746] Wed, 09 May 2012 14:41 Go to previous messageGo to next message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 18:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
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));
	}

}



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom content Assist [message #870947 is a reply to message #870256] Thu, 10 May 2012 10:21 Go to previous messageGo to next message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 10:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi I do not understand your question: the method that's called
depends from the place you press crtl space


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Custom content Assist [message #870964 is a reply to message #870949] Thu, 10 May 2012 11:19 Go to previous messageGo to next message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 16:27 Go to previous message
Freddy H is currently offline Freddy HFriend
Messages: 26
Registered: April 2012
Junior Member
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 16:27]

Report message to a moderator

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


Current Time: Thu Mar 28 12:39:36 GMT 2024

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

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

Back to the top