Skip to main content



      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 11:58 Go to next message
Eclipse UserFriend
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 11:58] by Moderator

Re: Xtext 2.0.0 - Problem with custom DescriptionLabelProvider [message #826144 is a reply to message #826063] Wed, 21 March 2012 14:14 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Xtext 2.0.0 - Problem with custom DescriptionLabelProvider [message #826568 is a reply to message #826144] Thu, 22 March 2012 04:27 Go to previous messageGo to next message
Eclipse UserFriend
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 04:54 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Xtext 2.0.0 - Problem with custom DescriptionLabelProvider [message #1036329 is a reply to message #826063] Mon, 08 April 2013 04:40 Go to previous messageGo to next message
Eclipse UserFriend
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 04:41] by Moderator

Re: Xtext 2.0.0 - Problem with custom DescriptionLabelProvider [message #1036412 is a reply to message #1036329] Mon, 08 April 2013 06:50 Go to previous message
Eclipse UserFriend
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.
Previous Topic:Use IDerivedStateComputer with non-xbase projects
Next Topic:Eclipse Downloads with 2.3.1
Goto Forum:
  


Current Time: Sun Jul 27 05:06:11 EDT 2025

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

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

Back to the top