Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Project with multiple natures: Icon precedence?
Project with multiple natures: Icon precedence? [message #1111497] Wed, 18 September 2013 05:47 Go to next message
Alan DW is currently offline Alan DW
Messages: 103
Registered: March 2012
Senior Member
Hello everyone,

I'm developing a plug-in which attaches multiple Eclipse Project Natures to the projects that use it. All of them come with their own "overlay icons" for the project explorer.

How does Eclipse decide which of these overlay icons to show? Does it depend on the order in which the natures where added? Or something else? Basically I want one particular project nature icon to take precedence over the others. Is that possible? I have been looking for this piece of information for quite a while now and could not find any concrete information.


Thanks,


Alan
Re: Project with multiple natures: Icon precedence? [message #1120230 is a reply to message #1111497] Sun, 29 September 2013 06:24 Go to previous messageGo to next message
Daniel Mising name is currently offline Daniel Mising name
Messages: 9
Registered: April 2011
Junior Member
I never found any documentation but through experimentation I did discover the first nature has precedence, as retrieved/controlled via IProjectDescription objects. As a rough (and probably slow) example consider the following:

IProjectDescription projectDescription = project.getDescription();
List<String> natureIds = new ArrayList<String>(Arrays.asList(projectDescription.getNatureIds()));
natureIds.add(0, DOMINANT_NATURE_ID);
projectDescription.setNatureIds(natureIds.toArray(new String[0]));

Re: Project with multiple natures: Icon precedence? [message #1121182 is a reply to message #1111497] Mon, 30 September 2013 07:01 Go to previous message
Alan DW is currently offline Alan DW
Messages: 103
Registered: March 2012
Senior Member
Hi Daniel,

thanks for your response. I thought about the possibility that it always just takes the first project nature in the list myself already. I just tried your code and unfortunately it is still displaying the wrong project nature overlay image for me. But maybe I'm facing a special case here since I'm dealing with a lot of auto-generated code and god knows what might be happening in there.


Actually, I just discovered the following fact: Eclipse is not displaying only *one* nature overlay icon, it is displaying *all* of them on top of each other. However, the "draw order" of these icons seems to be independent from the order of the nature IDs in the project description...

If you - or anyone else - find any other solution, please let me know.

Thanks,


Alan



EDIT: It turns out that I might have been fooled here. The "other" project nature which is drawn on top of my nature is the Xtext project nature. I've just discovered that this nature icon is not realized as a typical project nature icon, but rather as a full-blown decorator. And this decorator is drawn on top of all project nature decorators to begin with. Turns out that Daniel was right after all!

[Updated on: Mon, 30 September 2013 07:14]

Report message to a moderator

Previous Topic:Custom Common Navigator
Next Topic:How to use Eclipse Ant Task from Java Code
Goto Forum:
  


Current Time: Tue Jul 29 08:52:59 EDT 2014

Powered by FUDForum. Page generated in 0.01975 seconds