Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » No icons after exporting
No icons after exporting [message #1111724] Wed, 18 September 2013 12:38 Go to next message
romain ognier is currently offline romain ognier
Messages: 18
Registered: September 2013
Junior Member
Hi !
I am facing a problem :
After exporting my project, I don't have any icons on my treeView anymore.

Here is my code :
public class TodoLabelProvider extends LabelProvider {

	private static final Image FOLDER = getImage("folder.png");
	private static final Image FILE = getImage("file.png");


	@Override
	public Image getImage(Object element) {
		if (element instanceof Message) {
			return FOLDER;
		} else if (element instanceof Word) {
			return FILE;
		}
		return null;
	}

	private static Image getImage(String file) {
		Bundle bundle = FrameworkUtil.getBundle(TodoLabelProvider.class);
		URL url = FileLocator.find(bundle, new Path("icons/" + file), null);
		ImageDescriptor image = ImageDescriptor.createFromURL(url);
		return image.createImage();
	} 
} 

Here is my build.properties :
output.. = bin/
bin.includes = META-INF/,\
               .,\
               plugin.xml,\
               Application.e4xmi,\
               css/default.css,\
               template/,\
               xslt/,\
               icons/
source.. = src/


I don't understand why it does not work.
Do I have to add something in the plugin.xml ?

Thank you for your help !

ps : it works just fine when i launch the application from eclipse.
Re: No icons after exporting [message #1112834 is a reply to message #1111724] Fri, 20 September 2013 04:33 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas Helming
Messages: 363
Registered: July 2009
Senior Member
Hi,
can you check the deployed version of your bundle, whether the icons are
in it? Do you deploy the bundle as a jar or as a folder?
Regards
Jonas

Am 18.09.2013 18:38, schrieb romain ognier:
> Hi !
> I am facing a problem :
> After exporting my project, I don't have any icons on my treeView anymore.
>
> Here is my code :
> public class TodoLabelProvider extends LabelProvider {
>
> private static final Image FOLDER = getImage("folder.png");
> private static final Image FILE = getImage("file.png");
>
>
> @Override
> public Image getImage(Object element) {
> if (element instanceof Message) {
> return FOLDER;
> } else if (element instanceof Word) {
> return FILE;
> }
> return null;
> }
>
> private static Image getImage(String file) {
> Bundle bundle = FrameworkUtil.getBundle(TodoLabelProvider.class);
> URL url = FileLocator.find(bundle, new Path("icons/" + file),
> null);
> ImageDescriptor image = ImageDescriptor.createFromURL(url);
> return image.createImage();
> } } Here is my build.properties :
> output.. = bin/
> bin.includes = META-INF/,\
> .,\
> plugin.xml,\
> Application.e4xmi,\
> css/default.css,\
> template/,\
> xslt/,\
> icons/
> source.. = src/
>
> I don't understand why it does not work.
> Do I have to add something in the plugin.xml ?
> Thank you for your help !
>
> ps : it works just fine when i launch the application from eclipse.
>
Re: No icons after exporting [message #1114788 is a reply to message #1112834] Mon, 23 September 2013 03:55 Go to previous messageGo to next message
romain ognier is currently offline romain ognier
Messages: 18
Registered: September 2013
Junior Member
I am just exporting my project as an Eclipse product.
So I don't know what to tell you.
Re: No icons after exporting [message #1114832 is a reply to message #1114788] Mon, 23 September 2013 05:11 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1066
Registered: July 2012
Senior Member
Did you ensure to add your icons to the build.properties?

http://www.vogella.com/articles/EclipseProductDeployment/article.html#deployproduct_buildproperties
Re: No icons after exporting [message #1115563 is a reply to message #1114832] Tue, 24 September 2013 05:06 Go to previous messageGo to next message
romain ognier is currently offline romain ognier
Messages: 18
Registered: September 2013
Junior Member
Yes.
My build property is in my first message :

output.. = bin/
bin.includes = META-INF/,\
               .,\
               plugin.xml,\
               Application.e4xmi,\
               css/default.css,\
               template/,\
               xslt/,\
               icons/
source.. = src/


you can see "icons/" in the bin.includes
Re: No icons after exporting [message #1115579 is a reply to message #1115563] Tue, 24 September 2013 05:36 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1066
Registered: July 2012
Senior Member
Oh sorry, missed that.

Did you ensure that all necessary bundles are added to your product?
Re: No icons after exporting [message #1115634 is a reply to message #1115579] Tue, 24 September 2013 07:09 Go to previous messageGo to next message
romain ognier is currently offline romain ognier
Messages: 18
Registered: September 2013
Junior Member
No problem Smile

How can I ensure that ?

[Updated on: Tue, 24 September 2013 07:09]

Report message to a moderator

Re: No icons after exporting [message #1115675 is a reply to message #1115634] Tue, 24 September 2013 08:22 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1066
Registered: July 2012
Senior Member
Open your product configuration and click "Add Required" on the Dependencies tab

[Updated on: Tue, 24 September 2013 08:22]

Report message to a moderator

Re: No icons after exporting [message #1115684 is a reply to message #1115675] Tue, 24 September 2013 08:33 Go to previous messageGo to next message
romain ognier is currently offline romain ognier
Messages: 18
Registered: September 2013
Junior Member
Just did it.
And it still does not work Crying or Very Sad
Re: No icons after exporting [message #1115688 is a reply to message #1115684] Tue, 24 September 2013 08:39 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1066
Registered: July 2012
Senior Member
In your exported product, there is a folder named plugins. Locate your plugin JAR there and open it with an archive tool. Check if your icons are in there. That's what Jonas was suggesting.
Re: No icons after exporting [message #1115694 is a reply to message #1115688] Tue, 24 September 2013 08:48 Go to previous messageGo to next message
romain ognier is currently offline romain ognier
Messages: 18
Registered: September 2013
Junior Member
Yes, they are !
Re: No icons after exporting [message #1115702 is a reply to message #1115694] Tue, 24 September 2013 08:57 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5014
Registered: July 2009
Senior Member
Why doing the loading this hard?

TodoLabelProvider.class.getClassLoader().getResource("icons/"+name) is
much simpler.

Tom

On 24.09.13 14:48, romain ognier wrote:
> Yes, they are !
Re: No icons after exporting [message #1115709 is a reply to message #1115702] Tue, 24 September 2013 09:10 Go to previous messageGo to next message
romain ognier is currently offline romain ognier
Messages: 18
Registered: September 2013
Junior Member
Yes, it is simpler.
So I changed my code :

public class TodoLabelProvider extends LabelProvider {

	private static final Image FOLDER = getImage("folder.png");
	private static final Image FILE = getImage("file.png");


	@Override
	public String getText(Object element) {
		if (element instanceof Dico) {
			Dico dico = (Dico) element;
			return dico.getName();
		} else if (element instanceof Message) {
			Message messageJ = (Message) element;
			return messageJ.getName();
		}
		return ((Word) element).getName();
	}

	@Override
	public Image getImage(Object element) {
		if (element instanceof Message) {
			return FOLDER;
		} else if (element instanceof Word) {
			return FILE;
		}
		return null;
	}

	// Helper Method to load the images
	private static Image getImage(String file) {
		URL url = TodoLabelProvider.class.getClassLoader().getResource("icons/"+file);
		
		ImageDescriptor image = ImageDescriptor.createFromURL(url);
		return image.createImage();
		
	} 
} 


But it still does not work. Crying or Very Sad
Re: No icons after exporting [message #1115732 is a reply to message #1115709] Tue, 24 September 2013 09:56 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1066
Registered: July 2012
Senior Member
Are you sure that your use cases are the same as when starting the product from within Eclipse? That means, are you sure the objects are of the corresponding type?
Re: No icons after exporting [message #1115745 is a reply to message #1115732] Tue, 24 September 2013 10:17 Go to previous messageGo to next message
romain ognier is currently offline romain ognier
Messages: 18
Registered: September 2013
Junior Member
Yes, I am.

I am pretty sure that this is :
ImageDescriptor image = ImageDescriptor.createFromURL(url);

which does not work.
Cause i use
TodoLabelProvider.class.getClassLoader().getResource(file)

somewhere else in my code on xml file and it works perfectly fine. I put my icons in the same directory of my xml file but it still does not find them !

Edit :
Ok, I may have find something usefull, I don't know why, but :
URL url = TodoLabelProvider.class.getClassLoader().getResource(file);

clearly does not work. url is null.

Does this have anything to do with the fact that my method is static ?

[Updated on: Tue, 24 September 2013 10:35]

Report message to a moderator

Re: No icons after exporting [message #1115758 is a reply to message #1115745] Tue, 24 September 2013 10:44 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1066
Registered: July 2012
Senior Member
It shouldn't. Is your code in a plugin or in a fragment?
Re: No icons after exporting [message #1115765 is a reply to message #1115758] Tue, 24 September 2013 10:57 Go to previous messageGo to next message
romain ognier is currently offline romain ognier
Messages: 18
Registered: September 2013
Junior Member
Ok... I found out...
And I feel really ashamed.

It seems that eclipse is not case sensitive but the exported project is.
My files name extension was in upper case.

I am really sorry I bothered you for this. Thank you really much anyway.

Re: No icons after exporting [message #1115954 is a reply to message #1115765] Tue, 24 September 2013 16:23 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5014
Registered: July 2009
Senior Member
This was the next I was to suggest! This is f** win32 which does not
care about upper/lowercase whereas any sensible filesystem does and jar
is a filesystem type which is one ;-)

Tom

On 24.09.13 16:57, romain ognier wrote:
> Ok... I found out...
> And I feel really ashamed.
>
> It seems that eclipse is not case sensitive but the exported project is.
> My files name extension was in upper case.
>
> I am really sorry I bothered you for this. Thank you really much anyway.
>
>
Previous Topic:ACTIVE_PART: exactly when is it set?
Next Topic:Create product with resources
Goto Forum:
  


Current Time: Sun Apr 20 12:36:38 EDT 2014

Powered by FUDForum. Page generated in 0.02306 seconds