Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to change icon based on content in Project Explorer
How to change icon based on content in Project Explorer [message #332888] Wed, 12 November 2008 16:54 Go to next message
Sue  is currently offline Sue Friend
Messages: 14
Registered: July 2009
Junior Member
I've created my own file type and I want to associate an icon in the
Project Explorer for the file based on the content of the file. My files
have the same extensions but based on the header of the file they need to
show different icons. How would I do this?
Re: How to change icon based on content in Project Explorer [message #332900 is a reply to message #332888] Thu, 13 November 2008 09:54 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
(*) You would need a content type and a describer. The describer would read
the header and associate the content type with the file.
(*) You need to define a content type specific icon for the file:
http://blog.eclipse-tips.com/2008/04/content-type-specific-f ile-icons.html

- Prakash
--

http://blog.eclipse-tips.com

"Sue " <sdimagno@gmail.com> wrote in message
news:74a842fc0edd2bb12803278bae05aa6e$1@www.eclipse.org...
> I've created my own file type and I want to associate an icon in the
> Project Explorer for the file based on the content of the file. My files
> have the same extensions but based on the header of the file they need to
> show different icons. How would I do this?
>
Re: How to change icon based on content in Project Explorer [message #332902 is a reply to message #332888] Thu, 13 November 2008 10:29 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Sue wrote:
> I've created my own file type and I want to associate an icon in the
> Project Explorer for the file based on the content of the file. My
> files have the same extensions but based on the header of the file
> they need to show different icons. How would I do this?
>
Per default views (Navigater, Package Explorer, Project Explorer, ...)
show the icon of the editor who is assigned to that file type per
default. Files (or content types) itself don't have an icon. You could
also try to use the navigatorContent extension point.

Dani
Re: How to change icon based on content in Project Explorer [message #332906 is a reply to message #332902] Thu, 13 November 2008 15:48 Go to previous messageGo to next message
Sue  is currently offline Sue Friend
Messages: 14
Registered: July 2009
Junior Member
I guess I'm still confused. I have two different editors that open files
with the same extension. I would like the default editor for the file to
be based on the content of the file. That is, reading the header to
determine which editor to open. In the editor extension point, each
editor has a different icon associated with it. So, when I open the file
using "Open With" and select either editor, the correct icon shows up in
the editor. But, the tree just shows the one icon. (The icon for the
editor that is defined first.) How do I control the icon in the package
explorer tree?
Re: How to change icon based on content in Project Explorer [message #332907 is a reply to message #332906] Thu, 13 November 2008 16:25 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Sue wrote:
> I guess I'm still confused. I have two different editors that open
> files with the same extension. I would like the default editor for
> the file to be based on the content of the file. That is, reading the
> header to determine which editor to open. In the editor extension
> point, each editor has a different icon associated with it. So, when
> I open the file using "Open With" and select either editor, the
> correct icon shows up in the editor. But, the tree just shows the one
> icon. (The icon for the editor that is defined first.) How do I
> control the icon in the package explorer tree?
>
Which version of Eclipse do you use? You need 3.4 or newer and make sure
that the 'File Icons Based On Content Analysis' label decorator is enabled.

Dani
Re: How to change icon based on content in Project Explorer [message #332908 is a reply to message #332907] Thu, 13 November 2008 16:43 Go to previous messageGo to next message
Sue  is currently offline Sue Friend
Messages: 14
Registered: July 2009
Junior Member
I'm using 3.4.1 and that option is enabled.
Re: How to change icon based on content in Project Explorer [message #332922 is a reply to message #332908] Fri, 14 November 2008 07:49 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Sue wrote:
> I'm using 3.4.1 and that option is enabled.
>
Are you sure your content type is correctly detected?

Dani
Previous Topic:F10 key mapping / Ubuntu (Gnome)
Next Topic:question about resource traversal in eclipse
Goto Forum:
  


Current Time: Sat Apr 27 02:24:48 GMT 2024

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

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

Back to the top