Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » label provider(where to put the image)
label provider [message #776281] Sun, 08 January 2012 02:36 Go to next message
Mokhtar Alshubei is currently offline Mokhtar AlshubeiFriend
Messages: 121
Registered: November 2011
Location: Germany
Senior Member
Hello,

please in which folder should one put the label icon like "myicon.gif" in order to have it displayed in the editor outline???



Regards,
Mokhtar
Re: label provider [message #776388 is a reply to message #776281] Sun, 08 January 2012 08:19 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
from the doc....


Styling the outline
You can also customize the icons and texts for an outline node. By default, Xtext uses the label provider of your language. If you want the labels to be specific to the outline, you can override the methods _text(modelElement) and _image(modelElement) in your DefaultOutlineTreeProvider (src).
Re: label provider [message #776439 is a reply to message #776388] Sun, 08 January 2012 11:57 Go to previous messageGo to next message
Mokhtar Alshubei is currently offline Mokhtar AlshubeiFriend
Messages: 121
Registered: November 2011
Location: Germany
Senior Member
but i did style the text of the outline element i want from here
public class CTLabelProvider extends DefaultEObjectLabelProvider {

	@Inject
	public CTLabelProvider(AdapterFactoryLabelProvider delegate) {
		super(delegate);
	}


	//Labels and icons can be computed like this:
	
	String text(Greeting ele) {
		
			  return "greeting( "+ ele.getName + ")";
	}
	 
    String image(Greeting ele) {
      return "greeting.gif";
    }

it is working for the text but not for the icon. still i didnt know where to throw the "greeting.gif" in my folders

Thanks
Mokhtar
Re: label provider [message #776442 is a reply to message #776439] Sun, 08 January 2012 12:06 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Quote:
Dealing with images can be cumbersome, too, as image handles tend to be scarce system resources. The AbstractLabelProvider (src) helps you managing the images: In your implementation of doGetImage(Object) you can as well return an Image, an ImageDescriptor or a string, representing a path in the icons/ folder of the containing plug-in. This path is actually configurable by Google Guice. Have a look at the PluginImageHelper (src) to learn about the customizing possibilities.


have a look at the domainmodel example for monkey see monkey do


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:[XTEND] Code generation
Next Topic:syntax coloring
Goto Forum:
  


Current Time: Fri Apr 19 23:14:54 GMT 2024

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

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

Back to the top