Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext 2.0.0 - Problem with custom DescriptionLabelProvider
Xtext 2.0.0 - Problem with custom DescriptionLabelProvider [message #826063] Wed, 21 March 2012 15:58 Go to next message
Steffen Schuette is currently offline Steffen SchuetteFriend
Messages: 26
Registered: August 2010
Junior Member
Hi,

I uncimmented the Descriptionlabelprovider in the ui project and now it looks like htis:

public class DslDescriptionLabelProvider extends DefaultDescriptionLabelProvider {

	public String text(IEObjectDescription ele) {
	  return "my "+ele.getName();
	}
 /*
    String image(IEObjectDescription ele) {
      return ele.getEClass().getName() + ".gif";
    }	 
*/

}


I also added the following code to the UiModule.java

	
public void configureResourceUIServiceLabelProvider(Binder binder) {
	  binder.bind(ILabelProvider.class)
	    .annotatedWith(ResourceServiceDescriptionLabelProvider.class)
    .to(DslDescriptionLabelProvider.class);
}


However, I do not get the "my ..." text, e.g. in the autocompletion dropdown menu.

All other providers (outline, label, etc...) worke like charm.

What's wrong with my code?


Thanks

Steffen

[Updated on: Wed, 21 March 2012 15:58]

Report message to a moderator

Re: Xtext 2.0.0 - Problem with custom DescriptionLabelProvider [message #826144 is a reply to message #826063] Wed, 21 March 2012 18:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

what about using the wrong hook. have a look at org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.DefaultProposalCreator.DefaultProposalCreator(AbstractJavaBasedContentProposalProvider, ContentAssistContext, String, IQualifiedNameConverter)

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext 2.0.0 - Problem with custom DescriptionLabelProvider [message #826568 is a reply to message #826144] Thu, 22 March 2012 08:27 Go to previous messageGo to next message
Steffen Schuette is currently offline Steffen SchuetteFriend
Messages: 26
Registered: August 2010
Junior Member
Hi,

thanks for the hint. I finally managed to call my own apply function. However, the given candidate parameter

public ICompletionProposal apply(IEObjectDescription candidate) {


Is not the real instance of the candidate but (as the parameter type indicates) only a description of it.
However, for providing my custom description I'd like to incorporate some attribute values of the real object.

Is there any chance to get it from within the apply method? Or is ther another approach?


Thanks

Steffen
Re: Xtext 2.0.0 - Problem with custom DescriptionLabelProvider [message #826586 is a reply to message #826568] Thu, 22 March 2012 08:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi

(a) resolve the eobject behind the descriptions (may be very very inperformant)
(b) add stuff to the user data of the IEObjectDescriptions (DefaultResourceDescriptionStrategy)

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext 2.0.0 - Problem with custom DescriptionLabelProvider [message #1036329 is a reply to message #826063] Mon, 08 April 2013 08:40 Go to previous messageGo to next message
Claudio Heeg is currently offline Claudio HeegFriend
Messages: 75
Registered: April 2013
Member
I'm sorry, but I feel like having to revive this.
I want to offer custom descriptions solely for labels, and shouldn't that work with Steffen's code? Label Provider works as it should, label description doesn't, the customised description just does not appear anywhere.
Also referring to the documentation here.

(And now that I see that this thread was created in '12, not '13, I feel a little silly, but what gives.)

[Updated on: Mon, 08 April 2013 08:41]

Report message to a moderator

Re: Xtext 2.0.0 - Problem with custom DescriptionLabelProvider [message #1036412 is a reply to message #1036329] Mon, 08 April 2013 10:50 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
As i Said: you have to resolve the EOBjectOrProxy in the IEObjectDEscription Yuurself
(havce a look at EcoreUtil.resolve)
but as said before: this will be inperformant.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Use IDerivedStateComputer with non-xbase projects
Next Topic:Eclipse Downloads with 2.3.1
Goto Forum:
  


Current Time: Thu Apr 25 23:51:10 GMT 2024

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

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

Back to the top